lab 1: pitch tuner (v.9a)1 laboratory 1 a simple pitch tuner

13
Lab 1: pitch tuner (v.9a) 1 Laboratory 1 A simple Pitch tuner

Upload: lorin-page

Post on 19-Dec-2015

231 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 1

Laboratory 1

A simple Pitch tuner

Page 2: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 2

Objectives

• To lean how to interface analogue signals to digital systems

• To learn how to process audio signals in embedded systems.

• Aim

• To develop a pitch tuner using an embedded system.

Page 3: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 3

Signal processing steps

• Capture signal by microphone

• Amplify the signal

• Feed to ADC of AMR7 micro.

• Convert to digital , find autocorrelation coeff.

• Find pitch

Page 4: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 4

Hardware system

ADC input

ARM7PC for display result

RS232

Mic

Micamp

Page 5: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 5

Amplifier• What is the best bias voltage at pin3(non-invert. input) ?• Condenser MIC output impedance is 75 Ohms, why this

circuit is not a good design. How to correct it?– Hint: Input=1KHZ, find impedance of C1 and input of the amp.– Solution: C1>1uF, R2=1K, V3 = 100K(VR), use , one VR to replace VR1,2. Discuss why?

Page 6: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 6

Software: Algorithm to find period=1/frequency

Digitize signal

Find auto correlation coefficients r() : r0,r1,…,rn

Period= distance between two peaks of r()

Page 7: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 7

Auto-correlation to find rj=0, rj=1, rj=2,…

• The signal is s0,s1,..,s511

• Example: j=time lag

• Auto-correlation coefficients rj={ r0, r1,.., rn=8, …} are:

511503...

12411310291808511504

...1141039281707

511508...

74635241303511509

...64534231202

511510...

54433221101511511

...44332211000

ssssssssssssrssssssssssssr

ssssssssssssrssssssssssssrssssssssssssrssssssssssssr

Page 8: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 8

Matlab example 1

• a=[1 3 9 3 2 3 8 3 2 ], • r=(xcorr(a)) ,round (r)• R=r(j=time lag)• r=[ 2 9 35 60 96 72 86 123 190

123 86 72 96 60 35 9 17 2]

• Exercise• Verify by hand the first 3 (r [ j ]) elements after

the signal overlapped with itself.

Page 9: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 9

Matlab Example1:a=[1 3 9 3 2 3 8 3 2 ],r=(xcorr(a)) figure(1),clf,subplot(2,1,1)plot(a),subplot(2,1,2)plot(r)

Period=4,

AutoCorr.Xcorr (r)

Data(a)

Pick 2 peaks and measure period

The middle is the peak

Page 10: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 10

Since correlation is mirrored at the lag time (j=0) when the signal overlapped with itself

• Only positive time lag is considered

• Fundamental Period=j2

Lag Time jin samples

Auto correlation R(j)

Rthe_max (j1)Rsecond_max (j2)

j1=0 j2

Page 11: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 11

Matlab Example2:

y=sin wave of 440 Hz

• dt=0.0001 • time=[0:dt:2]• freq=440• nu=2.0*pi*freq• y=sin(nu*time) %angular freq. (sin wave of 440 Hz)• r=(xcorr(y))• figure(2) , clf, subplot(2,1,1), plot(time,y)• axis ([0 0.01 -1 1])• subplot(2,1,2), plot(time(1:100),r(1:100))•

Page 12: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 12

Matlab Example2:In fact any two peaks will give you the answersine wave of 440 Hz,period=0.0091-0.0068 (by inspection between 2 peaks)freq=1/period=434.7Hz

input Data(y)

AutoCorr.(r)

0.0068 0.0091

Page 13: Lab 1: pitch tuner (v.9a)1 Laboratory 1 A simple Pitch tuner

Lab 1: pitch tuner (v.9a) 13

Conclusion

• Studied a method of measuring the pitch of an audio sound.