VBAPSpeakerArray question (save/load raw buffer data)

I have loaded a VBAPSpeakerArray to a Buffer. It’s a 62 channel speaker array and I’m computing the optimised pairs and triplets based on azimuth and inclination values loaded from a .csv file.

b = Buffer.loadCollection(s, ~vbapSpeakerArray.getSetsAndMatrices);

For the performance, I would like to persist this analysis to a file rather than have to call .getSetsAndMatrices on load which is a blocking operation.

I’m having a hard time with this. If I save .write the buffer as raw, headerless data, Buffer.read can’t read it. If I save it as a .wav file, my loaded values differ from the original (I guess because the load function is interpreting them as amplitude values between -1 and 1).

What’s the simplest way to load a list of values from a file to a Buffer?

Maybe save an Archive:

a = VBAPSpeakerArray.new(2, [ -30, 30, 0, -110, 110 ]); // 5.1 array

a.getSetsAndMatrices.writeArchive("/Users/spluta1/Desktop/test") //use your own file path 

b = Object.readArchive("/Users/spluta1/Desktop/test")

b.postln;

Sam

A wav file using 32-bit float format should preserve the values exactly.

If you use int16 or int24 then you’d lose values outside of -1.0 to +1.0.

b = Buffer.alloc(s, 100, 1);

a = {
	RecordBuf.ar(
		Line.ar(0, 100, b.duration),
		b, loop: 0, doneAction: 2
	)
}.play;

b.write("~/float.wav".standardizePath, headerFormat: "wav", sampleFormat: "float");

b.free;

b = Buffer.read(s, "~/float.wav".standardizePath);

b.get(98, _.postln);  // 99.0 = outside of -1.0 to +1.0, preserved correctly

hjh

Both work! Thanks for the help @Sam_Pluta and @jamshark70