Problem with setting Delay to captured sound via mic


I’m currently working on capturing sound from microphone (already achieved - ported cpp sample to c#). Now I need to delay this sound playback (or delay captured sound from mic?) by certain amount of time which is also dynamically changing through runtime.

I already tried to create dsp on mic channel like that:
RuntimeManager.CoreSystem.createDSPByType(DSP_TYPE.DELAY, out var delayDSP); _channel.addDSP(0, delayDSP); delayDSP.setActive(true); delayDSP.getNumParameters(out var index); // delay num parameter delayDSP.setParameterFloat(index, CurrentDelay * 1000f); Debug.Log($"Parameter {delayDSP} | ParameterIndex: {index} | CurrentDelay: {CurrentDelay}");

But it didn’t worked. When I changed DSP type to Echo and left the rest code unchanged it is working out of box. So maybe I’m trying to achieve delay in wrong way?

I’ve also tried to add the same dsp (Type Delay) to output channelGroup but also didn’t worked.

Pointing the right direction is welcome :slight_smile:


What version of FMOD are you using?

So the delay is applied when starting the sound here:

    Delay playback until our desired latency is reached.
if (!channel && samplesRecorded >= adjustedLatency)
    result = system->playSound(sound, 0, false, &channel);

So to ‘reapply’ the delay essentially you would have to restart the recording session and apply the new desired delay to this if statement. Also make sure that you increase size of the buffer so accommodate the new delay as well:

exinfo.length = nativeRate * sizeof(short) * nativeChannels; /* 1 second buffer, size here doesn't change latency */

If an Echo DSP is providing the behavior you are aiming for I think that is the best solution.

Hope this helps!