Hi there,
Trying to achieve what seemed simple at first (in my rookie's mind). I want to play a sound, and save first 1024 samples from buffer as csv table.
It's sort of works but saved csv is not accurate, the records are messed up chunks, sometimes not starting at the beginning of the file.
I saved my .wav file in audacity as .csv table to have an accurate reference.
I reckon I need some kind of synchronization between beginning of the play() and for loop.
Thank you for your help in advance!
here is the code:
import ddf.minim.*;
Minim minim;
AudioPlayer groove;
AudioMetaData meta;
Table table;
void setup()
{
minim = new Minim(this);
groove = minim.loadFile("noise.wav", 1024);
meta = groove.getMetaData();
table = new Table();
table.addColumn("id");
table.addColumn("data");
//print some sample info
println(groove.bufferSize());
println(meta.sampleFrameCount());
groove.play();
for (int i=0; i < groove.bufferSize(); i++) {
TableRow newRow = table.addRow();
newRow.setInt("id", table.getRowCount() - 1);
newRow.setFloat("data", groove.mix.get(i));
}
saveTable(table, "data/data.csv");
}
void draw() {
}