osctools/csvrandomwriter/csvrandomwriter.pde

22 lines
529 B
Plaintext

Table table;
float frequency=4; //data frequency in Hz
int duration=10; //in s
void setup() {
table = new Table();
table.addColumn("time"); // in milliseconds
table.addColumn("heartrate");
table.addColumn("random");
for (int i=0;i<(int)(duration*frequency);i++) {
TableRow newRow = table.addRow();
newRow.setFloat("time", (float)(i/frequency));
newRow.setFloat("heartrate", noise(i/10)*40.0+60);
newRow.setFloat("random", random(1));
}
saveTable(table, "data.csv");
println("Finished");
}