Multi channel audio

Hi All,

I’m trying to build a sketch that shows me levels of audio coming into a system. I want to be able to do more than 2 channels so i know that i need more than the processing.sound library can provide currently and my searching has led me to javax.sound.sampled.*, however this is as far as my searching and playing has got me.

Does anyone know how to query the system for how many lines are coming in and to get the amplitude of audio on each line?

Many thanks,

1 Like

Use minim. It is listed under Contributions > Sound on the Libraries page.

Apparently minim cannot do this – my mistake.

What OS are you on? I’m not sure if Minim supports getting more than two channels from a JavaSound device, and on Windows there’s the added complexity that the soundcard gets split into multiple stereo devices which needs special handling.

Another option would be Beads with JACK.

1 Like

I had a quick look at minim and couldn’t see or find any examples of multiple channel audio in (more than 2), so i discounted it from my search - minim.getLineIn(); only seems to be for mono and stereo from the default sound card?

so i’ve had a look at beads and i got to the following;

import beads.*;
import java.util.Arrays;
AudioContext ac;

void setup() {

ac = new AudioContext();
UGen microphoneIn = ac.getAudioInput();
Gain g = new Gain(ac, 1, 0.5);


color fore = color(255, 102, 204);
color back = color(0,0,0);

void draw() {
//set the background
Arrays.fill(pixels, back);
//scan across the pixels
for(int i = 0; i < width; i++) {
//for each pixel work out where in the current audio buffer we are
int buffIndex = i * ac.getBufferSize() / width;
//then work out the pixel height of the audio data at that point
int vOffset = (int)((1 + ac.out.getValue(0, buffIndex)) * height / 2);
//draw into Processing’s convenient 1-D array of pixels
vOffset = min(vOffset, height);
pixels[vOffset * height + i] = fore;

but this is for a single audio input - i have found and think that defaultaudioformat is what i need - but i have no idea how to implement it within the above ?