Cabbage Logo
Back to Cabbage Site

Problems using chnset with gentable (fixed)

Hi, I’ve been trying to use chnset to change both the visibility and table number of gentable. I have just read that you can’t change table number. That’s fine, I’ve thought of a work around, but I’d like to be able to turn visibilty on and off. These are my code snippets:


gentable bounds(5, 555, 560, 150), tablenumber(6), identchannel("WaveViewer")


if (kOsc1Mode == 1) then 
    chnset "visible(0)", "WaveViewer"  
    kOsc1FTable chnget "osc1FTable" 
    SfTableString sprintfk "tablenumber(%i)", kOsc1FTable 
    chnset "visible(1)",  "WaveViewer"   
    chnset SfTableString, "WaveViewer"    


If I don’t include the visibility settings above, then gentable is on. If I add the visibility settings above, then gentable is off. If I swap the settings shown above, then gentable is once again on. So it seems to take the initial value, but not any alterations. I started thinking it must of been processing my if statements at i-time only, but… If I add a printfs to the “else” section, I can see that SfTableString does definitely get updated at k-rate whenever i use my “osc1FTable” widget. Any thoughts?


It’s hard to tell without seeing the entire file. But toggling the table visibility does work. Changing the tables using tablenumber() from Csound code doesn’t work. But it should, even if it’s not recommended. I’ll take a look at that. Btw, where did you read that it’s not possible? It might remind me of why it’s not currently possible! Here’s a simple example that should do the job for you. Two tables, toggled when a user presses a button.

ToggleTables.csd (980 Bytes)

Cheers for the example! This was the thread I found about it:

I’ve tried getting round the gentable tablenumber() business by copying the table I want to see to another one, but that doesn’t seem to be working either… maybe it is my implementation? I don’t know, it’s starting to do my head in, lol

If I post the full .csd and the line numbers in question, would you look through it? Or would you want me to cut it down to the most basic example possible? I’m not too keen on the latter idea, lol, but the problem is in the ARDevSynth I’ve posted, and the code isn’t the best organised in the world, so I’d feel pretty mean making you look through it!

Try this one.
ToggleTables.csd (813 Bytes)
I think I may have preventing them from updating the table number was so that people wouldn’t abuse it. But to be honest, I can’t recall just now. Anyhow, copying the table seems to work Ok.

That second example crashes cabbage on opening

ah, lol, just looked at the first example. Didn’t think of toggling differnet instances of gentable, that;s the answer :smiley:

Just in case, here is the fixed example from before. Sorry, I left in some code that I knew would crash it! Accidentally of course…

test.csd (785 Bytes)

1 Like

that second on doesn’t change anything for me. I assume it should, from the users perspective, do the same as the first

Did you try clicking the button a few times? It should work like the first. If not then it’s usually because of your audio card not been selected, which stops the instrument from running.

hmm, that could of been it, cos I’d crashed my whole computer with something else I was doing in cabbage just before, so jack probably wasn’t open. I’m out of time, I’ll try it again tomorrow. Maybe that could explain my other errors that have mysteriously come and gone, haha

I should really put some kind of notice in to the user when the audio card isn’t selected. I have got caught with this myself on occasion!

I’ve added a check on startup to see if Cabbage have been able to select a valid audio device. If not, a message is given to the user asking them to select a valid device.

Ah nice one! I forgot to update you on the situation there didn’t I. It was
indeed a problem with my audio device, when I made sure I opened it with
jack running, both examples worked fine :smiley: