A strange problem about audio play using MATLAB (Maybe a bug in MATLAB!)
7 views (last 30 days)
Show older comments
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'!
0 Comments
Accepted Answer
Daniel Shub
on 19 Jul 2011
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.
0 Comments
More Answers (3)
See Also
Categories
Find more on Audio and Video Data in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!