-
Notifications
You must be signed in to change notification settings - Fork 0
/
Record.M
29 lines (23 loc) · 881 Bytes
/
Record.M
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function Out=Record(Fs,Duration)
% Record a Fs Hz, mono wave file from microphone with Duration second(s)
%
% veisi@mehr.sharif.edu
fprintf(' Recording %g-second wave (Press a key to start)...\n', Duration);
pause;
fprintf(' >> Start recording ...\n');
Out = wavrecord(Duration*Fs,Fs, 'uint8');
fprintf(' >> Finish %g-second of recording.\n', Duration);
% ==== Play recirded file
Out = (double(Out)-128)/128;
wavplay(Out, Fs, 'sync');
% ===== Plot recorded waveform
%hold on
plot((1:Duration*Fs)/Fs, Out,'b--');
title('Recorded wave file');
%axis([0 Duration min(Out) max(Out)]);
grid on
%hold off
% ==== Save recorded file
FileName = 'suar.wav';
wavwrite(Out, Fs, 8, FileName);
fprintf(' >> The file is save to "%s"\n', FileName);