Csound Csound-dev Csound-tekno Search About

Re: Bug in linseg (recent versions)

Date1999-05-20 12:33
Fromjpff@maths.bath.ac.uk
SubjectRe: Bug in linseg (recent versions)
Message written at 20 May 1999 11:30:19 +0100
--- Copy of mail to tkunze@ccrma.stanford.edu ---

>>>>> "Tobias" == Tobias Kunze  writes:

 >> I can confirm that it works well with Csound versions up to 3.48
 Tobias> Not for me.  Csound Version 3.473 (Mar  9 1998) has a linseg
 Tobias> opcode that resembles more an IIR filter than a line generator.

 Tobias> Set sr=kr=10 and amplify by 256:

 Tobias>   ; foo.orc
 Tobias>   sr=10	        ; just 10 samples
 Tobias>   kr=10 
 Tobias>   ksmps=1
 Tobias>   nchnls=1
 Tobias>   instr    1
 Tobias>   a1 linseg 0,1/kr,1,2/kr,-1,1/kr,0,p3-4/kr,0
 Tobias>   out a1*256    ; easy to read in hex, not too small, not too large
 Tobias>   endin

 Tobias>   ; foo.sco
 Tobias>   i1 0 1


 Tobias> Then create a soundfile without header and check out the cool 
 Tobias> impulse response (all numbers in hex):

 Tobias>   % csound -h -s -o foo foo.orc foo.sco
 Tobias>   ovarall amps: 640.0
 Tobias>   result:       0000 0100 0200 0080 ff00 fd80 0000 0280 0215 01aa
 Tobias>     decimal:       0  256  512  128 -256 -640    0  640  533   26
 Tobias>   expected:     0000 0100 0000 ff00 0000 0000 0000 0000 0000 0000 
 Tobias>     decimal:       0  256    0 -256    0    0    0    0    0    0

If I add a display a1,1 to the orchestra you see that the lineseg has
the points (0,0) (1,1) (3, -1) (4, 1) (10,0) and linear
interpolation.  It clearly should be 
           (0,0) (1,1) (3, -1) (4, 0) (10,0)
so I accept that something odd is happening.  Will look at the code,
which is in ugens1.c function linseg.

The only record i can find of a change in this area was in 3.47 when I
noticed that it could write off the end of an array, and I did
apparently rewrite teh code about that time.  I will see if I still
have the previous version.