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 › Using linein for Minim BeatDetection
Page Index Toggle Pages: 1
Using linein for Minim BeatDetection (Read 1106 times)
Using linein for Minim BeatDetection
Feb 6th, 2010, 11:50am
 
I want to use the Linein sound for the Minim Beat detection.
There is this example of Beatdetection that uses a mp3 file as input
http://code.compartmental.net/tools/minim/manual-beatdetect/

and there is this example of the linein support.
http://code.compartmental.net/tools/minim/manual-audioinput/

But i am having a hard time combining those two.
Does anybody knows how to use the linein for beatdetection ?

Thx

Re: Using linein for Minim BeatDetection
Reply #1 - Feb 9th, 2010, 5:36am
 
Hi,

You need to add an AudioInput, initialise it and then feed it to the BeatDetect like this;

Code:
import ddf.minim.*;
import ddf.minim.analysis.*;

Minim minim;
AudioPlayer song;
AudioInput in;
BeatDetect beat;

float eRadius;

void setup()
{
size(200, 200, P3D);
minim = new Minim(this);
minim.debugOn();

//song = minim.loadFile("marcus_kellis_theme.mp3", 2048);
//song.play();

// get a line in from Minim, default bit depth is 16
in = minim.getLineIn(Minim.STEREO, int(1024));

// a beat detection object song SOUND_ENERGY mode with a sensitivity of 10 milliseconds
beat = new BeatDetect();

ellipseMode(CENTER_RADIUS);
eRadius = 20;
}

void draw()
{
background(0);
beat.detect(in.mix);
float a = map(eRadius, 20, 80, 60, 255);
fill(60, 255, 0, a);
if ( beat.isOnset() ) eRadius = 80;
ellipse(width/2, height/2, eRadius, eRadius);
eRadius *= 0.95;
if ( eRadius < 20 ) eRadius = 20;
}

void stop()
{
// always close Minim audio classes when you are finished with them
//song.close();
in.close();
// always stop Minim before exiting
minim.stop();

super.stop();
}


I've only commented out the parts of the original you don't need and added some code from the other example.

Hope this helps.
Re: Using linein for Minim BeatDetection
Reply #2 - Feb 9th, 2010, 12:35pm
 
To get isKick(), isSnare() etc. work, use :
beat = new BeatDetect(in.bufferSize(), in.sampleRate());
Page Index Toggle Pages: 1