Adding two sinusoids of the same frequency CMPT 368: Lecture 3 Additive Synthesis Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University • Adding two sinusoids of the same frequency but with possibly different amplitudes and phases, produces another sinusoid at that frequency. January 16, 2008 3 sin(4πt) 2sin(4πt + π/4) sum Amplitude 2 1 0 −1 −2 −3 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Time (s) Figure 1: Adding two sinusoids of the same frequency. 1 CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 Mathematical Proof Spectrum • Recalling the expression for sinusoidal motion and trigonometric identities1 , we may see that • The spectrum of a signal is a graphical representation of the frequency components it contains and their complex amplitudes. x = A sin(ω0t + φ) = A sin(φ + ω0t) = [A sin φ] cos ω0t + [A cos φ] sin ω0t = B cos ω0t + C sin ω0t, • Signals may therefore be represented as the sum of N sinusoids of arbitrary amplitudes, phases, AND frequencies: where the amplitude A is given by √ A = B 2 + C 2, and the phase φ is given by φ = tan −1 x(t) = C . B N X Ak cos(ωk t + φk ) k=0 • We may therefore, synthesize a sound by setting up a bank of oscillators, each set to the appropriate amplitude, phase and frequency. Note: The derivation of A and φ will be given in a subsequent lecture. • The output of each oscillator is added together to produce a synthesized sound, and thus the synthesis technique is called additive synthesis. Every sinusoid can be expressed as the sum of a sine and cosine function, or equivalently, an “in-phase” and “phase-quadrature” component. 1 2 For the homework you will need the identity cos(A + B) = cos(A) cos(B) − sin(A) sin(B) CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 3 CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 4 Additive Synthesis Additive Synthesis Caveat • Additive synthesis provides the maximum flexibility in the types of sound that can be synthesized. • In certain cases, it can realize tones that are “indistinguishable from real tones.” • Drawback: it often requires many oscillators to produce good quality sounds, and can be very computationally demanding. • Also, many functions are useful only for a limited range of pitch and loudness. • Signal analysis is often a prerequisite for additive synthesis of specific sounds. This will allow you to determine the amplitude, phase and frequency functions. – For example, the timbre of a piano played at A4 is different from one played at A2; – similarly, the timbre of a trumpet played loudly is quite different from one played softly at the same pitch. • Therefore, this technique is also sometimes called Fourier recomposition. • It is possible however, to use some knowledge of acoustics to determine functions. – For example, in specifying amplitude envelopes for each of the oscillators, it is useful to know that in many acoustic instruments, the higher harmonics attack last and decay first. CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 5 CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 6 Creating Different Periodic Waveforms Amplitude 1 • Different “standard” periodic waveforms can be created using additive synthesis. 0.5 0 −0.5 −1 Table 1: Other Simple Waveforms Synthesized by Adding Cosine Functions Type Harmonics Amplitude 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 0.6 0.7 0.8 0.9 1 0.6 0.7 0.8 0.9 1 Time (s) Phase (cos) Phase (sin) square Odd, n = [1, 3, 5, ..., N] 1/n −π/2 0 triangle Odd, n = [1, 3, 5, ..., N] 1/n2 0 π/2 Even and Odd, n = [1, 2, 3, ..., N] 1/n −π/2 0 sawtooth Amplitude 2 1 0 −1 −2 0 0.1 0.2 0.3 0.4 0.5 Time (s) Amplitude 2 1 0 −1 −2 0 0.1 0.2 0.3 0.4 0.5 Time (s) Figure 2: Summing sinusoids to produce other simple waveforms CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 7 CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 8 Harmonics and Pitch Square Wave Spectrum Magnitude 1 0.8 0.6 • Notice that even though these new waveforms contain more than one frequency component, they are still periodic. 0.4 0.2 0 0 5 10 15 Frequency (Hz) Triangle Wave Spectrum • Because each of these frequency components are integer multiples of some fundamental frequency f0, they are called harmonics. Magnitude 1 0.8 0.6 • Signals with harmonic spectra have a fundamental frequency and therefore have a periodic waveform (the reverse is, of course, also true). 0.4 0.2 0 0 5 10 15 Frequency (Hz) Sawtooth Wave Spectrum • Pitch is our subjective response to the fundamental frequency. Magnitude 1 0.8 • The harmonics contribute to the timbre of a sound, but do not necessarily alter the pitch. 0.6 0.4 0.2 0 0 5 10 15 Frequency (Hz) Figure 3: Spectra of complex waveforms CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 9 Relating to Acoustics 10 Pitch • In acoustics, to excite a higher harmonic of an instrument, your excitation mechanism, whether it be blowing through a mouthpiece, plucking or bowing a string, must contain a component at a frequency matching that harmonic. OPEN−OPEN f PRESSURE VARIATIONS CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 2f • There is a nonlinear relationship between pitch perception and frequency. • Listeners usually compare tones on the basis of the musical interval separating them. For example, the pitch interval of an octave corresponds to a frequency ratio of 2:1. • We will often encounter a pitch notation wich designates a pitch with an octave: C4 is middle C. 3f 4f • We often hear of the pitch A4 as “A440”, or A at 440 Hz. The pitch one octave below, A3 is therefore 220 Hz. Figure 4: Vibrational modes of a tube open at both ends. CLOSED−OPEN • In equal tempered tuning, there are 12 evenly spaced tones in an octave, called semi-tones. PRESSURE VARIATIONS f 3f • How do you calculate the pitch 1 semitone above A440? 5f 7f Figure 5: Vibrational modes of a tube open at one end and closed at the other. CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 11 CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 12 • The resulting waveform shows that there is a periodic, low frequency amplitude envelope superimposed on a higher frequency sinusoid. Beat Notes • What happens when we add two frequencies that are not harmonically related? Beat Note Waveform (f0 = 220 Hz, f1 = 2 Hz) 1 0.8 • The Beat note comes about by adding two sinusoids that are very close in frequency. 0.6 0.4 Spectrum of Beat Note 0.2 Amplitude 1 0.9 0.8 0 −0.2 0.7 −0.4 Magnitude 0.6 0.5 −0.6 0.4 −0.8 0.3 −1 0 0.2 0.4 0.6 0.2 0.8 1 1.2 1.4 1.6 1.8 2 Time (s) 0.1 Figure 7: Waveform of a Beat Note. 0 205 210 215 220 225 230 235 Frequency (Hz) • What is going on? Figure 6: Beat Note made by adding sinusoids at frequencies 218 Hz and 222 Hz. CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 13 Multiplication of Sinusoids • What happens when we multiply a low frequency sinusoids with a higher frequency sinusoid? Begin by using the inverse Euler formula: x(t) = sin(2π(220)t) cos(2π(2)t) j2π(220)t j2π(2)t e − e−j2π(220)t e + e−j2π(2)t = 2j 2 i 1 h j2π(222)t −j2π(222)t j2π(218)t e −e +e − e−j2π(218)t = 4j 1 = [sin(2π(222)t) + sin(2π(218)t)] 2 which is a sum of real sine functions. • From this we can now see that there will be four frequency components in the spectrum (including the negative frequencies), none of which are the two multiplied frequency components. Rather, the spectrum has their sum and the difference. • Sinusoidal multiplication can therefore be expressed as an addition (which makes sense because all signals can can be represented by the sum of sinusoids). CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 15 CMPT 368: Computer Music Theory and Sound Synthesis: Lecture 3 14