Example #1
0
File: audio.go Project: velour/ui
// PlayWAV plays the sound from a wav file and returns a Sound for it.
func PlayWAV(path string, repeat bool) *Sound {
	data, ok := sounds[path]
	if !ok {
		var err error
		if data, err = loadWAV(path); err != nil {
			panic(err)
		}
		sounds[path] = data
	}
	C.SDL_LockAudio()
	defer C.SDL_UnlockAudio()
	s := &Sound{audioData: data, repeat: repeat}
	playing = append(playing, s)
	return s
}
Example #2
0
func LockAudio() {
	C.SDL_LockAudio()
}
Example #3
0
File: audio.go Project: velour/ui
// Stop stops the sound from playing.
func (s *Sound) Stop() {
	C.SDL_LockAudio()
	defer C.SDL_UnlockAudio()
	s.repeat = false
	s.pos = 0
}