Cabbage Logo
Back to Cabbage Site

Invalid Table Number Error

Hi again, haven’t posted here in a while. I’m working on another plugin that, similar to the other one I made, divides the signal into a given number of bands that’s controlled by a slider and goes up to 100, and then frequency shifts them by the same amount + an extra control that “tilts” the frequency shift values, shifting the low bands by a larger amount when tilted to the right or the high bands when tilted to the left. There’s also the option to randomize the shift amount on each band by a given range. I made this system by generating two fuction tables, one for the tilt and another one for the randomization, updating them with the knob values when they are changed and then accessing their values using the tabmorph opcode to give the user the control to transition between them so he can control the range of randomization after tilting (or just not tilt at all and just randomize. The thing is, there’s this error that I can’t get rid of:

INIT ERROR in instr 1 (opcode tabmorph) line 324: tabmorph: invalid table number

I tried both using both the “gir” and “ifn” arguments of the ftgen opcode I used to generate the tables and update them in the “ifn1” and “ifn2” init parameteros of tabmorph, without success. What am I doing wrong?

By the way, if you’re wondering why didn’t I do it in the spectral domain, it’s because after checking out some examples to learn how to code spectral csound I concluded that I just don’t really like how “vocodey” it sounds, it’s kinda like the sound looses it’s edge with the fft processing that csound does (idk maybe it’s just me and I haven’t looked into it enough), and meanwhile I don’t really mind the phase issues of just stacking all those bandpass filters. Also, I didn’t use an UDO to do all the duplicates instead of just bruteforcing it because I had already started this code before I even knew what UDO’s were, and tbh I’m kinda too lazy to convert all the duplicated code into udo’s :sweat_smile: :sweat_smile: might do it one day if I see that it really does affect the performance but right now i’m not really sure about it (rn I’m using a tool that lets me duplicate code with incrementing numbers, it isn’t really that hard to work with so much duplicated code using that and the built in find and replace tool).

pd. there is already an UDO in the code because the whole thing is a modified version of Ian McCurdy’s frequency shifter from 2013 I found and reused to save time because at the end of the day I wasn’t gonna sell this plugin or anything so I thought I’d save time. The code already had the frequency shift udo. My dumbass did not understand how that worked anyway for quite some time even though a quite self explanatory exaple was just sitting in front of my eyes :rofl: :rofl:

Here’s the csd file
Misshaper.csd (266.9 KB)

  • The code’s quite large due to all the duplication, so here’s where all the relevant stuff is: the tables are generated in the first 4 instruments before the main one (inst 1), and the tabmorph arguments are used throughout the bands in the kfshift setup section at line 322 and in the frequency shifters section at line 1175

Could you try to replicate this in a more isolated example and post that here?

Shot in the dark here but:
Csound usually initializes instr in order, therefore will init instr 1 first and at that point the tables have not yet been created.

As an example:

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
;================================
<CsInstruments>

sr = 48000
ksmps = 10
nchnls = 1
0dbfs  = 1

instr table
  giSine  ftgen 1, 0, 1024, 10, 1
endin

instr 1
  out oscil:a(line:k(.4,p3,0),220,giSine)
endin 

</CsInstruments>
;================================
<CsScore>
;i"table" 0 .1
i1 0 4
</CsScore>
</CsoundSynthesizer>

The above produces the invalid table number error (table not found).

Changing instr 1 to instr 2 (including doing so in the score) will still produce the error.

However, if you change instr 1 to instr 2 (in the score as well) and also uncomment the score line:
i"table" 0 .1
then Csound will assign instr table as instr 1 and now instr 2 will find the table, the code works.

So the error appears to be that tables are not being properly created before instr 1 is initialized. There are probably several ways around this.

Perhaps try (in the score):

i"UpdateTable1" 0 .1
i"UpdateTable2" 0 .1
i"UpdateTable3" 0 .1
i"UpdateTable4" 0 .1
i 5 0 [606024*7]

Note that you will need to change instr 1 to at least instr 5 to allow the “UpdateTable” instruments to initialize first. I can’t test it (and the code is huge!) so it’s only a suggestion but maybe worth a try.

alr that worked perfectly! thank you very much!!

:+1: