Csound Csound-dev Csound-tekno Search About

Re: Distorsion

Date1999-04-15 02:29
FromHans Mikelson
SubjectRe: Distorsion
Hi,

The distort1 opcode is not band limited.  Post filtering the signal may help
a little.  For band-limited distortion look into using Chebyshev polynomials
(GEN13 & GEN14).  Also refer to my article in Csound magazine last month for
another distortion example.  The two shape parameters in distort effect the
shape of the upper and lower wave form.  This is illustrated best using a
sine wave.  Following is an example:

; ORCHESTRA
sr=44100
kr=4410
ksmps=10
nchnls=2

       instr    1

idur   =        p3
iamp   =        p4
ifqc   =        cpspch(p5)
ipre   =        p6
ipost  =        p7
ish1   =        p8
ish2   =        p9

aamp   linseg   0, .01, 1, idur-.02, 1, .01, 0
asig   oscil    iamp, ifqc, 1
adst   distort1 asig, ipre, ipost, ish1, ish2
       outs     adst*aamp, adst*aamp

       endin

; SCORE
f1 0 8192 10 1

;   Sta  Dur  Amp   Pitch  Pre  Post  UpperShape  LowerShape
i1  0    .5   10000 7.00   10   1     0           0
i1  +    .    .     .      .    .     .1          .
i1  .    .    .     .      .    .     .2          .
i1  .    .    .     .      .    .     .1         -.1
i1  .    .    .     .      .    .     .2         -.2