Created
June 4, 2016 14:47
-
-
Save tmwatchanan/08ab1c2fcca6897aea7e58cd27e08f5c to your computer and use it in GitHub Desktop.
Audio MATLAB scripting – recording with microphone, and audio player for the recorded audio data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| p = audioplayer(s, 1.5*Fs); | |
| p.play(); | |
| % t = (0:(length(s)-1))/Fs; % Ts = 1/Fs | |
| % figure; plot(t,s) | |
| figure; plot(s); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Fs = 10000; %Sampling Frequency [Hz] | |
| Duration = 5; %Duration for recording [sec] | |
| Nbit = 8; %Bits per sample [bits] | |
| r = audiorecorder(Fs,Nbit,1); % 1 = Number of channels | |
| % r is the object of audiorecorder class | |
| disp('Start Recording') | |
| recordblocking(r, Duration); % record for duration time | |
| disp('Finish') | |
| s = getaudiodata(r, 'double'); % s will be array r but in double type | |
| t = (0:(length(s)-1))/Fs; % Ts = 1/Fs | |
| figure; plot(t,s) | |
| %figure; plot(s); | |
| % plto spectrum | |
| F = fft(s); | |
| figure; plot(abs(F)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment