Skip to content

Instantly share code, notes, and snippets.

@alexey-dc
Last active December 15, 2015 19:49
Show Gist options
  • Save alexey-dc/5314165 to your computer and use it in GitHub Desktop.
Save alexey-dc/5314165 to your computer and use it in GitHub Desktop.
Sound API
-- cached, sound played based on the name for the sound effect, rather than the file name
SoundManager.map("dropped_bass", "dropped_bass.ogg")
SoundManager.map("explosion", "explosion.ogg")
SoundManager.preload("dropped_bass")
-- Assume a script that does mapping and preloading for each game (based on a data file)
-- volume is in [0, 1], pitch is in [0, inf)
SoundManager.playSound("explosion", volume, pitch) -- Sounds that aren't preloaded are loaded automatically, does not loop
SoundManager.playMusic("dropped_bass", volume, loops) -- Streamed, loops = -1 means loop forever, 0 = loops once and don't repeat
SoundManager.stopMusic()
-- Will probably need extensions for volume control, stopping arbitrary sounds, etc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment