Cabbage Logo
Back to Cabbage Site

Generating weighted sum of tables with GEN18

Hi everyone,

I’m trying to generate a weighted sum of pre-existing tables from the orchestra.
For that I’m using ftgen with GEN18, which does nothing but crushes Cabbage. Am I looking in the right direction with it?

The idea is to have an array of weights for 20 tables and mix them like that.
Here’s the code:

instr calculateWeightedTable
    
    ftset 50, 0
    ftset 48, 0
    
    iCounter = 1
    
    while iCounter< lenarray(gSFiles) do
    tablecopy 50, iCounter

    iCurWeight init giWeights[iCounter-1]

    iTabNrA ftgen 48, 0, 2621434, 18, 50, 1, 0, 262143, iCounter, iCurWeight,0,262143
    tablecopy 50, 48
    iCounter += 1
    od
    turnoff
endin  

Thank you in advance!

Can you provide me with a complete example? I’ve not used GEN18 before but I can take a look. Btw. have you tried it outside of Cabbage with vanilla Csound? It might be Csound that is causing the problem rather than Cabbage.

SOLVED!
So, for everyone facing the same issue in the future: tablemix opcode does the same job and actually works. The only difference to GEN18 is that it takes only two tables at once. Which in my case is okay, because I sum the tables in loop one after another.

Hey Rory,
There’s not much more happening regarding this snippet. Just a global array of weights plus an instrument call with ‘event’ from another instrument. Haven’t tried it with vanilla, but it seems to me that GEN18 just crushes it.

Thank you for the quick response anyway!
It’s great to have you supporting newbies!

There wasn’t much support dished out here, you figure it out on your own :slight_smile: Btw, there is also the ftmorph opcode. He’s an example of it using p5js and Csound.