Hi,
I am quite new to processing and am getting a constructor error when compiling, this is my code for the logAverages.pde:
Code:/**
* Linear Averages
* by Damien Di Fede.
*
* This sketch demonstrates how to use the averaging abilities of the FFT.
* 128 linearly spaced averages are requested and then those are drawn as rectangles.
*/
import ddf.minim.analysis.*;
import ddf.minim.*;
import processing.serial.*;
Serial myPort; // Create object from Serial class
int val; // Data received from the serial port
Minim minim;
AudioPlayer jingle;
FFT fft;
FFTAnalyser analyser;
void setup()
{
String portName = Serial.list()[0];
myPort = new Serial(this, portName, 9600);
size(512, 200, P2D);
//minim = new Minim(this);
//jingle = minim.loadFile("song.mp3", 2048);
analyser = new FFTAnalyser(this, "song.mp3", 2048);
// loop the file
//jingle.loop();
// create an FFT object that has a time-domain buffer the same size as jingle's sample buffer
// and a sample rate that is the same as jingle's
// note that this needs to be a power of two
// and that it means the size of the spectrum will be 1024.
// see the online tutorial for more info.
//fft = new FFT(jingle.bufferSize(), jingle.sampleRate());
// use 128 averages.
// the maximum number of averages we could ask for is half the spectrum size.
//fft.linAverages(128);
//fft.logAverages(60, 5);
rectMode(CORNERS);
}
void draw()
{
background(0);
fill(0,0,255);
// perform a forward FFT on the samples in jingle's mix buffer
// note that if jingle were a MONO file, this would be the same as using jingle.left or jingle.right
fft.forward(jingle.mix);
int w = int(analyser.specSize()/analyser.avgSize());
for(int i = 0; i < analyser.avgSize(); i++)
{
// draw a rectangle for each average, multiply the value by 5 so we can see it better
rect(i*w, height, i*w + w, height - analyser.getAvg(i));
if(i > 6)
fill(255,0,0);
}
setDmxChannel(1,(int)(analyser.getAvg(10)*3));
setDmxChannel(2,0);
setDmxChannel(3,(int)(analyser.getAvg(0)));
setDmxChannel(4,255);
}
void setDmxChannel(int channel, int value) {
// Convert the parameters into a message of the form: 123c45w where 123 is the channel and 45 is the value
// then send to the Arduino
myPort.write( str(channel) + "c" + str(value) + "w" );
}
void stop()
{
// always close Minim audio classes when you finish with them
/*
jingle.close();
minim.stop();
*/
analyser.stop();
super.stop();
}
and here is the code from my FFTAnalyser
Code:
import ddf.minim.analysis.*;
import ddf.minim.*;
public class FFTAnalyser {
public float [] peaks; // peaks of the averages, aka "maxAverages" in other implementations
public int [] peakHoldTimes; // how long to hold THIS peak meter? decay if == 0
public int peakHoldTime; // how long do we hold peaks? (in fft frames)
public float peakDecayRate; // how quickly the peaks decay: 0f=instantly .. 1f=not at all
public FFT fft;
public float samplingRate;
public int minBandwidth = 60;
public int bandsPerOctave = 5;
Minim minim;
AudioPlayer jingle;
public FFTAnalyzer(LogAverages parent, String filename, int sampleRate) {
minim = new Minim(parent);
jingle = minim.loadFile(filename, sampleRate);
jingle.loop();
fft = new FFT(jingle.bufferSize(), jingle.sampleRate());
fft.logAverages(this.minBandwidth, this.bandsPerOctave);
}
/*
public setLogAverage(int minBandwidth, int bandsPerOctave){
}
*/
public float getAvg(int i){
return this.fft.getAvg(i);
}
public float avgSize(){
return this.fft.avgSize();
}
public float specSize(){
return this.fft.specSize();
}
public void stop(){
// always close Minim audio classes when you finish with them
this.jingle.close();
this.minim.stop();
}
}
The error im getting is:
The constructor LogAverages.FFTAnalyser(LogAverages, String, int) is undefined.
Can anyone help?