Open eglaysher opened 8 years ago
The ogg vorbis speech files are 48k, which was the frequency rate of sdl_mixer before the patch. Might have to go through all sound loaders and make sure they match the mixer sample rate?
I added code to dump the decoded wav data for the voice samples in SDLSoundSystem::KoePlayImpl(); right after we've decoded the ogg vorbis data into a raw wav file. The data, when played from mplayer on the command line, sounds fine.
But in rlvm, the voice sample is tone shifted down.
Apparently sdl_mixer has known issues dealing with audio samples that aren't a multiple of 11025hz (11025hz, 22050hz, 44100hz), and doesn't have proper resampling.
References: http://forum.caravelgames.com/viewtopic.php?TopicID=12332 http://osdl.sourceforge.net/main/documentation/rendering/SDL-audio.html
So it shouldn't be a surprise that the 48khz ogg files aren't being played properly.
Jagarl had some sort of workaround for the 48k to 44.1k problem:
// rate conversion は SDL_ConvertAudio ではうまく行かない
// 48000Hz -> 44100Hz or 22050Hz などを想定
// 長さは短くなるはずなので、特に処理はなし
This is done immediately after SDL_ConvertAudio(cvt);
in wavfile.cc. I'm not sure this is something I can copy since most of the sound conversion is being done inside sdl_mixer. Grabbing a library like libresample or libsamplerate and converting the raw wavforms before we hand them off to sdl_mixer is probably the easiest way to move forward.
(The extreme fix is ripping out the entire sdl_mixer based sound system as it exists and move...to something else? That would be a lot of work for a new pile of new, non-real world hardened, hard to test code.)
While trying to fix a different audio issue, 691a70f734ce93e043919a2f582054002cd1e212 broke the pitch of voices in Clannad. There's probably multiple things to work out here.