Fundamentals
Export Targets
Code Export
Patcher UI
Special Topics
RNBO Raspberry Pi OSCQuery Runner
Configuring Audio on the Raspberry Pi
Steps to configure your audio device settings on the Raspberry Pi target for use with RNBO.
Recall that the on the Raspberry Pi, the RNBO Runner uses JACK Audio Connection Kit to manage connections to all audio devices available to the Pi. The RNBO Runner exposes an OSC-based interface to JACK, which you can use to select your active soundcard, choose a sample rate, and restart JACK. You can use this OSC interface directly, but it's often easier to use the special audio configuration Max patch included with the RNBO package.
The Audio Configuration Patch
The easiest way to access the audio configuration patch is through the export sidebar. Open the export sidebar and navigate to the configuration page for your Raspberry Pi. At the top of this page you should see a button labeled "Audio Config."
Click this button to open the configuration patcher.
Choosing an Audio Device
The Audio Config Patch can be used to choose your audio output device, as well as set the sample rate that device on your Raspberry Pi. After choosing your Raspberry Pi from the umenu at the top of the patch, the umenu labeled 2 should become populated with all of the audio devices available on your Pi.
You may be wondering about the "Dummy" soundcard. The RNBO Rasperry Pi image defines the "Dummy" device for use with RNBO devices that do not produce audio. For example, if you had a RNBO device that synthesized MIDI events but which did not produce any sound, you could use that device with the "Dummy" sound card. If the "Dummy" sound card is the only one listed, then you may not have an audio device connected. Connect your device, then select your Pi again from the umenu at the top of the patch. This should repopulate the dictionary view, as well as the umenu labeled 2, with the connected sound card.
Changing the Sample Rate
The umenu labeled 3 can be used to change the sample rate of the selected audio device. The umenu in the patch includes the sample rates 44100 and 48000, but you can format the message yourself if you need another sampling rate. Consult the documentation for your hardware to find out which sample rates are supported.
Pushing Changes
After making changes to your selected soundcard or sample rate, you will need to restart JACK on the Raspberry Pi. The button labeled 4 in the bottom right of the patch will force JACK to restart, which will then pick up your changes. If you don't hear the changes you're expecting, you may need to hit this button to restart JACK.
Using the OSC Interface
If you have advanced needs, for example you want to configure JACK programmatically, you can send OSC messages to your Raspberry Pi to change your JACK settings. You can also send an HTTP GET request to /rnbo/jack
to get the current state of audio on your Raspberry Pi in JSON format.
const http = require("http");
const host = "c74rpi.local"; // replace with the hostname of your Raspberry Pi, or its IP address
const port = 5678; // HTTP interface is exposed on this port
const path = "/rnbo/jack";
const fetchJackStatus = async (host, port, path) => {
const options = {
protocol: "http:",
host,
port,
path,
family: 4
};
return new Promise((resolve, reject) => {
http.get(options, function (res) {
var json = '';
res.on('data', function (chunk) {
json += chunk;
});
res.on('end', function () {
if (res.statusCode === 200) {
try {
resolve(json);
} catch (e) {
reject(e);
}
} else {
reject('Status: ' + res.statusCode);
}
});
}).on('error', reject);
});
}
fetchJackStatus(host, port, path).then((res) => console.log(res));
This might return a result that looks something like this:
{
"FULL_PATH": "/rnbo/jack",
"CONTENTS": {
"info": {
"FULL_PATH": "/rnbo/jack/info",
"CONTENTS": {
"alsa_cards": {
"FULL_PATH": "/rnbo/jack/info/alsa_cards",
"CONTENTS": {
"hw:0": {
"FULL_PATH": "/rnbo/jack/info/alsa_cards/hw:0",
"TYPE": "s",
"VALUE": "Dummy - Dummy\nDummy 1",
"ACCESS": 1,
"CLIPMODE": "none"
},
"hw:1": {
"FULL_PATH": "/rnbo/jack/info/alsa_cards/hw:1",
"TYPE": "s",
"VALUE": "bcm2835_headphonbcm2835 Headphones - bcm2835 Headphones\nbcm2835 Headphones",
"ACCESS": 1,
"CLIPMODE": "none"
},
"hw:2": {
"FULL_PATH": "/rnbo/jack/info/alsa_cards/hw:2",
"TYPE": "s",
"VALUE": "USB-Audio - USB AUDIO CODEC\nBurrBrown from Texas Instruments USB AUDIO CODEC at usb-3f980000.usb-1.2, full",
"ACCESS": 1,
"CLIPMODE": "none"
},
"hw:CODEC": {
"FULL_PATH": "/rnbo/jack/info/alsa_cards/hw:CODEC",
"TYPE": "s",
"VALUE": "USB-Audio - USB AUDIO CODEC\nBurrBrown from Texas Instruments USB AUDIO CODEC at usb-3f980000.usb-1.2, full",
"ACCESS": 1,
"CLIPMODE": "none"
},
"hw:Dummy": {
"FULL_PATH": "/rnbo/jack/info/alsa_cards/hw:Dummy",
"TYPE": "s",
"VALUE": "Dummy - Dummy\nDummy 1",
"ACCESS": 1,
"CLIPMODE": "none"
},
"hw:Headphones": {
"FULL_PATH": "/rnbo/jack/info/alsa_cards/hw:Headphones",
"TYPE": "s",
"VALUE": "bcm2835_headphonbcm2835 Headphones - bcm2835 Headphones\nbcm2835 Headphones",
"ACCESS": 1,
"CLIPMODE": "none"
}
}
}
}
},
"config": {
"FULL_PATH": "/rnbo/jack/config",
"DESCRIPTION": "Jack configuration parameters",
"CONTENTS": {
"card": {
"FULL_PATH": "/rnbo/jack/config/card",
"TYPE": "s",
"VALUE": "hw:2",
"RANGE": [
{
"VALS": [
"hw:0",
"hw:1",
"hw:2",
"hw:CODEC",
"hw:Dummy",
"hw:Headphones"
]
}
],
"ACCESS": 3,
"CLIPMODE": "both",
"DESCRIPTION": "ALSA device name"
},
"num_periods": {
"FULL_PATH": "/rnbo/jack/config/num_periods",
"TYPE": "i",
"VALUE": 2,
"RANGE": [
{
"VALS": [
1,
2,
3,
4
]
}
],
"ACCESS": 3,
"CLIPMODE": "both",
"DESCRIPTION": "Number of periods of playback latency"
},
"period_frames": {
"FULL_PATH": "/rnbo/jack/config/period_frames",
"TYPE": "i",
"VALUE": 256,
"RANGE": [
{
"VALS": [
32,
64,
128,
256,
512,
1024
]
}
],
"ACCESS": 3,
"CLIPMODE": "both",
"DESCRIPTION": "Frames per period"
},
"sample_rate": {
"FULL_PATH": "/rnbo/jack/config/sample_rate",
"TYPE": "f",
"VALUE": 48000,
"RANGE": [
{
"MIN": 22050
}
],
"ACCESS": 3,
"CLIPMODE": "both",
"DESCRIPTION": "Sample rate"
}
}
},
"active": {
"FULL_PATH": "/rnbo/jack/active",
"TYPE": "F",
"VALUE": null,
"ACCESS": 3,
"CLIPMODE": "none"
}
}
}
Given this configuration, if you wanted JACK to use hw:0, the "Dummy" soundcard, you could send it an OSC message like the following (this uses the sendosc command line tool):
sendosc c74rpi.local 1234 /rnbo/jack/config/card s hw:0
Similarly, you could set the sample rate with a message like this:
sendosc c74rpi.local 1234 /rnbo/jack/config/sample_rate i 96000