What is the maximum sample rate supported by sound() ?

41 views (last 30 days)
I have a set of software produced for the purpose of demonstrating sigma-delta digital-to-analog conversion as used by audio CDs. Everything works fine until it tries to play the signal resampled at 32 Fs (32*8000 = 256,000). Then it gives out the following error:
Error using sound (line 76) Device Error: Invalid sample rate
Error in soundsc (line 53) sound(varargin{:})
The command was: soundsc(analog_output,256000) where: analog_output is a 1x32,485 vector of sound samples ranging from -1.5145 to 1.5151 The only limit I have been able to find are in audio player.m where: MinimumSampleRate = 80 MaximumSampleRate = 1e6 are specified. 256,000 should be in those bounds. Am I hitting a hardware or API limit on the Macintosh? If so, how do I find that limit other than trial and error (128,000 works)

Accepted Answer

Star Strider
Star Strider on 1 Apr 2015
See the documentation on audiodevinfo.
It depends on your audio card. See for example Windows: How to determine your audio card's, or USB mic's, maximum sampling rate. For a Mac, I suggest a DuckDuckGo search on ‘sound card maximum sampling rate macintosh’ to see how to determine that.
  2 Comments
Kip Haggerty
Kip Haggerty on 1 Apr 2015
Thanks Star Strider. Unfortunately, the info seems well hidden. From your suggestions, I did learn that the utility Audio MIDI Setup does change the output sampling rate and bit depth. Output functions at 44.1, 48, and 96 kHz. Therefore, anything above that is sample rate converted before it makes its noise. I also learned that the driver is Core Audio (I already knew that). What Matlab does not seem to report back is the limits it will apply before sending the data to Core Audio or in other words, its error checking limits. Trial and Error pegs that at 200 kHz and not one Hz higher. So, in playing with DAC sampling rates in Matlab, the SNR calculations are correct, but playing the audio of that signal is mostly about its duration (shorter for faster sampling) and not sound quality because the computer down samples the audio to its setting anyway. Ironically, the Matlab code is from pedagogy on Sigma-Delta DACs for CDs.
Star Strider
Star Strider on 2 Apr 2015
My pleasure. I also found it difficult to get the same information on my sound card when I tried it (Win 8.1 here). It never occurred to me to consider those limits before you raised them in your Question.

Sign in to comment.

More Answers (1)

nasir
nasir on 10 Mar 2017
Sample rate, in hertz, of audio data y, is specified as a positive number from 1000 through 384000. Valid values depend on both the sample rates permitted by MATLAB® and the specific audio hardware on your system. MATLAB has a hard restriction of 1000 Hz <= Fs <= 384000 Hz, although further hardware-dependent restrictions apply.

Categories

Find more on Audio I/O and Waveform Generation 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!