Make Simutrans speak your language.

r100.0: Sound frequency: slightly wrong, half inflexible, no conversion

Started by GreaseMonkey, September 09, 2008, 06:43:54 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


It's possible to play various types of music other than MIDI if you use SDL_mixer. However, if you attempt to play a WAV, OGG, MP3, or any audio format supported by SDL_mixer, it plays it at simutrans' sound frequency and not the audio frequency. I know this is somewhat unexpected, and I don't expect it fixed, but when I downsampled a tune, I noticed something odd...

Are you sure you meant to use 22500Hz? Because the closest standard frequency is 22050Hz.

[ben@roflcopter ~/Desktop/FOLDERS/simutrans]$ grep 22500 */*
music/                      Mix_OpenAudio(22500, AUDIO_S16SYS, 2, 1024);
sound/               int freq = 22500;
sound/             desired.freq = 22500;

By the way, if you're afraid of breaking stuff, don't worry too much about it. If you get a frequency converter set up though, or the sounds happen to be 22050Hz, then I recommend you tweak those.
Also, I'm pretty sure some cards don't particularly like frequencies they're not used to, but I'm also pretty sure that most OSes convert the frequencies anyway (I think mine works best with 48000Hz or something).

ALSO: Why does sdl_midi use a static frequency? That needs to be fixed.

EDIT: By the way, I am running FreeBSD, not Linux, although they are quite similar.


Actually, the frequency is supposed to be 22050. Honestly, this is mostly to save computer power, as rendering midi is very CPU expensive. And most of all sound effects are 11025 kHz mono to save disk space for the distribution.

The SDL_midi is not made by me, thus I have not really an idea, what you mean by
QuoteALSO: Why does sdl_midi use a static frequency? That needs to be fixed.


The code uses a fixed frequency because SDL_Mixer needs a frequency to use. As prissi said, higher frequency needs more cpu power, hence using 22050kHz (and yes 22500 was a typo). Seem to remember the frequency value is needed when initialising the sound system so it couldn't be changed for each music file, however I'm sure it'd be possible to add a configuration option to change this frequency.
Unfortunately the system I'm using at the moment doesn't seem to want to run sdl_mixer so I can't test sound support currently.