MATLAB audiorecorder和wavwrite

时间:2011-10-08 14:13:53

标签: matlab audio signal-processing

在阅读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);

1 个答案:

答案 0 :(得分:0)

您正在创建recObj两次,第二次创建它时,您使用默认设置而不是自定义设置创建它。删除对audiorecorder的第二次调用,一切都应按预期工作。