We are about to switch to a new forum software. Until then we have removed the registration on this forum.
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() {
}
Answers
Still dunno much about the Minim library. But just maybe addListener() might be a fix? :-/
Take a look at this previous forum thread: O:-)
https://Forum.Processing.org/two/discussion/10900/stitch-together-audio-samples-from-microphone-to-get-continuous-signal
It uses AudioInput though. But maybe the same technique can be used for AudioPlayer too? :-??
Ah, yes, addListener(), I was looking at it in minim docs, but the example provided there has too many parts I couldn't grasp.
Thanks for the link, perhaps I can get more insight from the examples in that thread and moreover my final goal is to use AudioInput.
I'm just using AudioPlayer for now to have better control of input and output tables, to be able to compare them.
Cheers