In this tutorial I would like to show you how to handle sound effects. But before you start, make sure that you have installed World of Padman correctly in the current version. With older versions, errors could occur when using this tutorial.
Supported file formats
Actually, the id-Tech3 engine used in Quake 3 Arena only supports sound files in WAV format. This is a container format which contains so-called PCM raw data and thus can represent the samples of the audio signal in uncompressed digital form. To do this, the WAV files must conform to the following specification:
- Number of channels: 1 (corresponds to mono)
- Sample rate per second: 22,050 Hz
- Bits per sample: 8 bit or 16 bit
Certainly, this specification does not conform to the usual audio CD quality (44,100 Hz, 16 bit, stereo), but the uncompressed WAV file format can quickly lead to greater demand for memory and hard disk space. Presumably for this reason and the large number of simultaneously played sounds at the same time, one made a compromise in terms of sound quality. Although sound files could basically be saved in 44,100 Hz, these were still played in Quake 3 Arena only with 22,050 Hz (high) or 11,025 Hz (low), depending on the chosen quality setting by the user.
Since the development of the id-Tech3 engine in the context of the ioquake3 project, the audio codec Ogg Vorbis has also been supported. The OGG file format is a container format for lossy compressed audio files, which however is a patent-free audio format and thus may be used without a license, unlike the widely used MP3 format. Since this is only an alternative container format, it is basically subject to the same limitations as the WAV file format within the ioquake3 engine.
Only with the support of OpenAL these quality restrictions for sound files were removed. We have also modified the ioquake3 engine to support sound files with a sample rate of 44,100 Hz natively, even if OpenAL is not enabled. Due to the expected size of WAV files, it is therefore generally advisable to switch to the OGG file format. Despite the audio compression an improved sound quality can be expected now. To do this, the OGG files must conform to the following specification:
- Number of channels: 1 (corresponds to mono)
- Sample rate per second: 44,100 Hz
- Bits per sample: 16 bit
Please note that the compression can be done individually, but for World of Padman sound quality level 2 has proven to be a good compromise between sound quality and file size. This corresponds to an avarage bit rate of 96 kbit/s. To convert WAV files to OGG files, there is a small tool called oggdropXPd.
Insert sound effects
In Radiant, sound effects are inserted into a map using the target_speaker entity, which you can find in the context menu (right-click) under target. After selecting the entity, you can use the [N] key to bring up the Enities menu window. By specifying noise in the Key field, you must assign the path to a sound file in the Value field (here: sounds/maps/animal/cricket_chirping2). Confirm the entry with the [ENTER] key. So that the sound effect can now be played without any further action, you must at least activate the spawnflag looped_on. For more information on spawnflags, see the next section.
Please note, that the path must always be given with a slash instead of a backslash, as is common in Unix systems. For an overview of existing sound effects and their paths in World of Padman, see the catalog: sound effects. In contrast to the previous handling with Quake 3 Arena, the path must now be given without the file suffix (WAV), if you want to use sounds in the OGG file format as well. The ioquake3 engine automatically adds the correct file suffix and falls back to WAV, if there is no OGG file available. See the following examples:
- OGG or WAV: sounds/maps/ambient/car_crash
- Only WAV: sounds/maps/ambient/car_crash.wav
Spawnflags and their meaning
Through the use of so-called spawnflags you can define various settings for the target_speaker entity. These can also be combined with each other, although not all combinations make sense or work.
- looped_on allows to play a sound effect without a break in an infinite loop from the start of the map. The sound can be switched off and on again via a trigger.
- looped_off allows to play a sound effect without a break in an infinite loop, but does not start from the start of the map. A trigger can turn the sound on and off again. For the sound effect to be played at all, it must always be started via a trigger.
- global allows to be played a sound effect through the entire map and at full volume regardless of the actual position. This spawnflag can not be combined with any of the above described looped spawn flags and must always be started via a trigger.
- activator allows to play a sound effect which is only audible to the player who triggered it. For the sound effect to be played at all, it must always be started via a trigger.
Delay sound effects randomly
With the keys wait and random you can delay the playback of a sound effect at random. For example, wait (here: 15) will cause a delay of 15 seconds before the sound effect is played back. By specifying random (here: 5), this delay will be shortened or extended by a randomly determined time between 0 and 5 seconds. For example, ambient noise that is supposed to contribute to the atmosphere in the map can be played back differently in time from the start of the map, without, for example, a func_timer being required as a trigger. The spawnflag looped_on must not be activated with this method!
Sound effects with triggers
Sound effects can be turned on or off by triggers. These triggers can be anything, such as a trigger_multiple, func_timer, func_button, func_door or even items like weapons or powerups.
In the TrashMap, for example, while picking up the iMPERiUS, the sound “Give it to me baby” is played back globally throughout the entire map. To do it yourself, first select the entity weapon_imperius and then the entity target_speaker. If both entities has been selected in the described order, press the key combination [Ctrl+K] to associate the entity weapon_imperius with the entity target_speaker. The order of the selection is crucial!
Alternatively, you can also enter the keys target for the entity weapon_imperius and targetname for the entity target_speaker directly for each Entity in the Entities menu window to create a link between the two. The keys target and targetname must have the same value in the Value field (here: target_speaker25), so that the assignment works correctly. However, this value must then be unique in the whole map, so the automatic assignment as described above is highly recommended and ensures just that.
In another, more classic example, there is a sound effect played back in the TrashMap as soon as the player passes through a tuft of grass. For this purpose, a simple brush of approximately the same dimensions was created around the tuft of grass and completely covered with the texture common/trigger. The brush remains selected and is made a trigger/trigger_multiple via the context menu (right-click). Then the entity target_speaker is added to the selection. If both entities are selected in the described order, press the key combination [Ctrl+K] to associate the trigger_multiple with the entity target_speaker. The keys target and targetname are given the same value then in the Value field (here: target_speaker22).
So that the sound is not played continuously, if someone accidentally stops in the tuft of grass, the trigger_multiple is additionally delayed by a few seconds with the key wait entered via the Entities menu window.
Influence the volume
There is basically no parameter to influence the volume or range of a sound effect in the map. However, you can focus a sound effect at certain points of a map by the increased use of the same taget_speaker in selected spatial intervals. To duplicate, select the entity taget_speaker and press the spacebar. Any keys and values that you already have defined are preserved in the duplicated entity.