Csound Csound-dev Csound-tekno Search About

[Csnd] Karplus-Strong instrument using deltapx

Date2013-03-08 07:34
FromForrest Cahoon
Subject[Csnd] Karplus-Strong instrument using deltapx
I'm starting to work with precise intonation again, and I'm following up on something Steven Yi said back in this thread: http://csound.1045644.n5.nabble.com/Where-do-these-beat-frequencies-come-from-td5478171.html#a5481118

At the time I thought Steven's suggestion meant writing new plucked-string opcodes in C which would be more precisely tuned, but now when I look back I realize I should be able to design a Karplus-Strong instrument entirely in Csound using deltapx to specify the delay line, and (hopefully) get the pitch precision I'm after without diving into internals.

However, I'm having trouble putting an instrument like that together -- still a bit confused about how deltapx is actually supposed to work -- and I thought I'd appeal to the list to see if I could get some help.


Date2013-03-08 17:23
FromRussell Pinkston
SubjectRE: [Csnd] Karplus-Strong instrument using deltapx

Here is a CSD with some example “roll your own” Karplus-Strong instruments I made for my Csound class:

 

http://ems.music.utexas.edu/dwnld/classcsd/karplus2.csd

 

They don’t use deltapx, but they could, easily enough. Hope they are helpful.

 


From: Forrest Cahoon [mailto:forrest.cahoon@gmail.com]
Sent: Friday, March 08, 2013 1:34 AM
To: csound list
Subject: [Csnd] Karplus-Strong instrument using deltapx

 

I'm starting to work with precise intonation again, and I'm following up on something Steven Yi said back in this thread: http://csound.1045644.n5.nabble.com/Where-do-these-beat-frequencies-come-from-td5478171.html#a5481118

At the time I thought Steven's suggestion meant writing new plucked-string opcodes in C which would be more precisely tuned, but now when I look back I realize I should be able to design a Karplus-Strong instrument entirely in Csound using deltapx to specify the delay line, and (hopefully) get the pitch precision I'm after without diving into internals.

However, I'm having trouble putting an instrument like that together -- still a bit confused about how deltapx is actually supposed to work -- and I thought I'd appeal to the list to see if I could get some help.


Date2013-03-09 17:01
FromForrest Cahoon
SubjectRe: [Csnd] Karplus-Strong instrument using deltapx
On Fri, Mar 8, 2013 at 11:23 AM, Russell Pinkston <pinkstonrf@austin.utexas.edu> wrote:

Here is a CSD with some example “roll your own” Karplus-Strong instruments I made for my Csound class:

 

http://ems.music.utexas.edu/dwnld/classcsd/karplus2.csd

 

They don’t use deltapx, but they could, easily enough. Hope they are helpful.

 


Thanks, Russell! Since these examples use delayr/delayw they are very close to what I need.

I remember reading somewhere that the tone LPF opcode introduces a delay, and for precise tuning the delay introduced by tone has to be subtracted from the length of the Karplus-Strong delay line in order to compensate. So I think your instruments may be off a little bit from their advertised frequencies -- much more than the subsample differences in delay I'm currently worried about.

I can't find the reference to where I read that; it was a K/S example that was online years ago. Does anyone know about this?  I suppose I will be able to find the value empirically, since the delay was a specific whole number of samples, but it would be nice if someone who actually knows could weigh in.

Date2013-03-09 18:22
FromRussell Pinkston
SubjectRE: [Csnd] Karplus-Strong instrument using deltapx

Tone is a very simple, first order recursive filter. It would only introduce 1 sample of delay.

 


From: Forrest Cahoon [mailto:forrest.cahoon@gmail.com]
Sent: Saturday, March 09, 2013 11:01 AM
To: csound list
Subject: Re: [Csnd] Karplus-Strong instrument using deltapx

 

On Fri, Mar 8, 2013 at 11:23 AM, Russell Pinkston <pinkstonrf@austin.utexas.edu> wrote:

Here is a CSD with some example “roll your own” Karplus-Strong instruments I made for my Csound class:

 

http://ems.music.utexas.edu/dwnld/classcsd/karplus2.csd

 

They don’t use deltapx, but they could, easily enough. Hope they are helpful.

 

 

Thanks, Russell! Since these examples use delayr/delayw they are very close to what I need.

I remember reading somewhere that the tone LPF opcode introduces a delay, and for precise tuning the delay introduced by tone has to be subtracted from the length of the Karplus-Strong delay line in order to compensate. So I think your instruments may be off a little bit from their advertised frequencies -- much more than the subsample differences in delay I'm currently worried about.

I can't find the reference to where I read that; it was a K/S example that was online years ago. Does anyone know about this?  I suppose I will be able to find the value empirically, since the delay was a specific whole number of samples, but it would be nice if someone who actually knows could weigh in.


Date2013-03-09 18:43
FromJustin Smith
SubjectRe: [Csnd] Karplus-Strong instrument using deltapx
A recursive filter is IIR, and IIR filters introduce frequency dependent delay, meaning that while there may be strictly N samples of delay, it will effectively delay each sinusoidal partial by a different number of samples (some more and some less than the nominal delay size of the filter). I don't know how a delay on input that varies with spectrum interacts with Karplus-Strong though - Karplus-Strong is itself effectively a special case of an (unstable?) IIR filter IIRC.


On Sat, Mar 9, 2013 at 10:22 AM, Russell Pinkston <pinkstonrf@austin.utexas.edu> wrote:

Tone is a very simple, first order recursive filter. It would only introduce 1 sample of delay.

 


From: Forrest Cahoon [mailto:forrest.cahoon@gmail.com]
Sent: Saturday, March 09, 2013 11:01 AM
To: csound list
Subject: Re: [Csnd] Karplus-Strong instrument using deltapx

 

On Fri, Mar 8, 2013 at 11:23 AM, Russell Pinkston <pinkstonrf@austin.utexas.edu> wrote:

Here is a CSD with some example “roll your own” Karplus-Strong instruments I made for my Csound class:

 

http://ems.music.utexas.edu/dwnld/classcsd/karplus2.csd

 

They don’t use deltapx, but they could, easily enough. Hope they are helpful.

 

 

Thanks, Russell! Since these examples use delayr/delayw they are very close to what I need.

I remember reading somewhere that the tone LPF opcode introduces a delay, and for precise tuning the delay introduced by tone has to be subtracted from the length of the Karplus-Strong delay line in order to compensate. So I think your instruments may be off a little bit from their advertised frequencies -- much more than the subsample differences in delay I'm currently worried about.

I can't find the reference to where I read that; it was a K/S example that was online years ago. Does anyone know about this?  I suppose I will be able to find the value empirically, since the delay was a specific whole number of samples, but it would be nice if someone who actually knows could weigh in.



Date2013-03-09 23:51
FromRussell Pinkston
SubjectRE: [Csnd] Karplus-Strong instrument using deltapx

I think the 1 sample of actual delay is what’s important in this case, because the whole idea of K/S is that the length of the delay line is what determines the fundamental frequency of the “pluck.” So it seems to me that the one extra sample in the delay loop shouldn’t be significant.

 


From: Justin Smith [mailto:noisesmith@gmail.com]
Sent: Saturday, March 09, 2013 12:43 PM
To: csound@lists.bath.ac.uk
Subject: Re: [Csnd] Karplus-Strong instrument using deltapx

 

A recursive filter is IIR, and IIR filters introduce frequency dependent delay, meaning that while there may be strictly N samples of delay, it will effectively delay each sinusoidal partial by a different number of samples (some more and some less than the nominal delay size of the filter). I don't know how a delay on input that varies with spectrum interacts with Karplus-Strong though - Karplus-Strong is itself effectively a special case of an (unstable?) IIR filter IIRC.

 

On Sat, Mar 9, 2013 at 10:22 AM, Russell Pinkston <pinkstonrf@austin.utexas.edu> wrote:

Tone is a very simple, first order recursive filter. It would only introduce 1 sample of delay.

 


From: Forrest Cahoon [mailto:forrest.cahoon@gmail.com]
Sent: Saturday, March 09, 2013 11:01 AM
To: csound list
Subject: Re: [Csnd] Karplus-Strong instrument using deltapx

 

On Fri, Mar 8, 2013 at 11:23 AM, Russell Pinkston <pinkstonrf@austin.utexas.edu> wrote:

Here is a CSD with some example “roll your own” Karplus-Strong instruments I made for my Csound class:

 

http://ems.music.utexas.edu/dwnld/classcsd/karplus2.csd

 

They don’t use deltapx, but they could, easily enough. Hope they are helpful.

 

 

Thanks, Russell! Since these examples use delayr/delayw they are very close to what I need.

I remember reading somewhere that the tone LPF opcode introduces a delay, and for precise tuning the delay introduced by tone has to be subtracted from the length of the Karplus-Strong delay line in order to compensate. So I think your instruments may be off a little bit from their advertised frequencies -- much more than the subsample differences in delay I'm currently worried about.

I can't find the reference to where I read that; it was a K/S example that was online years ago. Does anyone know about this?  I suppose I will be able to find the value empirically, since the delay was a specific whole number of samples, but it would be nice if someone who actually knows could weigh in.

 


Date2013-03-10 00:10
FromOli Larkin
SubjectRe: [Csnd] Karplus-Strong instrument using deltapx
as you lower the cutoff of the 1pole IIR LPF in the feedback loop, the phase shift of the filter affects the tuning of the upper harmonics. You can use a linear phase FIR to avoid this. Faust is really excellent for playing with this stuff.



here's a PM tanpura i've been working on using Karplus strong plus some tricks...





On 9 Mar 2013, at 23:51, Russell Pinkston wrote:

I think the 1 sample of actual delay is what’s important in this case, because the whole idea of K/S is that the length of the delay line is what determines the fundamental frequency of the “pluck.” So it seems to me that the one extra sample in the delay loop shouldn’t be significant.

 


From: Justin Smith [mailto:noisesmith@gmail.com]
Sent: Saturday, March 09, 2013 12:43 PM
To: csound@lists.bath.ac.uk
Subject: Re: [Csnd] Karplus-Strong instrument using deltapx

 

A recursive filter is IIR, and IIR filters introduce frequency dependent delay, meaning that while there may be strictly N samples of delay, it will effectively delay each sinusoidal partial by a different number of samples (some more and some less than the nominal delay size of the filter). I don't know how a delay on input that varies with spectrum interacts with Karplus-Strong though - Karplus-Strong is itself effectively a special case of an (unstable?) IIR filter IIRC.

 

On Sat, Mar 9, 2013 at 10:22 AM, Russell Pinkston <pinkstonrf@austin.utexas.edu> wrote:

Tone is a very simple, first order recursive filter. It would only introduce 1 sample of delay.

 


From: Forrest Cahoon [mailto:forrest.cahoon@gmail.com]
Sent: Saturday, March 09, 2013 11:01 AM
To: csound list
Subject: Re: [Csnd] Karplus-Strong instrument using deltapx

 

On Fri, Mar 8, 2013 at 11:23 AM, Russell Pinkston <pinkstonrf@austin.utexas.edu> wrote:

Here is a CSD with some example “roll your own” Karplus-Strong instruments I made for my Csound class:

 

http://ems.music.utexas.edu/dwnld/classcsd/karplus2.csd

 

They don’t use deltapx, but they could, easily enough. Hope they are helpful.

 

 

Thanks, Russell! Since these examples use delayr/delayw they are very close to what I need.

I remember reading somewhere that the tone LPF opcode introduces a delay, and for precise tuning the delay introduced by tone has to be subtracted from the length of the Karplus-Strong delay line in order to compensate. So I think your instruments may be off a little bit from their advertised frequencies -- much more than the subsample differences in delay I'm currently worried about.

I can't find the reference to where I read that; it was a K/S example that was online years ago. Does anyone know about this?  I suppose I will be able to find the value empirically, since the delay was a specific whole number of samples, but it would be nice if someone who actually knows could weigh in.

 



Date2013-03-11 17:31
FromRussell Pinkston
SubjectRE: [Csnd] Karplus-Strong instrument using deltapx

Thanks for this, Oli. That does look like a useful filter for physical modeling. I checked out the tanpura sound file (sounds nice!), but couldn’t find the Csound code on the wiki. Did you mean to share that?

 


From: Oli Larkin [mailto:olilarkin@googlemail.com]
Sent: Saturday, March 09, 2013 6:11 PM
To: csound@lists.bath.ac.uk
Subject: Re: [Csnd] Karplus-Strong instrument using deltapx

 

as you lower the cutoff of the 1pole IIR LPF in the feedback loop, the phase shift of the filter affects the tuning of the upper harmonics. You can use a linear phase FIR to avoid this. Faust is really excellent for playing with this stuff.

 

 

 

here's a PM tanpura i've been working on using Karplus strong plus some tricks...

 

 

 

 

 

On 9 Mar 2013, at 23:51, Russell Pinkston wrote:



I think the 1 sample of actual delay is what’s important in this case, because the whole idea of K/S is that the length of the delay line is what determines the fundamental frequency of the “pluck.” So it seems to me that the one extra sample in the delay loop shouldn’t be significant.

 


From: Justin Smith [mailto:noisesmith@gmail.com]
Sent: Saturday, March 09, 2013 12:43 PM
To: csound@lists.bath.ac.uk
Subject: Re: [Csnd] Karplus-Strong instrument using deltapx

 

A recursive filter is IIR, and IIR filters introduce frequency dependent delay, meaning that while there may be strictly N samples of delay, it will effectively delay each sinusoidal partial by a different number of samples (some more and some less than the nominal delay size of the filter). I don't know how a delay on input that varies with spectrum interacts with Karplus-Strong though - Karplus-Strong is itself effectively a special case of an (unstable?) IIR filter IIRC.

 

On Sat, Mar 9, 2013 at 10:22 AM, Russell Pinkston <pinkstonrf@austin.utexas.edu> wrote:

Tone is a very simple, first order recursive filter. It would only introduce 1 sample of delay.

 


From: Forrest Cahoon [mailto:forrest.cahoon@gmail.com]
Sent: Saturday, March 09, 2013 11:01 AM
To: csound list
Subject: Re: [Csnd] Karplus-Strong instrument using deltapx

 

On Fri, Mar 8, 2013 at 11:23 AM, Russell Pinkston <pinkstonrf@austin.utexas.edu> wrote:

Here is a CSD with some example “roll your own” Karplus-Strong instruments I made for my Csound class:

 

http://ems.music.utexas.edu/dwnld/classcsd/karplus2.csd

 

They don’t use deltapx, but they could, easily enough. Hope they are helpful.

 

 

Thanks, Russell! Since these examples use delayr/delayw they are very close to what I need.

I remember reading somewhere that the tone LPF opcode introduces a delay, and for precise tuning the delay introduced by tone has to be subtracted from the length of the Karplus-Strong delay line in order to compensate. So I think your instruments may be off a little bit from their advertised frequencies -- much more than the subsample differences in delay I'm currently worried about.

I can't find the reference to where I read that; it was a K/S example that was online years ago. Does anyone know about this?  I suppose I will be able to find the value empirically, since the delay was a specific whole number of samples, but it would be nice if someone who actually knows could weigh in.

 

 


Date2013-03-11 17:51
FromOli Larkin
SubjectRe: [Csnd] Karplus-Strong instrument using deltapx

On 11 Mar 2013, at 17:31, Russell Pinkston wrote:

Thanks for this, Oli. That does look like a useful filter for physical modeling. I checked out the tanpura sound file (sounds nice!), but couldn’t find the Csound code on the wiki. Did you mean to share that?

no... maybe I will at some point though. It's made in faust not csound


 


From: Oli Larkin [mailto:olilarkin@googlemail.com] 
Sent: Saturday, March 09, 2013 6:11 PM
To: csound@lists.bath.ac.uk
Subject: Re: [Csnd] Karplus-Strong instrument using deltapx

 

as you lower the cutoff of the 1pole IIR LPF in the feedback loop, the phase shift of the filter affects the tuning of the upper harmonics. You can use a linear phase FIR to avoid this. Faust is really excellent for playing with this stuff.

 

 

 

here's a PM tanpura i've been working on using Karplus strong plus some tricks...

 

 

 

 

 

On 9 Mar 2013, at 23:51, Russell Pinkston wrote:



I think the 1 sample of actual delay is what’s important in this case, because the whole idea of K/S is that the length of the delay line is what determines the fundamental frequency of the “pluck.” So it seems to me that the one extra sample in the delay loop shouldn’t be significant.

 


From: Justin Smith [mailto:noisesmith@gmail.com] 
Sent: Saturday, March 09, 2013 12:43 PM
To: csound@lists.bath.ac.uk
Subject: Re: [Csnd] Karplus-Strong instrument using deltapx

 

A recursive filter is IIR, and IIR filters introduce frequency dependent delay, meaning that while there may be strictly N samples of delay, it will effectively delay each sinusoidal partial by a different number of samples (some more and some less than the nominal delay size of the filter). I don't know how a delay on input that varies with spectrum interacts with Karplus-Strong though - Karplus-Strong is itself effectively a special case of an (unstable?) IIR filter IIRC.

 

On Sat, Mar 9, 2013 at 10:22 AM, Russell Pinkston <pinkstonrf@austin.utexas.edu> wrote:

Tone is a very simple, first order recursive filter. It would only introduce 1 sample of delay.

 


From: Forrest Cahoon [mailto:forrest.cahoon@gmail.com] 
Sent: Saturday, March 09, 2013 11:01 AM
To: csound list
Subject: Re: [Csnd] Karplus-Strong instrument using deltapx

 

On Fri, Mar 8, 2013 at 11:23 AM, Russell Pinkston <pinkstonrf@austin.utexas.edu> wrote:

Here is a CSD with some example “roll your own” Karplus-Strong instruments I made for my Csound class:

 

 

They don’t use deltapx, but they could, easily enough. Hope they are helpful.

 

 

Thanks, Russell! Since these examples use delayr/delayw they are very close to what I need.

I remember reading somewhere that the tone LPF opcode introduces a delay, and for precise tuning the delay introduced by tone has to be subtracted from the length of the Karplus-Strong delay line in order to compensate. So I think your instruments may be off a little bit from their advertised frequencies -- much more than the subsample differences in delay I'm currently worried about.

I can't find the reference to where I read that; it was a K/S example that was online years ago. Does anyone know about this?  I suppose I will be able to find the value empirically, since the delay was a specific whole number of samples, but it would be nice if someone who actually knows could weigh in.