MATLAB PC-Based Audio Functions

Contents

wavrecord

This example acquires a 3 second sample from microphone input

Fs = 8000;
y = wavrecord(3*Fs,Fs);

wavwrite and wavfinfo

This example writes a sound file. then investigates the file using wavfinfo

filename = 'wavdemo.wav';
wavwrite(y,Fs,filename);
[m d] = wavfinfo(filename);
disp(d);
Sound (WAV) file containing: 24000 samples in 1 channel(s)

wavread and wavplay

[data, freq] = wavread(filename);
wavplay(data,freq);

show waveform

t = [0:length(y)-1]/Fs;
plot(t,y);