sound analysis and processing with matlab

16
STUDENTS: LƯU HOÀNG TÂN 40902371 PHẠM HOÀNG TUẤN 40903123 TUTOR: PhD HA HOANG KHA AUDIO SIGNALS WITH SOUNDCARD 1

Upload: tan-hoang-luu

Post on 20-Jun-2015

903 views

Category:

Engineering


11 download

DESCRIPTION

Matlab base software capturing sound form pc's soundcard and analyze its spectrum. Another soft creates some sound effects from a .wav file.

TRANSCRIPT

Page 1: Sound analysis and processing with MATLAB

1

STUDENTS:LƯU HOÀNG TÂN 40902371PHẠM HOÀNG TUẤN 40903123

TUTOR: PhD HA HOANG KHA

AUDIO SIGNALS WITH SOUNDCARD

Page 2: Sound analysis and processing with MATLAB

2

CONTENT

I

IIGenerate some sound efect

Stimulate and draw the spectrum

Page 3: Sound analysis and processing with MATLAB

3

I. Waveform and the spectrum of audio signal captured from soundcard

Overview diagram

Page 4: Sound analysis and processing with MATLAB

4

Create an analog input device object

ai = analoginput('winsound');addchannel(ai,1);

Changing object properties

ai.SampleRate = Fs; ai.SamplesPerTrigger = duration*Fs;ai.TriggerType = 'Manual';

Get data

start(ai);trigger(ai);[data, t] = getdata(ai);delete(ai);clear ai;

MATLAB daq toolbox

Page 5: Sound analysis and processing with MATLAB

5

MATLAB program

Page 6: Sound analysis and processing with MATLAB

6

Fs > 2B

Fs < 2B

Comment : If sampling frequency Fs < 2B, the signal spectrum is aliased by its image.

Signal spectrum with sampling frequency Fs

Page 7: Sound analysis and processing with MATLAB

7

Consider an sinusoidal signal 0.6V amplitude, frequency 5kHz as the input.

Page 8: Sound analysis and processing with MATLAB

8

In case Fs = 8000Hz

In the right window, there are two spectral line at -3kHz and 3kHz which does not match the spectrum of 5kHz sinusoidal signal

Page 9: Sound analysis and processing with MATLAB

9

In case Fs=48000Hz

The signal spectrum does match the one of 5kHz sinusoidal signal .

Page 10: Sound analysis and processing with MATLAB

10

II. Create sound effects Matlab program

The program read a .wav file which was build from stereo audio signal sampling at 44.1kHz. With the data, we generate several sound effect.

Page 11: Sound analysis and processing with MATLAB

11

MATLAB functions[x,fs] = wavread(‘road.wav’) : read file name road.wav and store the value to array x. sound(x,fs) : play the wav file converted to x in the previous description.soundsc(x,Fs) : scale the sound of the wav file. Scaling a signal means changing its frequency or amplitude.

Page 12: Sound analysis and processing with MATLAB

12

The signal and its spectrum by playing file road.wav

Page 13: Sound analysis and processing with MATLAB

13

Effects Changing the Speed

[hootie,fs]=wavread('hootie.wav'); %loads Hootie

Soundsc(hootie,fs/1.5) % How slow can you go?

soundsc(hootie,fs*1.5) % The Chimpmonks! Changing Volume soundsc(m*hootie,fs) Reverse

y=[1;2;3;4;5];

y2=flipud(y); %reverse the array y

Page 14: Sound analysis and processing with MATLAB

14

Digital Delay Experimentout = x;  % set up a new array, same size as old one

N=10000;  % delay amount N/44100 seconds

for n=N+1:length(left)

out(n)=x(n)+x(n-N);  % approximately ¼ second echo

end

soundsc(out,fs) % new echo

Digital Tone Control ( Low Pass Filter)[hootie,fs]=wavread('hootie.wav'); % loads Hootie

out=hootie;

for n=2:length(hootie)

out(n,:) = 0.9*out(n-1,:)+hootie(n,:);

end

soundsc(out,fs); % low pass filtered

Page 15: Sound analysis and processing with MATLAB

15

The signal spectrum at the output of LPF

Page 16: Sound analysis and processing with MATLAB

16

References

http://www.mathworks.com/help/daq/daq.htmlhttps://www.mathworks.com/products/daq/supported/sound-cards.ht

mlhttps://www.mathworks.com/products/daq/examples.html?file=/prod

ucts/demos/daq/acquiring_data/acquiring_data.htmlhttps://www.mathworks.com/help/daq/examples/discover-all-other-d

evices-using-the-legacy-interface.html?prodcode=DA&language=enhttp://www.mathworks.com/help/matlab/ref/wavread.html?cmdname

=wavreadhttp://www.mathworks.com/access/helpdesk/help/techdoc/ref/ref.sht

mlhttp://homepages.udayton.edu/~hardierc/ece203/sound.htmhttp://class.ee.iastate.edu/mmina/EELC-Cpree/Labs/Lab4-music.htmhttp://comm14.blogspot.com/2013/06/audio-effects-processor-matlab

-project.htmlhttp://www.h6.dion.ne.jp/~fff/old/technique/auditory/matlab.html