2018/01/02

Matlab: record and play sound

To record sound with matlab, use audiorecorder() and getaudiodata()

In this example,
sample rate Fs = 8000
number of bits NBITS = 8
number of channels NCHANS = 1 = Mono

>> recorder = audiorecorder(8000,8,1);
>> record(recorder); //Say something
>> stop(recorder);
>> play(recorder);
>> data = getaudiodata(recorder, 'double');
>> sound(data, 8000);
>> plot([1:size(data)]/8000,data); %Plot waveform
>> xlabel('sec');

Waveform of Mandarin Chinese '1 2 3' (中文「一、二、三」的波形)

Reference:

McLoughlin, I. (2009). Applied speech and audio processing: with Matlab examples. Cambridge University Press. pp 7-10.

沒有留言:

張貼留言