Saturday, June 19, 2010

How to play raw PCM audio data in Matlab?

function record()
    Fs = 8000;
    nBits = 16;
    nChannels = 1;
    recorder = audiorecorder(Fs, nBits, nChannels);
    disp('Start speaking for 2 seconds');
    recordblocking(recorder, 2);
    disp('End of Recording.');
    audiodata = getaudiodata(recorder, 'uint8');
    player = audioplayer(audiodata, Fs);
    playblocking(player);

No comments: