Csound Csound-dev Csound-tekno Search About

timout accuracy

Date1998-12-21 08:48
FromPedro Batista
Subjecttimout accuracy
Hey all

I've been working on a sequencer-like instr, and was using Pinkston's method 
with timeout and reinit for the individual 'notes'. I came accross a problem 
with the timout durations not being exactly those as the idur parameter 
specifies.
As an example I've isolated the problem in the following orc/sco. This 
should play 2 bars at 135bpm (32 notes 16thnotes). The resulting audio file 
should last for 3.555 seconds, and loop perfectly. It doesnt!, instead I end 
up with a slighty longer file (chopped off at 3.555, the expected instr 
duration), with a tempo of 132.3 ...
With a bit of gymnastics, I included a correction factor for the beat 
duration (in this case .98), which if you uncomment the line 'ibeat = ibeat 
* .98', will make things work as expected with this tempo. Other tempos 
require other corrections, with 60bpm being almost precise.
and then if I call several instances of the instrument (thats what Im doing 
in the real instrument, something similar to Hans Mikelson's drummach) they 
wont be in synch, each own drifting its own  amount.

So my question: am I missing something, or is there some uncontrolable 
timeout latency? I tryed several variations, two diff versions (v3.47 and 
v3.49 pc) without success.
It seems to me that the timout interval is being delayed by some cents 
(maybe processing time within the instrument...?) If so, is there any work 
around or am I doomed to work at 60bpm?

Thanks in advance
pedro

;ORCHESTRA
sr   =    44100
kr   =    441
ksmps     =    100

     instr     1
iamptab   =    p4
itempo    =    p5
ibeat     =    60/itempo    ;this should be it..
;ibeat    =    ibeat*.98    ; ..but
iseq =    0

ini:
idur =    .25*ibeat    ;duration is 1/4th of beat

;vary amps of consecutive notes to make it more interesting
iamp table     iseq, iamptab, 0, 0, 1
iseq =    iseq+1

;just some sound burst
kenv linseg    0, idur/8 , 1, idur/4, 1, idur/8, 0, idur/2, 0
aout rand 10000
     out  kenv*iamp*aout
     
     timout    0, idur, cont

     reinit    ini

cont:     endin

;SCORE
f1 0 4 -2 1 .4 .3 .7 ; amp table for the four 16th notes within a beat

;#  t   d   amptab tempo

Date1998-12-22 00:07
FromErik Spjut
SubjectRe: timout accuracy
Most timing things in Csound run at k-rate not a-rate. Unless your timings
are always exact multiples of a k-frame you'll find inaccuracies. Try
running with kr=sr and see if the problem goes away.

At 8:48 AM +0000 12/21/98, Pedro Batista wrote:
>Hey all
>
>I've been working on a sequencer-like instr, and was using Pinkston's method
>with timeout and reinit for the individual 'notes'. I came accross a problem
>with the timout durations not being exactly those as the idur parameter
>specifies.
>As an example I've isolated the problem in the following orc/sco. This
>should play 2 bars at 135bpm (32 notes 16thnotes). The resulting audio file
>should last for 3.555 seconds, and loop perfectly. It doesnt!, instead I end
>up with a slighty longer file (chopped off at 3.555, the expected instr
>duration), with a tempo of 132.3 ...
>With a bit of gymnastics, I included a correction factor for the beat
>duration (in this case .98), which if you uncomment the line 'ibeat = ibeat
>* .98', will make things work as expected with this tempo. Other tempos
>require other corrections, with 60bpm being almost precise.
>and then if I call several instances of the instrument (thats what Im doing
>in the real instrument, something similar to Hans Mikelson's drummach) they
>wont be in synch, each own drifting its own  amount.
>
>So my question: am I missing something, or is there some uncontrolable
>timeout latency? I tryed several variations, two diff versions (v3.47 and
>v3.49 pc) without success.
>It seems to me that the timout interval is being delayed by some cents
>(maybe processing time within the instrument...?) If so, is there any work
>around or am I doomed to work at 60bpm?
>
>Thanks in advance
>pedro
>
>;ORCHESTRA
>sr   =    44100
>kr   =    441
>ksmps     =    100
>
>     instr     1
>iamptab   =    p4
>itempo    =    p5
>ibeat     =    60/itempo    ;this should be it..
>;ibeat    =    ibeat*.98    ; ..but
>iseq =    0
>
>ini:
>idur =    .25*ibeat    ;duration is 1/4th of beat
>
>;vary amps of consecutive notes to make it more interesting
>iamp table     iseq, iamptab, 0, 0, 1
>iseq =    iseq+1
>
>;just some sound burst
>kenv linseg    0, idur/8 , 1, idur/4, 1, idur/8, 0, idur/2, 0
>aout rand 10000
>     out  kenv*iamp*aout
>
>     timout    0, idur, cont
>
>     reinit    ini
>
>cont:     endin
>
>;SCORE
>f1 0 4 -2 1 .4 .3 .7 ; amp table for the four 16th notes within a beat
>
>;#  t   d   amptab tempo
>i1  0 3.555   1     135  ; output tempo is 132.3 !?


-------------------------------------------------------------------------------
Erik Spjut (spyoot, rhymes with cute) - Associate Professor of Engineering
and  Associate Director for Engineering Computing,  Center for Design Education
Harvey Mudd College, Claremont, CA 91711-5990  USA
Erik_Spjut@hmc.edu      Ph & Voice mail (909) 607-3890      Fax (909) 621-8967