Skip to content

gen2brain/alsa

Repository files navigation

ALSA

Status Go Reference

Go reimplementation of tinyalsa library.

This library provides a Go interface to the Linux ALSA for interacting with sound card devices, allowing for raw audio (PCM) playback and capture, and control over mixer elements like volume and switches.

Usage

See utils and tests for usage examples.

Notes

This library does not support the ALSA plugin architecture and will only open direct hardware devices.

No dmix plugin that enables multiple applications to share a single audio output device. Additionally, no plug plugin that typically handles automatic conversions for sample rate and format (e.g., S16_LE to S32_LE).

The user is responsible for making sure that the provided audio data matches the exact hardware capabilities of the PCM device. These capabilities can be queried using the PcmParamsGet function.

Testing

Running the tests requires specific kernel modules to create virtual sound card devices for playback, capture, and mixer control tests without needing physical hardware:

  • snd-dummy: Creates a virtual sound card with a mixer, used for testing control functionality.
  • snd-aloop: Creates a loopback sound card, allowing playback data to be captured, which is essential for testing PCM I/O.

You can load them with the following commands:

sudo modprobe snd-dummy
sudo modprobe snd-aloop

About

Go reimplementation of tinyalsa

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages