intro to sinusoids n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Intro to Sinusoids PowerPoint Presentation
Download Presentation
Intro to Sinusoids

Loading in 2 Seconds...

play fullscreen
1 / 70

Intro to Sinusoids - PowerPoint PPT Presentation


  • 149 Views
  • Uploaded on

Intro to Sinusoids. What is a sinusoid? Mathematical equation : Function of the time variable : Amplitude : Frequency (# cycles per sec, Hertz) : Phase. FREQUENCY Radians/sec Hertz (cycles/sec) PERIOD (in sec). AMPLITUDE Magnitude PHASE. SINUSOIDAL SIGNAL.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Intro to Sinusoids' - dingbang


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
intro to sinusoids
Intro to Sinusoids
  • What is a sinusoid?
    • Mathematical equation

: Function of the time variable

: Amplitude

: Frequency (# cycles per sec, Hertz)

: Phase

sinusoidal signal
FREQUENCY

Radians/sec

Hertz (cycles/sec)

PERIOD (in sec)

AMPLITUDE

Magnitude

PHASE

SINUSOIDAL SIGNAL

Courtesy of James McClellan et al, Signal Processing First, 2003

intro to sinusoids1
Intro to Sinusoids
  • What is a sinusoid?
    • Plot
intro to sinusoids5
Intro to Sinusoids
  • How to plot a sinusoid?
    • Determine height
    • Determine zero crossings
  • Max height is +A
    • peaks oscillate: +A and -A
    • peaks occur when argument of cosine is a multiple of , i.e.,
intro to sinusoids6
Intro to Sinusoids
  • Zero crossings
    • where plot crosses zero
    • located at odd multiples of , i.e.,
  • Note: cycles repeat (periodic function)
    • sufficient to determine peak and zero crossings in one cycle and then replicate cycle
    • Period = length of cycle =
intro to sinusoids7
Intro to Sinusoids
  • We can also get equation from plot
    • find the parameters , , and
intro to sinusoids8
Intro to Sinusoids
  • We can also get equation from plot
    • find the parameters , , and

Answer:

intro to sinusoids9
Intro to Sinusoids
  • Procedure to get equation from plot
    • Find the amplitude
    • Find the period by measuring the time distance between positive peaks:
    • Find the phase by measuring the “time shift” (delay from 0) of a peak. Note: positive if peak moved to right, and negative if peak moved to left.
    • Then, compute
intro to sinusoids10
Intro to Sinusoids
  • Sinusoids can be interpreted as a “rotating phasor”
  • rotating angle
    • : speed of rotation (# cycles per sec)
    • : initial angle start point
generating signals using sinusoids
Generating Signals using Sinusoids
  • Main reason why sinusoids are important: they are basic tools for constructing other useful and more complicated signals
  • A new signal can be generated by combining together different sinusoids
generating signals using sinusoids1
Generating Signals using Sinusoids
  • Example: Beat Note Waveform
    • Beat notes generated by adding two sinusoids with nearby frequencies
    • They can also be generated by playing two neighboring piano keys
    • Mathematically:

where small.

generating signals using sinusoids2
Generating Signals using Sinusoids
  • Example: Beat Note Waveform
    • Let
    • Matlab Script File: beatnote.m

dur = 2.0;

fs = 8000;

f1 = 220; f2 = 180;

t = 0: (1/fs): dur;

x = cos(2*pi*f1*t)+cos(2*pi*f2*t);

plot(t,x); xlabel(‘Time,t’); ylabel(‘Beat Signal’);

sound(x,fs);

generating signals using sinusoids3
Generating Signals using Sinusoids
  • Example: Beat Note Waveform
    • Let
    • Matlab Function: beat.m

function [x,t] = beat(f0, d, dur);

fs = 8000;

f1 = f0+d; f2 = f0-d;

t = 0: (1/fs): dur;

x = cos(2*pi*f1*t)+cos(2*pi*f2*t);

matlab functions
Matlab Functions
  • Example: Beat Note Waveform
    • Let
    • Matlab Script File using Function beat.m

[x,t] = beat(200,20,1);

plot(t,x); xlabel(‘Time,t’); ylabel(‘Beat Signal’);

sound(x,fs);

generating signals using sinusoids4
Generating Signals using Sinusoids
  • A new signal can be generated by combining together different sinusoids
  • Periodic signals obtained when frequencies are integer multiples of :

where is called harmonic frequency of and is called the fundamental frequency.

generating signals using sinusoids5
Generating Signals using Sinusoids
  • A new periodic signal can be generated by combining together sinusoids having harmonically related frequencies
  • Period = length of one cycle =
periodic signals
PERIODIC SIGNALS
  • Repeat every T secs
    • Definition
    • Example:
    • Speech can be “quasi-periodic”

Courtesy of James McClellan et al, Signal Processing First, 2003

generating signals using sinusoids6
Generating Signals using Sinusoids
  • Example: Square Wave
  • For N =1:
generating signals using sinusoids7
Generating Signals using Sinusoids

Square Wave generates using only first 3 harmonic

Frequencies:

T=0.1

Courtesy of James McClellan et al, Signal Processing First, 2003

generating signals using sinusoids8
Generating Signals using Sinusoids
  • Example: Square Wave
    • Matlab Function square.m

function [x,t] = square(f0, N, dur);

fs = 8000;

t = 0:1/fs:dur;

x = zeros(1,length(t));

for m = 0:N

x = x + (8/((2*m+1)*pi))*cos(2*pi*(2*m+1)*f0*t- pi/2);

end

    • Generate and plot square waves with

= 25Hz, dur = 0.12 sec, and N=1,2,3,25

generating signals using sinusoids9
Generating Signals using Sinusoids
  • Example: Synthetic Vowel
  • Generated signal approximates the waveform produced by a man speaking the sound “ah”.
vowel waveform sum of all 5 components
Vowel Waveform (sum of all 5 components)

Courtesy of James McClellan et al, Signal Processing First, 2003

generating signals using sinusoids10
Generating Signals using Sinusoids
  • Example: Synthetic Vowel
    • Matlab Script File

dur = 1; f = 100;

fs = 8000;

t = 0:1/fs:dur;

x = 12226 * cos(2*pi*2*f*t + 1.508);

x = x + 29416 * cos(2*pi*4*f*t + 1.876);

x = x + 48836 * cos(2*pi*5*f*t - 0.185);

x = x + 13621 * cos(2*pi*16*f*t - 1.449);

x = x + 4723 * cos(2*pi*17*f*t);

plot(t,x); xlabel(‘Time, t’); ylabel(‘Vowel’)

sound(x,fs)

tuning fork example
TUNING FORK EXAMPLE
  • “A” is at 440 Hertz (Hz)
  • Waveform is a SINUSOIDAL SIGNAL
  • Computer plot looks like a sine wave
  • This should be the mathematical formula:

Courtesy of James McClellan et al, Signal Processing First, 2003

speech example
SPEECH EXAMPLE
  • More complicated signal (BAT.WAV)
  • Waveform x(t) is NOT a Sinusoid
  • Theory will tell us
    • x(t) is approximately a sum of sinusoids
    • FOURIER ANALYSIS
      • Break x(t) into its sinusoidal components
    • Called the FREQUENCY SPECTRUM

Courtesy of James McClellan et al, Signal Processing First, 2003

speech signal bat
Speech Signal: BAT
  • Nearly Periodic in Vowel Region
    • Period is (Approximately) T = 0.0065 sec

Courtesy of James McClellan et al, Signal Processing First, 2003

digitize the waveform
DIGITIZE the WAVEFORM
  • x[n] is a SAMPLED SINUSOID
    • A list of numbers stored in memory
  • Sample at 11,025 samples per second
    • Called the SAMPLING RATE of the A/D
    • Time between samples is
      • 1/11025 = 90.7 microsec
  • Output via D/A hardware (at Fsamp)

Courtesy of James McClellan et al, Signal Processing First, 2003

storing digital sound
STORING DIGITAL SOUND
  • x[n] is a SAMPLED SINUSOID
    • A list of numbers stored in memory
  • CD rate is 44,100 samples per second
  • 16-bit samples
  • Stereo uses 2 channels
  • Number of bytes for 1 minute is
    • 2 X (16/8) X 60 X 44100 = 10.584 Mbytes

Courtesy of James McClellan et al, Signal Processing First, 2003

sines and cosines
SINES and COSINES
  • Always use the COSINE FORM
  • Sine is a special case:

Courtesy of James McClellan et al, Signal Processing First, 2003

sinusoidal synthesis
Sinusoidal Synthesis
  • Sinusoids with DIFFERENT Frequencies
    • SYNTHESIZE by Adding Sinusoids
  • SPECTRUM Representation
    • Graphical Form shows DIFFERENT Frequencies
  • SPECTROGRAM Tool
    • Shows how frequency content varies in function of time
    • MATLAB function is specgram.m

Courtesy of James McClellan et al, Signal Processing First, 2003

spectrogram example
SPECTROGRAM EXAMPLE
  • Two Constant Frequencies: Beats

Courtesy of James McClellan et al, Signal Processing First, 2003

time varying frequency diagram
Time-Varying Frequency Diagram

A-440

Frequency is the vertical axis

Time is the horizontal axis

Courtesy of James McClellan et al, Signal Processing First, 2003

sinusoidal synthesis motivation
Sinusoidal Synthesis: Motivation
  • Synthesize Complicated Signals
    • Musical Notes
      • Piano uses 3 strings for many notes
      • Chords: play several notes simultaneously
    • Human Speech
      • Vowels have dominant frequencies
      • Application: computer generated speech
    • Can all signals be generated this way?
      • Sum of sinusoids?

Courtesy of James McClellan et al, Signal Processing First, 2003

fur elise waveform
Fur Elise WAVEFORM

Beat

Notes

Courtesy of James McClellan et al, Signal Processing First, 2003

simple test signal
SIMPLE TEST SIGNAL
  • C-major SCALE: stepped frequencies
    • Frequency is constant for each note

IDEAL

Courtesy of James McClellan et al, Signal Processing First, 2003

spectrogram of c scale
SPECTROGRAM of C-Scale

Sinusoids ONLY

From SPECGRAM

ANALYSIS PROGRAM

ARTIFACTS at Transitions

Courtesy of James McClellan et al, Signal Processing First, 2003

spectrogram of lab song
Spectrogram of LAB SONG

Sinusoids ONLY

Analysis Frame = 40ms

ARTIFACTS at Transitions

Courtesy of James McClellan et al, Signal Processing First, 2003

time varying frequency
Time-Varying Frequency
  • Frequency can change vs. time
    • Continuously, not stepped
  • FREQUENCY MODULATION (FM)
  • CHIRP SIGNALS
    • Linear Frequency Modulation (LFM)

VOICE

Courtesy of James McClellan et al, Signal Processing First, 2003

new signal linear fm
New Signal: Linear FM

QUADRATIC

  • Called Chirp Signals (LFM)
    • Quadratic phase
  • Freq will change LINEARLY versus time
    • Example of Frequency Modulation (FM)
    • Define “instantaneous frequency”

Courtesy of James McClellan et al, Signal Processing First, 2003

instantaneous freq
INSTANTANEOUS FREQ

Derivative

of the “Angle”

Makes sense

  • Definition
  • For Sinusoid:

Courtesy of James McClellan et al, Signal Processing First, 2003

instantaneous freq of the chirp
INSTANTANEOUS FREQ of the Chirp
  • Chirp Signals have Quadratic phase
  • Freq will change LINEARLY versus time

Courtesy of James McClellan et al, Signal Processing First, 2003

chirp spectrogram
CHIRP SPECTROGRAM

Courtesy of James McClellan et al, Signal Processing First, 2003

chirp waveform
CHIRP WAVEFORM

Courtesy of James McClellan et al, Signal Processing First, 2003

other chirps
OTHER CHIRPS
  • y(t) can be anything:
  • y(t) could be speech or music:
    • FM radio broadcast

Courtesy of James McClellan et al, Signal Processing First, 2003

sine wave frequency modulation fm
SINE-WAVE FREQUENCY MODULATION (FM)

Courtesy of James McClellan et al, Signal Processing First, 2003

music synthesis
Music Synthesis
  • Musical notes synthesized using a sinewave at a given frequency.
  • Musical scale is divided into 8 octaves; each octave consists of 12 notes.
  • Notes in each octave are related to notes in previous and next octave:
    • The frequency of a note is twice the frequency of the corresponding note in the previous adjacent (lower) octave.
  • Each octave contains 12 notes (5 black keys and 7 white) and the ratio between the frequencies of the notes is constant between successive notes: fnext note = 21/12 fprevious note
music octave
Music - Octave
  • D4 denotes D note in 4th octave
  • A4 or A-440 note (tone at 440 Hz) is usually a reference note called middle A.
music notation
Music - Notation

4

  • Musical notation shows which notes are to be played and their relative timing
sinewave synthesis
Sinewave Synthesis
  • Methods used
    • Recursive
    • Taylor’s Series
    • Look-up Table
recursive method
Recursive Method

Let A =  and B =n where  is the angle and n the index

For  = 1 and n= 1

Sin(2) and cos(2) can be computed using only four multiplications and 2 addition/subtraction

Sin(1) and cos(1) must first be precomputed and stored in memory

recursive method practical example
Recursive Method – Practical Example
  • Generate a sine wave of frequency F = 100 Hz having a sample frequency Fs equals to 8000 samples/s.
  • Calculate the angle increment 
    • Total number of samples/period = Fs/F = 80
    • The angle increment  = 360/80 = 4.5
  • Precompute sin(4.5) and cos(4.5)
  • Apply the recursive method
look up table
Look-up Table
  • Calculate the values of L evenly spaced points on a sinusoid and store them in memory
  • Suppose L = 16 and Fs = 16000 samples/s
  • The total number of cycles obtained per second is:16000/16 = 1000 Hz
    • The frequency calculated is called fundamental frequency given by:
look up table cont d
Look-up Table (Cont’d)
  • If the samples are not read sequentially from the look-up table (e.g., skipping one sample), the frequency generated will be:

where:

and  is the lookup table increment index.

Example:

Suppose Fs = 16 Khz, L = 16, and  = 2:

  • The maximum value  can reach is bounded by the Nyquist rate:
  • = L/2 => fsin= Fs/2;
look up table cont d1
Look-up Table (Cont’d)
  • Frequency synthesized for different values of  (L = 16)

What if  not integer?

Maximum Frequency

look up table non integer
Look-up Table – Non Integer 
  • Two Methods
    • Round – down
    • Interpolation
look up table round down method
Look-up Table – Round Down Method

“+”: Look-up Table

“o”: Desired Output

L = 8

 = 2.5

High Distortion!!

look up table interpolation
Look-up Table – Interpolation

Interpolation

0.5.(0.7071-1)+1 = 0.8536

Interpolation

0.5.(0.7071-1)+1 = 0.8536

(2,1)

(3,0.7071)

Linear interpolation method used

y = mx + b

where:

m = line slope given by (Base_address + l +1) – (Base_address + l ) Base_address is the beginning address of the lookup table.

b = (Base_address + l ).

x = fractional part of the pointer with 0<x<1

y = linear approximated output sample.

Note that () denotes indirect addressing.

amplitude modulation of tones adsr envelope
Amplitude Modulation of Tones - ADSR envelope
  • Smoothing may be needed since the musical note will not reach its full intensity instantaneously
  • Attack – Decay – Sustain- Release (ADSR) envelope
    • Attack time: time during which the musical note reaches its peak
    • Decay time: time required for the tone’s intensity to partially die away
    • Sustain time: time where the tone’s intensity remains unchanged
    • Release time: time for final attenuation
adsr generation
ADSR Generation
  • One segment at a time (A – D – S – R)
  • Approximated as rising/decaying exponentials
adsr generation cont d
ADSR Generation – cont’d
  • If Fs = 16000 samples/s and assuming a max note duration of 1 second, we need to store 16K in memory for the ADSR envelope values, which consumes a lot of memory
  • An alternative to the lookup ADSR is to try to compute the values “on the fly” using the equation:

^

where g is the rise/decay rate and x(n) is the desired target value; initially x(-1)= 0.

adsr generation cont d1
ADSR Generation – cont’d

x[n]

g

y[n]

z-1

1-g

  • The equation presented previously is a first-order IIR filter given by the following difference equation:
adsr generation cont d2
ADSR Generation – cont’d

Why???

IIR Filter

Solve for the equation and show that the output have an exponential shape