我正在为当前项目使用SDL_Mixer,并且试图通过Mix_ChannelFinished函数同步声音。似乎可以让我调用Mix_PlayChannel,但不能让我在函数中调用Mix_SetPanning。这导致排队的音频声音更大。我在函数外部调用它确实有帮助,但是在排队的音频开始处有明显的响度差距。
这是声音结束后我调用的函数:
void playQueueSound(int channel)
{
printf("\n playing %d", channels[channel].soundIndex);
if (channels[channel].soundIndex > (-1))
{
//printf("\n playing %d", channels[channel].soundIndex);
AudioSource::getSource(channels[channel].objId)->removeSound(channel);
channels[channel].soundIndex = (-1);
if (channels[channel].queueIndex > (-1))
{
if (Mix_PlayChannel(channel, soundEffects[channels[channel].queueIndex].chunk, channels[channel].queueLoopMode)<0)
{
printf("\n cant play %s", Mix_GetError());
}
setObjPanning(AudioSource::getSource(channels[channel].objId), channel);
channels[channel].soundIndex = channels[channel].queueIndex;
}
else
{
channels[channel].objId = -1;
}
channels[channel].queueIndex = -1;
channels[channel].queueLoopMode = 0;
}
}