ha, good find
just for reading 2 links of prior discussions
FFT frequencies ,
Not sure how to work with Minim's FFT feature ,
the link to the reference
where obviously most of your code come from
https://processing.org/reference/libraries/sound/FFT.html
and a very interesting line in the processing code
https://github.com/processing/processing-sound/blob/master/src/processing/sound/FFT.java#L39 ,
in words:
in the processing sound lib the bands are really bands,
and not samples == bands * 2
while in minim lib not.
that are the 2 codes i play with:
sound lib:
// https://discourse.processing.org/t/frequencies-not-adding-up/9170
import processing.sound.*;
SoundFile file;
FFT fft;
int bands = 1024;
float[] spectrum = new float[bands];
void setup() {
size(1024, 512);
// file = new SoundFile(this, "sin440.wav");
file = new SoundFile(this, "the_a.mp3");
file.play();
fft = new FFT(this, bands);
fft.input(file);
}
void draw() {
fft.analyze(spectrum);
for (int i = 0; i < bands; i++) {
stroke(0, 0, 0);
/*
if (i == 2) {
stroke(0, 0, 255);
}
if (i == 5) {
stroke(0, 255, 255);
}
if (i == 10) {
stroke(0, 255, 0);
}
if (i == 20) {
stroke(255, 0, 0);
}
*/
line( i, height, i, height - spectrum[i]*height*5 );
if ( keyPressed) if ( i < 30 ) println("i "+i+" amp "+nf(spectrum[i],1,1));
}
}
minim lib
import ddf.minim.*;
import ddf.minim.analysis.*;
String soundfile = "the_a.mp3"; // "sin440.wav"
Minim minim;
AudioPlayer sound;
FFT spectrum;
float zoom =0.5;
void setup() {
size(600, 600);
noStroke();
fill(255);
minim = new Minim(this);
sound = minim.loadFile(soundfile, 1024);
sound.loop();
spectrum = new FFT(sound.bufferSize(), sound.sampleRate());
println("bufferSize() "+sound.bufferSize());
println("sampleRate() "+sound.sampleRate());
println("fft.specSize()"+spectrum.specSize());
}
void draw() {
background(0);
spectrum.forward(sound.mix);
for (int i = 0; i < spectrum.specSize(); i++) {
float x = map(i, 0, spectrum.specSize(), 0, width);
rect(x, height-10, width/spectrum.specSize(), -spectrum.getBand(i)*zoom);
if ( keyPressed) if ( i < 30) println("i "+i+" amp "+nf(spectrum.getBand(i), 1, 1));
}
}
sound lib max amp at i 20 ( at bands = 1024 it uses 2048 samples )
minim lib max amp at i 10 ( use 1024 samples and give 513 values ( 512 bands ))
also i assume that both use DFT math,
while here
FFT of 1D array of 1024 measurements ,
i play with a complex algorithm i copy
and that does have 2 values per band.
( that was my first idea when i read your question )
i tested with my 440Hz mp3 file but
also i used your online link and did a crosscheck