MATLAB: A strange problem about audio play using MATLAB (Maybe a bug in MATLAB!)

audio player

I have record an audio segment from computer audio input port and save the audio segment with the .wav format. The sample rate is 44.1kHz and the length is 3'30". Then I downsampled the audio segment and make its sample rate 1000Hz using MATLAB, then saved the downsampled audio segment as .wav file using 'wavwrite' command in MATLAB. The downsampled audio file is 3'30" if played by Audition(an audio softwave),but if played by MATLAB command 'sound' or 'audioplayer',the time is just 3'!

Best Answer

The wav file format supports arbitrary sample rates. I think the sample rates must be positive integers less than 2^32, but 1000 Hz is a valid sample rate for a wav file. Audition reads the wav file header and therefore displays the correct duration. The reason your playback is wrong is that the soundcard does not support the sample rate. Most soundcards have a few native sample rates and then interpolate to get to the requested sample rate. In some cases, like yours, if the sample rate is too high or too low, the sound card chokes and behaves unpredictably (in your case dropping back to the default of 44.1kHz).
I would not recommend using any sample other than 44.1kHz. If you really want a different sample rate stick with something between 8192 Hz and 196 kHz.