How to change sound style while it's playing?

Hi All!

I want to know if it’s possible to stop a sound in its middle and then play another sound from this time. For example, cover versions - you may play the same melody with a guitar or with a piano. Let’s say you play the first half with a guitar and then start from the next note but play with a piano. Is it possible in Unity?

If they are the same tempo, length, timings, then it should be easy.
Play the new sound, assign the time or timesamples of the audiosource playing the old sound to the audiosource playing the new sound. Then stop the old sound. You might want to very quickly fade the new sound in and fade the old sound out, because starting and stopping them like that will probably sound very abrupt.

Starting on a particular note is more difficult. The computer doesn’t know where the notes are.

If you have a constant tempo, and a particular timing, like 4x4 then you should be able to use the dsptime to keep track of the beat that you are in, and you can make the transition on particular beats. You can use playscheduled to play the audiosource accurately on an upcoming beat.

are you talking about implementing MIDI?

I’m not sure what MIDI is, but maybe yes. I have a set of notes (music) and I want to play them and change the musical instrument while it’s playing without restarting.

MIDI is a format. In what format are your files?

Do the files contain single notes or do they contain music?

Frankly, I don’t have any files yet. It’s just an idea I have.
I thought I would make sounds with Guitar Pro, it allows to use different musical instruments. But I don’t know which format I will use.

You can easily set from which point the audioclip will be played, so if you have two audioclips with the same length, just save the moment of change and skip the next clip to that moment