Beispiel #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
}
Beispiel #2
0
func LockAudio() {
	C.SDL_LockAudio()
}
Beispiel #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
}