# Delay effect

**URL:** <https://forum.cabbageaudio.com/t/delay-effect/1701>\
**Category:** Csound Noobs\
**Created:** [8 December 2019 19:30 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701 "2019-12-08T19:30:53Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerardotrance](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/gerardotrance/32/1537_2.png) [@gerardotrance](https://forum.cabbageaudio.com/u/gerardotrance)\
**Post date:** [8 December 2019 19:30 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701/1 "2019-12-08T19:30:54Z")

</div>

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 🧐

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [8 December 2019 20:31 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701/2 "2019-12-08T20:31:12Z")

</div>

> [@gerardotrance](#):
>
> Which opcode would be good to create a ping pong style delay

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 😉

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.

---

<div class="post-metadata">

**Author:** ![gerardotrance](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/gerardotrance/32/1537_2.png) [@gerardotrance](https://forum.cabbageaudio.com/u/gerardotrance)\
**Post date:** [8 December 2019 22:23 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701/3 "2019-12-08T22:23:24Z")

</div>

```
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

---

<div class="post-metadata">

**Author:** ![rorywalsh](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/rorywalsh/32/165_2.png) [@rorywalsh](https://forum.cabbageaudio.com/u/rorywalsh)\
**Post date:** [8 December 2019 23:02 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701/4 "2019-12-08T23:02:12Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gerardotrance](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/gerardotrance/32/1537_2.png) [@gerardotrance](https://forum.cabbageaudio.com/u/gerardotrance)\
**Post date:** [9 December 2019 16:22 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701/5 "2019-12-09T16:22:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![iainmccurdy](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/i/8baadc/32.png) [@iainmccurdy](https://forum.cabbageaudio.com/u/iainmccurdy)\
**Post date:** [9 December 2019 17:17 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701/6 "2019-12-09T17:17:15Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![gerardotrance](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/gerardotrance/32/1537_2.png) [@gerardotrance](https://forum.cabbageaudio.com/u/gerardotrance)\
**Post date:** [9 December 2019 17:53 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701/7 "2019-12-09T17:53:42Z")

</div>

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🧐

---

<div class="post-metadata">

**Author:** ![iainmccurdy](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/i/8baadc/32.png) [@iainmccurdy](https://forum.cabbageaudio.com/u/iainmccurdy)\
**Post date:** [9 December 2019 18:30 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701/8 "2019-12-09T18:30:26Z")

</div>

‘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.

---

<div class="post-metadata">

**Author:** ![gerardotrance](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/gerardotrance/32/1537_2.png) [@gerardotrance](https://forum.cabbageaudio.com/u/gerardotrance)\
**Post date:** [9 December 2019 18:53 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701/9 "2019-12-09T18:53:39Z")

</div>

```
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

---

<div class="post-metadata">

**Author:** ![gerardotrance](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/gerardotrance/32/1537_2.png) [@gerardotrance](https://forum.cabbageaudio.com/u/gerardotrance)\
**Post date:** [9 December 2019 19:02 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701/10 "2019-12-09T19:02:09Z")

</div>

I just put my headphones on 👍 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 🧐🤔

---

<div class="post-metadata">

**Author:** ![iainmccurdy](https://forum.cabbageaudio.com/letter_avatar_proxy/v4/letter/i/8baadc/32.png) [@iainmccurdy](https://forum.cabbageaudio.com/u/iainmccurdy)\
**Post date:** [9 December 2019 19:28 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701/11 "2019-12-09T19:28:42Z")

</div>

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
```

---

<div class="post-metadata">

**Author:** ![gerardotrance](https://forum.cabbageaudio.com/user_avatar/forum.cabbageaudio.com/gerardotrance/32/1537_2.png) [@gerardotrance](https://forum.cabbageaudio.com/u/gerardotrance)\
**Post date:** [11 December 2019 16:39 UTC](https://forum.cabbageaudio.com/t/delay-effect/1701/12 "2019-12-11T16:39:04Z")

</div>

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 🧐
