Exemple #1
0
// 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
}
Exemple #2
0
func UnlockAudio() {
	C.SDL_UnlockAudio()
}
Exemple #3
0
// Stop stops the sound from playing.
func (s *Sound) Stop() {
	C.SDL_LockAudio()
	defer C.SDL_UnlockAudio()
	s.repeat = false
	s.pos = 0
}
Exemple #4
0
func CloseAudio() {
	C.SDL_UnlockAudio()
}