Why can I still hear sound when the frequency of the periodic function inside Play is higher than the range of human ear?

Just saying SampleRate -> 10000000 does not mean that the hardware is capable of playing samples at that rate. (Most modern devices can do 192 kHz; but it's likely you're running at 48 kHz.)

Mathematica or the OS or the sound driver or the hardware will resample the data to something that is supported. Depending on how well the resampling is implemented, the 1 MHz signal will either vanish or be folded back to a lower frequency.

To avoid resampling, you should use SampleRate -> 48000 (or any other rate supported by your hardware).


Along with the fact that the hardware is incapable of very high sampling rates (as described by CL), this is an example of a generic effect called aliasing that happens whenever the sampling frequency is less than half the frequency of the signal (this is called the Nyquist frequency). Here is a Wolfram Demonstration about this effect, and Wikipedia has a good article called aliasing. Here also is a previous Stack Exchange question that addresses the issue.


When I tried this once, I used:

Play[Sin[12000*2 Pi*t], {t, 0, 1}, SampleRate -> 44000]

which is near the top end for most adults. To annoy any teenagers in the same room, I tried:

Play[Sin[15000*2 Pi*t], {t, 0, 1}, SampleRate -> 44000]

and I know that worked, if only because I could hear the speaker starting and stopping.

Tags:

Sound