Cabbage Logo
Back to Cabbage Site

Question: Saving ftables in presets

I am currently working on a set of fft based tools and have completed a first version of a spectral EQ. The gui allows the user to draw and randomize function tables and then store, recall, and tween between them. I wanted to know if there was an elegant way to save user defined function tables as a preset so that a daw can recall the previous state on load. Right now the only way I can think of is to make a ton of invisible sliders in widget arrays to store the values within the snapshot.

Here is my current script: https://pastebin.com/J0G40zwR

1 Like

Nice instrument. Have you looked at the file read/write opcodes in Csound? foutk or dumpk could be used to write the values to a text file, while you could read them back into a function table using fink, or readk. They should do the trick.

1 Like

Thanks Rory. I will look into these opcodes and see how I can implement them. I will let you know how it goes.

I almost have this working, but I was wondering if there was a way to popup a save dialog with filebutton. Right now I have to create an empty file or create a name and save that file to a directory which is a little clunky.

I see what you mean. There used to be a ā€˜saveā€™ mode in Cabbage 1 that somehow didnā€™t get added to Cabbage 2. Can you leave it with me, Iā€™ll try to get it added soon.

1 Like

Can you try the latest beta from here. It has a mode(ā€œsaveā€) option now for filebutton. Let me know if it helps.

This seems to work nicely!
If you are interested I have update the code at the pastebin link

Thank you :slight_smile:

Looks cool. I canā€™t seem to recall saved tables however?

I just looked at it and it does not seem to be working- I will fix it and then repost.

Thanks,
Chris

I think it is fixed. I had an unnecessary turnoff opcode that seemed to be messing things up. (not quite sure why) I was able to reliably switch between three table lists when I was testing it, so I think it is in working order now. Here is the pastebin

Iā€™ll try this when I get a chance.

I donā€™t see any update when users load a table? But perhaps this was not part of the plan. It still seems to work fine. I only took a quick look over this, but it seems that you are calling chnset on the table on every k-cycle? This will slow things down considerably. It would be better to update only when the contents of the table change (apologies if this is what you are doing, it could be that Iā€™ve read the code wrong!)

Thanks for the feedback! I went ahead and moved the gui update inside of my if statements as you suggested. The selected table should be recalled when a list of tables is loaded, but this only happens some of the time and I am not quite sure why. It still works when the table number is recalled, so I know it is loading the table list into the function tables. Could this be a timing thing where csound is trying to recall the table before it is loaded?

Also, I tried using the populate method for the ā€œfileā€ setting on the filebutton to restrict displayed files to those with a customized extension of ā€œ*.speceqā€, but it does not seem to be working. This is not a big deal, but I was wondering if I made a mistake.

If you send on the .csd file I can take a look.

here is a link to the folder containing the .csd file and 2 preset files I have been using for testing

Thank you so much for being so helpful!

The populate thing is a bug, which I just fixed.Iā€™m not seeing any issues on Windows with this version. The tables seem to all load fine for me. But I need to test on OSX again as it didnā€™t seem to work for me there. Might it not be better to recall the tables automatically when the user selects one? From a UX point of view having to select a table, and then confirm selection seems an extra step you could easily omit?