Cabbage Logo
Back to Cabbage Site

Convert from ftsave txt back to audio/wav

Hi everyone,

since it is possible to store information of a wavfile in a table and with ftsave to a txt file
(even there is a warning in the opcode description not to write wav information)
I try to transform that txt into a useable table , which will then give me the possibility
to play the stored information back as audio again.

I know Matlab can store tables and write it back with audiowrite() to a wav file.

Is there a way to manage this in Csound/Cabbage?

So far I explored ftsave, ftload and TableToSF to see if it writes back the audio information back into a wav file. But it gives back an empty wav file instead.


why not simply save and reload the audio file? why bother with converting it back and forth between text?

yeah i use this in my instrument to save all params and waveform&tables in single file, it woks great.
ftsave gSFileName, 1, gipres,gitableL, gitableR, gitableL2, gitableR2 ,gilf1, gilf2, giEnv11, giEnv22

ftload gSFileName, 1, gipres, gitabL, gitabR, gitabL2, gitabR2, gilf11, gilf22, giEnv11, giEnv22

as you see here i saving lots of data and all in single file, then loading it back.
mind that before load, you need to generate all those tables and the should be not smaller than saved , or its will not work. begger is fine as i findout.


also if you run ftload&ftsave in separate instrument( as i do) , you need to run it for some time, 0.1 sec works fine here

1 Like

@Kzz thats great ! Thank you very much!

One thing might help if you could share the snippet of the tables you are acutally using and are assigned to that structure to go from there.


so, thats how it works best for me
i made separate instrument for save and for load

for save, gidata is preset table(or any usefull data), and table with audio data.
its good to know your audio table length , to generate same size or bigger when loading it back.
instr 100
ita = ftlen(giaudio)
; now we know how big is audio table , lets store it to data table. its not necessary , we always can generate big enough table when loading to avoid errors

tabw_i ita,0,gidata,0
ftsave gSFileName, 1, gidata, giaudio

now instrument to load data
instr 200
giaudio1 ftgen 51,0,2^21,10,0 ; generating big table to be sure

ftload gSFileName,1,gidata,giaudio1
itablen tab_i 0, gidata , 0 ; loading audio table length
giaudio ftgen 55,0, itablen,10,0 ; generating table exact size of stored audio
tableicopy giaudio1,giaudio ; copy loaded data to table you goin to work.

1 Like