Announcement: Be excellent to each other.


Caravel Forum : DROD Boards : Bugs : Linux: SDL_mixer is bad at resampling! (In which we discover that giving FMOD another try might be an even better idea than previously thought)
New Topic New Poll Post Reply
Poster Message
trick
Level: Legendary Smitemaster
Rank Points: 2580
Registered: 04-12-2003
IP: Logged
icon Linux: SDL_mixer is bad at resampling! (+1)  
Banjooie wrote:
Question: Are the sound files in the linux version different from the windows one? The 'break cracked wall' sound seems higher pitched, and some stuff seems tinny (Like the Secret Room sound.)
The sound files are identical. However, I think I know what causes this. The Linux version of DROD uses SDL_mixer, while the Windows version uses FMOD. The reason for this is some unexplained crashes in Linux while using FMOD, but this might actually have been solved recently.

Anyway, SDL_mixer doesn't do resampling. It can convert 11025hz and 22050hz to 44100hz (and vice versa, I think), but that's pretty much it. When looking at the ogg files in the Sounds directory, I discovered that LowShatter.ogg (the break wall sound) has a frequency of 12000 samples per second. This is not a multiple of 11025, so SDL_mixer can't handle it. However, SDL_mixer doesn't want to admit defeat, so instead it pretends that it converted the sample to 44100 and goes ahead and plays it at that rate. The result is that the sample is played 3.675 times too fast. When samples are played too fast, they also get a higher pitch. So there you go.

Some other sounds there have a frequency of 11025hz (belltoll.ogg, explosion.ogg, fuselighting.ogg, LongHarps.ogg, poptwang.ogg, ShortHarps.ogg, snoring.ogg). ShortHarps.ogg is the secret room sound, so I assume this is the cause of the tinnyness. I guess SDL_mixer just isn't very good at resampling audio even for frequencies it supports.

I can see at least three solutions to this problem:

1. Replace at least the LowShatter.ogg file with something with a decent frequency. Maybe even make everything 44100hz.

If I can get my hands on the original wavs to make new oggs, this wouldn't be a too bad idea. It would mean a little more space taken up by the sounds, though.

2. Fix SDL_mixer.

Er, no. Not now, at least. Maybe later sometime in the unspecified future, if I can figure out how to, but I assume SDL_mixer for SDL 1.3 will fix this problem for good anyway.

3. Go back to FMOD.

At the moment, assuming the random crash problem is indeed fixed, this seems like the best solution, because this would also bring back crossfading to the world of penguins. SDL_mixer only supports one music track, so it can't do crossfading. FMOD can. And, of course, FMOD does proper resampling. Also, I was just talking with Mike about the possibility of using FMOD for Linux again yesterday, before this came up. Coincidence ? Probably, yeah, but hey.

However, the release of 2.0.15 is right around the corner, and a FMOD switch should at least have a little testing before it goes official, specially since we had problems with it before. That means betatesting the patch. Which means I need to get it done now. But I can't do that, due to some other stuff. So, the FMOD switch will have to wait for a little bit. Maybe we should just go with fixing the .ogg files for now after all.

TODO: Figure this out.

~ Gerry

[Last edited by trick at 10-12-2006 08:35 PM]
10-12-2006 at 08:31 PM
View Profile Send Private Message to User Send Email to User Show all user's posts Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Bugs : Linux: SDL_mixer is bad at resampling! (In which we discover that giving FMOD another try might be an even better idea than previously thought)
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.