Interaction Design WikiSystems Engineering

Gigaport HD+





It’s possible to output sound over multiple audio channels from Processing using a usb Audio Interfaces like the Gigaport HD+ or AG. The initial installation is a little fiddly, however once you have your system setup in will run perfectly every time. 

Setting up USB Audio Interface.

It’s not possible for Processing to simply send multiple audio channels to the one device, so we are going to setup OSX to treat the Audio Interface as if it where multiple stereo devices. Then we will be able to send stereo audio to each of these virtual devices in Processing. 

Steps

  1. Connect the device by USB cable to your computer, and then open the “Audio MIDI Setup” Utility in OSX.   

  2. Click the “add” icon in the lower left corner and select “Aggregate Device”. 
  3. In the options screen tick “Use” next to the USB Audio Interface. Right click the Device and select “Configure Speakers”. Here you are going to assign channels 1 to “left" and 2 to “right”. 
  4. Repeat the above steps, until you have enough channels for your project.

Processing

Install minim library and try out the following example code:

Example
Code:
import ddf.minim.*; 
import javax.sound.sampled.*;
Minim              minim; 
Minim              minim2; 
Minim              minim3; 
Minim              minim4;
AudioOutput        output; 
AudioOutput        output2; 
AudioOutput        output3; 
AudioOutput        output4;
Mixer.Info[] mixerInfo;
AudioPlayer player; 
AudioPlayer player2; 
AudioPlayer player3; 
AudioPlayer player4;
void setup() 
{ 
  size(512, 200, P3D);
  // create Minim objects  
  minim  = new Minim(this); 
  minim2  = new Minim(this); 
  minim3  = new Minim(this); 
  minim4  = new Minim(this);
 //show all the available channels  
  mixerInfo = AudioSystem.getMixerInfo(); 
  for(int i = 0; i < mixerInfo.length; i++){ 
  println(i + " = " + mixerInfo[i].getName()); 
} 
 // Assign the mixer based on the output from above, change mixerInfo[] 
  Mixer mixer = AudioSystem.getMixer(mixerInfo[2]); 
  Mixer mixer2 = AudioSystem.getMixer(mixerInfo[2]); 
  Mixer mixer3 = AudioSystem.getMixer(mixerInfo[2]); 
  Mixer mixer4 = AudioSystem.getMixer(mixerInfo[2]);
  minim.setOutputMixer(mixer); 
  output = minim.getLineOut();
  minim2.setOutputMixer(mixer2); 
  output2 = minim2.getLineOut();
  minim3.setOutputMixer(mixer3); 
  output3 = minim3.getLineOut();
  minim4.setOutputMixer(mixer4); 
  output4 = minim4.getLineOut();
  //playback sound  
  player = minim.loadFile("1.wav"); 
  player.play();
  player2 = minim2.loadFile("2.wav");  
  player2.play();
  player3 = minim3.loadFile("3.mp3");  
  player3.play();
  player4 = minim4.loadFile("4.mp3");  
  player4.play(); 
}