Answered
0
0

I’m trying to make FMOD play all sounds in sync with unity’s Time.captureFramerate feature. So basically make it only play one “sound frame” when I call studioSystem.update(), but I can’t figure it out. I have tried with MIX_FROM_UPDATE, STREAM_FROM_UPDATE and SYNCHRONOUS_UPDATE. But I obviusly have a poor understanding of how it works since none of it make any difference for my purpose.

I know the frame time is not the same on the rendering thread as the sounds thread, I already have the code that will sync all of that. It works great with Unity’s internal sound system if I sync everything by force-locking the sound thread with a AutoResetEvent. But that does not seem to be possible with FMOD since it creates deadlocks when you try to do anything with FMOD while having the sound thread locked.

I have also solved the actual sound recording with a custom DSP that seem to work well. So now I just need to be able to drive the sound in the exact speed I’m rendering.

Any idea?

Thanks in advance!

  • You must to post comments
Best Answer
1
0

FMOD creates it’s own thread to use for processing the mix, using MIX_FROM_UPDATE will cause the mix to be run from System::update() instead. STREAM_FROM_UPDATE is the same but for streams.

No Sound NRT will ensure you get one block per update.
System::setOutput(FMOD_OUTPUTTYPE_NOSOUND_NRT)

Then it just depends on how you want to capture the audio, one example could be to write a simple output plugin to save the audio out.

  • You must to post comments
0
0

This almost does the trick! The problem now is that the last audio frame get “stuck” in the system and just keeps repeating and going though my DSP until next audio frame executes. Which obviously make’s it record the same audio frame multiple times.

I’m going to se if I can sync my encoder so it only pickup a frame when I’ve called the FMOD.Update function once, but that doe snot feel like a stable solution. So is there any other way of solving this? Maybe some special placement if the DSP in the chain?

  • Cameron Baron

    Using NoSound NRT will only return information when System::update() is called, it sounds like you must be storing that information and reading from it more often than update is called.

  • Mikael Eriksson

    I was totally wrong, I did not managed to get it in the right mode apparently! But I’ve fixed it now and it works great! :) Thank you!

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.