Anonymous
YaBB Newbies
Offline
Posts: 4
Minim - Multiple AudioOutput possible?
Nov 24th , 2008, 4:07pm
Hi, I'm working on a graphical interface that displays each waveform (sine, triangle, saw & square) separate. It doesn't seem to be possible to create multiple AudioOutputs and attach each AudioSignal individually to solve this. Is there any other way I can display each waveform (AudioSignal) separate even if they are sounding simultaneously? Hope somebody has a solution. Thanks! // CODE EXAMPLE import ddf.minim.*; import ddf.minim.signals.*; AudioOutput outSine; AudioOutput outSaw; SineWave sine; SineWave saw; void setup() { size(512, 200); // always start Minim before you do anything with it Minim.start(this); // get a line out from Minim, // default sample rate is 44100, default bit depth is 16 outSine = Minim.getLineOut(Minim.STEREO, 512); outSaw = Minim.getLineOut(Minim.STEREO, 512); // create a sine wave Oscillator, // set to 440 Hz, at 0.5 amplitude, // using the sample rate of the output sine = new SineWave(440, 0.5, outSine.sampleRate()); saw = new SineWave(440, 0.5, outSaw.sampleRate()); // add the oscillator to the line out outSine.addSignal(sine); outSaw.addSignal(saw); } void draw() { background(0); stroke(255); // draw the waveforms for(int i = 0; i < outSine.left.size()-1; i++) { line(i, 50 + outSine.left.get(i)*50, i+1, 50 + outSine.left.get(i+1)*50); line(i, 150 + outSine.right.get(i)*50, i+1, 150 + outSine.right.get(i+1)*50); } for(int i = 0; i < outSaw.left.size()-1; i++) { line(i, 50 + outSaw.left.get(i)*50, i+1, 50 + outSaw.left.get(i+1)*50); line(i, 150 + outSaw.right.get(i)*50, i+1, 150 + outSaw.right.get(i+1)*50); } } void stop() { // always close Minim audio classes when you are done with them outSine.close(); outSaw.close(); // always stop Minim before exiting Minim.stop(); super.stop(); }