Basic Frequency Modulation Instrument
A - peak amplitude
fc - carrier frequency in hertz
fm - modulating frequency in hertz
delta_f - frequency deviation in hertz
I - index of modulation = delta_f/fm
Spectrum of FM Sound
The spectrum of a frequency modulated waveform consists of many sinusoidal components
Carrier frequency at fc with amplitude J0(I)
Sidebands at fc + kfm (k = ..., -3, -2, -1, 1, 2, 3) with amplitude Jk(I).
Bessel Functions
Bessel functions of the first kind of order n are solutions to Bessel's differential equation:
x2y'' + xy' + (x2 - n2)y = 0
Solution: Jn(x) = SUMk=0..inf[((-1)k(x/2)n+2k)/(k!(n+k)!)
Also: Jn+1(x) = (2n/x)Jn(x) - Jn-1(x)
More on Bessel Functions
J-k(I) = -Jk(I) for odd k
J-k(I) = Jk(I) for even k
Aliasing can occur since fc - kfm can be negative and fc + kfm can be greater than R/2.
Example
fc = 440Hz, fm = 440 Hz, delta_f = 880 Hz, A = 10000
Thus, I=2.
Amp at 440 Hz = J0(2) * 10000
Amp at 880 Hz = J1(2) * 10000
Amp at 0 Hz = J-1(2) * 10000
etc.
Simple FM Instrument
; p4 = amplitude ; p5 = carrier frequency ; p6 = modulating frequency ; p7 = index of modulation instr 1 k1 linseg 0, 0.2*p3, 1, 0.5*p3, 1, 0.3*p3, 0 k2 = k1 * p4 k3 = k1 * p6 * p7 // p6 * p7 = delta f a1 oscil k3, p6, 1 a2 = a1 + p5 a3 oscil k2, a2, 1 out a3 endin f1 0 2048 10 1 i1 0 2 20000 440 440 3 e
Harmonicity Ratio
H = fm/fc
Examples:
H = 1/2 (frequency component appears between 0 Hz and carrier frequency: fc-fm)
H = 2 (odd harmonics appear only)
H = 1/sqrt(2) (inharmonic sounds like bells)
Instruments:
Horn (H=1, I = 5)
Bassoon (H=1/5, I = 1.5)
Clarinet (H=2/3, I = 4 to 6)
Gong (H = sqrt(2), I = 10)
Waveshaping
Waveshaping is a technique of distortion which creates complex spectra from simple tones by explicitly altering the shape of the original waveform
Eavh waveshaping instrument is characterized by its transfer function
Transfer Function
Let the transfer function of a waveshaping instrument be F(x), defined for x between -1 and 1.
The new waveform is given by solving F(x) given x is an output from a unit-amplitude sinusoidal waveform.
The process of waveshaping is equivalent to composition of functions.
Calculating the Output Spectrum
If the input of a waveshaper is a sinusoid of unit amplitude, then the amplitudes of the harmonics of the output waveform can be determined based on Pascal's triangle. (SEE HANDOUT)
Given a transfer function F(x) = cnxn + cn-1xn-1 + ... + c1x + c0 where x is the output of a unit-amplitude
sinusoid, the output waveform from F(x) has harmonics hj (j=0,1,...,n) whose amplitudes are given by the
formulas:
h0 = SUMk=0..n(ckH[k,0]/2k)
hj = SUMk=0..n(ckH[k,0]/2k-1) for j=1,...,n
where H[k,j] is the table entry in Pascal's triangle (HANDOUT) at row k, column j (counting from 0)
Example
F(x) = 4x5 + 6x4 - (11/3)x3 + (5/4)x - (7/4)
h0 = 1/2 (DC or average power), h1 = 1, h2 = 3, h3 = 1/3, h4 = 3/4, h5 = 1/4
Spectral Matching
In order to determine the actual transfer function needed to generate a desired output waveform, a technique called spectral matching is used.
Chebyshev polynomials are used to reconstruct the original transfer function.
Chebyshev Polynomials
The Chebyshev polynomial of the first kind of order k is defined by Tk(x) = cos(k arccos x)
Also, Tn+1(x) = 2xTn(x) - Tn-1(x)
Thus, T0(x) = 1, T1(x) = x, T2(x) = 2x2 - 1, etc. (SEE HANDOUT)
Building the Transfer Function
If hj is the amplitude of the jth harmonic of an audio waveform (with n harmonics) output by a
waveshaper, then the transfer function required to generate this waveform is
F(x) = h0T0(x) + h1T1(x) + ... + hnTn(x).
Example
h0 = 1/2, h1 = 1, h2 = 3, h3 = 1/3, h4 = 3/4, h5 = 1/4
F(x) = 4x5 + 6x4 - (11/3)x3 + (5/4)x - (7/4)
Properties of Waveshapers
If a transfer function is an even function, then the output will consist of only even harmonics.
An odd transfer function yields an output with odd harmonics only.
The more extreme the change in slope is for a transfer function, the greater the number and intensity of harmonics that will be in the output waveform.
The highest harmonic of the output waveform must be nf0, for an input unit-amplitude sinusoid, where f0 is the frequency of the sinusoid and n is the highest degree of F(x), the transfer function.
New Csound Commands and Function Generators
ar table andx, ifn
Extracts sample at index andx from function table number ifn.
GEN09 - sum of sinusoids, specifying each sinusoid's partial (harmonic) number, amplitude (strength)
and phase (in degrees)
f # time size 9 pna stra phsa pnb strb phsb ...
GEN13 - generate transfer function F(x) defined from -1 to 1 in wavetable given amplitude of desired
audio spectrum
f # time size 13 1 1 h0 h1 h2 h3 ... hn
GEN03 - generate transfer function F(x) defined from -1 to 1 in wavetable given coefficients of transfer
function equation
f # time size 3 -1 1 c0 c1 c2 ... cn
Waveshaping in Csound (based on numerical example above)
; p4 = amplitude of note ; p5 = fundamental frequency
instr 1 a1 oscil 255, p5, 1 a2 = a1 + 256 a3 table a2, 2 a4 = a3 * p4 out a4 endin
f1 0 256 9 1 1 90 ; cosine wave (sine offset by 90 degrees) f2 0 512 13 1 1 0.5 1 3 0.3333 0.75 0.25 ; transfer function using harmonics OR f2 0 512 3 -1 1 -1.75 1.25 0 -3.6667 6 4 ; transfer function using coefficients i1 0 5 20000 440 e
COURSE INFORMATION | HOMEWORK ASSIGNMENTS
COURSE PROJECT | CS240 HELP DESK