# Multi channel audio

**URL:** <https://discourse.processing.org/t/multi-channel-audio/443>\
**Category:** Libraries\
**Created:** [May 27, 2018, 3:17pm UTC](https://discourse.processing.org/t/multi-channel-audio/443 "2018-05-27T15:17:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![crazylogic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/crazylogic/32/508_2.png) [@crazylogic](https://discourse.processing.org/u/crazylogic)\
**Post date:** [May 27, 2018, 3:17pm UTC](https://discourse.processing.org/t/multi-channel-audio/443/1 "2018-05-27T15:17:19Z")

</div>

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,  
Matt

---

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [May 27, 2018, 4:10pm UTC](https://discourse.processing.org/t/multi-channel-audio/443/2 "2018-05-27T16:10:32Z")

</div>

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

- ~~[https://processing.org/reference/libraries/#sound](https://processing.org/reference/libraries/#sound)~~
- ~~[http://code.compartmental.net/minim/index.html](http://code.compartmental.net/minim/index.html)~~

Apparently minim cannot do this – my mistake.

---

<div class="post-metadata">

**Author:** ![neilcsmith](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/neilcsmith/32/144_2.png) [@neilcsmith](https://discourse.processing.org/u/neilcsmith)\
**Post date:** [May 27, 2018, 5:20pm UTC](https://discourse.processing.org/t/multi-channel-audio/443/3 "2018-05-27T17:20:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![crazylogic](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/crazylogic/32/508_2.png) [@crazylogic](https://discourse.processing.org/u/crazylogic)\
**Post date:** [May 27, 2018, 11:05pm UTC](https://discourse.processing.org/t/multi-channel-audio/443/4 "2018-05-27T23:05:23Z")

</div>

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() {  
> size(800,800);
> 
> ac = new AudioContext();  
> UGen microphoneIn = ac.getAudioInput();  
> Gain g = new Gain(ac, 1, 0.5);  
> g.addInput(microphoneIn);  
> ac.out.addInput(g);
> 
> ac.start();  
> }
> 
> color fore = color(255, 102, 204);  
> color back = color(0,0,0);
> 
> void draw() {  
> loadPixels();  
> //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;  
> }  
> updatePixels();  
> }

but this is for a single audio input - i have found [Generated Documentation (Untitled)](http://www.beadsproject.net/doc/index.html?net/beadsproject/beads/core/AudioContext.html) and think that defaultaudioformat is what i need - but i have no idea how to implement it within the above ?
