MATLAB audiorecorder and wavwrite [closed]
While reading the website of MathWorks I learned that they are discouraging the usage of wavrecord function, because it's going to be deprecated soon, so I decided to use the audiorecorder instead. Everyth开发者_StackOverflowing was fine, even the play function was also playing the recorded audio, but when I use wavwrite function to write to a wav file it's not sounding well, basically I noticed that the duration is not set properly.
I am showing the program, please suggest me how to make it correct. Thank you.
fs = 44100
bits = 16
recObj = audiorecorder(fs, bits, 1);
%# get(recObj)
%# Collect a sample of your speech with a microphone, and plot the signal data:
%# Record your voice for 5 seconds.
recObj = audiorecorder;
disp('Start speaking.')
recordblocking(recObj, 5);
disp('End of Recording.');
%# Play back the recording.
play(recObj);
%# Store data in double-precision array.
myRecording = getaudiodata(recObj);
%disp(size(myRecording));
%# Plot the waveform.
plot(myRecording);
wavwrite(myRecording, fs, bits,'sample01_6k');
%#wavplay(myRecording,fs);
you are creating recObj twice, and the second time you create it, you create it with default settings instead of your custom settings. Remove the second call to audiorecorder and everything should work as expected.
加载中,请稍侯......
精彩评论