Our game is a top-down 2D game, and we are playing most of our sounds via FMod Studio events. However, as a fallback for modders, we have the ability to define simple sounds to play, and for this we use the low-level API.
Now the problem with this is that if such a “simple” sound is emitted on the left side of the player, the sound is mostly panned on the left ear, and barely audible on the right ear. In our FMod Studio events we have the 3D Panner set up to minimize this effect, but I can’t seem to imitate this for the low-level API channels.
This is how we create our FMOD::Sound objects:
FMOD::Sound* sound; auto ret = m_lowLevelEngine->createSound(src->GetData(), FMOD_OPENMEMORY_POINT | FMOD_CREATESTREAM | FMOD_3D | FMOD_3D_LINEARSQUAREROLLOFF, &exinfo, &sound);
We then play the sound and get its channel like this: (we unpause it a bit later)
m_lowLevelEngine->playSound(ss, grp, true, &chnl);
Then, we set the 3D position in the channel directly after initialization as well as on update whenever the sound source changes position: (SOUND_SCALE
is 64.0f)
FMOD_VECTOR vel = { 0, 0, 0 }; FMOD_VECTOR position = { pos.x / SOUND_SCALE, pos.y / SOUND_SCALE, pos.z / SOUND_SCALE }; chnl->set3DAttributes(&position, &vel);
But this causes the extreme panning that I’m trying to avoid/minimize.
I’ve tried adding a 3D panner DSP to the channel in an attempt to mimic the Studio event’s properties in this channel, but it doesn’t make a lot of difference: (I’ve tried a bunch of different values for these as well)
FMOD::DSP* panDSP = nullptr; m_lowLevelEngine->createDSPByType(FMOD_DSP_TYPE_PAN, &panDSP); panDSP->setParameterFloat(FMOD_DSP_PAN_2D_DIRECTION, 0.0f); panDSP->setParameterFloat(FMOD_DSP_PAN_2D_EXTENT, 0.0f); panDSP->setParameterFloat(FMOD_DSP_PAN_3D_MIN_DISTANCE, desc.m_minDist / SOUND_SCALE); panDSP->setParameterFloat(FMOD_DSP_PAN_3D_MAX_DISTANCE, desc.m_maxDist / SOUND_SCALE); panDSP->setParameterInt(FMOD_DSP_PAN_3D_EXTENT_MODE, FMOD_DSP_PAN_3D_EXTENT_MODE_USER); panDSP->setParameterFloat(FMOD_DSP_PAN_3D_MIN_EXTENT, 360.0f); panDSP->setParameterFloat(FMOD_DSP_PAN_3D_PAN_BLEND, 0.05f); chnl->addDSP(0, panDSP);
What am I missing? Any help or pointers to put me in the right direction would be appreciated. Thanks!