Cabbage Logo
Back to Cabbage Site

Sync Time Delay Checkbox

Greetings,

I have programmed an echo effect for L and R channels based on Iain’s example. I would also like to implement a checkbox to sync between the channels, once it is pressed it should have the same feedback and delay time on both channels. I have some doubts about this based on my code:

  • I don’t get any visual feedback on the knobs, as once the sync button is pressed it should move both knobs at the same time, I don’t know if there is a way to do that.

  • Also I’m pretty sure that the sync is not being applied properly as I don’t hear any difference when I press the button, and I can keep adjusting the time and feedback on each channel, so I don’t know if the if loop is good.

I share some screenshots of the plugin and my code, in case someone can help me, thanks in advance.

ChannelDelay.csd (2.2 KB)

Could it has something to do with this typo kTimeR = kTimeR:

if (kSync) == 1 then

    ; If sync checkbox is checked, copy TimeLeft to TimeRight and FDB_Left to FDB_Right    
    kTimeR = kTimeR
    kFBR = kFBL
    
endif

To sync the can use the cabbageSetValue opcode. Note there is also a typo in the sync channel. You have it named “KSync”, but try accessing it with “sync”. Here is code that will update the UI when the users hits sync:

if kSyncTrig == 1 && kSync == 1then
    cabbageSetValue "TimeRight", kTimeL
endif

Okay thanks!

I solve the DSP problem with that corrections, sorry because was something easy, but I still dont know how can I set the visual GUI update, my idea is to move the time and feedback knobs toghether when I move one channel or other in sync mode.

I am not sure what is the meaning of this code:

if kSyncTrig == 1 && kSync == 1then
    cabbageSetValue "TimeRight", kTimeL
endif

I dont have any kSyncTrig variable, thanks a lot!

Sorry, I’m on my phone now, you can get a trigger variable from cabbageGetValue. I’ll send an example later when I’m at my PC…

Try this:

<Cabbage> bounds(0, 0, 0, 0)
form caption("Untitled") size(400, 300), guiMode("queue") pluginId("def1")
rslider bounds(250, 188, 100, 100), channel("DryWet"), range(0, 1, 0, 1, 0.01), text("DRY/WET"), trackerColour(0, 255, 0, 255), outlineColour(0, 0, 0, 50), textColour(0, 0, 0, 255)

rslider bounds(100, 94, 100, 100), channel("TimeLeft"), range(0, 1, 0, 1, 0.01), text("Time Left"), trackerColour(0, 255, 0, 255), outlineColour(0, 0, 0, 50), textColour(0, 0, 0, 255)
rslider bounds(102, 196, 100, 100), channel("TimeRight"), range(0, 1, 0, 1, 0.001), populate("0"), text("Time Right"), trackerColour(0, 255, 0, 255), outlineColour(0, 0, 0, 50), textColour(0, 0, 0, 255)

rslider bounds(-2, 94, 100, 100), channel("FDB_Left"), range(0, 1, 0, 1, 0.01), text("FDB Left"), trackerColour(0, 255, 0, 255), outlineColour(0, 0, 0, 50), textColour(0, 0, 0, 255)
rslider bounds(0, 196, 100, 100), channel("FDB_Right"), range(0, 1, 0, 1, 0.001), populate("0"), text("FDB Right"), trackerColour(0, 255, 0, 255), outlineColour(0, 0, 0, 50), textColour(0, 0, 0, 255)

checkbox bounds(276, 8, 70, 34) text("Sync") channel("Sync")  colour:1(255, 50, 45, 255) fontColour:0(0, 0, 0, 255)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 -m0d 
</CsOptions>
<CsInstruments>
; Initialize the global variables. 
ksmps = 32
nchnls = 2
0dbfs = 1


instr 1

    kDry cabbageGetValue "DryWet"
    kTimeL, kTimeLTrig cabbageGetValue "TimeLeft"
    kTimeR, kTimeRTrig cabbageGetValue "TimeRight"

    kFBL chnget "FDB_Left"
    kFBR chnget "FDB_Right"

    kSync, kSyncTrig cabbageGetValue "Sync"
    printf "Synced", kSyncTrig

    if kSync == 1 then
        if kSyncTrig == 1 then
            cabbageSetValue "TimeRight", kTimeL
        endif
    
        cabbageSetValue "TimeRight", kTimeL, kTimeLTrig
        cabbageSetValue "TimeLeft", kTimeR, kTimeRTrig
    endif

    iMaxTime =       8

    aIn inch 1
    aIn inch 2

    if (kSync) == 1 then

        ; If sync checkbox is checked, copy TimeLeft to TimeRight and FDB_Left to FDB_Right    
        kTimeR = kTimeR
        kFBR = kFBL
    
    endif

    aBufL    delayr  iMaxTime
    aTapL    deltapi a(kTimeL)
             delayw  aIn + aTapL*kFBL

    aBufR    delayr  iMaxTime
    aTapR    deltapi a(kTimeR)
             delayw  aIn + aTapR*kFBR

    /*Dry wet section*/     
    aDL = aTapL * kDry
    aDR = aTapR * kDry

    /*Final output*/
    aOutL = aIn + aDL
    aOutR = aIn + aDR
    
    outs  aOutL, aOutR 
endin
</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
;starts instrument 1 and runs it for a week
i1 0 [60*60*24*7] 
</CsScore>
</CsoundSynthesizer>

Thank you very much!!

It works, now I understand what you mean creating a new trigger variable to update de GUI with cabbageSetValue.

1 Like