User Manual/Appendix: Music and sound

From ScummVM :: Wiki
Jump to navigation Jump to search

Music drivers

Some games (such as Sam & Max Hit the Road) only contain music in the form of MIDI data. At one time, this prevented music for these games from working on platforms that do not support MIDI, or soundcards that do not provide MIDI drivers (e.g. many soundcards will not play MIDI under Linux). ScummVM can now emulate MIDI mode using AdLib, FluidSynth MIDI or MT-32 emulation modes: on most operating systems and for most games, ScummVM will by default use AdLib emulation for music playback. However, if you are capable of using native MIDI, we recommend using one of the Native MIDI drivers below for best sound and performance. This may require manual configuration on some systems.

Name Description
null Null output: don't play any music
 
adlib Internal AdLib emulation (default)
fluidsynth FluidSynth MIDI emulation
mt32 Internal MT-32 emulation
pcjr Internal PCjr emulation (only usable in SCUMM games)
pcspk Internal PC Speaker emulation
towns Internal FM-TOWNS YM2612 emulation (only usable in SCUMM FM-TOWNS games)
 
CAMD Amiga MIDI (Commodore Amiga MIDI Driver - Amiga only).
windows Windows MIDI (Windows only). Uses built-in sequencer
 
core CoreAudio sound (Mac OS X only)
coremidi CoreMIDI sound (Mac OS X only). Use only if you have a hardware MIDI synthesizer
 
alsa Output using ALSA sequencer device (Unix only)
seq Use /dev/sequencer for MIDI (Unix only)
 
timidity Connect to TiMidity++ MIDI server

You can either select a sound driver using the Launcher, or run ScummVM with the the '-e' option (see Command line options), for example:

   scummvm -eadlib monkey2

Emulation drivers

AdLib emulation

By default an AdLib card will be emulated and ScummVM will output the music as sampled waves. This is the default mode for most games, and offers the best compatibility between machines and games. Up to version 0.13.1 only one emulator was available (the MAME OPL emulator). After version 0.13.1 the DOSBox OPL emulator has been added. However this emulator is still experimental.

FluidSynth MIDI emulation

If ScummVM was build with libfluidsynth support it will be able to play MIDI music through the FluidSynth driver. You will have to specify a SoundFont to use, however. Since the default output volume from FluidSynth can be fairly low, ScummVM will set the gain by default to get a stronger signal. This can be further adjusted using the --midi-gain command-line option, or the "midi_gain" config file setting.

The setting can take any value from 0 through 1000, with the default being 100. (This corresponds to FluidSynth's gain settings of 0.0 through 10.0, which are presumably measured in decibel.)

NOTE: The processor requirements for FluidSynth can be fairly high in some cases. A fast CPU is recommended.

MT-32 emulation

Some games which contain MIDI music data also have improved tracks designed for the MT-32 sound module. ScummVM can now emulate this device, however you must provide original MT-32 ROMs to make it work:

MT32_PCM.ROM - IC21 (512KB) MT32_CONTROL.ROM - IC26 (32KB) and IC27 (32KB), interleaved byte-wise

Place these ROM's in the game directory, in your extrapath, or in the directory where your ScummVM executable resides.

You don't need to specify --native-mt32 with this driver, as it automatically gets turned on.

NOTE: The processor requirements for the emulator are quite high; a fast CPU is strongly recommended.

Native MIDI drivers

Use the appropriate -e<mode> command line option from the list above to select your preferred MIDI device. For example, if you wish to use the Windows MIDI driver, use the -ewindows option.

Sequencer MIDI (Unix only)

If your soundcard driver supports a sequencer, you may set the environment variable "SCUMMVM_MIDI" to your sequencer device -- for example, to /dev/sequencer

If you have problems with not hearing audio in this configuration, it is possible you will need to set the "SCUMMVM_MIDIPORT" variable to 1 or 2. This selects the port on the selected sequencer to use. Then start scummvm with the -eseq parameter. This should work on several cards, and may offer better performance and quality than AdLib emulation. However, for those systems where sequencer support does not work, you can always fall back on AdLib emulation.

ALSA sequencer (Unix only)

If you have installed the ALSA driver with the sequencer support, then set the environment variable SCUMMVM_PORT or the config file parameter alsa_port to your sequencer port. The default is "65:0".

Here is a little how-to on how to use the ALSA sequencer with your soundcard. In all cases, to have a list of all the sequencer ports you have, try the command

aconnect -o -l

This should give output similar to:

client 64: 'External MIDI 0' [type=kernel]
    0 'MIDI 0-0        '
client 65: 'Emu10k1 WaveTable' [type=kernel]
    0 'Emu10k1 Port 0  '
    1 'Emu10k1 Port 1  '
    2 'Emu10k1 Port 2  '
    3 'Emu10k1 Port 3  '
client 128: 'Client-128' [type=user]
    0 'TiMidity port 0 '
    1 'TiMidity port 1 '

This means the external MIDI output of the sound card is located on the port 64:0, four WaveTable MIDI outputs in 65:0, 65:1, 65:2 and 65:3, and two TiMidity ports, located at 128:0 and 128:1.

If you have a FM-chip on your card, like the SB16, then you have to load the SoundFonts using the sbiload software. Example:

sbiload -p 65:0 /etc/std.o3 /etc/drums.o3

If you have a WaveTable capable sound card, you have to load a sbk or sf2 SoundFont using the sfxload software. Example:

sfxload /path/to/8mbgmsfx.sf2

If you don't have a MIDI capable soundcard, there are two options: FluidSynth and TiMidity. We recommend FluidSynth, as on many systems TiMidity will 'lag' behind music. This is very noticeable in iMUSE-enabled games, which use fast and dynamic music transitions. Running TiMidity as root will allow it to setup real time priority, which may reduce music lag.

Asking TiMidity to become an ALSA sequencer:

timidity -iAqqq -B2,8 -Os1S -s 44100 &

(If you get distorted output with this setting, you can try dropping the -B2,8 or changing the value.)

Asking FluidSynth to become an ALSA sequencer (using SoundFonts):

 fluidsynth -m alsa_seq /path/to/8mbgmsfx.sf2

Once either TiMidity or FluidSynth are running, use the 'aconnect -o -l' command as described earlier in this section.

Using TiMidity++ MIDI server

If you system lacks any MIDI sequencer, but you still want better MIDI quality than default AdLib emulation can offer, you can try TiMidity++ MIDI server. See http://timidity.sourceforge.net/ for download and install instructions.

First, you need to start a daemon:

   timidity -ir 7777

Now you can start scummvm and try selection TiMidity music output. By default, it will connect to localhost:7777, but you can change host/port by defining "TIMIDITY_HOST" environment variable.

Using compressed audio files

Using MP3 files for CD audio

Use LAME or some other MP3 encoder to rip the cd audio tracks to files. Name the files track1.mp3, track2.mp3, etc. ScummVM must be compiled with MAD support to use this option. You will need to rip the file from the CD as a WAV file, then encode the MP3 files at a constant bit rate. If you are using LAME, this can be done with the following LAME command:

lame -t -q 0 -b 96 track1.wav track1.mp3

Using Ogg Vorbis files for CD audio

Use oggenc or some other Vorbis encoder to encode the audio tracks to files. Name the files track1.ogg, track2.ogg, etc. ScummVM must be compiled with Vorbis support to use this option. You will need to rip the files from the CD as a WAV file, then encode the Vorbis files. If you are using oggenc, then it can be done using the following command with the value following -q specifying the desired quality from 0 to 10:

oggenc -q 5 track1.wav

Using Flac files for CD audio

Use FLAC or some other FLAC encoder to encode the audio tracks to files. Name the files track1.flac, track2.flac, etc. If your filesystem only allows three-letter extensions, name the files track1.fla, track2.fla, etc. ScummVM must be compiled with FLAC support to use this option. You will need to rip the files from the CD as a WAV file, then encode the FLAC files. This can be done with the following FLAC command:

flac --best track1.wav

Remember that the quality is always the same, varying encoder options will only affect the encoding time and resulting filesize.

Compressing MONSTER.SOU with MP3

You need LAME, along with our compress_scumm_sou utility from the scummvm-tools package to perform this task, and ScummVM must be compiled with MAD support.

compress_scumm_sou monster.sou

Eventually, you will have a much smaller monster.so3 file, copy this file to your game directory. You can safely remove the monster.sou file.

Compressing MONSTER.SOU with Ogg Vorbis

As above, but ScummVM must be compiled with OGG support. Run:

compress_scumm_sou --vorbis monster.sou

This should produce a smaller monster.sog file, which you should copy to your game directory. Ogg encoding may take a considerably longer amount of time than MP3, so have a good book handy.

Compressing MONSTER.SOU with Flac

As above, but ScummVM must be compiled with Flac support. Run:

compress_scumm_sou --flac monster.sou

This should produce a smaller monster.sof file, which you should copy to your game directory. Remember that the quality is always the same, varying encoder options will only affect the encoding time and resulting file size. Playing with the blocksize (-b <value>) has the biggest impact on the resulting file size -- 1152 seems to be a good value for those kinds of sound files. Be sure to read the encoder documentation before you use other values.

Compressing music/sfx/speech in AGOS games

Use our compress_agos utility from the scummvm-tools package to perform this task. You can choose between multiple target formats, but note that you can only use each if ScummVM was compiled with the respective decoder support enabled.

 compress_agos effects     (For Acorn CD version of Simon 1)
 compress_agos simon       (For Acorn CD version of Simon 1)
 compress_agos effects.voc (For DOS CD version of Simon 1)
 compress_agos simon.voc   (For DOS CD version of Simon 1)
 compress_agos simon.wav   (For Windows CD version of Simon 1)
 compress_agos simon2.voc  (For DOS CD version of Simon 2)
 compress_agos simon2.wav  (For Windows CD version of Simon 2)
 compress_agos mac         (For Macintosh version of Simon 2)
 compress_agos voices1.wav (For Windows 2CD/4CD version of Feeble)
 compress_agos voices2.wav (For Windows 2CD/4CD version of Feeble)
 compress_agos voices3.wav (For Windows 4CD version of Feeble)
 compress_agos voices4.wav (For Windows 4CD version of Feeble)
 compress_agos Music       (For Windows version of Puzzle Pack)

For Ogg Vorbis add --vorbis to the options, i.e.

compress_agos --vorbis

For Flac add --flac and optional parameters, i.e.

compress_agos --flac

Eventually you will have a much smaller *.mp3, *.ogg or *.fla file, copy this file to your game directory. You can safely remove the old file.

Compressing speech/music in Broken Sword

The compress_sword1 tool from the scummvm-tools package can encode music and speech to MP3, Ogg Vorbis as well as Flac. The easiest way to encode the files is simply copying the executable into your BS1 directory (together with the lame encoder) and run it from there. This way, it will automatically encode everything to MP3. Afterward, you can manually remove the SPEECH?.CLU files and the wave music files.

To compress the files using Ogg Vorbis instead of MP3:

compress_sword1 --vorbis

To compress the files using Flac instead of MP3:

compress_sword1 --flac

To get a full list of the options:

compress_sword1 --help

Compressing speech/music in Broken Sword II

Use our compress_sword2 utility from the scummvm-tools package to perform this task. You can choose between multiple target formats, but note that you can only use each if ScummVM was compiled with the respective decoder support enabled.

 compress_sword2 speech1.clu
 compress_sword2 music1.clu

For Ogg Vorbis add --vorbis to the options, i.e.

compress_sword2 --vorbis

Eventually you will have a much smaller *.cl3 or *.clg file, copy this file to your game directory. You can safely remove the old file.

It is possible to use Flac compression by adding the --flac option. However, the resulting *.clf file will actually be larger than the original.

Please note that compress_sword2 will only work with the four speech/music files in Broken Sword II. It will not work with any of the other *.clu files, nor will it work with the speech files from Broken Sword.

Output sample rate

The output sample rate tells ScummVM how many sound samples to play per channel per second. There is much that could be said on this subject, but most of it is beyond the scope of this document. The short version is that for most games 22050 Hz is fine, but in some cases 44100 Hz is preferable. On extremely low-end systems you may want to use 11025 Hz, but it’s unlikely that you will have to worry about that.

To elaborate, most of the sounds that ScummVM has to play were sampled at either 22050 Hz or 11025 Hz. Using a higher sample rate will not magically improve the quality of these sounds, thus 22050 Hz is fine.

Some games use CD audio. If you use compressed files for this, they are probably sampled at 44100 Hz, so for these games that may be a better choice of sample rate.

When using the AdLib, FM Towns, PC Speaker or IBM PCjr music drivers, ScummVM is responsible for generating the samples. Usually 22050 Hz will be plenty for these, but there is at least one piece of AdLib music in Beneath a Steel Sky that will sound a lot better at 44100 Hz.

Using frequencies in between is not recommended. For one thing, your sound card may not support it. In theory, ScummVM should fall back on a sensible frequency in that case, but don’t count on it. More importantly, ScummVM has to resample all sounds to its output frequency. This is much easier to do well if the output frequency is a multiple of the original frequency.