在阅读website of MathWorks时,我了解到他们不鼓励使用wavrecord
函数,因为它很快就会被弃用,所以我决定使用audiorecorder
。一切都很好,即使播放功能也播放录制的音频,但当我使用wavwrite
函数写入wav文件时听起来不是很好,基本上我注意到持续时间设置不正确。
我正在展示该计划,请建议我如何使其正确。谢谢。
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);
答案 0 :(得分:0)
您正在创建recObj
两次,第二次创建它时,您使用默认设置而不是自定义设置创建它。删除对audiorecorder
的第二次调用,一切都应按预期工作。