We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I am relatively new to processing and I'm trying to find a way to make processing register bass frequences only. This is for a school project where we are making a party lamp that can detect if there is a party going on in the house.
We have tried different solutions, mainly using the beatDetect class, but we find it difficult to get processing to register bass only. Either the code is too sensitive to other background noises, or we can't figure out what type of frequency, or band, to use with isRange. (Using information from this webpage: http://code.compartmental.net/minim/javadoc/ddf/minim/analysis/BeatDetect.html#isRange(int,%20int,%20int) ). This code should make the square "jump" when it registers a frequency in the bass spectrum, but it jumps all the time even when we speak. We want to make it jump only when there are low bass-frequencies.
Sorry about the weird explanation, but can somebody help us? Here is the code we are experimenting with:
import ddf.minim.*;
import ddf.minim.analysis.*;
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);
}
}
Minim minim;
//AudioPlayer song;
AudioInput in;
BeatDetect beat;
BeatListener bl;
int time = 30;
float kickSize, snareSize, hatSize;
void setup()
{
size(512, 200);
smooth();
//Minim.start(this);
minim = new Minim(this);
// get a line in from Minim, default bit depth is 16
in = minim.getLineIn(Minim.STEREO, int(1024));
// a beat detection object that is FREQ_ENERGY mode that
// expects buffers the length of song's buffer size
// and samples captured at songs's sample rate
beat = new BeatDetect(in.bufferSize(), in.sampleRate());
beat.setSensitivity(300);
kickSize = snareSize = hatSize = 16;
// make a new beat listener, so that we won't miss any buffers for the analysis
bl = new BeatListener(beat, in);
beat.setSensitivity(time);
}
void draw()
{
background(0);
fill(255);
if ( beat.isRange(1,1,1) ) kickSize = 32;
stroke(255);
strokeWeight(kickSize);
rect(width/4, height/2, 20, 20);
kickSize = constrain(kickSize * 0.95, 16, 32);
for (int i=0; i<10; i++) {
println(beat.getDetectCenterFrequency(i));
}
}
void stop()
{
// always close Minim audio classes when you are finished with them
in.close();
// always stop Minim before exiting
minim.stop();
// this closes the sketch
super.stop();
}