Audio Stream to programmer instrument

Hi everyone,
I’m trying to implement an audio stream from a video in Unity following the example in https://www.fmod.com/docs/2.02/unity/examples-video-playback.html

So far, so good, except that now, I want to stream the audio directly into an instance of a programmer instrument in Fmod Studio to have more controls.

And that’s where I’m stuck.
I’ve already checked the following resource Using FMOD with voice chat utilizing OnAudioFilterRead()
but I think I’m not quite understanding how exactly you can grab the Fmod.sound and put it inside a programmer instrument.

Do I have to use a callback for this, or using only Sound.lock and Sound.unlock, is enough?

If anybody can explain step by step how it would work would be awesome.
Thank you!

Hi,

What version of the FMOD integration are you using? Could you please explain what controls you are looking for over the programmer instrument? It might be possible to avoid having to use a programmer instrument and control the sound directly.

Hi Connor,
I’m using Fmod Studio 2.02.13.

Initially, I wanted to spatialize the audio stream, and I’ve figured it out using the set3DAttributes on the channel Group.
But now, I need to duck another bus group when the audio stream is present, using a sidechain compressor.

And that’s where I think implementing the audio stream to a programmer instrument would be easier to manage for me, as I’m not sure if I would need to implement other features afterwards (like, adding reverb, or else).

Hi,

Thank you for the explanation. This can still be done on the sound rather than using a programmer instrument.

In the Video playback example, we play the sound on the MasterChannelGroup. Instead what we want to do is create a new group for the video audio:

The only difference is we will want to call lockChannelGroup() (FMOD Engine | Studio API Reference - Bus::lockChannelGroup) which will ensure that the channel group is kept in memory when we attach the sound. Here is how I retrieved the channel group:

FMODUnity.RuntimeManager.StudioSystem.getBus("bus:/VideoGroup", out FMOD.Studio.Bus videoGroupBus);
if (videoBus.isValid())
{
	videoBus.lockChannelGroup();
	FMODUnity.RuntimeManager.StudioSystem.flushCommands();

	videoBus.getChannelGroup(out FMOD.ChannelGroup videoChannelGroup);
}
else
{
	Debug.Log("Failed to lock Channel Group");
}

You will notice I also call flushCommands() (FMOD Engine | Studio API Reference - System::flushCommands) which ensures that the lock command is called before the next update.

Just remember to attach your sound to the videoChannelGroup as we do to the mMasterChannelGroup and to unlock the channel group at some point.

Hope this helps!