Ticket #8341: output-freq.2.diff
File output-freq.2.diff, 11.7 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 133 133 134 134 virtual void setWindowCaption(const char *caption); 135 135 virtual bool openCD(int drive); 136 virtual void setOutputSampleRate(int rate); 136 137 virtual int getOutputSampleRate() const; 137 138 138 139 virtual bool hasFeature(Feature f); … … 169 170 SDL_Surface *_tmpscreen; 170 171 bool _overlayVisible; 171 172 173 // Audio 174 int _samplesPerSec; 175 172 176 // CD Audio 173 177 SDL_CD *_cdrom; 174 178 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(SAMPLES_PER_SEC), 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 // Originally, we always used 2048 samples. This loop will produce the 298 // same result at 22050 Hz, and should hopefully produce something 299 // sensible for other frequencies. Note that it must be a power of two. 300 301 uint16 samples = 0x8000; 302 303 for (;;) { 304 if (samples / (_samplesPerSec / 1000) < 100) 305 break; 306 samples >>= 1; 307 } 308 309 desired.freq = _samplesPerSec; 296 310 desired.format = AUDIO_S16SYS; 297 311 desired.channels = 2; 298 desired.samples = 2048;312 desired.samples = samples; 299 313 desired.callback = proc; 300 314 desired.userdata = param; 301 if (SDL_OpenAudio(&desired, NULL) != 0) {315 if (SDL_OpenAudio(&desired, &obtained) != 0) { 302 316 return false; 303 317 } 318 // Note: This should be the obtained output rate, but it seems that at 319 // least on some platforms SDL will lie and claim it did get the rate 320 // even if it didn't. Probably only happens for "weird" rates, though. 321 _samplesPerSec = obtained.freq; 304 322 SDL_PauseAudio(0); 305 323 return true; 306 324 } … … 309 327 SDL_CloseAudio(); 310 328 } 311 329 330 void OSystem_SDL::setOutputSampleRate(int rate) { 331 // The function can't be called after the audio device has been opened 332 if (SDL_GetAudioStatus() == SDL_AUDIO_STOPPED) 333 _samplesPerSec = rate; 334 } 335 312 336 int OSystem_SDL::getOutputSampleRate() const { 313 return SAMPLES_PER_SEC;337 return _samplesPerSec; 314 338 } 315 339 316 340 #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 -
common/system.h
diff -urN ScummVM/common/system.h ScummVM+test/common/system.h
old new 546 546 virtual void clearSoundCallback() = 0; 547 547 548 548 /** 549 * Set the desired output sample rate. It has to be called before 550 * setSoundCallback(), and it's not certain that we actually get it. 551 * Use getOutputSampleRate() to find out. 552 */ 553 virtual void setOutputSampleRate(int rate) = 0; 554 555 /** 549 556 * Determine the output sample rate. Audio data provided by the sound 550 557 * callback will be played using this rate. 551 558 * @return the output sample rate -
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 21 21 */ 22 22 23 23 #include "stdafx.h" 24 #include "common/config-manager.h" 24 25 #include "common/file.h" 25 26 #include "common/util.h" 26 27 … … 111 112 _premixProc = 0; 112 113 int i = 0; 113 114 114 _outputRate = (uint) _syst->getOutputSampleRate(); 115 116 if (_outputRate == 0) 117 error("OSystem returned invalid sample rate"); 115 if (ConfMan.hasKey("output_rate")) 116 _syst->setOutputSampleRate(ConfMan.getInt("output_rate")); 118 117 119 118 _globalVolume = 0; 120 119 _musicVolume = 0; … … 125 124 _channels[i] = 0; 126 125 127 126 _mixerReady = _syst->setSoundCallback(mixCallback, this); 127 _outputRate = (uint) _syst->getOutputSampleRate(); 128 129 if (_outputRate == 0) 130 error("OSystem returned invalid sample rate"); 131 132 debug(1, "Output sample rate: %d Hz", _outputRate); 128 133 } 129 134 130 135 SoundMixer::~SoundMixer() {