FFFF GitHub - gogpu/audio: Pure Go audio engine — WASAPI, CoreAudio, PulseAudio. Zero CGO. · GitHub
[go: up one dir, main page]

Skip to content
gogpuPublic

About

Pure Go audio engine — WASAPI, CoreAudio, PulseAudio. Zero CGO.

Resources

Code of conduct

Contributing

Security policy

Stars

8 stars

Watchers

1 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
< 8000 svg data-component="Octicon" aria-hidden="true" focusable="false" class="octicon octicon-file color-fg-muted" viewBox="0 0 16 16" width="16" height="16" fill="currentColor" display="inline-block" overflow="visible" style="vertical-align:text-bottom">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GoGPU Logo

audio

Pure Go audio engine for Windows, macOS, and Linux
Zero CGO. PCM output. WAV decoding. Mixing. Platform-native drivers.

CI Go Reference Go Report Card License Zero CGO


Overview

audio is a Pure Go audio engine for the gogpu ecosystem. It provides low-latency PCM audio output, WAV decoding, and multi-channel mixing using platform-native APIs — without CGO.

Part of the gogpu GPU computing ecosystem (~800K+ LOC Pure Go).

Features

  • Pure Go — zero CGO on all platforms. Uses goffi/syscall for platform calls
  • Platform-native drivers — WASAPI (Windows), CoreAudio (macOS), PulseAudio (Linux)
  • WAV decoder — Pure Go WAV file parsing and playback
  • Mixer — multi-channel audio mixing with per-channel volume
  • io.Reader streams — composable audio pipeline (decoder → mixer → driver)
  • Non-blocking — audio runs in background goroutine, never blocks rendering

Status

Windows audio output working (WASAPI). macOS and Linux drivers planned.

Architecture

User Code
    │
    ▼
audio.Context (singleton, manages audio device)
    │
    ├── WAV Decoder (Pure Go)
    ├── Mixer (multi-channel, volume control)
    │       ↑ ReadFloat32er (pull model)
    ▼
Platform Driver (background goroutine → hardware)
    ├── WASAPI (Windows) ✅ — COM vtable via syscall.SyscallN
    ├── CoreAudio (macOS) — planned
    └── PulseAudio (Linux) — planned

API

package audio

// Create audio context (one per application)
ctx, err := audio.NewContext()
defer ctx.Close()

// Play a WAV file
player, err := ctx.PlayWAV(wavData)
player.SetVolume(0.8)

// Play from io.Reader stream
player, err := ctx.NewPlayer(pcmReader)
player.Play()

Examples

# Play 440Hz sine wave
go run ./examples/play_wav

# Play Mozart's "Eine Kleine Nachtmusik" (Casio watch style)
go run ./examples/mozart

Platform Support

Platform Driver Status
Windows WASAPI (COM vtable via syscall) ✅ Working
macOS CoreAudio (AudioQueue via goffi) Planned
Linux PulseAudio (libpulse-simple via dlopen) Planned

Ecosystem

Package Description
gogpu Application framework, windowing
gogpu/sound UI system sounds (clicks, alerts)
gogpu/audio Full audio engine (this package)
wgpu Pure Go WebGPU
gg 2D graphics
ui GUI toolkit

Related: gogpu/sound (UI System Sounds)

For simple UI feedback sounds (button clicks, notifications), use gogpu/sound — a thin platform delegation layer (~500 LOC) that plays OS system sounds via winmm.dll (Windows), NSSound (macOS), and PulseAudio (Linux).

gogpu/audio is for games, media apps, and audio visualization that need full PCM playback, mixing, and streaming.

Star History

Star History Chart

License

MIT License — see LICENSE.

About

Pure Go audio engine — WASAPI, CoreAudio, PulseAudio. Zero CGO.

Resources

Code of conduct

Contributing

Security policy

Stars

8 stars

Watchers

1 watching

Forks

Releases

Sponsor this project

Packages

Contributors

Languages

0