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
2
CONTENT
I
IIGenerate some sound efect
Stimulate and draw the spectrum
I. Waveform and the spectrum of audio signal
captured from soundcard
3
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
MATLAB program
5
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 Experiment
out = 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
References
http://www.mathworks.com/help/daq/daq.html
https://www.mathworks.com/products/daq/supported/sound-cards.html
https://www.mathworks.com/products/daq/examples.html?file=/products/de
mos/daq/acquiring_data/acquiring_data.html
https://www.mathworks.com/help/daq/examples/discover-all-other-devices-
using-the-legacy-interface.html?prodcode=DA&language=en
http://www.mathworks.com/help/matlab/ref/wavread.html?cmdname=wavrea
d
http://www.mathworks.com/access/helpdesk/help/techdoc/ref/ref.shtml
http://homepages.udayton.edu/~hardierc/ece203/sound.htm
http://class.ee.iastate.edu/mmina/EELC-Cpree/Labs/Lab4-music.htm
http://comm14.blogspot.com/2013/06/audio-effects-processor-matlab-
project.html
http://www.h6.dion.ne.jp/~fff/old/technique/auditory/matlab.html
16

Sound analysis and processing with MATLAB