I've got the microphone set up to stereo mix on my laptop - so it should be reading the sound being played out only.
I'm running the following code and it's going bananas over silence. My computer is making no noise and it's acting like it's at a rave.
My aim is to build a little bit extra around the BeatDetect class to read decaying thresholds. I've looked at the code and ddf has left a route in there to monitor thresholds (isRange). But I've ran the drawGraph command it's going ****ing mental.
Could someone please try running this code for me please? If it does nothing - then it's my machine. If it goes mental for you, then I've set it up wrong somehow. It should run verbatim with Processing 1.0.5.
Thanks for your time.
Code:
import ddf.minim.signals.*;
import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
Minim minim;
AudioInput mic;
BeatDetect beat;
BeatListener bl;
float eRadius;
void setup()
{
size(200, 200, P3D);
minim = new Minim(this);
mic = minim.getLineIn(Minim.MONO, 2048);
beat = new BeatDetect(2048, 44100);
bl = new BeatListener(beat, mic);
beat.setSensitivity(300);
ellipseMode(CENTER_RADIUS);
eRadius = 20;
}
void draw()
{
background(0);
float a = map(eRadius, 20, 80, 60, 255);
fill(60, 255, 0, a);
if ( beat.isKick() ) eRadius = 80;
ellipse(width/2, height/2, eRadius, eRadius);
eRadius *= 0.95;
if ( eRadius < 20 ) eRadius = 20;
beat.drawGraph(this);
}
void stop()
{
mic.close();
minim.stop();
super.stop();
}
class BeatListener implements AudioListener
{
private BeatDetect beat;
private AudioInput source;
BeatListener(BeatDetect beat, AudioInput source)
{
this.source = source;
this.source.addListener(this);
this.beat = beat;
}
void samples(float[] samps)
{
beat.detect(source.mix);
}
void samples(float[] sampsL, float[] sampsR)
{
beat.detect(source.mix);
}
}