Csound Csound-dev Csound-tekno Search About

[Csnd] delay dependent on ksmps?

Date2014-02-18 19:03
FromForrest Cahoon
Subject[Csnd] delay dependent on ksmps?
Hi, all!

I have been working with what should be a very simple Karplus-Strong string, and I'm finding that the frequency I'm varies radically with the ksmps value I use.

Here's my csd:

<CsoundSynthesizer>


<CsInstruments>

sr=48000

ksmps=1

nchnls=2


instr 1

iDur = p3

iAmpl = ampdbfs(p4)

iFreq = p5

iCycle = 1/iFreq

aSignal = noise(iAmpl, 0) * linseg(1, 2*iCycle, 1, 0, 0)

aDelayed = aSignal

aFiltered init 0

aDelayed delay aFiltered + aDelayed, iCycle

aFiltered tone aDelayed, sr/2

aOut = aFiltered * linseg(0, 2*iCycle, 0, 0, 1)

outs aOut, aOut

endin


</CsInstruments>


<CsScore>

i1 0 20 -10 240

</CsScore>


</CsoundSynthesizer>


and here is the frequency I get, measured with Sonic Visualiser, for various values of ksmps:


ksmps observed frequency
192 122
96 162
48 193
24 214
12 226
6 233
3 236
1 239


It looks like the delay is a integer multiple of k-cycles? I wasn't expecting such radical changes in my output just by changing ksmps. This should at least be documented, if not fixed somehow to give more accurate delay rates.


On a related note, I wasn't able to find the source for the delay opcode -- I have been grepping for the opcode name, but "delay" turns up zillions of lines. How do I find it?


Forrest



Date2014-02-18 19:16
FromRory Walsh
SubjectRe: [Csnd] delay dependent on ksmps?
Csound processes ksmps samples every k-rate cycle. If you wish to have
very small delays lines you need to decrease ksmps. For short delay
lines just leave ksmps at 1, or better still, wrap the code in a UDO
and set the ksmps value locally.

On 18 February 2014 19:03, Forrest Cahoon  wrote:
> Hi, all!
>
> I have been working with what should be a very simple Karplus-Strong string,
> and I'm finding that the frequency I'm varies radically with the ksmps value
> I use.
>
> Here's my csd:
>
> 
>
>
> 
>
> sr=48000
>
> ksmps=1
>
> nchnls=2
>
>
> instr 1
>
> iDur = p3
>
> iAmpl = ampdbfs(p4)
>
> iFreq = p5
>
> iCycle = 1/iFreq
>
> aSignal = noise(iAmpl, 0) * linseg(1, 2*iCycle, 1, 0, 0)
>
> aDelayed = aSignal
>
> aFiltered init 0
>
> aDelayed delay aFiltered + aDelayed, iCycle
>
> aFiltered tone aDelayed, sr/2
>
> aOut = aFiltered * linseg(0, 2*iCycle, 0, 0, 1)
>
> outs aOut, aOut
>
> endin
>
>
> 
>
>
> 
>
> i1 0 20 -10 240
>
> 
>
>
> 
>
>
> and here is the frequency I get, measured with Sonic Visualiser, for various
> values of ksmps:
>
>
> ksmps observed frequency
> 192 122
> 96 162
> 48 193
> 24 214
> 12 226
> 6 233
> 3 236
> 1 239
>
>
> It looks like the delay is a integer multiple of k-cycles? I wasn't
> expecting such radical changes in my output just by changing ksmps. This
> should at least be documented, if not fixed somehow to give more accurate
> delay rates.
>
>
> On a related note, I wasn't able to find the source for the delay opcode --
> I have been grepping for the opcode name, but "delay" turns up zillions of
> lines. How do I find it?
>
>
> Forrest
>
>