0
0

[b:13alvdzq]Detailed Description:[/b:13alvdzq]
Sometimes it is desirable to adjust the levels of the output speakers for your final mix.
With FMOD EX, the following code can be used. Default should be 1.0f for all parameters. Can be boosted up to 5.0f or lowered to 0.0f for complete attenuation.

[b:13alvdzq]Solution 1:[/b:13alvdzq]
[code:13alvdzq]
FMOD_RESULT adjustFinalMix(FMOD::System *system, float fl, float fr, float c, float lf, float bl, float br, float sl, float sr)
{
FMOD::DSP *dsphead;
FMOD::DSPConnection *dspconnection;
int count, numspeakers;
FMOD_RESULT result;

result = system->getSoftwareFormat(0, 0, &numspeakers, 0, 0, 0);
ERRCHECK(result);

result = system->getDSPHead(&dsphead);
ERRCHECK(result);

result = dsphead->getInput(0, 0, &dspconnection);
ERRCHECK(result);

float levels[8][8] = 
{ 
    { fl, 0,  0,  0,  0,  0,  0,  0  }, // front left 
    { 0,  fr, 0,  0,  0,  0,  0,  0  }, // front right 
    { 0,  0,  c,  0,  0,  0,  0,  0  }, // center 
    { 0,  0,  0,  lf, 0,  0,  0,  0  }, // lfe 
    { 0,  0,  0,  0,  bl, 0,  0,  0  }, // rear left 
    { 0,  0,  0,  0,  0,  br, 0,  0  }, // rear right 
    { 0,  0,  0,  0,  0,  0,  sl, 0  }, // side left 
    { 0,  0,  0,  0,  0,  0,  0,  sr }, // side right 
};

for (count = 0; count < numspeakers; count++) 
{ 
    dspconnection->setLevels((FMOD_SPEAKER)count, levels[count], 8);
}

return FMOD_OK;

}

[/code:13alvdzq]

[b:13alvdzq]Notes:[/b:13alvdzq]
Note the use of the ‘master bus’ here. If you want it on a category, use EventCategory::getChannelGroup, then ChannelGroup::getDSPHead instead of the above system->getDSPHead.
I would recommend in the latter case using getOutput instead of getInput as well.

  • You must to post comments
0
0

Here is an alternate version where you can control the output of the first reverb, a new parameter ‘reverb’ is added, so the levels affect the reverb, not the main mix.

[code:3ed096h2]
FMOD_RESULT adjustFinalMix(FMOD::System *system, float fl, float fr, float c, float lf, float bl, float br, float sl, float sr, bool reverb)
{
FMOD::DSP *dsphead;
FMOD::DSPConnection *dspconnection;
int count, numspeakers;
FMOD_RESULT result;

result = system->getSoftwareFormat(0, 0, &numspeakers, 0, 0, 0);
ERRCHECK(result);

result = system->getDSPHead(&dsphead);
ERRCHECK(result);

if (reverb)
{
    int numinputs = 0;
    FMOD::DSP *dspcgt;

    result = dsphead->getInput(0, &dspcgt, 0);
    ERRCHECK(result);

    result = dspcgt->getNumInputs(&numinputs);
    ERRCHECK(result);

    for (count = 0; count < numinputs; count++)
    {
        FMOD::DSP *input;
        FMOD_DSP_TYPE type;

        result = dspcgt->getInput(count, &input, &dspconnection);
        ERRCHECK(result);
        result = input->getType(&type);
        ERRCHECK(result);

        if (type == FMOD_DSP_TYPE_SFXREVERB)
        {
            break;
        }
    }
    if (count == numinputs)
    {
        return FMOD_ERR_DSP_NOTFOUND;
    }
}
else
{
    result = dsphead->getInput(0, 0, &dspconnection);
    ERRCHECK(result);
}

float levels[8][8] = 
{ 
    { fl, 0,  0,  0,  0,  0,  0,  0  }, // front left 
    { 0,  fr, 0,  0,  0,  0,  0,  0  }, // front right 
    { 0,  0,  c,  0,  0,  0,  0,  0  }, // center 
    { 0,  0,  0,  lf, 0,  0,  0,  0  }, // lfe 
    { 0,  0,  0,  0,  bl, 0,  0,  0  }, // rear left 
    { 0,  0,  0,  0,  0,  br, 0,  0  }, // rear right 
    { 0,  0,  0,  0,  0,  0,  sl, 0  }, // side left 
    { 0,  0,  0,  0,  0,  0,  0,  sr }, // side right 
};

for (count = 0; count < numspeakers; count++) 
{ 
    dspconnection->setLevels((FMOD_SPEAKER)count, levels[count], 8);
}

return FMOD_OK;

}
[/code:3ed096h2]

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.