Why does playing the same sound with different positions at the same time result in only one sound in the middle position?
The code below correctly plays the same sound in two separate positions.
But if I remove the sleep line, FMOD plays just one sound as I commented.
FMOD_Sound_Set3DMinMaxDistance(g_Sound, 5000.0f, 10000.0f);
{
FMOD_VECTOR pos = { -5000.0f, 0.0f, 0.0f };
FMOD_CHANNEL* channel;
FMOD_System_PlaySound(g_System, g_Sound, NULL, TRUE, &channel);
FMOD_Channel_Set3DAttributes(channel, &pos, NULL);
FMOD_Channel_SetPaused(channel, FALSE);
}
{
// Without this line, two sounds are merged into a single one at the center.
std::this_thread::sleep_for(std::chrono::microseconds(1));
FMOD_VECTOR pos = { +5000.0f, 0.0f, 0.0f };
FMOD_CHANNEL* channel;
FMOD_System_PlaySound(g_System, g_Sound, NULL, TRUE, &channel);
FMOD_Channel_Set3DAttributes(channel, &pos, NULL);
FMOD_Channel_SetPaused(channel, FALSE);
}
I don’t know if this is the expected result mathematically, or acoustically, or if FMOD is designed that way for efficiency.
And, yes, this won’t happen most of the time in most games, because most sounds will be triggered by user input at runtime.
But in some special cases, this can be a problem.
Let’s imagine a music game that allows users to write their songs.
Let’s say it can also load MIDI files and play the notes with user sound files.
Then there may be high chances of playing multiple sounds at the exact same time.
In this case, if a user tries to play the same sound in different positions at the same time, it won’t work as the user expected.
Also, I recently came up with some interesting ideas but it’s only possible when the same sound in different multiple positions can travel around me (listener).
Is there a way to avoid this unwanted merging effect other than the above sleep trick?