ROS Package bob_synth
A high-fidelity, low-latency ROS 2 synthesizer node designed for AI-driven audio generation and autonomous bot assistants.
AI Logic & Integration
This package is specifically optimized for AI interaction. It provides a clean ROS 2 API for real-time parameter manipulation and audio streaming.
Objective: Provide a stable, predictable sound engine for AI agents (like Eva).
Communication: Uses standard ROS 2 topics and services for parameter synchronization.
Payload: High-quality 16-bit PCM audio (Int16MultiArray) at 44.1kHz.
Architecture
The system follows a modular, decoupled architecture for maximum stability and flexibility:
Synth Node (C++): The real-time engine. Handles wave generation, State Variable Filtering (SVF), ADSR envelopes, and LFO modulation.
Synth GUI (Python): The human control interface (Moog-style rack).
Audio Sink (Python): The playback engine, available as a Headless Sink for server/docker use or integrated into the GUI. Uses
sounddevice(ALSA) for jitter-free playback on hardware (HDMI, Speakers).
ROS 2 API
Topics
Topic |
Type |
Description |
|---|---|---|
|
|
Raw stereo PCM data (44.1kHz). |
|
|
AI Interface: Accepts JSON strings to update parameters. |
Parameters
Name |
Type |
Range |
Description |
|---|---|---|---|
|
double |
20 - 2000 |
Base frequency of the oscillator. |
|
string |
sine, square, triangle, saw |
Oscillator shape. |
|
double |
0 - 20 |
LFO frequency for vibrato. |
|
double |
0 - 100 |
LFO intensity. |
|
double |
0.0 - 2.0 |
Envelope attack time (seconds). |
|
double |
0.0 - 2.0 |
Envelope decay time. |
|
double |
0.0 - 1.0 |
Envelope sustain level. |
|
double |
0.0 - 2.0 |
Envelope release time. |
|
bool |
true/false |
Triggers the ADS phase or starts Release. |
Getting Started
Installation
Ensure you have the required Python dependencies:
pip3 install numpy sounddevice
Running
Start the Synthesis Engine:
ros2 run bob_synth synth_node
Start the GUI & Player (Desktop)
ros2 run bob_synth synth_gui.py
Headless Player (CLI/Docker)
For environments without a graphical environment (X11) or when only audio playback is needed:
ros2 run bob_synth audio_sink.py
CLI (One-Shot)
ros2 topic pub /synth_config std_msgs/msg/String "data: '{\"frequency\": 220.0, \"waveform\": \"sawtooth\", \"filter_cutoff\": 2500.0, \"filter_resonance\": 0.6}'"
AI Control Interface (JSON)
The synthesizer is primarily designed to provide AI agents with an additional “expressive output layer” (similar to emoticons/icons). Control is handled via the /synth_config topic using JSON strings.
JSON Schema
Key |
Type |
Range |
Description |
|---|---|---|---|
|
boolean |
|
Triggers the ADSR envelope |
|
float |
20.0 - 2000.0 |
Base oscillator frequency in Hz |
|
string |
|
Oscillator type |
|
float |
0.0 - 1.0 |
Master gain (volume) |
|
float |
20.0 - 16000.0 |
Cutoff frequency of the SV filter |
|
float |
0.0 - 0.95 |
Filter resonance (Q factor) |
|
float |
0.0 - 20.0 |
LFO frequency (vibrato speed) |
|
float |
0.0 - 100.0 |
LFO intensity (modulation depth) |
|
float |
0.0 - 2.0 |
ADSR time values (seconds) |
GUI & User Interface
The GUI is provided for visualization and manual parameter adjustments during development and testing.
Control Panels
OSCILLATOR: Waveform selection and base frequency adjustment.
MODULATION: LFO for frequency modulation (vibrato/experimental FX).
FILTER: 12dB State Variable Filter (low-pass) with resonance.
ENVELOPE: Standard ADSR envelope for volume shaping.
MASTER/TRIGGER: Final output volume and manual note trigger button.