Cabbage Logo
Back to Cabbage Site

Gentable sliders

Im Trying to make a harmonic editor for waveforms, like in dune. I have all of the widgets i need for the action, yet anyway i try to get the sliders to affect the gentable nothing happens. Ive tried using k, i and a rate vaiables, and nothing seems to be working. Could anyone offer me help on this?

Try re-sending the “tablenumber(x)” info into the gentable widget’s identchannel, it “forces an update” to display the table with any new changes.

The way I’ve been using it, I end up with something kind of like this:

I also have an example doing something similar with an ADSR envelope I could dig up, it’s more straightforward and the code is in a shareable state if needed :slight_smile:

gentable bounds(26, 26, 840, 394) tablenumber(1.0) tablebackgroundcolour(15, 15, 15, 89) tablecolour:0(53, 153, 219, 255) identchannel("1.0") like this?

Not quite. You want to assign an identchannel name to the widget. Like this:
gentable bounds(26, 26, 840, 394) tablenumber(1) tablebackgroundcolour(15, 15, 15, 89) tablecolour:0(53, 153, 219, 255) identchannel("table1")

And then in your code, when the table is altered…send the tablenumber to that identchannel, like this:
chnset "tablenumber(1)", "table1"

I recommend trying to rate limit how often you send a chnset to the widget, I usually keep it at no more than 20hz.

Caveat: I didn’t test that pseudo code, but I think it gives the rough idea.

Check out the SimpleTable example in the Misc csds.

2020-05-30 20.26.17

ok. I checked out the example, and used that code to try and get it working. All i did was change variable names to the ones i have and my thought process was “its tthe same code. Nothing should change” however when i implement the code in it

kChanged changed kOsc1band1, kOsc1band2, kOsc1band3, kOsc1band4, kOsc1band5
if kChanged==1 then
	;if a slider changes trigger instrument 2 to update table
	event "i", 2, 0, .01, kOsc1band1, kOsc1band2, kOsc1band3, kOsc1band4, kOsc1band5
endif

endin

instr	2
iNormal = (chnget:i("normal")==0 ? -1 : 1)
iTable ftgen 1, 0, 1024, 10*iNormal, p4, p5, p6, p7, p8
chnset "tablenumber(1)", "osc1table"	; update table display
endin

it doesnt return an error: but nothing happens

Can you post the entire .csd file?

yep. I dont have any ui control of the panel yet, i just wanted to get the panel working. All im after right now is the gentableHept-X.csd (10.8 KB)

That appears to be working to me!

The problem however, the ui and table only get updated when you hit keys. I can change the sliders as i hit keys on the midi keys, and the graph will change in the background.

You want to move the part that watches for changes and triggers the update instrument (2 in your case) into an “always on” instrument, rather than the one that gets triggered as a synth when keys are hit.

Hope that helps!

This is something that I still get caught out with at times! I sit there wondering why my GUI is not responding, only to realise there are no instruments running :see_no_evil: