Continuously setting the next bytes for a playing audioclip?
Hi everybody
I have a game idea, where the players actions will influence the music heavily. The pitch and volume which unity already can change, while a clip is playing is not enough. So an external system is required to do at least some time scaling on the clip. To solve this, then it should proably be done with something like:
Get the next second or so of sound with the AudioClip.GetData.
Send this to an external time scaling system.
Get new float[] with the modulated sound back. Convert to AudioClip.
Make the audiosource play this.
For this I have three question.
Have I missed something in Unity or the asset store that might already do this for me? Change the duration of notes in a song, but not the pitch continuously based on game input.
For step number 1, how can I keep a running int with the exact location in the sound? I am thinking about the offsetSamples parameter to the Audioclip.GetData.
For step number 4, if I convert the 1 second float[] to an AudioClip and play it directly on a AudioSource, will it line up? For example a long note that goes higher and higher in pitch, but at some point it should go change pitch faster. Will it have some sort of small step in the pitch each time a new AudioClip is created?
Any helps and tips about these two questions will be much appreciated =)
Best Regards Povl