I am trying to get echo cancellation to work with FMOD.
Problem is: I am using DSPs, how do I get all the other sounds while having my mic input routed through the DSP callback simultaneously in order for me to be able to pass my mic input and the echo reference (all the other sounds) at the same time?
‘how do i get all the other sounds’. You will have to insert a capture dsp at the head of the DSP network, ie the master channel group.
Recording does not route through a DSP, so you will have to capture the buffer from the microphone and put it into another buffer, which a DSP can read from with some delay, because the recording buffer will possibly not have enough data yet. This will incur some latency.
Theoretically you can add a ‘play’ DSP for the record buffer, and from this custom DSP call System::getRecordPosition and Sound::lock , but the timing might drift. Only ASIO output lets you keep output and input in lock step.
We have a play/record example in the core_api examples folder which plays as it records, but because of drift the frequency of the play channel has to be slightly adjusted in realtime to keep the 2 in sync.
A similar technique could be used if the ‘play dsp’ was played on a channel with System::playDSP as it adds a resampler and you can call Channel::setFrequency on it.