Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdl_mixer can't resample 48k sound files #72

Open
eglaysher opened this issue Feb 27, 2016 · 4 comments
Open

sdl_mixer can't resample 48k sound files #72

eglaysher opened this issue Feb 27, 2016 · 4 comments

Comments

@eglaysher
Copy link
Owner

While trying to fix a different audio issue, 691a70f broke the pitch of voices in Clannad. There's probably multiple things to work out here.

eglaysher added a commit that referenced this issue Feb 28, 2016
This reverts commit 691a70f.

This fix caused tonal problems with voices in Clannad FV edition.

This is #72 in the bug tracker.
@eglaysher
Copy link
Owner Author

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?

@eglaysher
Copy link
Owner Author

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.

@eglaysher
Copy link
Owner Author

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.

@eglaysher eglaysher changed the title Sort out what frequency we should be using everywhere. sdl_mixer can't resample 48k sound files Mar 14, 2016
@eglaysher eglaysher modified the milestone: The Birthday Release Jul 3, 2016
@eglaysher
Copy link
Owner Author

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.)

eglaysher added a commit that referenced this issue Sep 11, 2017
This doesn't fix the real problem with GH-72, but it does paper over it
enough so that we can release.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant