Cabbage Logo
Back to Cabbage Site

Delay effect

Which opcode would be good to create a ping pong style delay something you might hear in a trance synth possibly even with tempo sync :face_with_monocle:

Have you looked at the Csound manual, or even the Cabbage examples? Or how about a simple google search for ‘delay csound’? All of these methods should reveal some useful information for you :wink:

For tempo sync, check out the HostInfo example in the Cabbage Misc folder. That shows how to retrieve such information as the current BPM from the host.

Trying to create a delay effect in my synth had a look at csound manual tried this solution and having no luck here it so far
instr 3

 

ga1 init 0

 

aBufout delayr 0.5

 

aTap1 deltap 0.1373

aTap2 deltap 0.2197

aTap3 deltap 0.4193

delayw ga1 + (aTap3*0.4)

 

outs ((aTap1+aTap2+aTap3)*0.4)

 

ga1 = 0

  

endin

</CsInstruments>

<CsScore>

;causes Csound to run for about 7000 years...

f0 z

i 2 0 z

i 3 0 25

</CsScore>

</CsoundSynthesizer>

Don’t know if anyone has any ideas where I’m going wrong

Can you attach a full example…
Btw, the delay opcode might be easier than the deltap ones…

I’m getting a little lost here🤔 is creating the delay effect as simple as the moogladder and butterhp and the reverbsc were they just take some input and arguments and the output a signal or is there more to it something I’m missing

To create the classic ping-pong delay effect you create a stereo delay with feedback and double the delay time you want but then offset the input to one of those channels using another delay (no feedback) that uses the desired delay time. The offset-delayed signal is also sent directly to the same channel. This all probably sounds confusing but here is the code:
aIn mpulse 1, 0

kTime    =       0.2    ; delay time
kFB      =       0.8    ; feedback ratio
iMaxTime =       4

aInDel   delay   aIn, 0.2 ; offset delay

aBufL    delayr  iMaxTime
aTapL    deltapi kTime * 2 ; n.b. delay time doubled
         delayw  aIn + aTapL*kFB

aBufR    delayr  iMaxTime
aTapR    deltapi kTime*2
         delayw  aInDel + aTapR*kFB
         
         outs    aIn + aTapL, aIn + aTapR + aInDel

If I want to control the delay with widgets I assume the kvariables are what I want to chnget but what are the units being used🧐

‘kTime’ is the delay time and it is in seconds. Make sure to set ‘iMaxTime’ to be greater than double the maximum value possible from the delay time widget.
‘kFB’ is a feedback ratio for the echoes, this should be within the range 0 to 1.
I hope this helps.

kTime = 0.2

kFB = 0.8

iMaxTime = 4

 

aInDel delay aOuthpf, 0.2

 

aBufL delayr iMaxTime

aTapL deltapi kTime*2

 

      delayw aOuthpf + aTapL * kFB

aBufR delayr iMaxTime

aTapR deltapi kTime*2

    delayw aInDel + aTapR*kFB   

 

outs (aOuthpf + aTapL), (aOuthpf + aTapR + aInDel)

 

ga1 += aOuthpf

endin

This is my code for the delay I’m still not getting a ping pong delay effect in my synth everything else is working but no echo ping pong delay

I just put my headphones on :+1: I hear a stereo effect but it’s not quite what I had in mind although could be nice for adding some width to the synth sound I don’t know if I was clear the delay I had in mind was the kind you would get on a subtractive wavetable synth the kind you would have synced to your daws tempo :face_with_monocle::thinking:

In my original code, the offset delay needs to be made using vdelay in order for the delay time to adjustable in realtime; sorry about that. Having said that, the code as it is works so if you’re not hearing it, there must be a problem elsewhere. In this example it generates a ‘chime’ sound which subsequently ping-pongs alternately in the left and right speakers. It is also a good idea to interpolate the delay time to a-rate (as I have done here) if you plan on moving it in realtime.

instr 1
aEnv     expon   1, 0.2, 0.001
aIn      poscil  aEnv, 440

kTime    =       0.2    ; delay time

kFB      =       0.8    ; feedback ratio
iMaxTime =       4

aInDel   vdelay  aIn, a(kTime)*1000, iMaxTime*1000

aBufL    delayr  iMaxTime
aTapL    deltapi a(kTime) * 2 ; n.b. delay time doubled
         delayw  aIn + (aTapL * kFB)

aBufR    delayr  iMaxTime
aTapR    deltapi a(kTime) * 2
         delayw  aInDel + (aTapR * kFB)
         
         outs    aIn + aTapL, aIn + aTapR + aInDel
endin

I’ve implemented the code above and I’m getting a delay effect when midi notes are on how do I get feedback after I have pressed and released the midi key like you’d get on a guitar delay box :face_with_monocle: