Capturing stereo output from Fmod

Hi all,
I’m trying to capture Fmod’s output and pass it to a video recorder.
I’ve based my code on the DSP Capture example.
https://www.fmod.com/docs/2.02/unity/examples-dsp-capture.html

The audio recorded on the video is distorted though.

Checkign the Fmod data; when I request channel count and sample rate from FMODUnity.RuntimeManager.CoreSystem at the start of play I get 2 channels and 48,000.

Checking the values in the DSP capture I get a buffer length: 512 inchannels:6 and outchannels:6.

Which matches the six channels which seem to be recorded inside the video (by inspecting with ffmpeg). So I seem to be getting a set of 6 DSP channels, what I really want is the final stereo mix.

How can I capture just the stereo output from Fmod?

Many thanks for any thoughts…

Given that your FMOD system is already outputting stereo, the easiest fix should be to use DSP::setChannelFormat on the capture DSP. This should force it the DSP to downmix from (presumably) 5.1 to stereo, and assuming you’re placing the capture DSP at the head (index 0 or FMOD.CHANNELCONTROL.DSP.HEAD) of the master ChannelGroup already, shouldn’t cause any change in the system’s output since there’s no other effects between the capture DSP and the system output, which was already downmixing to stereo.

Give that a try and let me know if you run into any issues.

1 Like

Ah, thank you so much - that worked!

For anyone arriving here in the future I modified the dsp capture example, with this

mCaptureDSP.setChannelFormat(FMOD.CHANNELMASK.STEREO, 2, FMOD.SPEAKERMODE.MAX);
 if (masterCG.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.TAIL, mCaptureDSP) != FMOD.RESULT.OK)

@Leah_FMOD I’m adding the DSP at the tail, which I assume would be at the end of the processing chain, my reasoning was to attempt to capture the final mix. You mentioned adding it at the HEAD is that actually the end of the chain or am I missing something?

Signal flow in FMOD is from tail to head - the head is the DSP unit closest to the output, and the tail the unit closest to the input. This can be a little unintuitive, especially since the Studio mixer and the Core API profiler present it differently, but it makes more sense if you think of it like a linked list, with a head “output” node that has a list of tail “input” nodes that connect to it.

I’d recommend reading over our White Paper on FMOD’s DSP Architecture and Usage for more information.

1 Like

Ah, that makes sense now; I had assumed it the other way around from the docs, it mentioned that HEAD has an index of 0, making me assume it was at the start of the chain (like standard array indexing)

I think your explaination is super clear;
“Signal flow in FMOD is from tail to head - the head is the DSP unit closest to the output”

Could I suggest adding it into the docs, maybe here

https://www.fmod.com/docs/2.02/api/core-api-channelcontrol.html#fmod_channelcontrol_dsp_index

or in the DSP Architecture whitepaper, as even after a second read I wasn’t clear on it.

thanks again

There’s definitely a few places where signal flow and tail/head could be explained for clarity, and I’ve noted it internally. Thanks for pointing it out.