如何将wavrecord转换为audiorecorder?

时间:2017-02-14 01:55:33

标签: matlab signal-processing

我的代码在最新版本的matlab中不再有效,因为不再使用wavrecord。我该如何转换它:

Fs=8000;

my_voice=wavrecord(3*Fs,Fs,'int16');

wavplay(myvoice,Fs);

现在可以在Matlab上运行吗?

1 个答案:

答案 0 :(得分:0)

守则:

<figure> <img src="http://img.loadedcamp.net/hfjfjd.jpg" /> </figure>
<p>This is the news and it is here.</p>
<figure> <img src="http://img.loadedcamp.net/YTgxbj.jpg" /> </figure>
<p>The new is posted by an author</p>

这将重现您在问题中发布的代码(类似于answer @Jørgen linked in the comments)。

以上代码的说明:

首先,让我们分解您的代码所做的事情。

my_voice = wavrecord(3*Fs, Fs, 'int16')记录以% Setup the recording object Fs = 8000; Nbits = 16; my_recorder = audiorecorder(Fs, Nbits, 1) % Record the audio record(my_recorder, 3); % Retrieve the sampled recording my_voice = getaudiodata(my_recorder); % Play the sampled recording play(my_voice); Hz采样的16位音频3秒。如果您未指定频道,则默认为Fs = 8000或1频道输入。

现在,您希望使用mono函数复制此行为。

audiorecorder(Fs, nBits, nChannels)创建一个audiorecorder()对象,以audiorecorder Hz的频率对nBits音频进行采样。

您想要录制16位音频,因此FsnBits = 16 Hz采样,并且由于您未使用Fs = 8000指定频道,因此您使用的是1声道音频输入,因此wavrecord()此处为nChannels1

您仍希望指定my_recorder = audiorecorder(8000,16,1)秒的录制时间。因此,您应该在3秒内记录my_recorder个对象的数据:3

为了检索采样音频:record(my_recorder, 3)