42
D. Rocchesso: Sound Processing
sonogram
state variables
; [-40 dB]
iw0
= 2*ipi*p4/sr ; frequency correspondent to the phase of the pole
ir
= exp((1/(sr*p5))*log(ithres)) ; radius of the pole
ia1
= -2*ir*cos(iw0) ; coefficient a1 of the filter denominator
ia2
= ir*ir ;
coeff. a2 of the filter denominator
ig
= (1-ir)*sqrt(1-2*ir*cos(2*iw0)+ir*ir)*10*sqrt(p5)
; coefficient to have unit gain at the center of the band
izero
= 0
as1
init izero ; initialize the filter status
as2
init izero
afilt
= -ia1*as1-ia2*as2+ig*ga1 ; difference equation
out
afilt
as2
= as1
; filter status update
as1
= afilt
endin
The orchestra can be experimented with the score
;instr. time
durat.
freq.
decay
i1
0
30.0
i2
0
5
700
0.1
i2
5
5
700
1.0
i2
10
5
1700
0.2
i2
15
5
2900
2.0
i2
20
5
700
1.0
i2
20
5
1700
1.5
i2
20
5
2900
2.0
The sounds resulting from the score performance are represented in the
sonogram of fig. 20, where larger magnitudes are represented by darker points.
In the filtering instrument, the filter coefficients are computed according to
the formulas (47) and (39), starting from the given decay time and central
frequency. Moreover, the signal is rescaled by a gain such that the magnitude
of the frequency response is one at the central frequency. Empirically, we have
found that, in order to keep some homogeneity in the output energy level even
for very narrow frequency responses, it is useful to insert a further factor equal
to ten times the square root of the decay time. Another observation concerns
the difference equation. This equation uses two state variables as1 and as2,
used to store the previous values of the output. The state variables are updated
in the final two lines of the instrument.
It is interesting to reduce the control rate in the orchestra, for instance by
a factor ten. The resulting sounds will have fundamental frequencies lowered
by the same factor and the spectrum will be repeated at multiples of sr/10.
This kind of artifacts is often found when writing explicit filtering structures
in CSound and using a sample rate different from the control rate. The reason
for such a strange behavior is found in the special block processing used by