Sinusoids CMPT 318: Lecture 3 Sinusoids • “Sinusoids” is a collective term referring to both sine and cosine functions. Tamara Smyth, tamaras@cs.sfu.ca School of Computing Science, Simon Fraser University • A sinusoid is a function of time having the following form: x(t) = A sin(ωt + φ), where x is the quantity which varies over time and January 16, 2006 A ω f t φ ωt + φ , , , , , , peak amplitude radian frequency (rad/sec) = 2πf frequency (Hz) time (seconds) initial phase (radians) instantaneous phase (radians) Sinusoidal Signal 2 Amplitude 1 0 −1 −2 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Time (s) Figure 1: Sinusoid where A = 2, ω = 2π5, and φ = π/4. 1 CMPT 318: Fundamentals of Computerized Sound: Lecture 3 Amplitude and Magnitude. 2 Phase and Period. • The term peak amplitude, often shortened to amplitude, is the nonnegative value of the waveform’s peak (either positive or negative). • The initial phase φ, given in radians, tells us the position of the waveform cycle at t = 0. Also sometimes called: – phase offset – phase shift – phase factor • The instantaneous amplitude of x is the value of x(t) (either positive or negative) at time t. • The instantaneous magnitude, or simply magnitude, of x is nonnegative and is given by |x(t)|. • One cycle of a sinusoid is 2π radians. • The period T of a sinusoid is the time (in seconds) it takes to complete one cycle. • Since sinusoids are periodic with period 2π, an initial phase of φ is indistinguishable from an initial phase of φ ± 2π. – We may therefore restrict the range of φ so that it does not exceed 2π. – Typically we choose the range −π < φ < π, but we many also encouter 0 < φ < 2π. CMPT 318: Fundamentals of Computerized Sound: Lecture 3 3 CMPT 318: Fundamentals of Computerized Sound: Lecture 3 4 Frequency Sine and cosine functions. • The frequency f of the waveform is given in cycles per second or Hertz (Hz). • Frequency is equivalent to the inverse of the period T of the waveform, • The sine and cosine function are very closely related and can be made equivalent simply by adjusting their initial phase: π π sin θ = cos(θ − ) or cos θ = sin(θ + ). 2 2 1 Hz. Amplitude f = 1/T • The radian frequency ω, given in radians per second, is equivalent to the frequency in Hertz scaled by 2π, ω = 2πf 0.5 0 −0.5 −1 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2 Time (s) (rad/sec). Figure 2: Phase relationship between cosine and sine functions. • In calculus, the sine and cosine functions are derivatives of one other. That is, d sin θ d cos θ = cos θ and = − sin θ. dt dt CMPT 318: Fundamentals of Computerized Sound: Lecture 3 5 y(t) = s(t + 1) = t + 1 = t+1 • If a signal can be expressed in the form we say x(t) is a time-shifted version of s(t). 1 y(t) = s(t+1) 1 0 1 A positive phase indicates a shift to the left whereas a negative phase indicates a shift to the right. 1 0 1 2 3 0≤t+1≤1 − 1 ≤ t ≤ 0, which is simply s(t) with its origin shifted to the left, or advanced in time, by 1 seconds. x(t) = s(t − t1), x(t) = s(t−2) 6 • Shifting the function by t1 = −1 seconds yields Time-shifting a signal. s(t) CMPT 318: Fundamentals of Computerized Sound: Lecture 3 −1 0 1 2 Figure 3: Time-shifting a signal. • Consider the simple function s(t) = t 0 ≤ t ≤ 1. • Shifting the function by t1 = 2 seconds yields x(t) = s(t − 2) = t − 2 = t−2 0≤t−2≤1 2 ≤ t ≤ 3, which is simply s(t) with its origin shifted to the right, or delayed, by 2 seconds. CMPT 318: Fundamentals of Computerized Sound: Lecture 3 7 CMPT 318: Fundamentals of Computerized Sound: Lecture 3 8 Sinusoidal and Circular Motion Sinusoidal and Circular Motion cont. • Consider a vector of length one (1), rotating at a steady speed in a plane, the vector tracing a circle with a radius equal to its length. • The x- and y-axis are the horizontal and vertical lines intersecting at the circle’s centre. y-axis (0, 1) π/2 π/4 ( √12 , √12 ) 1 π θ (-1, 0) (1, 0) x-axis 2π (0, -1) 3π/2 Figure 5: The vector coordinates are determined by projecting onto the x and y-axis. Figure 4: A vector rotating along the unit circle. • Projecting the vector onto the x- and y-axes allows us to determine its coordinates in the xy-plane. • Each time the vector completes one rotation of the circle, it has completed a cycle of 2π. • The rate at which the vector completes one cycle is given by its frequency. • If the vector is rotated in a counterclockwise direction, at angle θ from the positive x-axis, projecting onto both the x- and y-axes creates right angle triangles. • The length of the vector is given by its amplitude (which for simplicity, in this case, is one (1)). • Trigonometric identities, with knowledge of θ and the vector length, will help us determine the coordinates. CMPT 318: Fundamentals of Computerized Sound: Lecture 3 9 CMPT 318: Fundamentals of Computerized Sound: Lecture 3 Sinusoids and Circular Motion cont. Adding two sinusoids of the same frequency • Projecting onto the x- and y-axis gives a sequence of points that resemble a cosine and sine function respectively. • Adding two sinusoids of the same frequency but with possibly different amplitudes and phases, produces another sinusoid at that frequency. 3 sin(4πt) 2sin(4πt + π/4) sum 2 Amplitude amplitude −−−> 10 time −−−> 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 7: Adding two sinusoids of the same frequency. amplitude −−−> time −−−> • Recalling the expression for sinusoidal motion and trigonometric identities1 , we may see that x = A sin(ω0t + φ) = A sin(φ + ω0t) = [A sin φ] cos ω0t + [A cos φ] sin ω0t = B cos ω0t + C sin ω0t, Figure 6: Projecting onto the x and y axis. CMPT 318: Fundamentals of Computerized Sound: Lecture 3 1 11 sin(A + B) = sin(A) cos(B) + cos(A) sin(B) CMPT 318: Fundamentals of Computerized Sound: Lecture 3 12 where the amplitude A is given by √ A = B 2 + C 2, Vector Addition • Since one vector represents one sinusoid, to add two sinusoids of the same frequency, we need only perform vector addition. and the phase φ is given by y−axis −1 C . φ = tan B V Every sinusoid can be expressed as the sum of a sine and cosine function, or equivalently, an “in-phase” and “phase-quadrature” component. U U V x−axis Figure 8: Adding sinusoids using vector addition. • Since the vectors have the same frequency, they will rotate as a unit and their sum will have the same frequency. • The sum vector u + v in Figure 8 also has its own x and y component (from projecting onto the x- and y-axes) and therefore may have a different amplitude and phase. CMPT 318: Fundamentals of Computerized Sound: Lecture 3 13 CMPT 318: Fundamentals of Computerized Sound: Lecture 3 14