A simple audio engine for Go with an SDL2 back-end and others to come eventually.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1.0 KiB

audio: Simple Audio Engine for Go

Package audio is a simple audio engine for Go that can play some music and sound files. It currently supports an SDL2 (Mixer) driver suitable for use on desktop systems like Linux, Mac OS and Windows, with support to load and play music files (.ogg and .mp3 format, depending on your system libraries) and sound effects (.wav).


See the examples/play/main.go for a simple command-line media player sample that uses the SDL2 engine.

package main

import (

func main() {
    sfx, err := sdl.New(mix.INIT_MP3 | mix.INIT_OGG)
    if err != nil {

    // Call once at program startup.
    defer sfx.Teardown()

    // Load a file from disk.
    music, err := sfx.LoadMusic("filename.mp3")
    if err != nil {

    // Play it.

    // Wait until done.
    for sfx.Playing() {
        time.Sleep(1 * time.Second)