Cabbage Logo
Back to Cabbage Site

Gui Linking

Hey cabbages,

I’m sure its a simple one but I’m just not having any luck.

I’m trying to link to hsliders so that when one moves the other one moves with it, is there a way to do this? I understand that its easy enough to do within the code but I want the gui to move with it (so its clear for the end user).

Eg hslider1 = hslider2
When hslider1 is moved on screen I want the hslider2 gui to move with it.

Any help would be appreciated, thanks!

Hello,
Did you try to get the value from slider1 and then set value of slider 2?

    kvalue chnget "slider1"
    chnset kvalue, "slider2"

Hey Karamel thanks for the reply!

Unfortunately I’m still having some trouble and could not get that to work.
Here what I have simplified down.
Basically when link is on, I need the two sliders to have the same value on the visual interface (for end user) and not only in csound. Any help again is really appreciated! Thank you!

<Cabbage>
form caption("Untitled") size(400, 300), colour(58, 110, 182), pluginID("def1")
keyboard bounds(8, 158, 381, 95)
vslider bounds(72, 0, 31, 139), channel("vslider1"), range(0, 10, 0) text("wet")
vslider bounds(124, 0, 36, 139), channel("vslider2"), range(0, 10, 0) text("wet1")

button bounds(202, 37, 60, 25), channel("but1"), text("Unlinked", "Link")
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

kwet  chnget "vslider1"
kwet1 chnget "vslider2"

kbut1 chnget "but1"

if kbut1 = 0 then
kwet = kwet
kwet1 = kwet1
else
kwet = kwet1
endif


</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
</CsScore>
</CsoundSynthesizer>

You spelled your channel names incorrectly when calling chnset. They should have the same channel names as declared with the widgets. There was also no instr 1 definition. Note that when posted code, you should hit the ‘Preformatted text’ button when the code is selected. Otherwise half your .csd text will be missing and users won’t be able to see what the issue is. I’ve updated your post. I’ve attached a working example. Good luck. updated.csd (957 Bytes)

Ah okay I see my mistake and have learned from it thank you so much! I’ll be sure to do that if I post another time, thanks again Rory.