Sound analysis and processing with MATLAB
-
Upload
tan-hoang-luu -
Category
Engineering
-
view
903 -
download
11
description
Transcript of Sound analysis and processing with MATLAB
![Page 1: Sound analysis and processing with MATLAB](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/1.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/2.jpg)
2
CONTENT
I
IIGenerate some sound efect
Stimulate and draw the spectrum
![Page 3: Sound analysis and processing with MATLAB](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/3.jpg)
3
I. Waveform and the spectrum of audio signal captured from soundcard
Overview diagram
![Page 4: Sound analysis and processing with MATLAB](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/4.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/5.jpg)
5
MATLAB program
![Page 6: Sound analysis and processing with MATLAB](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/6.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/7.jpg)
7
Consider an sinusoidal signal 0.6V amplitude, frequency 5kHz as the input.
![Page 8: Sound analysis and processing with MATLAB](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/8.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/9.jpg)
9
In case Fs=48000Hz
The signal spectrum does match the one of 5kHz sinusoidal signal .
![Page 10: Sound analysis and processing with MATLAB](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/10.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/11.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/12.jpg)
12
The signal and its spectrum by playing file road.wav
![Page 13: Sound analysis and processing with MATLAB](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/13.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/14.jpg)
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](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/15.jpg)
15
The signal spectrum at the output of LPF
![Page 16: Sound analysis and processing with MATLAB](https://reader035.fdocuments.in/reader035/viewer/2022062220/558529e8d8b42a86388b46d1/html5/thumbnails/16.jpg)
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