Ticket #8341: output-freq-alt.diff
File output-freq-alt.diff, 10.5 KB (added by , 20 years ago) |
---|
-
README
diff -urN ScummVM/README ScummVM+test/README
old new 34 34 * 7.3 Native MIDI support 35 35 * 7.4 UNIX native & ALSA sequencer support 36 36 * 7.5 Using compressed audiofiles (MP3, Ogg Vorbis, Flac) 37 * 7.6 Output sample rate 37 38 8.0) Configuration Files 38 39 9.0) Compiling 39 40 X.X) Credits … … 330 331 atari, fmtowns, mac, pc) 331 332 --multi-midi Enable combination of Adlib and native MIDI 332 333 --native-mt32 True Roland MT-32 (disable GM emulation) 334 --output-rate=RATE Select output sample rate in Hz (e.g. 22050) 333 335 --aspect-ratio Enable aspect ratio correction 334 336 335 337 --alt-intro Use alternative intro for CD versions of Beneath a … … 861 863 Eventually you will have a much smaller *.mp3, *.ogg or *.fla file, copy this 862 864 file to your game dir. You can safely remove the old file. 863 865 866 7.6) Output sample rate: 867 ---- ------------------- 868 869 The output sample rate tells ScummVM how many sound samples to play per channel 870 per second. There is much that could be said on this subject, but most of it 871 would be irrelevant here. The short version is that for most games 22050 Hz is 872 fine, but in some cases 44100 Hz is preferable. On extremely low-end systems 873 you may want to use 11025 Hz, but it's unlikely that you have to worry about 874 that. 875 876 To elaborate, most of the sounds ScummVM has to play were sampled at either 877 22050 Hz or 11025 Hz. Using a higher sample rate will not magically improve the 878 quality of these sounds. Hence, 22050 Hz is fine. 879 880 Some games use CD audio. If you use compressed files for this, they are 881 probably sampled at 44100 Hz, so for these games that may be a better choice of 882 sample rate. 883 884 When using the Adlib, FM Towns, PC Speaker or IBM PCjr music drivers, ScummVM 885 is responsible for generating the samples. Usually 22050 Hz will be plenty for 886 these, but there is at least one piece of Adlib music in Beneath a Steeel Sky 887 that will sound a lot better at 44100 Hz. 888 889 Using frequencies in between is not recommended. For one thing, your sound card 890 may not support it. In theory, ScummVM should fall back on a sensible frequency 891 in that case, but don't count on it. More importantly, ScummVM has to resample 892 all sounds to its output frequency. This is much easier to do well if the 893 output frequency is a multiple of the original frequency. 894 864 895 865 896 8.0) Configuration file: 866 897 ---- ------------------- … … 944 975 joystick_num number Number of joystick device to use for input 945 976 master_volume number The master volume setting (0-255) 946 977 music_driver string The music engine to use. 978 output_rate number The output sample rate to use, in Hz. Sensible 979 values are 11025, 22050 and 44100. 947 980 alsa_port string Port to use for output when using the 948 981 ALSA music driver. 949 982 music_volume number The music volume setting (0-255) -
backends/sdl/sdl-common.h
diff -urN ScummVM/backends/sdl/sdl-common.h ScummVM+test/backends/sdl/sdl-common.h
old new 169 169 SDL_Surface *_tmpscreen; 170 170 bool _overlayVisible; 171 171 172 // Audio 173 int _samplesPerSec; 174 172 175 // CD Audio 173 176 SDL_CD *_cdrom; 174 177 int cd_track, cd_num_loops, cd_start_frame, cd_duration; -
backends/sdl/sdl.cpp
diff -urN ScummVM/backends/sdl/sdl.cpp ScummVM+test/backends/sdl/sdl.cpp
old new 95 95 #endif 96 96 _hwscreen(0), _screen(0), _screenWidth(0), _screenHeight(0), 97 97 _tmpscreen(0), _overlayVisible(false), 98 _samplesPerSec(0), 98 99 _cdrom(0), _scaler_proc(0), _modeChanged(false), _dirty_checksums(0), 99 100 _mouseVisible(false), _mouseDrawn(false), _mouseData(0), 100 101 _mouseHotspotX(0), _mouseHotspotY(0), … … 289 290 290 291 bool OSystem_SDL::setSoundCallback(SoundProc proc, void *param) { 291 292 SDL_AudioSpec desired; 293 SDL_AudioSpec obtained; 292 294 293 295 memset(&desired, 0, sizeof(desired)); 294 296 295 desired.freq = SAMPLES_PER_SEC; 297 if (ConfMan.hasKey("output_rate")) 298 _samplesPerSec = ConfMan.getInt("output_rate"); 299 else 300 _samplesPerSec = SAMPLES_PER_SEC; 301 302 // Originally, we always used 2048 samples. This loop will produce the 303 // same result at 22050 Hz, and should hopefully produce something 304 // sensible for other frequencies. Note that it must be a power of two. 305 306 uint16 samples = 0x8000; 307 308 for (;;) { 309 if (samples / (_samplesPerSec / 1000) < 100) 310 break; 311 samples >>= 1; 312 } 313 314 desired.freq = _samplesPerSec; 296 315 desired.format = AUDIO_S16SYS; 297 316 desired.channels = 2; 298 desired.samples = 2048;317 desired.samples = samples; 299 318 desired.callback = proc; 300 319 desired.userdata = param; 301 if (SDL_OpenAudio(&desired, NULL) != 0) {320 if (SDL_OpenAudio(&desired, &obtained) != 0) { 302 321 return false; 303 322 } 323 // Note: This should be the obtained output rate, but it seems that at 324 // least on some platforms SDL will lie and claim it did get the rate 325 // even if it didn't. Probably only happens for "weird" rates, though. 326 _samplesPerSec = obtained.freq; 304 327 SDL_PauseAudio(0); 305 328 return true; 306 329 } … … 310 333 } 311 334 312 335 int OSystem_SDL::getOutputSampleRate() const { 313 return SAMPLES_PER_SEC;336 return _samplesPerSec; 314 337 } 315 338 316 339 #pragma mark - -
base/gameDetector.cpp
diff -urN ScummVM/base/gameDetector.cpp ScummVM+test/base/gameDetector.cpp
old new 78 78 " atari, fmtowns, mac, pc)\n" 79 79 " --multi-midi Enable combination Adlib and native MIDI\n" 80 80 " --native-mt32 True Roland MT-32 (disable GM emulation)\n" 81 " --output-rate=RATE Select output sample rate in Hz (e.g. 22050)\n" 81 82 " --aspect-ratio Enable aspect ratio correction\n" 82 83 "\n" 83 84 #if !defined(DISABLE_SKY) || !defined(DISABLE_QUEEN) … … 312 313 ConfMan.set("music_driver", option, kTransientDomain); 313 314 END_OPTION 314 315 316 DO_LONG_OPTION("output-rate") 317 ConfMan.set("output_rate", (int)strtol(option, 0, 10), kTransientDomain); 318 END_OPTION 319 315 320 DO_OPTION_BOOL('f', "fullscreen") 316 321 ConfMan.set("fullscreen", cmdValue, kTransientDomain); 317 322 END_OPTION -
doc/05_01.tex
diff -urN ScummVM/doc/05_01.tex ScummVM+test/doc/05_01.tex
old new 37 37 &atari, fmtowns, mac, pc)\\ 38 38 --multi-midi &Enable combination of Adlib and native MIDI\\ 39 39 --native-mt32 &True Roland MT-32 (disable GM emulation)\\ 40 --output-rate=RATE &Select output sample rate in Hz (e.g. 22050)\\ 40 41 --aspect-ratio &Enable aspect ratio correction\\ 41 42 \\ 42 43 --alt-intro &Use alternative intro for CD versions of Beneath a\\ -
doc/07.tex
diff -urN ScummVM/doc/07.tex ScummVM+test/doc/07.tex
old new 34 34 \input {07_02.tex} 35 35 \input {07_03.tex} 36 36 \input {07_04.tex} 37 \input {07_05.tex} 38 No newline at end of file 37 \input {07_05.tex} 38 \input {07_06.tex} -
doc/07_06.tex
diff -urN ScummVM/doc/07_06.tex ScummVM+test/doc/07_06.tex
old new 1 2 %%% Local Variables: 3 %%% mode: latex 4 %%% TeX-master: "readme" 5 %%% End: 6 7 \subsection{Output sample rate} 8 9 The output sample rate tells ScummVM how many sound samples to play per channel 10 per second. There is much that could be said on this subject, but most of it 11 would be irrelevant here. The short version is that for most games 22050 Hz is 12 fine, but in some cases 44100 Hz is preferable. On extremely low-end systems 13 you may want to use 11025 Hz, but it's unlikely that you have to worry about 14 that. 15 16 To elaborate, most of the sounds ScummVM has to play were sampled at either 17 22050 Hz or 11025 Hz. Using a higher sample rate will not magically improve the 18 quality of these sounds. Hence, 22050 Hz is fine. 19 20 Some games use CD audio. If you use compressed files for this, they are 21 probably sampled at 44100 Hz, so for these games that may be a better choice of 22 sample rate. 23 24 When using the Adlib, FM Towns, PC Speaker or IBM PCjr music drivers, ScummVM 25 is responsible for generating the samples. Usually 22050 Hz will be plenty for 26 these, but there is at least one piece of Adlib music in Beneath a Steeel Sky 27 that will sound a lot better at 44100 Hz. 28 29 Using frequencies in between is not recommended. For one thing, your sound card 30 may not support it. In theory, ScummVM should fall back on a sensible frequency 31 in that case, but don't count on it. More importantly, ScummVM has to resample 32 all sounds to its output frequency. This is much easier to do well if the 33 output frequency is a multiple of the original frequency. -
doc/08.tex
diff -urN ScummVM/doc/08.tex ScummVM+test/doc/08.tex
old new 92 92 joystick\_num &number Number of joystick device to use for input\\ 93 93 master\_volume &number The master volume setting (0-255)\\ 94 94 music\_driver &string The music engine to use.\\ 95 output\_rate &number The output sample rate to use, in Hz. Sensible\\ 96 & values are 11025, 22050 and 44100.\\ 95 97 alsa\_port &string Port to use for output when using the\\ 96 98 & ALSA music driver.\\ 97 99 music\_volume &number The music volume setting (0-255)\\ -
sound/mixer.cpp
diff -urN ScummVM/sound/mixer.cpp ScummVM+test/sound/mixer.cpp
old new 111 111 _premixProc = 0; 112 112 int i = 0; 113 113 114 _outputRate = (uint) _syst->getOutputSampleRate();115 116 if (_outputRate == 0)117 error("OSystem returned invalid sample rate");118 119 114 _globalVolume = 0; 120 115 _musicVolume = 0; 121 116 … … 125 120 _channels[i] = 0; 126 121 127 122 _mixerReady = _syst->setSoundCallback(mixCallback, this); 123 _outputRate = (uint) _syst->getOutputSampleRate(); 124 125 if (_outputRate == 0) 126 error("OSystem returned invalid sample rate"); 127 128 debug(1, "Output sample rate: %d Hz", _outputRate); 128 129 } 129 130 130 131 SoundMixer::~SoundMixer() {