0% found this document useful (0 votes)
38 views5 pages

This Is Used For Recording Audio Signal Via Mi-Crophone: %NAME: KOY Brosoeu %Group:I4-EA %ID: E20130325

test voice

Uploaded by

ChhaylySreng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views5 pages

This Is Used For Recording Audio Signal Via Mi-Crophone: %NAME: KOY Brosoeu %Group:I4-EA %ID: E20130325

test voice

Uploaded by

ChhaylySreng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Table of Contents

........................................................................................................................................ 1
This is used for recording audio signal via microphone .............................................................. 1
view and play soun ............................................................................................................. 1
play sound signal ................................................................................................................ 2
save signal data .................................................................................................................. 2
load signal ......................................................................................................................... 2

%NAME: KOY Brosoeu


%Group:I4-EA
%ID : e20130325

This is used for recording audio signal via mi-


crophone
clear all; close all; clc; % free out some memory
% create voice recording object
voice = audiorecorder;
t = 5; % lenght of time for recodring
% Define callbacks to show when recording starts and completes.
voice.StartFcn = 'disp(''Start speaking.'')';
voice.StopFcn = 'disp(''End of recording.'')';

record(voice, t); % start recodring

Start speaking.

pause(t + 1);
data = getaudiodata(voice);

End of recording.

view and play soun


time = (0:length(data)-1)./(voice.SampleRate);
time = time(:);
plot(time, data, 'k');
xlabel('t[s]'); ylabel('Amplitude[V]');
grid minor;

1
play sound signal
sound(data,voice.SampleRate);

save signal data


fs = voice.SampleRate;
save('my_voice.mat', 'data', 'fs');
clear all; close all; clc;

load signal
load 'my_voice.mat';
x = data;
clear data;

l = length(x); % length of signal


time = 1/fs.*l;
t = linspace(0,time,l); % create time vector[s]

% convert signal to frequency spectrum


NFFT = 2^nextpow2(l);
X = fft(x, NFFT)/l;
% compute power
XdB = (2*abs(X)).^2;

2
% frequency array
f = fs/2*(linspace(0,1,NFFT/2+1));
figure
% plot sound in time domain
subplot(1,2,1);
plot(t, x, 'k'); grid minor;
axis([0, time, -.5, .5]);
xlabel('Time[s]'); ylabel('Amplitude');
title('Wave form of Hello!');
% Plot single-sided amplitude spectrum.
subplot(1,2,2);
plot(f,XdB(1:NFFT/2+1), 'k'); grid minor;
axis([0, 4e3, 0, 1.5e-4]);
title('Power spectrum of Hello!')
xlabel('Frequency (Hz)')
ylabel('Power')

%AFTER FILTER
load my_voice
bpf=fdesign.bandpass('Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2',200,250,1600,1700,10,1,10,fs)
D=design(bpf);
y=filter(D,data);
sound(y,fs);
l = length(y); % length of signal
time = 1/fs.*l;
t = linspace(0,time,l); % create time vector[s]

% convert signal to frequency spectrum


NFFT = 2^nextpow2(l);
Y = fft(y, NFFT)/l;
% compute power
YdB = (2*abs(Y)).^2;
% frequency array
f = fs/2*(linspace(0,1,NFFT/2+1));
figure
% plot sound in time domain
subplot(1,2,1);
plot(t, y, 'k'); grid minor;
axis([0, time, -.5, .5]);
xlabel('Time[s]'); ylabel('Amplitude');
title('Wave form of Hello!');
% Plot single-sided amplitude spectrum.
subplot(1,2,2);
plot(f,YdB(1:NFFT/2+1), 'k'); grid minor;
axis([0, 4e3, 0, 1.5e-4]);
title('Power spectrum of Hello!')
xlabel('Frequency (Hz)')
ylabel('Power')

3
4
Published with MATLAB R2015a

You might also like