infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band...

Post on 24-Dec-2015

214 views 0 download

Transcript of infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band...

infinity-project.org

Engineering education

for today’s classroom

2

Design Problem - Digital Band

• Build a digital system that can create music of any style, with any performers, whenever we want to hear it

User controls

Music source

infinity-project.org

Engineering education

for today’s classroom

3

Outline

• Music, Sound, and Signals

• Making Music from Sines and Cosines

• Improving the Design - Making Different Instruments

infinity-project.org

Engineering education

for today’s classroom

4

2.1 Introduction

infinity-project.org

Engineering education

for today’s classroom

5

Ways to Make Music

• All systems that make music Have a musical source Have a way to read

music information Convert musical

information to sound Create sound waves in

air• The result: A sound

signal - but what is it?

infinity-project.org

Engineering education

for today’s classroom

6

Signals are Everywhere

• Signal: A pattern or variation that contains information

infinity-project.org

Engineering education

for today’s classroom

7

2.2 Music, Sound and Signals

infinity-project.org

Engineering education

for today’s classroom

8

Sound Signals

• Sound Signal: A pattern or variation in molecules that a sound makes

• Sound has a speed that is different for different materials

infinity-project.org

Engineering education

for today’s classroom

9

Making Sounds Using Signals

• Amazing Fact: Any sound can be created, stored, and played using signals!

• Microphones and loudspeakers enable us to record and play sounds

• We only need one signal to represent any one sound

infinity-project.org

Engineering education

for today’s classroom

10

Exercise: Plotting Signals

• Plot the signals s(t) = 2 t + 3

s(t) = 0.3 cos(3 t)

s(t) = 6 t2 - 4

time (sec)

time (sec)

time (sec)

• Which one of these looks like a musical signal?

infinity-project.org

Engineering education

for today’s classroom

11

Manipulating Signals

Three musically-useful ways:1. Amplitude scaling: Changing its height

x(t) = A • s(t) 2. Time shifting: Moving left or right

y(t) = s(t + d)3. Time scaling: Stretching or shrinking

the time axisz(t) = s(c • t)

infinity-project.org

Engineering education

for today’s classroom

12

Plots of Real Instrument Signals

infinity-project.org

Engineering education

for today’s classroom

13

Plots of Notes on a Piano Keyboard

infinity-project.org

Engineering education

for today’s classroom

14

Musical Signals and Period

• Observation: The simplest musical signals are periodic; they have shapes that repeat

• Period: The repeating interval T of a periodic signal in units of time (seconds, milliseconds.)

• For any periodic signal p(t), p(t) = p(t + T).

time (sec)

p(t)Example: T = 0.0038 sec = 3.8 msecp(t+T)

infinity-project.org

Engineering education

for today’s classroom

15

Pitch and Fundamental Frequency

• Pitch: how high or low a periodic signal sounds. Can we be more precise?

• Yes! Use fundamental frequency, given by

f = 1/T • Units of frequency: cycles

per second or Hertz (Hz)

infinity-project.org

Engineering education

for today’s classroom

16

Problem: Fundamental Frequency and Period

• Determine the fundamental frequencies of the sounds shown

time

Sinusoidal Signal

time

Saxophone SignalSolution: Both haveperiods of

0.0038 sec. Therefore, f=1/0.0038f = 263Hz(middle C)

infinity-project.org

Engineering education

for today’s classroom

17

A Little Musical Notation

• Each note on a page of sheet music corresponds to a signal with a particular frequency and duration…

The x-axis is time

The y-axisis frequency

infinity-project.org

Engineering education

for today’s classroom

18

The Key to Reading Music

• When a musical score is played, each note becomes a signal with a fundamental frequency

• The type of note determines its duration

infinity-project.org

Engineering education

for today’s classroom

19

Making Musical Sounds

• Signals that have a pitch are periodic• A periodic signal repeats over and over• Therefore, to make a single note from a musical

instrument, we need to create one period of its sound and play it over and over.

p(t)

infinity-project.org

Engineering education

for today’s classroom

20

Our First Digital Band Design

Loudspeaker

Sound Waves

Single period of instrument signal

Translate notes to fundamental frequenciesand durations

infinity-project.org

Engineering education

for today’s classroom

21

Infinity Project Experiment - 2.1

infinity-project.org

Engineering education

for today’s classroom

22

Plots of Speech

infinity-project.org

Engineering education

for today’s classroom

23

Plots of Speech - Block Diagram

infinity-project.org

Engineering education

for today’s classroom

24

2.3 Making Music from Sines and Cosines

infinity-project.org

Engineering education

for today’s classroom

25

Refining the Design

• How do we get the musical information to our digital band?

• How do we specify each instrument’s signal shape?

• How do we make several instrument sounds and play them simultaneously?

infinity-project.org

Engineering education

for today’s classroom

26

Specifying the Musical Score

• Traditionally, music has been written on paperPortable and easy for humans to readDestructible and a little hard for digital

devices to read

• Is there a more convenient format for our musical information?

infinity-project.org

Engineering education

for today’s classroom

27

Musical Instrument Digital Interface (MIDI)

• MIDI specifies (a) note on/off time stamps and (b) note frequencies

• Convenient digital format

• A standard in widespread use

Translate notes to fundamental frequenciesand time stamps

infinity-project.org

Engineering education

for today’s classroom

28

Specifying the Shape of the Musical Instrument Sound

• Most musical instrument signals have complicated shapes

• We shall start with simple periodic signals - the sine and cosine functions

infinity-project.org

Engineering education

for today’s classroom

29

Turning a Sine or Cosine into a Sinusoid

• To make a sound from a sine or cosine function, make the angle a function of time

s(t) = A cos(2 π t / T) [angle units: radians] A = {Amplitude} , T = {Period}

• Can show: s(t) = s(t + T) is periodic

Example:A = 3.1

T = 2.5 msec

People can’t hear the

difference between sinesand cosines!

infinity-project.org

Engineering education

for today’s classroom

30

Making Simple Melodies

time (sec) time (sec)

time (sec) time (sec)

Saxophone Sinusoid

infinity-project.org

Engineering education

for today’s classroom

31

Our Second Digital Band Design

Translate notes to fundamental frequenciesand time stamps

Cosine generator

This system allows us to play simple single-notemelodies with a simple (sinusoidal) instrument sound.

How do we extend thissystem to play(a) Different

instruments?(b) Multiple notes

simultaneously?

infinity-project.org

Engineering education

for today’s classroom

32

Making More than One Note at a Time

• To play two notes simultaneously, add their signals together

MIDI Information:

Translate notes to period valuesand time stamps

Cosine generator

Cosine generator

Block Diagram:

infinity-project.org

Engineering education

for today’s classroom

33

Example Problem: Adding Two Signals Together

time (sec)

time (sec)

infinity-project.org

Engineering education

for today’s classroom

34

Example Problem: Solution

infinity-project.org

Engineering education

for today’s classroom

35

Example: Adding Two Sinusoids Together

• This problem is hard to do by hand…

• …but easy to do digitally!

infinity-project.org

Engineering education

for today’s classroom

36

Reverse-Engineering the Musical Score

• Spectrum: A plot of a signal’s frequency content over a specified window

• “Spikes” in the spectrum correspond to sinusoids

• Spectrum Analysis: A procedure for computing the spectrum

Spectrum Analysis is also easy to do digitally!

infinity-project.org

Engineering education

for today’s classroom

37

Spectrogram

infinity-project.org

Engineering education

for today’s classroom

38

Infinity Project Experiment - 2.2

infinity-project.org

Engineering education

for today’s classroom

39

Generating Sine and Cosine Signals

infinity-project.org

Engineering education

for today’s classroom

40

Generating Sine and Cosine Signals

infinity-project.org

Engineering education

for today’s classroom

41

Infinity Project Experiment-2.3

infinity-project.org

Engineering education

for today’s classroom

42

Listening to Sines and Cosines

infinity-project.org

Engineering education

for today’s classroom

43

Listening to Sines and Cosines

infinity-project.org

Engineering education

for today’s classroom

44

Infinity Project Experiment-2.4

infinity-project.org

Engineering education

for today’s classroom

45

Measuring a Tuning Fork

infinity-project.org

Engineering education

for today’s classroom

46

Measuring a Tuning Fork

infinity-project.org

Engineering education

for today’s classroom

47

Infinity Project Experiment - 2.5

infinity-project.org

Engineering education

for today’s classroom

48

Building the Sinusoidal MIDI Player

infinity-project.org

Engineering education

for today’s classroom

49

Building the Sinusoidal MIDI Player

infinity-project.org

Engineering education

for today’s classroom

50

Infinity Project Experiment - 2.6

infinity-project.org

Engineering education

for today’s classroom

51

The Spectrogram File Read

infinity-project.org

Engineering education

for today’s classroom

52

The Spectrogram File Read

infinity-project.org

Engineering education

for today’s classroom

53

The Spectrogram Microphone

infinity-project.org

Engineering education

for today’s classroom

54

The Spectrogram Microphone

infinity-project.org

Engineering education

for today’s classroom

55

2.4 Improving the Design—Making Different Instruments

infinity-project.org

Engineering education

for today’s classroom

56

Improving the Design - Making Better Instrument Sounds

• Synthesis: The creation of useful and interesting sounds from more basic signals

• Three types:Waveform SynthesisAdditive Synthesis(Physical Modeling Synthesis)

infinity-project.org

Engineering education

for today’s classroom

57

Waveform Synthesis

• Method: Using a single period from a real instrument sound, make period signals at different frequencies

• Procedure: Copy, Time Warp, and Repeat

T

infinity-project.org

Engineering education

for today’s classroom

58

Time Warping

• Goal: “Stretch” or “squeeze” a periodic signal to change its period

• Formula:pnew(t) = p((Tnew / T) t) pnew(t) = p((f / fnew ) t)

• Result: pnew(t) = pnew(t + Tnew)

infinity-project.org

Engineering education

for today’s classroom

59

Example Problem: Time Warping

Original Signal Time Warped Signal #1

Time Warped Signal #2

What are the fundamental frequencies of these signals?

infinity-project.org

Engineering education

for today’s classroom

60

Additive Synthesis

• Fact: Any signal can be approximated to arbitrary accuracy by adding the right sinusoids together.

• Example: Saxophone sound

infinity-project.org

Engineering education

for today’s classroom

61

Giving a Sound its Character: The Envelope

• Most musical sounds don’t have a constant volume Piano and guitar: Decay away Flute and trumpet: Always changing

• Envelope: The (changing) amplitude of a sound over time, denoted as e(t).

Example: Piano e(t)

infinity-project.org

Engineering education

for today’s classroom

62

Using the Envelope for Sound Synthesis

• Formula: s(t) = e(t) x p(t)

• Can use with p(t) from either waveform or additive synthesis

e(t) x p(t) = s(t)

infinity-project.org

Engineering education

for today’s classroom

63

Making Music Using Envelope and Periodic Signals

infinity-project.org

Engineering education

for today’s classroom

64

Plots of Clarinet Note

infinity-project.org

Engineering education

for today’s classroom

65

Infinity Project Experiment - 2.7

infinity-project.org

Engineering education

for today’s classroom

66

SketchWave with MIDI

infinity-project.org

Engineering education

for today’s classroom

67

SketchWave with MIDI

infinity-project.org

Engineering education

for today’s classroom

68

Infinity Project Experiment - 2.8

infinity-project.org

Engineering education

for today’s classroom

69

SketchWave with Envelope Functions

infinity-project.org

Engineering education

for today’s classroom

70

Sketch-Wave with Envelope Functions

infinity-project.org

Engineering education

for today’s classroom

71

Infinity Project Experiment - 2.9

infinity-project.org

Engineering education

for today’s classroom

72

Echo Generator

infinity-project.org

Engineering education

for today’s classroom

73

Echo Generator

infinity-project.org

Engineering education

for today’s classroom

74

Interesting Application - 2.10

infinity-project.org

Engineering education

for today’s classroom

75

Sound Effects: Reverberation

infinity-project.org

Engineering education

for today’s classroom

76

Sound Effects: Reverberation

infinity-project.org

Engineering education

for today’s classroom

77

Sound Effects -Flanging

infinity-project.org

Engineering education

for today’s classroom

78

Sound Effects Flanging

infinity-project.org

Engineering education

for today’s classroom

79

Master Design Problem

infinity-project.org

Engineering education

for today’s classroom

80

Master Design Problem: Ultimate Karaoke Machine

• Design a system that would make any singer sound like a music superstar!

• Goals Pitch correction - “Fix” any wrong notes

while the singer is singing?Music creation - Background tracks?Special effects - An “Elvis” preset? Practice - Can it teach the singer to sing

better?

infinity-project.org

Engineering education

for today’s classroom

81

Steps in the Design

• ConstraintsLow cost, portable, wireless…?

• Research and Gather InformationHas this been done before?

• Create and AnalyzeBlock diagram? Functions of each block?

• Choose, Build, and TestHow well does it work?

infinity-project.org

Engineering education

for today’s classroom

82

End of Chapter 2