Minim beat detection
in
Programming Questions
•
2 years ago
Hello all,
I'm pretty new to processing, still learning the basics at uni.
I'm doing a project on interactivity, and am trying to create a beat detection program that generates wave formations from the where your mouse is orientated.
The first issue is the void stop(); it keeps giving me the error: unexpected token void
And the second issue when i comment out the void stop(), i get another error message: found one too many { characters without a } to match it.
not too sure what I'm doing wrong, can anybody suggest any remedies?
Sketch:
import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer song;
BeatDetect beat;
ArrayList beatBars;
int amo = 100;
void setup(){
size (700,400);
minim = new Minim(this);
song = minim.loadFile("skunk.mp3",2048);
song.play();
beat = new BeatDetect();
beatBars = new ArrayList(100);
int count = 0;
while(count < amo){
beatBars.add(new bar(count * 7, height/2, 7,0));
count = count +1;
}
noStroke();
}
void draw(){
background(255);
int count = 0;
while(count < beatBars.size()){
waveBar = (bar)beatBars.get(count);
waveBar.drawBeatBar();
if(waveBar.isOverXpos() == true){
waveBar.h = mouseY - height/2;
}else{
waveBar.h = waveBar.h * 0.95;
}
count = count +1;
}
void stop(){
song.close();
minim.stop();
super.stop();
}
*******BAR CLASS IN SEP TAB*********
public class bar{
public float xPos;
public float yPos;
public float w;
public float h;
public float bar = 200;
public bar(float pX, float pY, float wid, float hei){
xPos = pX;
yPos = pY;
w = wid;
h = hei;
}
public void drawBeatBar(){
beat.detect(song.mix);
float a = map(bar,0,75,150,200);
if(beat.isOnset())bar = 200;
fill(xPos/3,yPos/5,yPos/3,abs(h));
rect(xPos,yPos,w,h);
xPos = xPos + 1;
count = count +1;
if(xPos > 700){
xPos = 0;
}
bar *= 0.95;
if(bar < 0) bar = 0;
}
public boolean isOverXpos(){
if((mouseX > xPos) && (mouseX < xPos + w)){
return true;
} else{
return false;
}
}
I'm pretty new to processing, still learning the basics at uni.
I'm doing a project on interactivity, and am trying to create a beat detection program that generates wave formations from the where your mouse is orientated.
The first issue is the void stop(); it keeps giving me the error: unexpected token void
And the second issue when i comment out the void stop(), i get another error message: found one too many { characters without a } to match it.
not too sure what I'm doing wrong, can anybody suggest any remedies?
Sketch:
import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer song;
BeatDetect beat;
ArrayList beatBars;
int amo = 100;
void setup(){
size (700,400);
minim = new Minim(this);
song = minim.loadFile("skunk.mp3",2048);
song.play();
beat = new BeatDetect();
beatBars = new ArrayList(100);
int count = 0;
while(count < amo){
beatBars.add(new bar(count * 7, height/2, 7,0));
count = count +1;
}
noStroke();
}
void draw(){
background(255);
int count = 0;
while(count < beatBars.size()){
waveBar = (bar)beatBars.get(count);
waveBar.drawBeatBar();
if(waveBar.isOverXpos() == true){
waveBar.h = mouseY - height/2;
}else{
waveBar.h = waveBar.h * 0.95;
}
count = count +1;
}
void stop(){
song.close();
minim.stop();
super.stop();
}
*******BAR CLASS IN SEP TAB*********
public class bar{
public float xPos;
public float yPos;
public float w;
public float h;
public float bar = 200;
public bar(float pX, float pY, float wid, float hei){
xPos = pX;
yPos = pY;
w = wid;
h = hei;
}
public void drawBeatBar(){
beat.detect(song.mix);
float a = map(bar,0,75,150,200);
if(beat.isOnset())bar = 200;
fill(xPos/3,yPos/5,yPos/3,abs(h));
rect(xPos,yPos,w,h);
xPos = xPos + 1;
count = count +1;
if(xPos > 700){
xPos = 0;
}
bar *= 0.95;
if(bar < 0) bar = 0;
}
public boolean isOverXpos(){
if((mouseX > xPos) && (mouseX < xPos + w)){
return true;
} else{
return false;
}
}
1