Version: v0.0.0-...-6506882 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2020 License: MIT Imports: 2 Imported by: 0



Package sdl implements an audio engine using libSDL2.



This section is empty.


This section is empty.


This section is empty.


type Engine

type Engine struct {
	// contains filtered or unexported fields

Engine is the SDL2 audio engine.

func New

func New(flags int) (*Engine, error)

New initializes an SDL2 Mixer for the audio engine.

Pass the SDL2 Mixer flags for its initialization. The flags are an OR'd value made up of:


func (*Engine) LoadMusic

func (e *Engine) LoadMusic(filename string) (Track, error)

LoadMusic loads a music file from disk.

func (*Engine) LoadMusicBin

func (e *Engine) LoadMusicBin(data []byte) (Track, error)

LoadMusicBin loads a music file from bytes data.

func (*Engine) LoadSound

func (e *Engine) LoadSound(filename string) (Track, error)

LoadSound loads a wave file from disk.

func (*Engine) LoadSoundBin

func (e *Engine) LoadSoundBin(data []byte) (Track, error)

LoadSoundBin loads a wave file from bytes data.

func (*Engine) Playing

func (e *Engine) Playing() bool

Playing returns if either music or sounds are currently playing.

func (*Engine) PlayingMusic

func (e *Engine) PlayingMusic() bool

PlayingMusic returns if music is currently playing.

func (*Engine) PlayingSound

func (e *Engine) PlayingSound() bool

PlayingSound returns if sounds are playing.

func (*Engine) Setup

func (e *Engine) Setup() error

Setup initializes SDL2 Mixer.

func (*Engine) StopAll

func (e *Engine) StopAll()

StopAll stops all music and sounds.

func (*Engine) StopMusic

func (e *Engine) StopMusic()

StopMusic stops all music.

func (*Engine) StopSounds

func (e *Engine) StopSounds()

StopSounds stops all sounds.

func (*Engine) Teardown

func (e *Engine) Teardown() error

Teardown closes the SDL mixer.

type Track

type Track struct {
	// contains filtered or unexported fields

Track is a music or sound effect file.

func (Track) Destroy

func (t Track) Destroy() error

Destroy the track.

func (Track) Pause

func (t Track) Pause() error

Pause the track.

func (*Track) Play

func (t *Track) Play(loops int) error

Play the track.

func (Track) Stop

func (t Track) Stop() error

Stop the track.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto