The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: captain crunch on November 22, 2013, 08:29:34 PM

Title: Sound playback in sdl2 backend and pak64
Post by: captain crunch on November 22, 2013, 08:29:34 PM
Version: simutrans r6913, linux-amd64, sdl2-backend, pak64
The sounds Water.wav and arctic.wav produce only noise and not the expected sound.
When I resample them to a multiple of 11025Hz using sox, they play alright.
Title: Re: Sound playback in sdl2 backend and pak64
Post by: prissi on November 22, 2013, 10:27:37 PM
Sounds more like an error of SDL2 then. They are legal wavefiles.
Title: Re: Sound playback in sdl2 backend and pak64
Post by: ArthurDenture on November 24, 2013, 10:05:04 PM
I can reproduce this problem as well. Turns out there's an open bug (https://bugzilla.libsdl.org/show_bug.cgi?id=58) from 2006 where SDL 2.0 can only convert samples if the difference between their sample rate and the game's sample rate is a power of 2.

Given that that bug has been open for essentially forever, I wouldn't hold out hopes for a fix. Would it be possible to instead replace those sound files with ones that are at 11025 or 22050 Hz? Basically as captain crunch described. I think the following files are affected:

pak64/sound/arctic.wav
pak64/sound/planelow.wav
pak64/sound/Water.wav
pak128/sound/horsegallop2.wav
Title: Re: Sound playback in sdl2 backend and pak64
Post by: prissi on November 24, 2013, 10:21:54 PM
Some of them I got with lower rate. But indeed,  I can convert them. (Although it is strange that SDL cannot cope with 44100 and 48000 samples at the same time ...
Title: Re: Sound playback in sdl2 backend and pak64
Post by: Ters on November 24, 2013, 10:41:14 PM
Is SDL2 really doing the mixing itself? I thought those days were over, with every contemporary low-level sound API I know exposing abstracting mixing to hardware or software, even with mixed sampling rates.
Title: Re: Sound playback in sdl2 backend and pak64
Post by: prissi on December 02, 2013, 10:02:14 PM
Thanks, I fixed the paks.
Title: Re: Sound playback in sdl2 backend and pak64
Post by: ArthurDenture on December 03, 2013, 02:24:26 AM
Yay, thanks!