Csound Csound-dev Csound-tekno Search About

[Csnd] Code Share: Simple Delay Line

Date2019-12-11 00:06
FromSteven Yi
Subject[Csnd] Code Share: Simple Delay Line
Hi All,

I'm not sure if this would be of use to anyone, but here it is
anyways. :)  Delays came up in a conversation and I mentioned you
could just write one in Csound so I put one together for a demo.
Here's a simple non-interpolating delay line with .25 second delay
time:

instr CustomDelayLine

  ;; 0.25 second delay
  idel_size = 0.25 * sr
  kdelay_line[] init idel_size
  kread_ptr init 1
  kwrite_ptr init 0

  asig = vco2(0.5, 220 * (1 + int(lfo:k(3, 2, 2))) * expon(1, p3, 4), 10)
  asig = zdf_ladder(asig, 2000, 4)

  kindx = 0
  while (kindx < ksmps) do
    kdelay_line[kwrite_ptr] = asig[kindx]
    asig[kindx] = asig[kindx] + kdelay_line[kread_ptr]

    kwrite_ptr = (kwrite_ptr + 1) % idel_size
    kread_ptr = (kread_ptr + 1) % idel_size

    kindx += 1
  od

  out(asig, asig)

endin

schedule("CustomDelayLine", 0, 10)

(Can copy/paste/select/ctrl-e to evaluate and experiment with in
live.csound.com)

Cheers!
Steven

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2019-12-11 23:08
FromPablo Zoani Heffele
SubjectRe: [Csnd] Code Share: Simple Delay Line
Thank you Steven!
Is going to be very nice to study this.
This kind of code always helps to understand how csound works,
especially how the k- and a- rates are related.

Regards, Pablo.

De: A discussion list for users of Csound <CSOUND@LISTSERV.HEANET.IE> en nombre de Steven Yi <stevenyi@GMAIL.COM>
Enviado: martes, 10 de diciembre de 2019 16:06
Para: CSOUND@LISTSERV.HEANET.IE <CSOUND@LISTSERV.HEANET.IE>
Asunto: [Csnd] Code Share: Simple Delay Line
 
Hi All,

I'm not sure if this would be of use to anyone, but here it is
anyways. :)  Delays came up in a conversation and I mentioned you
could just write one in Csound so I put one together for a demo.
Here's a simple non-interpolating delay line with .25 second delay
time:

instr CustomDelayLine

  ;; 0.25 second delay
  idel_size = 0.25 * sr
  kdelay_line[] init idel_size
  kread_ptr init 1
  kwrite_ptr init 0

  asig = vco2(0.5, 220 * (1 + int(lfo:k(3, 2, 2))) * expon(1, p3, 4), 10)
  asig = zdf_ladder(asig, 2000, 4)

  kindx = 0
  while (kindx < ksmps) do
    kdelay_line[kwrite_ptr] = asig[kindx]
    asig[kindx] = asig[kindx] + kdelay_line[kread_ptr]

    kwrite_ptr = (kwrite_ptr + 1) % idel_size
    kread_ptr = (kread_ptr + 1) % idel_size

    kindx += 1
  od

  out(asig, asig)

endin

schedule("CustomDelayLine", 0, 10)

(Can copy/paste/select/ctrl-e to evaluate and experiment with in
live.csound.com)

Cheers!
Steven

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2019-12-12 07:46
Fromjoachim heintz
SubjectRe: [Csnd] Code Share: Simple Delay Line
yes, that's brilliant code and so instructive!
one of the big strengths of csound that this is so easy ...
thanks steven for this -
	joachim



On 12/12/2019 00:08, Pablo Zoani Heffele wrote:
> Thank you Steven!
> Is going to be very nice to study this.
> This kind of code always helps to understand how csound works,
> especially how the k- and a- rates are related.
> 
> Regards, Pablo.
> ------------------------------------------------------------------------
> *De:* A discussion list for users of Csound  
> en nombre de Steven Yi 
> *Enviado:* martes, 10 de diciembre de 2019 16:06
> *Para:* CSOUND@LISTSERV.HEANET.IE 
> *Asunto:* [Csnd] Code Share: Simple Delay Line
> Hi All,
> 
> I'm not sure if this would be of use to anyone, but here it is
> anyways. :)  Delays came up in a conversation and I mentioned you
> could just write one in Csound so I put one together for a demo.
> Here's a simple non-interpolating delay line with .25 second delay
> time:
> 
> instr CustomDelayLine
> 
>    ;; 0.25 second delay
>    idel_size = 0.25 * sr
>    kdelay_line[] init idel_size
>    kread_ptr init 1
>    kwrite_ptr init 0
> 
>    asig = vco2(0.5, 220 * (1 + int(lfo:k(3, 2, 2))) * expon(1, p3, 4), 10)
>    asig = zdf_ladder(asig, 2000, 4)
> 
>    kindx = 0
>    while (kindx < ksmps) do
>      kdelay_line[kwrite_ptr] = asig[kindx]
>      asig[kindx] = asig[kindx] + kdelay_line[kread_ptr]
> 
>      kwrite_ptr = (kwrite_ptr + 1) % idel_size
>      kread_ptr = (kread_ptr + 1) % idel_size
> 
>      kindx += 1
>    od
> 
>    out(asig, asig)
> 
> endin
> 
> schedule("CustomDelayLine", 0, 10)
> 
> (Can copy/paste/select/ctrl-e to evaluate and experiment with in
> live.csound.com)
> 
> Cheers!
> Steven
> 
> Csound mailing list
> Csound@listserv.heanet.ie
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
> Send bugs reports to
> https://github.com/csound/csound/issues
> Discussions of bugs and features can be posted here
> Csound mailing list Csound@listserv.heanet.ie 
>  
> https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to 
> https://github.com/csound/csound/issues Discussions of bugs and features 
> can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here