Patching in RNBO.js with multiple inlets and outlets
Hello RNBO Community,
I am working on a implementation of an audio algorithm that uses the microphone for some adaptive audio purpose.
In my RNBO Patch i have 5 signal inlets, all mono (index 6 - 12 are events inputs) :
index 1, in1 -> microphone
index 2, in2 -> audiofile1 L channel
index 3, in3 -> audiofile1 R channel
index 4, in4 -> audiofile2 L channel
index 5, in5 -> audiofile2 R channel
I have also 4 signal outlets:
index 1, out1 -> output audio1 L channel
index 2, out2 -> output audio1 R channel
index 3, out3 -> output audio2 L channel
index 4, out4 -> output audio2 R channel
RNBO Device has this:
{channelCount: 2, channelCountMode: 'explicit', channelInterpretation: 'discrete'}
but if I analyse the RNBO device via another ScriptProcessor about the channels data I see channelCount: 4 and an array that is basically only on the first place filled with a buffer.

As I am struggle a lot to patch this things correctly together, never had it run without any artifacts.
Can someone explain me where I should look closer to, to get the patching under control?
I use a channelSplitter to get the four signal outputs, but it seems that all the signal output is in the frist channel against what I would expect with my four outlets. Is there another way or a setting I need to change?
When I try to patch all the audioNodes to a specific channel audiosource.connect(device.node, 0, 1) then I cannot hear any audio out (it depends on inlet 2 - 4)
I need to connect audiosource.connect(device.node) directly without adding a concrete in output channel the audio nodes.
I am happy for any help or further explaination what I need to do to mastering the patching in RNBO.
Thank you,
David & Robert
Hi there,
let me try to help you here and address a few points from your message.
The information currently reported by device.node
is slightly off as you point out and I can confirm that it doesn't match the reality of the node's channel count as reported by the device. This used to be a limitation of the AudioWorklet API but we'll have a look if we can improve that given that the browser implementations had a few iterations.
In general I'd recommend to work on a channel not an input / output basis with RNBO at this point to make things a bit easier to reason about. Currently RNBO in the WebAudio context supports both, channels as well and inputs and does some reassigning internally but that can in fact be a bit misleading and I'd recommend to use one input with multiple channels. In fact, the RNBO node does output on a single outport with multiple channels currently. Using a ChannelMerger and a ChannelSplitter should be helpful here to make this work with your graph and needs.
Have you tried using a simple pass through RNBO patcher, maybe with a gain stage to test the mapping to confirm that it's an issue with the Web implementation / your graph and not the patch?
If you are dealing with multiple channels, i/o in WebAudio I also recommend reading who the API interprets channels and mixing techniques. MDN has a good resource:
https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Basic_concepts_behind_Web_Audio_API#audio_channels
Let me know if that helps or if you have a small portion of your code to share, happy to take a look.
Thanks
Hey Florian,
thank you very much that you took the time to help me. Based on your input I tested out different ways and figured out a way that worked for me.
I set the RNBO Device to speakers and channelCount to max to make it work like intended.
// 2 · RNBO-Device erzeugen
const { createDevice } = RNBO
const device = await createDevice({ context: context, patcher })
const node = device.node
node.channelInterpretation = 'speakers'
node.channelCountMode = 'max'
Then I prepared all my six input sources as mono. So all the Audionodes have
input1L.channelCount === 1
input1R.channelCount === 1
input2L.channelCount === 1
input2R.channelCount === 1
input3L.channelCount === 1
input3R.channelCount === 1
and then connect them based on inputs and outputs... like this
// 3 · SIGNAL-Inputs verbinden
input1L && input1L .connect(node, 0, 0) // Mono
input1R && input1R .connect(node, 0, 1) // Mono
input2L && input2L .connect(node, 0, 2) // Mono
input2R && input2R .connect(node, 0, 3) // Mono
input3L && input3L .connect(node, 0, 4) // Mono
input3R && input3R .connect(node, 0, 5) // Mono
I also update some Message Events in the beginning, but to make the inputs work I needed to set a timeout and send in the values 2 seconds later to actually work correctly.
So, thanks a lot for your answer it helped me figuring out this!