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

82

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

Page 1: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.
Page 2: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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

Page 3: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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

Page 4: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

4

2.1 Introduction

Page 5: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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?

Page 6: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

6

Signals are Everywhere

• Signal: A pattern or variation that contains information

Page 7: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

7

2.2 Music, Sound and Signals

Page 8: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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

Page 9: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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

Page 10: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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?

Page 11: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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)

Page 12: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

12

Plots of Real Instrument Signals

Page 13: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

13

Plots of Notes on a Piano Keyboard

Page 14: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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)

Page 15: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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)

Page 16: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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)

Page 17: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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

Page 18: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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

Page 19: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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)

Page 20: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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

Page 21: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

21

Infinity Project Experiment - 2.1

Page 22: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

22

Plots of Speech

Page 23: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

23

Plots of Speech - Block Diagram

Page 24: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

24

2.3 Making Music from Sines and Cosines

Page 25: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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?

Page 26: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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?

Page 27: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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

Page 28: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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

Page 29: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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!

Page 30: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

30

Making Simple Melodies

time (sec) time (sec)

time (sec) time (sec)

Saxophone Sinusoid

Page 31: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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?

Page 32: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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:

Page 33: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

33

Example Problem: Adding Two Signals Together

time (sec)

time (sec)

Page 34: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

34

Example Problem: Solution

Page 35: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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!

Page 36: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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!

Page 37: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

37

Spectrogram

Page 38: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

38

Infinity Project Experiment - 2.2

Page 39: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

39

Generating Sine and Cosine Signals

Page 40: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

40

Generating Sine and Cosine Signals

Page 41: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

41

Infinity Project Experiment-2.3

Page 42: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

42

Listening to Sines and Cosines

Page 43: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

43

Listening to Sines and Cosines

Page 44: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

44

Infinity Project Experiment-2.4

Page 45: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

45

Measuring a Tuning Fork

Page 46: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

46

Measuring a Tuning Fork

Page 47: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

47

Infinity Project Experiment - 2.5

Page 48: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

48

Building the Sinusoidal MIDI Player

Page 49: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

49

Building the Sinusoidal MIDI Player

Page 50: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

50

Infinity Project Experiment - 2.6

Page 51: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

51

The Spectrogram File Read

Page 52: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

52

The Spectrogram File Read

Page 53: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

53

The Spectrogram Microphone

Page 54: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

54

The Spectrogram Microphone

Page 55: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

55

2.4 Improving the Design—Making Different Instruments

Page 56: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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)

Page 57: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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

Page 58: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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)

Page 59: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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?

Page 60: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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

Page 61: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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)

Page 62: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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)

Page 63: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

63

Making Music Using Envelope and Periodic Signals

Page 64: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

64

Plots of Clarinet Note

Page 65: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

65

Infinity Project Experiment - 2.7

Page 66: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

66

SketchWave with MIDI

Page 67: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

67

SketchWave with MIDI

Page 68: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

68

Infinity Project Experiment - 2.8

Page 69: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

69

SketchWave with Envelope Functions

Page 70: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

70

Sketch-Wave with Envelope Functions

Page 71: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

71

Infinity Project Experiment - 2.9

Page 72: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

72

Echo Generator

Page 73: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

73

Echo Generator

Page 74: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

74

Interesting Application - 2.10

Page 75: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

75

Sound Effects: Reverberation

Page 76: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

76

Sound Effects: Reverberation

Page 77: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

77

Sound Effects -Flanging

Page 78: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

78

Sound Effects Flanging

Page 79: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

79

Master Design Problem

Page 80: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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?

Page 81: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

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?

Page 82: infinity-project.org Engineering education for today’s classroom 53 Design Problem - Digital Band Build a digital system that can create music of any.

infinity-project.org

Engineering education

for today’s classroom

82

End of Chapter 2