We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSound,  Music Libraries › Minim - Multiple AudioOutput possible
Page Index Toggle Pages: 1
Minim - Multiple AudioOutput possible? (Read 644 times)
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();
}
Re: Minim - Multiple AudioOutput possible?
Reply #1 - Nov 24th, 2008, 7:21pm
 
it might be time for minim to update their documentation !
all their document mention static methods, but the actual implementation must be instanciated like this :

henri


// CODE EXAMPLE

import ddf.minim.*;
import ddf.minim.signals.*;

AudioOutput outSine;
AudioOutput outSaw;

SineWave sine;
SineWave saw;

void setup()
{
 size(512, 200);
 Minim minim = new Minim(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(200, 0.5, outSine.sampleRate());
 saw = new SineWave(5000, 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();
 

 super.stop();
}
Re: Minim - Multiple AudioOutput possible?
Reply #2 - Nov 25th, 2008, 4:43am
 
Yah, I'm behind on this. The most reliable source for info about the current API is the Javadoc, unfortunately.
Re: Minim - Multiple AudioOutput possible?
Reply #3 - Nov 25th, 2008, 4:46am
 
Also, the code that mots posted seems to do exactly what you want.
Re: Minim - Multiple AudioOutput possible?
Reply #4 - Nov 25th, 2008, 10:00pm
 
Thanks Mots and Damien! It worked for me!
Page Index Toggle Pages: 1