1======================================================
2Understanding the audio settings
3======================================================
4
5This guide expands on the information contained on the :doc:`audio settings <../settings/audio>` page.
6
7
8How do the audio settings work together?
9==========================================
10
11The **Preferred device** in the global settings Audio tab, or the **Music device** in the game-specific settings Audio tab, specifies the device that ScummVM uses to output audio. This device can be an emulated sound device or a software synthesizer, or an actual hardware device such as a soundcard or a hardware MIDI synthesizer. When set to **<default>**, ScummVM will automatically choose the most appropriate option for the played game.
12
13If **Preferred device** or **Music device** is set to **<default>** and ScummVM chooses either an MT-32 or General MIDI device automatically, the settings on the MT-32 or MIDI tabs also apply, and the devices selected on these tabs are the ones that will be used. If **Preferred device** or **Music device** is set to either an MT-32 device or a GM device, ScummVM will use that device and ignore the devices chosen on the MT-32 and MIDI tabs.
14
15Not all settings are applicable to all games. For example, changing the General MIDI settings will not have any effect on a game that only has CD audio.
16
17
18The evolution of PC audio
19=============================
20
21For a look at the evolution of PC audio, see `this video on YouTube <https://www.youtube.com/watch?v=a324ykKV-7Y>`_, or `this excellent post <http://www.oldskool.org/sound/pc>`_.
22
23Many of these old-school audio devices can be emulated by ScummVM:
24
25- PC Speaker: emulates the built-in PC speaker. This is mostly supported by older games, and was the only option before sound cards became widely used.
26
27    *pcspk*
28
29- IBM PCjr: emulates the sound of the 1984 IBM PCjr computer, which, enhanced with a Texas Instruments chip, provided three-voice sound and a white noise generator.
30
31    *pcjr*
32
33- Creative Music System `(C/MS) <https://en.wikipedia.org/wiki/Sound_Blaster#Creative_Music_System>`_: emulates the first sound card developed by Creative Technology (later Creative Labs), the precursor to the SoundBlaster line of sound cards. The C/MS provided 12 channels of square-wave stereo sound.
34
35    *cms*
36
37- C64 Audio: emulates the sound chip `(Sound Interface Device) <https://theconversation.com/the-sound-of-sid-35-years-of-chiptunes-influence-on-electronic-music-74935>`_ in the Commodore 64 computer. The SID was a three-voice synthesizer module, with a fourth voice for sampled drums or speech.
38
39    *C64*
40
41- Amiga Audio: emulates the Amiga audio chip, `Paula <https://en.wikipedia.org/wiki/Original_Chip_Set#Audio>`_, which had four 8-bit PCM sound channels.
42
43    *CAMD*
44
45- FM-Towns Audio: emulates the audio of the `FM Towns PC  <https://en.wikipedia.org/wiki/FM_Towns#Sound>`_. Games on FM Towns computers often used audio CD standard tracks. The soundchips were capable of eight PCM voices and six FM channels.
46
47    *towns*
48
49- PC-98 Audio: emulates the audio of the NEC PC-9801-26 and PC-9801-86 sound cards.
50
51    *pc98*
52
53- SegaCD Audio: emulates the audio of the Sega CD add-on for the Sega Genesis/32x.
54
55    *segacd*
56
57To find out which emulation is compatible with the game you're playing, have a look at the manual that comes with the game.
58
59What is MIDI?
60======================
61
62MIDI is a communications protocol for musical information; it can be likened to digital sheet music. By itself, MIDI is not sound. Hardware or software synthesizers create (synthesize) audio by interpreting the information given to them by the MIDI protocol.
63
64While some older soundcards (and a few modern ones) have their own hardware-based synthesizers, this is relatively rare. Generally, soundcard drivers work with software synthesizers to interpret MIDI and output audio.
65
66Some games only contain MIDI audio data. In the past this prevented audio for these games from working on platforms that did not support MIDI, or with soundcards that did not provide MIDI drivers. ScummVM can now convert MIDI data to sampled audio using MIDI device emulators.
67
68
69What is General MIDI?
70------------------------------
71
72General MIDI is a MIDI standard which is implemented by a large number of devices. While using MIDI as its protocol, it also specifies an instrument map and some other information that devices must implement.
73
74
75.. _FS:
76
77General MIDI device emulation (FluidSynth)
78*************************************************
79
80If the ScummVM you're using has libfluidsynth support it will be able to play MIDI music by using the FluidSynth emulator if set as the **Preferred device** or **Music device**, or if specified in the MIDI tab when **Preferred device** or **Music device** is set to **<default>** and ScummVM chooses General MIDI output automatically.
81
82You will have to specify a SoundFont in the MIDI tab for ScummVM to use FluidSynth. MIDI is like digital sheet music; it needs a library of sound samples known as a SoundFont to draw from to synthesize music. See the `ScummVM forum <https://forums.scummvm.org/viewtopic.php?t=14541>`_ for an example of a great SoundFont.
83
84The default output volume from FluidSynth can be fairly low, so ScummVM automatically sets the gain to get a stronger signal. Use the :ref:`MIDI gain <gain>` setting to further adjust this.
85
86The processor requirements for FluidSynth are quite high; a fast CPU is recommended.
87
88What is MT-32?
89---------------------
90
91The MT-32 is a `Roland sound module <https://en.wikipedia.org/wiki/Roland_MT-32>`_, although the term also commonly refers to a range of devices that are fully compatible with the MT-32. MT-32 devices also use MIDI as the communications protocol.
92
93
94.. _MT-32:
95
96MT-32 device emulation
97********************************
98
99Some games which contain MIDI music data have tracks designed specifically for the Roland MT-32. ScummVM can emulate the MT-32 device, however you must provide the original MT-32 ROMs, taken from the MT-32 module, for the emulator to work. These files are:
100
101- MT32_PCM.ROM - IC21 (512KB)
102- MT32_CONTROL.ROM - IC26 (32KB) and IC27 (32KB)
103
104Place these ROMs in the game directory, in your extrapath, or in the directory where your ScummVM executable resides. ScummVM also looks for ``CM32L_PCM.ROM`` and ``CM32L_CONTROL.ROM``—the ROMs from the CM-32L device—and uses these instead of the MT32 ROMs if they are available.
105
106.. note::
107
108    The MT-32 ROMs are copyrighted, and are not provided by ScummVM. These must be taken from your own MT-32 module.
109
110ScummVM uses the MT-32 emulator if it is set as the **Preferred device** or **Music device**, or if it is specified in the MT-32 tab when **Preferred device** or **Music device** is set to **<default>** and ScummVM chooses MT-32 output automatically.
111
112You don't need to enable **True Roland MT-32** in the MT-32 tab, ScummVM does this automatically.
113
114.. tip::
115
116    Some games work better with some MT-32 devices than others. As an example, Lure of the Temptress makes use of extra sound effects included with the CM-32L and won't sound right with an MT-32. Likewise, The Colonel's Bequest uses some bugs in the early MT-32 modules, which means that later devices will play incorrect sound effects!
117
118    `This Wikipedia article <https://en.wikipedia.org/wiki/List_of_MT-32-compatible_computer_games>`_ provides a comprehensive list of MT-32 compatible games, including which games work best with which device.
119
120The processor requirements for the MT-32 emulator are quite high; a fast CPU is strongly recommended.
121
122
123Built-in MIDI support
124--------------------------
125
126All MIDI ports show up in the **Preferred device** or **Music device** dropdown selector. If you have selected a MIDI port, you need to specify what type of MIDI device this is with the options in the :ref:`MT-32 <mt32>` tab.
127
128- Enable **True Roland MT-32** to tell ScummVM that the MIDI device is an MT-32 (or fully compatible) device.
129- Enable **Roland GS device** to tell ScummVM to use an MT-32 soundtrack on a GS device. This is not supported by all games.
130- If no options are selected, ScummVM treats the device on the port as a General MIDI device.
131
132If you select an option that does not match the actual device, this might have unintended consequences. For example, if a game only has support for MT-32 and you have a General MIDI device selected as the **Preferred device** or **Music device**, ScummVM will convert the MT-32 MIDI data to GM-compatible MIDI data. While this might work fine for some games, it really depends on how the game has made use of the MT-32.
133
134
135
136macOS/Mac OSX
137***************
138
139Mac has a built-in MIDI synthesizer; Apple DLS software synthesizer. It uses the Mac's built-in sounds (which are based on Roland GS).
140
141The `Apple Support page <https://support.apple.com/en-nz/guide/audio-midi-setup/ams875bae1e0/mac>`_ has further information about setting up MIDI devices on a Mac.
142
143Windows
144**********
145
146Windows has a generic built-in MIDI synthesizer—GS WaveTable Synth—also based on Roland's GS sounds.
147
148For an in-depth look at audio and MIDI device setup on a Windows computer, see this `very helpful article <http://donyaquick.com/midi-on-windows/>`_.
149
150Linux
151******
152
153MIDI device setup might vary depending on your Linux distro.
154
155If you do not have a hardware MIDI device, there are two options: FluidSynth and TiMidity. FluidSynth is recommended as TiMidity might have some lag, depending on the system.
156
157Here are a couple of helpful articles from the Ubuntu community documentation to get you started.
158
159`How to: Software Synthesizers <https://help.ubuntu.com/community/Midi/SoftwareSynthesisHowTo>`_
160
161`How to: Hardware synthesizer soundcard setup <https://help.ubuntu.com/community/Midi/HardwareSynthesisSetup?action=show&redirect=MidiHardwareSynthesisSetup>`_
162
163,,,,,,,,,,,,,,,,,,,,
164
165.. _adlib:
166
167What is AdLib?
168================
169
170AdLib devices do not use MIDI. They instead have a chip that produces sound through FM synthesis. While some games do store their audio data using a MIDI-derived format, this is converted by the game to work with the AdLib chip. ScummVM emulates a few different AdLib configurations, and selects the most appropriate for the game:
171
172- The original AdLib and SoundBlaster card had one OPL2 chip.
173- The SoundBlaster Pro 1 had two OPL2 chips
174- The SoundBlaster Pro 2 and 16 had an OPL3 chip.
175
176The AdLib emulator setting offers MAME, DOSBox and Nuked emulation, with MAME being the least accurate and using the least CPU power, and Nuked being the most accurate and also using the most CPU power - DOSBox is somewhere in between.
177
178There is also the option to select the OPL2LPT and OPL3LPT devices, which are external hardware devices with a real OPL chip, connected through the parallel port of a computer.
179
180AdLib does not require a SoundFont or ROMs, so for many games it might be the easiest to configure. However, if an MT-32 or GS emulator or device is available, ScummVM will prioritize this over AdLib.
181
182Mixed AdLib/MIDI mode
183------------------------
184Some games contain sound effects that are exclusive to the AdLib soundtrack, or the AdLib soundtrack might provide better sound effects. For these games, you can combine MIDI music with AdLib sound effects by using the :ref:`mixed AdLib/MIDI mode <multi>`.
185
186.. note::
187
188    Mixed AdLib/MIDI mode is not supported by all games.
189
190Digital Sound effects
191=======================
192
193Some games have both sampled and synthesized sound effects. ScummVM will usually use the sampled sound effects, even if you select Adlib, MT-32 or GM as your audio device. Some games allow you to choose between sampled and synthesized sound effects by using the **Prefer digital sound effects** option in the Engine tab.
194
195.. _outputrate:
196
197Sample output rate
198========================
199
200The output sample rate tells ScummVM how many sound samples to play per channel per second.
201
202Most of the sounds were originally sampled at either 22050Hz or 11025Hz, so using a higher sample rate in these cases will not improve the quality of the audio.
203
204For games that use CD audio, the sounds were probably sampled at 44100Hz, so that is a better sample rate to choose for these games.
205
206ScummVM generates the samples when using AdLib, FM-Towns, PC Speaker or IBM PCjr emulated sound. 22050Hz will usually be fine for these options, although for Beneath a Steel Sky 44100Hz is recommended.
207
208ScummVM has to resample all sounds to the selected output frequency. It is recommended to choose an output frequency that is a multiple of the original frequency. Choosing an in-between number might not be supported by your sound card.
209
210.. _buffer:
211
212Audio buffer size
213==========================
214
215There is no option to control audio buffer size through the GUI, but the default value can be overridden in the the :doc:`configuration file <../advanced_topics/configuration_file>` with the *audio_buffer_size* configuration keyword. The default value is calculated based on output sampling frequency to keep audio latency below 45ms.
216
217Appropriate values are normally between 512 and 8192, but the value must be one of: 256, 512, 1024, 2048, 4096, 8192, 16384, or 32768.
218
219Smaller values yield faster response time, but can lead to stuttering if your CPU isn't able to catch up with audio sampling when using the sound emulators. Large buffer sizes might lead to minor audio delays (high latency).
220
221
222