minim: saving buffer samples as csv

edited March 2018 in Library Questions

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();

  //print some sample info

  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() {


  • edited March 2018

    Still dunno much about the Minim library. But just maybe addListener() might be a fix? :-/

    Take a look at this previous forum thread: O:-)

    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.


Sign In or Register to comment.