Learn Working with Multiple RNBO Devices

Getting Started

Welcome to RNBO

Quickstart

RNBO Basics

Key Differences

Why We Made RNBO

Coding Resources

Fundamentals

Audio IO

Messages to rnbo~

Using Parameters

MIDI in RNBO

Messages and Ports

Polyphony and Voice Control

Audio Files in RNBO

Using Buffers

Using the FFT

Export Targets

Export Targets Overview

VST/AudioUnit
Max External Target
Raspberry Pi Target
The Web Export Target
The C++ Source Code Target

Code Export

Working with JavaScript
Working with C++

Special Topics

Sample Accurate Patching
Scala and Custom Tuning

RNBO and Max for Live

RNBO Raspberry Pi OSCQuery Runner

Metadata

Export Description

Raspberry Pi GPIO

Updating the RNBO Package

Working with Multiple RNBO Devices

The WebAudio API is designed around the concept of audio processing nodes. Each of these nodes can have zero or more audio inputs, as well as zero or more audio outputs.

The WebAudio API is designed around the concept of audio processing nodes. Each of these nodes can have zero or more audio inputs, as well as zero or more audio outputs. When we create a RNBO device, we also create a WebAudio node that wraps the exported RNBO code. This makes it easy to use multiple RNBO devices together in an audio processing chain.

// This code assumes that we have two RNBO patches, one exported as synth.export.json,
// and one exported as effect.export.json
const { createDevice } = require ("@rnbo/js");

async function setup() {
    const WAContext = window.AudioContext || window.webkitAudioContext;
    const context = new WAContext();

    // Create gain node and connect it to audio output
    const outputNode = context.createGain();
    outputNode.connect(context.destination);
    
    // Fetch the exported patchers
    let response = await fetch("export/synth.export.json");
    const synthPatcher = await response.json();
    response = await fetch("export/effect.export.json");
    const effectPatcher = await response.json();

    // Create the devices
    const synthDevice = await createDevice({ context, patcher: synthPatcher });
    const effectDevice = await createDevice({ context, patcher: effectPatcher });

    // Connect the devices in series
    synthDevice.node.connect(effectDevice.node);
    effectDevice.node.connect(outputNode);
}

setup();

Splitting and Merging Audio Channels

As mentioned, a WebAudio node can have multiple input and output channels. The node property of a RNBO device has as many input channels as the exported RNBO patcher has in~ indexes, and as many output channels as the patcher has out~ indexes. The connect method of a WebAudio node has two optional arguments, one for the output index and one for the input index. Using these arguments, one could take a monophonic RNBO device and pass it through a stereo effect.

// Create the devices
const synthDevice = await createDevice({ context, patcher: synthPatcher });
const effectDevice = await createDevice({ context, patcher: effectPatcher });

// Diffuse the monophonic output of the synthesizer into stereo 
synthDevice.node.connect(effectDevice.node, 0, 0);
synthDevice.node.connect(effectDevice.node, 0, 1);
effectDevice.node.connect(outputNode);

For more information, check the API documentation for AudioNode, and the documentation for the AudioContext functions createChannelSplitter and createChannelMerger.