转至:http://bbs.ednchina.com/BLOG_ARTICLE_222507.HTM

利用matlab的音频信号处理工具箱,可以实现声音的录制和播放。

 录音函数wavrecord语法为:


y=wavrecord(n,fs,channel,dataType);


其中


n为采样点数,fs为采样频率,channel(通常取1或者2)为录音通道数,dataType(例如double,single,int16,uint8)是采样点的数据类型。


例子:


fs=16000;           %取样频率


duration=2;         %录音时间


fprintf('Press any key to start %g seconds of recording...\n',duration);


pause;


fprintf('Recording...\n');


y=wavrecord(duration*fs,fs);         %duration*fs 是总的采样点数


fprintf('Finished recording.\n');


fprintf('Press any key to play the recording...\n');


pause;


wavplay(y,fs);


将上述代码保存为record01.m文件,在matlab命令行下输入刚才保存的文件名即可。

Logo

一站式虚拟内容创作平台,激发创意,赋能创作,进入R空间,遇见同道,让优质作品闪耀发光。​

更多推荐