Sound

Below is a sample sound configuration, with links to documentation for every attribute. See manual about sounds for information how to initialize sound repository from such XML configuration.

<?xml version="1.0"?>

<sounds>
  <!--
    Contains a list of <sound> elements.
    Only the "name" attribute is required, and all names must be unique.
    The sound URL (filename) by default
    (if you don't specify other URL explicitly) is determined like this:
    - In CGE <= 6.4: <name>.wav
    - In CGE >= 6.5:
      <name>.ogg, or
      <name>.wav (whichever is found first), or
      none (this causes a warning).
  -->

  <sound
    name="player_sudden_pain"
    url=""
    default_importance="max"
    gain="1.0"
    min_gain="0.0"
    max_gain="1.0" />

  <!-- And more <sound> elements... -->
  <sound name="test_sound_1" />
  <sound name="test_sound_2" />
  <sound name="test_sound_3" />

  <!--
    (Since CGE >= 6.5):

    Sound group is like a directory of sound files.
    Sounds within a group named "fight" must be played using a qualified
    name like "fight/drum_beat".
    This way sound names must only be unique within their group.

    Sound group can also (optionally) correspond to an actual subdirectory
    of sound files, if it has a subdirectory attribute.
    In this case, all the sounds inside are searched within that subdirectory.
    For example <sound> with name drum_beat is by default opened from
    "drum_beat.wav". But if it's in a group with subdirectory="fight",
    then it's actually opened from "fight/drum_beat.wav".

    You can make groups within groups (just like directories in directories).
  -->
  <group name="fight" subdirectory="fight">
    <sound name="drum_beat" />
    <sound name="drum_ending" />
  </group>
</sounds>

Some notes about sound files

  • Right now we support OggVorbis and (uncompressed) WAV files.

  • A general advice when creating sounds is to keep them normalized, which means "as loud as possible". It doesn't matter if you record a mouse squeak or a plane engine, the sound file should be equally loud. This allows to have best quality sound.

    Scale the sound by changing the gain property in sound configuration.

  • If sound is supposed to be spatialized (i.e. played by Sound3D method), make sure it is mono. Some OpenAL implementations never spatialize stereo sounds.

  • Specifically when making footsteps sound: synchronize it's duration with the HeadBobbingTime, which you can set for example using player XML configuration file (if your game loads it). By default it's 0.5, which means your footsteps sound should be around half-second long. Or you can record 2 footsteps and make it 1-second long.

    The important thing is to synchronize these times, to make them feel right in the game — visuals (head bobbing) should match what you hear (footsteps sound).