Cabbage Logo
Back to Cabbage Site

Gentable and ftables

Hello,
I’ve a problem with the gentable widget.
In the program attached a gentable widget is linked to ftable 1 to visualize/editing it, with a selector and a button I can save it in another ftable and save the ftable in an external file (with ftsave/ save button).
In another part of the program I copy the stored ftable to ftable 1.
What happen is that when I load a table it is visualized correctly in the gentable widget but as soon as i try to edit the table the content changes but it sort of reset the table content. Seems like ftable 1 is owerwritten by the widget,

Can someone find where the problem is in my code?

Ciao
Stefano

gentableVsFtable.zip (12.0 KB)

Editing a function table with the gentable widget will overwrite the existing function table data. It’s definitely destructive editing that takes place. Perhaps you can use the tablenumber() identifier with your gentable’s identifier channel to dynamically update the table as you go?

But next time I’ll use gentable I will destroy the new table instead of modifying it, unless I create another instrument that will algebrically sum the gentable output (maybe stored in a spare table) with the stored ftable output and than update the display. Am I wrong?

Cabbage grabs table points when the table is created using a GEN routine. ftload does not create a table using its gen routine. It simply copies data from a file into the table index by index. @gsenna wrote a new opcode called getftargs that will grab the current table string in terms of GEN arguments.

This can then be saved to a file and later recalled to recreate a table using scoreline The only thing is that I’m not sure it works with ftgen. His example uses an f-statement from the score, and when I tried to use an ftgen it didn’t work. It will need some testing, but maybe it’s a solution. I’m tied up with work stuff right now, but let me know how you get on. The step sequencer looks great. I hope we can get it to work properly!

1 Like

Hi,

I’ve just tested the getftargs opcode with ftgen and it seems to work fine, but let me know if it isn’t working for you and I’ll see what I can do. In the end we can always ask John at the Csound list.

By the way, it would be great if the mode property of the filebutton in Cabbage 2 would accept -instead of “file”- the arguments “open” and “save”. Right now it triggers an “Open file…” dialog and we would need a “Save as…” one in order to give getftargs some use. Of course you could always end up generating the file name in Csound with the current time stamp or similar, but that’s cumbersome to manage afterwards.

Cheers.

That’s a good point. I’ll remove file and add open and save instead.

Thank you for the info, I’ll give a try to getftargs soon (I hope).
In the meantime I’ve replaced the gentable with a series of vsliders, the gui looks a little bit crowded but works as expected.

I did a test and I confirm that the trick to avoid overwriting is to use scoreline instead of copying tables values.
Since I didn’t have getftargs (I’m using an older version on this pc) I’ve concatenated strings with a loop to produce the ftable string (instr 18 in the csd), with GEN 2 is easy for GEN 5 or 7 I’ll need gsenna opcode (but this is another story).
The problem seems solved with this method.
Maybe is worth to mention this in the manual?

Thank you again

Stefano
gentableVsFtableString.zip (12.0 KB)

Nice work. What do you think I should add the to the manual? Let me know, or provide me with a few lines and I can add it. Thanks.

Something like:
Editing a function table with the gentable widget will overwrite the existing function table data.
Loading ftable data with ftload opcode or by direct indexing will cause the data contained to be deleted (resetted) at the first gentable operation.
Creating or updating the ftable from the score or with scoreline the data will be preserved, displayed and edited by gentable without resetting it’s content.

Sounds good. I’ll throw that in the next time I get a chance.

[edit] I’ve updated the text in the docs with this info. Thanks.