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 Audio Output from input
Page Index Toggle Pages: 1
Minim Audio Output from input? (Read 2929 times)
Minim Audio Output from input?
Dec 11th, 2008, 11:32am
 
Hello there!

I am adding an effect for an audio input  with

in = minim.getLineIn(Minim.STEREO, 512);

Now, after having added a band pass filter to the input, I'd like to hear it. But I'm having troubles routing out the signal to an AudioOutput. The documentation (http://code.compartmental.net/tools/minim/manual-audioinput/) does not make this 100% clear but only states:

"An input is readonly, so adding effects to an AudioInput object will not cause you to hear the input through the speakers with an effect on it. To do that, you’d need to pipe the input back through an AudioOutput object."

And then the only tutorials are mentioning mp3's as input or waveform generators as output...
I've tried different stuff (like out.addSignal(in);), but with no result (only errors).

How to do this? Any help will be greatly appreciated. :-)
Re: Minim Audio Output from input?
Reply #1 - May 12th, 2009, 2:42am
 
This is exactly my problem!

I'm a newbie in processing so I'll get back here if I find the solution. Meanwhile I'm navigating through the libraries, but I'm still not finding anything.
Re: Minim Audio Output from input?
Reply #2 - Aug 9th, 2009, 7:45pm
 
I have been looking at this too and haven't come up with an answer for any sound library. Has this been done yet? Connecting a live input to a live output?

Thanks
Re: Minim Audio Output from input?
Reply #3 - Sep 18th, 2009, 10:38am
 
New to processing as well, and I'd love to know how to do this w/ Minim as well.
Re: Minim Audio Output from input?
Reply #4 - Sep 22nd, 2009, 5:00pm
 
Have you tried creating your own AudioSignal that generates the output as you want to hear it? This signal can the be added to your AudioOutput.

Quote:
If you want to write an audio generating class to work with Minim, you must implement the AudioSignal interface
-- AudioSignal JavaDocs


I don't know how your bandpass filter works, but if you can shift out float arrays of audio data then this should work.

hth,

/m
Re: Minim Audio Output from input?
Reply #5 - Nov 5th, 2009, 4:55am
 
You can try this (tested, works): create a class that implements both AudioSignal and  AudioListener. Whatever is sampled from input is then copied to output. Example solution (not really elegant):
loop sketch  file (only setup method):
Code:

void setup()
{
 size(512, 200, P2D);
 
 minim = new Minim(this);
 int buffer = 1024;
 out = minim.getLineOut(Minim.STEREO, buffer);
 in = minim.getLineIn(Minim.STEREO, buffer);
 signal = new InputOutputBind(1024);
 //add listener to gather incoming data
 in.addListener(signal);
 // adds the signal to the output
 out.addSignal(signal);
}


class implementing AudioSignal and  AudioListener:
Code:
class InputOutputBind implements AudioSignal, AudioListener
{
 private float[] leftChannel ;
 private float[] rightChannel;
InputOutputBind(int sample)
 {
   leftChannel = new float[sample];
   rightChannel= new float[sample];
 }
 // This part is implementing AudioSignal interface, see Minim reference
 void generate(float[] samp)
 {
   arraycopy(leftChannel,samp);
 }
 void generate(float[] left, float[] right)
 {
    arraycopy(leftChannel,left);
    arraycopy(rightChannel,right);
 }
// This part is implementing AudioListener interface, see Minim reference
 synchronized void samples(float[] samp)
 {
    arraycopy(samp,leftChannel);
 }
 synchronized void samples(float[] sampL, float[] sampR)
 {
   arraycopy(sampL,leftChannel);
   arraycopy(sampR,rightChannel);
 }  
}


HTH,
Tomek
Page Index Toggle Pages: 1