Skip to content

Latest commit

 

History

History
80 lines (57 loc) · 2.52 KB

audio.md

File metadata and controls

80 lines (57 loc) · 2.52 KB

sugar. audio

Any volume value here is always between 0 and 1.

sugar.audio. init_audio ([sfx_vol = 1, music_vol = 1])

  • Initializes the audio subsystem of Sugar.
  • Is called by init_sugar(...).

sugar.audio. shutdown_audio ()

  • Shuts down the audio subsystem.
  • Is called by shutdown_sugar().

sugar.audio. load_sfx (filepath, [id], [volume = 1])

  • Loads the file at filepath as the sound effect id.
  • If id isn't set, the next available numeral sfx id is used.
  • volume will only be applied on this sound effect. It is multiplicative with sfx_volume(v).
  • Returns the sound effect's id.

sugar.audio. load_music (file, [id], [volume = 1])

  • Loads the file at filepath as the music id.
  • If id isn't set, the next available numeral music id is used.
  • volume will only be applied on this music. It is multiplicative with sfx_volume(v).
  • Returns the music's id.

sugar.audio. sfx_volume (v)

  • Sets the volume for sound effects. (0 - 1)

sugar.audio. music_volume (v)

  • Sets the volume for music. (0 - 1)

sugar.audio. unload_sfx (id)

  • Unloads the sound effect id.

sugar.audio. unload_music (id)

  • Unloads the music id.

sugar.audio. sfx (id, [distance = 0, [stereo_angle = 0]], [pitch = 1])

  • Plays the sound effect id.
  • If distance is set, volume is decreased accordingly.
  • If setreo_angle is set, the sound effect is directed accordingly in stereo. (0 is center, -0.25 is left, 0.25 is right)
  • If pitch is set, the sound effect is pitched accordingly. 0.5 is down an octave, 2 is up an octave.

sugar.audio. music ([id, [loop]])

  • Plays the music id.
  • If loop is true, the music will start over after it ends.
  • Call music() with no arguments to stop the playing music.