addDSP on ChannelGroup v. Channel

I’m following the effects.cpp example from FMOD Studio lowlevel API to apply some DSP on a music. When using the master ChannelGroup (system->getMasterChannelGroup), I can apply the DSP and everything works as expected. But, I wish to add DSP just on a specific sound, and let the others without any processing. So tried to apply the DSP directly on the channel I’ve created for the music without luck.

I also tried to create a group, add the channel and apply the DSP on that group (like the channels_group.cpp example), without luck again. The only solution that have worked for me is using the ChannelGroup, but as I said before, it will not do what I want to do.

To sum up, the sounds are playing OK on channels, adding a DSP on the master channel group is OK too, but adding DSP directly on a single channel I want isn’t working.

Maybe I am making a mistake, since I’m new to FMOD? Can anyone help me on this? Currently I’m working on Linux (FMOD 1.04.02).

Thank you all.

Hi ,
Can you show some of the code you use to add the dsp to the channel? it should just be a matter of Channel::addDSP (use say FMOD_CHANNELCONTROL_DSP_HEAD as the index).
I assume your DSP can handle different channel formats, like mono vs 5.1 etc?

Hi, posting here just the FMOD related code I’m using, since the sound and channel creation:

    m_result = m_system->createStream(file.c_str(), FMOD_LOOP_NORMAL | FMOD_2D,
                0, &m_sound);

    m_result = m_channel->setCallback(channelCallback);

    m_result = m_system->playSound(m_sound, 0, true, &m_channel);
    // BLOCK
    m_result = m_system->createDSPByType(FMOD_DSP_TYPE_LOWPASS, &m_dsp);
    m_result = m_channel->addDSP(0, dsp);
    // BLOCK

With the above code the applied DSP doesn’t work. But changing the code between “BLOCK” to the code below, it works (using the master channel group, according the effects.cpp example):

    ChannelGroup *mastergroup = 0;
    m_result = m_system->getMasterChannelGroup(&mastergroup);

    m_result = mastergroup->addDSP(0, m_dsp);


Also, I’ve tried passing FMOD_CHANNELCONTROL_DSP_HEAD instead of 0 in addDSP, without success (according the documentation it’s the same thing :stuck_out_tongue: ).

Am I doing something wrong, or missing something??

Thank you.

answearing the message from brett:

m_result = m_system->createDSPByType(FMOD_DSP_TYPE_LOWPASS, &m_dsp);
m_result = m_channel->addDSP(0, dsp);

This is suspicious. You’re passing dsp not m_dsp.

Sorry, I let some commented lines on the code and when copying I’ve deleted the wrong one. The correct is:

m_result = m_channel->addDSP(0, m_dsp);

Also I noticed at the start you set a callback on an uninitialized
handle. Its probably null?

Nope, the callback is the follow:

        void *commandData1, void *commandData2)
    if (controlType == FMOD_CHANNELCONTROL_CHANNEL &&
            callbackType == FMOD_CHANNELCONTROL_CALLBACK_END) {
        cout << "CALLBACK OK" << endl;

    return FMOD_OK;

Just to know when the sound finishes playing, and it’s working here.

The fmod.log is the follow: (the “…/…/…/lowlevel_api/src/fmod_systemi.cpp(7248) : FMOD error (31) : An error occured that wasn’t supposed to. Contact support.” error appears always I use debug mode here).

I saw now that version 1.04.03 is out, have tested but got the same result, addDSP on a channel isn’t working for me.
Any help is appreciate. Thank you.

P.S.: I can’t login with the old user from the forum.

Are there multiple threads using the API or calling System::Update()?

Hi Nicholas.

No threads, but I call System update() from my main loop too (to ensure that the callback is fired correctly, and have checked if it is being called right now to avoid mistakes :stuck_out_tongue: ).

please do this.

Open the ‘playsound’ example in the fmod low level api examples.

add your code here

    Main loop

    if (Common_BtnPress(BTN_ACTION1))
        result = system->playSound(sound1, 0, false, &channel);

        FMOD::DSP *dsp;
        result = system->createDSPByType(FMOD_DSP_TYPE_LOWPASS, &dsp); 
        result = dsp->setParameterFloat(FMOD_DSP_LOWPASS_CUTOFF, 1500.0f);
        result = channel->addDSP(0, dsp);

It will leak dsp units but it doesnt matter, you can see that it works fine.

Also you said that it wasnt an uninitialized handle when I said it was? Yes it is. You can’t call operations on a channel handle before its even filled out by playsound. It is uninitialized, and you are going to get an error or unpredictable results.

1 Like

Also you said that it wasnt an uninitialized handle when I said it
was? Yes it is. You can’t call operations on a channel handle before
its even filled out by playsound. It is uninitialized, and you are
going to get an error or unpredictable results.

I though you were talking about the callback function. I’ve fixed that now, but my code still not working.

I’ve tested your code as you suggested, it works here. Also, have changed it to use my code, and it is working too. I will try to figure where my coding is failing. When getting new results will tell you.

Thank you for your patience, see ya :wink: