sound analysis and processing with matlab
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
1
STUDENTS:LƯU HOÀNG TÂN 40902371PHẠM HOÀNG TUẤN 40903123
TUTOR: PhD HA HOANG KHA
AUDIO SIGNALS WITH SOUNDCARD
2
CONTENT
I
IIGenerate some sound efect
Stimulate and draw the spectrum
3
I. Waveform and the spectrum of audio signal captured from soundcard
Overview diagram
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
5
MATLAB program
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
7
Consider an sinusoidal signal 0.6V amplitude, frequency 5kHz as the input.
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
9
In case Fs=48000Hz
The signal spectrum does match the one of 5kHz sinusoidal signal .
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.
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.
12
The signal and its spectrum by playing file road.wav
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
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
15
The signal spectrum at the output of LPF
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