Cabbage Logo
Back to Cabbage Site

Help me please About change widget

How to change each widget if I have 2 widget. Exam like widget 1 is drum setting and widget 2 is effect setting. When I push button and widget 1 will change to widget 2. I want to know anyways define widget. help me please…

Can you describe what you want in a little more detail? You want a latched button widget to toggle between two slider widgets in some way?

I have drumset 1 & drumset 2. And I have widget for adjust knob like level,tune,pan 1 page will have knob drumset1 only and have combobox I set name combobox like drumset1,drumset2 so when I select drumset2 I want to change all knob in drumset1 to be all knob of drumset2. like u push next button. You understand?

Thanks, I think I understand now. Here is a suggestion below. It allows you to adjust two different drums using a shared set of controls. You select the drum using the combobox. Each drum set contains just one drum for simplicity but this should be easily expandable. This example uses arrays to store the data for all the drums. There are probably other ways to do this but arrays tends to be the modern efficient way. I hope this helps, let me know if it doesn’t!

<Cabbage>
form caption("Untitled") size(400, 300), colour(58, 110, 182), pluginid("def1")
combobox bounds(10, 32, 80, 20) text("Drumset 1", "Drumset 2", "") channel("SelectDrumSet")
button bounds(60, 142, 125, 71) channel("PlayDrum") text("Hit!") latched(0)
rslider bounds(98, 30, 84, 90) range(0, 1, 0.5, 1, 0.001) channel("Volume") text("Volume") valuetextbox(1)
rslider bounds(198, 30, 84, 90) range(50, 2000, 500, 1, 0.001) channel("Pitch") text("Pitch") valuetextbox(1)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1

massign 0,2 ; all midi to instr 2

; create arrays for parameters for the different drums
gkDrumVolumes[] fillarray 0.5, 0.5
gkDrumPitches[] fillarray 500, 500

instr 1
; read in widgets
kSelectDrumSet chnget "SelectDrumSet"   ; select a drum/drum set
kVolume        chnget "Volume"
kPitch         chnget "Pitch"
kPlayDrum      chnget "PlayDrum"

; if a control is moved, write its value into the appropriate array location
if changed:k(kVolume)==1 then
gkDrumVolumes[kSelectDrumSet-1] = kVolume   ; note that combobox output starts at 1 so we need to subtract 1 to start at index 0
endif
if changed:k(kPitch)==1 then
gkDrumPitches[kSelectDrumSet-1] = kPitch
endif

; If trigger button is pressed, play the appropriate drum and send volume and pitch data
if trigger:k(kPlayDrum,0.5,0)==1 then
 event "i", p1+kSelectDrumSet, 0, 0.6, gkDrumVolumes[kSelectDrumSet-1], gkDrumPitches[kSelectDrumSet-1] 
endif
endin

giSine ftgen 0,0,4096,10,1 ; a sine wave (needed by foscil for FM synthesis)
 
instr 2 ; Drum 1
aEnv  expon  1, p3, 0.001
aSig  foscil aEnv*p4, p5, 1, 1, k(aEnv), giSine
      outs   aSig, aSig
endin

instr 3 ; Drum 2
aEnv  expon  1, p3, 0.001
aSig  foscil aEnv*p4, p5, 1.71, 1, k(aEnv), giSine
      outs   aSig, aSig
endin

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

thanks bro