1 Exposed_Audio_Functions
trac edited this page 2008-02-23 03:18:58 +00:00

Audio Objects

Sound

  • Overview:
  • Create a new sound, and assign it to a given handle.
  • Syntax:
  • handle = new Sound (FileName)
  • Example: Menu_Sound = new Sound ("audio/music/menu_track.ogg")
  • Parameters:
  • FileName: path and filename of source audio file (WAV or OGG).
  • Returns:
  • Handle to sound file.
  • Notes:

Audio Methods

free

  • Overview:
  • Use this command to free a created sound handle from memory, when it is no longer needed.
  • Syntax:
  • handle.free()
  • Parameters:
  • None
  • Returns:
  • None
  • Notes:
  • Sound handles are automatically freed on exit().

loop

  • Overview:
  • Use this command to set a certain handle to loop (repeat when it reaches the end of the track).
  • Syntax:
  • handle.loop()
  • Parameters:
  • None
  • Returns:
  • None
  • Notes:

play

  • Overview:
  • Use this command to play the sound attached to the given handle.
  • Syntax:
  • handle.play()
  • Parameters:
  • None
  • Returns:
  • None
  • Notes:

setGain

  • Overview:
  • Use this command to adjust the volume (gain) of a sound.
  • Syntax:
  • handle.SetGain(Gain)
  • Parameters:
  • Gain: Floating between value between 0 (silent) and 1 (max volume).
  • Returns:
  • None
  • Notes:

Audio Globals

snd_disabled

  • Overview:
  • Variable that stores the value of snd_disabled in the .cfg file. If it's true, no sound will play. If false, sound will play.
  • Syntax:
  • ReturnString = snd_disabled
  • Example: if (snd_disabled == true)
  • Parameters:
  • None
  • Returns:
  • boolean (true|false).
  • Notes:

snd_disable

  • Overview:
  • Enables/disables the playing of sounds by setting the value of snd_disabled.
  • Syntax:
  • snd_disable (boolean)
  • Example: snd_disable (true) // Set snd_disabled to true.
  • Parameters:
  • True to disable sound, false to enable sound.
  • Returns:
  • None.
  • Notes:
  • Documentation from the C++ implementation(snd.cpp!snd_disable): (temporarily) disable all sound output. because it causes future snd_open calls to immediately abort before they demand-initialize OpenAL, startup is sped up considerably (500..1000ms). therefore, this must be called before the first snd_open to have any effect; otherwise, the cat will already be out of the bag and we debug_warn of it. rationale: this is a quick'n dirty way of speeding up startup during development without having to change the game's sound code. can later be called to reactivate sound; all settings ever changed will be applied and subsequent sound load / play requests will work.