Robonix ALSA Audio Primitive
This package exposes a Linux host's ALSA microphone and speaker through the standard Robonix audio contracts. It is a reusable hardware primitive and does not depend on Webots.
Requirements
- Linux with
arecordandaplayfromalsa-utils - Robonix installed and initialized with
rbnx setup uvavailable onPATH- at least one ALSA capture or playback device
On Debian or Ubuntu:
sudo apt-get update
sudo apt-get install -y alsa-utils
Deployment
Reference the package from a robot deployment manifest:
primitive:
- name: audio_driver
url: https://github.com/syswonder/primitive-audio-driver-rbnx
branch: main
config:
mic_device: null
speaker_device: null
When a device is null, the primitive scans ALSA and selects a suitable
device. Use arecord -l and aplay -l to find explicit device identifiers
such as hw:1,0. The complete configuration surface and defaults are in
config.spec.
Build and start it through the robot deployment:
rbnx build
rbnx boot
rbnx build first creates an isolated package-owned Python environment, installs
the pinned protobuf/gRPC compiler and runtime into it, and then generates the
contract bindings with that same interpreter. The build imports every generated
*_pb2.py and *_pb2_grpc.py module before accepting the package. At runtime,
the primitive reuses this environment. During Driver(CMD_INIT), it scans ALSA
and initializes the selected capture and playback devices.
Capabilities
| Contract | Purpose |
|---|---|
robonix/primitive/audio/mic |
Streams raw microphone PCM to a caller. |
robonix/primitive/audio/speaker |
Plays caller-provided raw PCM. |
robonix/primitive/audio/list_devices |
Lists ALSA devices and the current route. |
robonix/primitive/audio/select_device |
Changes the input or output device. |
robonix/primitive/audio/driver |
Provides the standard lifecycle interface. |
The microphone path defaults to mono, 16-bit PCM and probes a supported sample rate, preferring 16 kHz. The speaker path defaults to mono, 16-bit PCM at 24 kHz. Consumers must send PCM matching the configured format.
Development checks
python3 -m unittest -v test_speaker_driver.py
python3 -m unittest discover -s tests -v
rbnx build
The package uses arecord and aplay only at runtime; the unit test does not
access an audio device.