osctools/csvrandomwriter/csvrandomwriter.pde

22 lines
538 B
Text
Raw Normal View History

2021-11-11 10:03:30 +00:00
Table table;
float frequency=4; //data frequency in Hz
int duration=1000*10; //in ms
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.setInt("time", (int)(i*(1000/frequency)));
newRow.setFloat("heartrate", noise(i/10)*40.0+60);
newRow.setFloat("random", random(1));
}
saveTable(table, "data.csv");
println("Finished");
}