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.
See utils and tests for usage examples.
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.
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