Cabbage Logo
Back to Cabbage Site

Array load from / save to file

Hello everybody
I’m trying to process input audio signals storing the result in a k-rate array which is updated continuously.
I’d like to save the array in a file, in order to load it back again to the array in a different moment but I don’t understand what kind of opcode use, because I don’t want to store my instrument output but its current internal state (the array) and I’d like to write it out all in a shot (taking the minimum time needed to save data, not waiting for k-time intervals multiplied by array size.
What opcodes or example should I look at as a reference?
Thank you

Sergio

There are quite a few opcodes you can use for this:
https://csound.com/docs/manual/SigioTop.html#SigioFileIO
I am not sure any of them will accept an array input. So you could instead use one of the table save/reading opcodes. Then use copya2fab and its complimentary opcode to convert to a table before writing, and convert back to an array after reading. It’s probably best to use a GEN02 sized table. You can also check these opcodes from Eduardo Moguillansky. You might also find something in there that helps. :+1:

Hello Rory
Thanks for the suggestions, I checked the first link and I’m using these 2 lines:
hdf5write “test.h5”, kAvg, kWindowNumber, kWindowWriteIdx, kWindowReadIdx ; Write variables to an hdf5 file

    ;kAvg[], kWindowNumber, kWindowWriteIdx, kWindowReadIdx hdf5read "test.h5", "kAvg", "kWindowNumber", "kWindowWriteIdx", "kWindowReadIdx" ; Open hdf5 file and read variables

the first line seems to work, but whenever I uncomment the second line and save Cabbage crashes.
How could I understand what’s going on? Is there an error log that I can check (btw my platoform is Windows 10).
Thank you

Sergio

Oh I’ve never used those opcodes, are they not for more specific applications? Also, I’m not sure they are included with the version of Csound you are using? They probably are, but I’ve never used them, so I can’t be sure what the problem is. I’m afraid that a crash in Csound is fatal for Cabbage. So even the log file will give no extra information. The only way to gather more information would be to build Csound yourself from source, and then run it through a debugger. Or, use one of the other opcodes :thinking: