开发者

MATLAB audiorecorder and wavwrite [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜