Minim and getFreq, why a 440 hz sound give me 437 hz
in
Core Library Questions
•
1 year ago
Hi,
I make some code (by reading the doc and forum)
I make some code (by reading the doc and forum)
- import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioInput in;
FFT fft;
float highestAmp=0,freq,frequency;
float amplitude;
void setup(){
size(512, 200);
background(0);
// initialize Minim and catching the output
minim = new Minim(this);
in = minim.getLineIn(Minim.MONO, 4096, 44100);
fft = new FFT(in.left.size(), 44100);
}
void draw() {
highestAmp=0;
amplitude=0;
frequency = 0;
fft.forward(in.left);
//searching from 0Hz to 20000Hz. getting the band, and from the band the frequency
for(int i = 0; i < 20000; i++) {
amplitude = fft.getFreq(i);
if (amplitude > highestAmp){
highestAmp = amplitude;
frequency = i;
}
}
//write the frequency on the screen
fill(255);
background(0);
text(frequency,200,100);
}
It's not so bad but when I play a wav from
http://www.mediacollege.com/audio/tone/download/ this is not the same result…
Is it my config (macbook pro with interne microphone and M-audio card) ? My code or the library ?
Feedback welcome !
Is it my config (macbook pro with interne microphone and M-audio card) ? My code or the library ?
Feedback welcome !
2