Sounds: Background and Local

From The DarkMod Wiki
Jump to navigationJump to search

written by Fidcal

Introduction

All that is assumed is you know the essentials described in Dark Radiant Must Know Basic Intro

If you want a global ambient sound heard throughout your mission then also read Adding ambient Sounds to your Map.

This tutorial covers general background sounds, local ambience, environmental, or sounds related to specific objects in the game such as a machine or a drain.


Sound File Types

OGG and WAV files are used in Dark Mod. For details see Sound File Formats

OGG files are compressed whereas WAV files do not compress well even in zip files (so I'm told!)

You can create your own sounds but there is already a large range provided in Dark Mod ready to use.

Those sound files can be referenced either directly (with full path and name) or via a definition file called a sound shader which can include various controls as well as the name of the sound file and path. Multiple sound file definitions can be included in one sound shader file. Other controls are available as properties in the speaker entity in the map file. These properties will override the equivalent definition in the sound shader.


Speaker Entity

The speaker entity is like a loudspeaker that you place in your mission.

To include a sound in your mission...

  • create a speaker entity and position it where you want the sound to be centred.
  • Add the property s_shader
  • In Dark Radiant you can select a sound shader from the button below the entity properties.


Properties of the Speaker Entity

The following are properties to add to the speaker entity to adjust the way it plays sounds. There is no need to dmap between adjustments of these properties. Assuming you have dmapped once you can just use map to test changes.

Before proceeding, it's worth quoting Orbweaver:

  1. If a speaker is looping, it will play all the time, but will obviously only be audible when the player is within range.
  2. If a speaker is non-looping but waits for trigger, then it will do nothing until triggered. Once triggered it will play but will only be audible if the player is within range.
  3. If a speaker is non-looping and untriggered, it will play once at startup, irrespective of whether the player is near enough to hear it.


Loudness, Volume

The s_volume property allows you to change the volume of a sound. It specifies the change to the volume of the audio file, in decibels, and may be positive or negative.

Be careful about making sounds too loud with this keyvalue, decibels are fairly "small" units and setting a volume increase of +20dB may well make the sound too loud for players. Ambient sounds should be at a similar volume throughout the map, and should not be so loud as to obliterate important gameplay sounds such as footsteps, or cause the player to reach for their volume control every time they enter a new area.

Control of volume by 'Ambient Volume' menu setting

If you want to give the player user-friendly control over the sound volume (as with ambient music, which some players prefer off), include the keypair "s_music" "1" on the speaker entity.

Direction of Source, Propogation through Doorways

s_occlusion 1 makes the sound go in a straight line and not through visportalled gaps like doorways etc. If set to 0 then it follows a natural route through openings.

s_omni 1 makes the sound come from no particular direction so this is ideal for ambience like rainfall or mood music (unless that music is meant to come from something in the game.) Set s_omni to 0 if you want your sound to sound like it is coming from the speaker entity.



Range, Radius, Distance covered by Sound

The units used for the distance reached by the speaker entity are in metres not Doom units so these approximate 40 normal units. In DoomEd the radius is shown in the grid view and this feature is also being added to Dark Radiant.

  • s_mindistance N = distance in metres from speaker at which sound starts to fade. Within that radius it is at full volume.
  • s_maxdistance N = distance in metres from speaker beyond which it cannot be heard at all.

Triggering a Sound

Speakers by default will start to play at mission start even if the player is not in range to hear them. But speakers can be set to wait for a trigger - so any switch, button or other trigger can start and stop them. To do this, set the property s_waitfortrigger to 1 then the speaker is disabled until triggered by a switch of some sort. Default is 0.


Playing a Sound Once

By default, if no looping or repeat is set up then a speaker will play once at mission start then stop. But unless the player is within range it will not be heard.

So to play a sound once when the player approaches you need a separate vicinity trigger (see also #Triggering a Sound) that triggers only once. This is how...

  • Create and place your speaker and give it the property s_waitfortrigger with a value of 1
  • At the place where you want the player to trigger the sound create a brush with a volume suitable for the trap so the player will pass into it.
  • With the brush selected, assign it (create) an entity trigger_once
  • The brush automatically gets a trigger texture which is invisible in-game.
  • Add the property target with the value being the name of your speaker.

When the player moves into that invisible brush it should trigger the speaker to play its sound once only.

Repeating a Sound Continuously

s_looping

s_looping repeats a sound seamlessly and is the one to use for continuous sound like rain, continuous machinery, etc. (compare also wait before using this.

s_looping set to 1 means...

  1. Play sound immediately the player is within range (set by s_maxdistance)
  2. Wait until the sound has finished playing
  3. Repeat endlessly unless the player moves out of range (set by s_maxdistance)

Set s_looping to 0 to disable (default)



wait (repeat)

wait n means repeat every n seconds endlessly so is the one to use to repeat with a gap between plays of the sound. Do NOT use it with s_looping set to 1 because 'wait' repeats on its own and s_looping will override it and repeat immediately and endlessly.

wait n means...

  1. Play sound immediately the player is within range (set by s_maxdistance)
  2. Wait n seconds from START of playing sound
  3. Repeat endlessly unless the player moves out of range (set by s_maxdistance)

What if n is shorter than the length of the wav or ogg file? If there is only a single sound in the sound shader file then it cuts the sound short and starts again. Here's an example of what happens If, eg, you play a bell sound that is 6 seconds long (the original ogg or wav file) and if you set wait 1 then it will...

  1. start to play the sound
  2. plays it for 1 second
  3. will not complete that but...
  4. begin again at the start every 1 second.

However, if there are multiple sounds in the sound shader file which are selected randomly then they one will be played every N seconds and they will overlap unless it happens to call the same one twice in a row (which can be prevented with nodupes in the sound shader file.)

Use with random to vary the wait time...

random

Use with the wait property to vary the repeat time. random n varies the wait time randomly by plus or minus n seconds. So for example...

  • wait 30
  • random 10

...will play the sound repeatedly between 20 to 40 seconds from the start of playing the sound.

If random is greater than wait then it works the same but with a minimum of zero, so....

  • wait 10
  • random 15

... will play the sound repeatedly between 0 and 25 seconds from the start of playing the sound.

he sound no directional source, ie, it will not seem to come from the direction of the speaker but from all directions.


Screen Shaking, Explosions, etc.

s_shakes set to 1 makes the screen shake when the sound is loud. Suitable for explosions, earthquakes.


Sound Shader Definition Files

This to be written. It might need a separate article in which case adjust the link above. Meanwhile here is an external link...

http://www.iddevnet.com/doom3/sounds.php

Setting Up Speakers aims to cover shaders as well.
(apologies for the overlap btw., plasticman)