0
0

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.

  • You must to post comments
1
0

please do this.

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

add your code here

/*
    Main loop
*/
do
{
    Common_Update();

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

        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.

  • You must to post comments
-1
0

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 :p ).

  • You must to post comments
0
0

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?

  • You must to post comments
0
0

Hi, posting here just the FMOD related code I’m using, since the sound and channel creation:
[code:38d8ang8]
...
m_result = m_system->createStream(file.c_str(), FMOD_LOOP_NORMAL | FMOD_2D,
0, &m_sound);
ERRCHECK(m_result);

m_result = m_channel->setCallback(channelCallback);
ERRCHECK(m_result);

m_system->update();

...
m_result = m_system->playSound(m_sound, 0, true, &m_channel);
ERRCHECK(m_result);
m_system->update();
...
// BLOCK
m_result = m_system->createDSPByType(FMOD_DSP_TYPE_LOWPASS, &m_dsp);
m_result = m_channel->addDSP(0, dsp);
ERRCHECK(m_result);
m_system->update();
// BLOCK
...
[/code:38d8ang8]

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):
[code:38d8ang8]
ChannelGroup *mastergroup = 0;
m_result = m_system->getMasterChannelGroup(&mastergroup);
ERRCHECK(m_result);

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

m_system->update();

[/code:38d8ang8]

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

Am I doing something wrong, or missing something??

Thank you.

  • You must to post comments
0
0

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:

FMOD_RESULT F_CALLBACK channelCallback(FMOD_CHANNELCONTROL *chanControl,
        FMOD_CHANNELCONTROL_TYPE controlType, FMOD_CHANNELCONTROL_CALLBACK_TYPE callbackType,
        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: http://pastebin.com/ST7Ln02p (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.

  • Nicholas Wilcox
    Are there multiple threads using the API or calling System::Update()?
  • You must to post comments
0
0

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 😉

  • You must to post comments
Showing 6 results
Your Answer

Please first to submit.