Array to File .writeArchive .readArchive


I’ve found that you can read/write any Object from/to a file directly with .readArchive and .writeArchive.

However, the output of Array and Signal is pretty different.



var o, p;
o = [
p = [
	// Array
	0, [ 0.74801242351532,  0.87406754493713,  0.64634370803833,  0.055408000946045,  
		0.62177062034607,  0.73370254039764,  0.3752326965332,  0.61893105506897,  
		0.30372893810272,  0.010981678962708 ]


Signal.chebyFill(10, [1]).writeArchive("somePath/ArraySC.txt");


Signal[ -1.0, -0.77777779102325, -0.55555558204651, -0.33333334326744, -0.11111111193895, 0.11111111193895, 0.33333334326744, 0.55555558204651, 0.77777779102325, 1.0 ]

Are these methods legacy ones? Is there a straight forward way to write almost all kinds of data (buffers, wavetables, arrays, signals, multichannel signals, etc) into files? By this I mean using only one method for all data types.

An Array may contain any kind of an Object, whereas a Signal can’t. For that reason, the Signal output can take advantage of the fact that the elements can only be that one type. For the Array example, even though you are only using Floats, the archiver doesn’t care about that - it has to be able to rebuild references if needed.

1 Like

As an aside, in general you will not be able to archive buffer content, because it lives in the server. The buffer object on the client side only contains meta data like the numChannels, the file path etc., see Buffer.

For my own stuff, I’ve written code that recreates the buffers using the file path in the archive, happy to share if it’s of interest.


1 Like

If you can share that I would be great!