A simple audio engine for Go with an SDL2 back-end and others to come eventually.
Go to file
Noah d0ed23cf73 Fix Null audio driver 2023-12-09 14:59:56 -08:00
examples/play Initial code for basic SDL2 audio engine 2020-04-28 22:54:51 -07:00
null Fix Null audio driver 2023-12-09 14:59:56 -08:00
sdl Add .Playing() function to Track interface 2023-03-09 22:55:53 -08:00
.gitignore Initial code for basic SDL2 audio engine 2020-04-28 22:54:51 -07:00
LICENSE.md Initial code for basic SDL2 audio engine 2020-04-28 22:54:51 -07:00
README.md Initial code for basic SDL2 audio engine 2020-04-28 22:54:51 -07:00
go.mod Add go.mod 2020-11-20 23:36:42 -08:00
interface.go Add .Playing() function to Track interface 2023-03-09 22:55:53 -08:00
null_test.go Initial code for basic SDL2 audio engine 2020-04-28 22:54:51 -07:00

README.md

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).

Example

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

package main

import (
    "time"
    "git.kirsle.net/go/audio/sdl"
)

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

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

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

    // Play it.
    music.Play(0)

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

License

MIT.