-
Notifications
You must be signed in to change notification settings - Fork 5
audio.um
Marek Maskarinec edited this page Mar 26, 2021
·
8 revisions
Audio playing library.
fn main() {
tophat.setup("sound example", 500, 500)
// some other stuff you want to do.
s1 := audio.load("file.wav")
s2 := audio.load("music.mp3")
s2.looping(true)
sounds := []audio.sound{ s1, s2 }
s2.play()
for 1 {
tophat.cycle(&w, &h, 0x000000ff, cam)
if input.isjustpressed(input.KEY_ENTER) {
s1.play()
}
if input.isjustpressed(input.KEY_ESCAPE) {
s1.stop()
s2.stop()
}
}
s1.delete()
s2.delete()
}
Basic sound type. Don't create by hand
fn load*(path: str): sound
Loads sound from given path.
fn setsound*(ss: []sound)
Sets, which sounds are active. You generally want to have all your sounds here.
fn (s: ^sound) looping*(l: bool)
Sets, if sound should replay after ending.
fn (s: ^sound) play*()
Plays the sound. If the sound if already playing, it won't do anything.
fn (s: ^sound) stop*()
Stops the playing sound. Doesn't save progress.
fn (s: ^sound) vol*(vol: real)
Sets volume of the sound.
fn (s: ^sound) del*()
Deletes the sound from memory.