Defer all GEN

I’ve got almost 5k GEN02 (almost table for microtuning, standard scale, etc.) and I’d love to defer their charging at the beginning (even for this number it’s not so much time, but for a question of memory space).
Is there a way or a flag for Csound to do that or it exists only the defer for GEN01?
Thank you,

GEN02 supports deferred size:

size – number of points in the table. The maximum tablesize is 16777216 (224) points. The value may be given as zero, in which case the number of values decides the table length.


What I mean with “defer” is to postpone loading of tables only once they’re used in csound. Just like putting the --defer-gen1 flag.

You could use something like ftgentmp:
Have an instrument which creates the function table, when the instrument terminates the table is destroyed and memory freed.

The second p field for all tables is the creation time is it not?

Yap, but is there a way to set it in order to be created only when I use it?

does it work when you put the ftgen line in an instrument?

As @g_b mentioned the ftgentmp opcode would do the trick.

Yes, but don’t I have to create an instrument for each GEN?

You can do this with one instrument, but yeah you will have to add there all the GENs you wish to use.
Use a parameter to select the GEN to use to create your temp table.
You will need some conditional statement:

Use a global var to save the current temp table.

I should make one instrument with an if of 5k line.
I think I’ll do it with Python API: I’ll check if the table is already created, if not I’ll compile it.

I think it could be interesting to add a flag just like --defer-gen1 but for all gen (or more typically, for gen2, too - which are the tables more custom) . No?

Why 5k lines?
You will have to list all the (~49) GENs but pass them different parameters on creation (as an array maybe?).
But I agree this looks easier using the API.
Have a look at: Csound: Tables

No, the problem is that I have 5000 GEN02 tuning temperaments.
I have a livecoding system and I won’t know which table I use during sessions, so everything must be always ready.

Thank you for the link, I think that if I use python it’ll be easier.

Ah ok yes, now I understand :sweat_smile:
I think that you could also use a score preprocessor to achieve that:

Steven on discord got me this answer, I’ll try because it can be a good solution!

1 Like