How to write Jitter cells as float32_array?

Charles Turner's icon

Hi all-

I stumbled around for a while to get the code below, which works for me. Is there a better ways to write Jitter matrix data to a raw binary file than this? Or in other words, is there something more elegant the Number conversion on my getcell() calls?

Thanks!

var myMatrix = new JitterMatrix(1, 'float32', 512);
var myData = [];
var fn = new File('~/Desktop/test.raw', 'write');

// Put some data in the Matrix...

for (var j=0; j < 15; j++) {
    myData.push(Number(myMatrix.getcell(j)));
};

fn.writefloat32(myData);
fn.close();
Charles Turner's icon

OK, I see I can simply say:

myMatrix.getcell(j)[0];

also:

1) Looks like Max 6.0 supports Javascript Float32Array and friends.
2) myData.push() is a bad idea if the Array is global: it'll just keep adding data between runs of the patch.

Best, Charles