Why can I still hear sound when the frequency of the periodic function inside Play is higher than the range of human ear?
We know that usually sound that is perceptible by humans has frequencies from about 20 Hz to 20,000 Hz, but as the title said, I can still hear the sound of the outputs of the following code:
(* The following sound won't cause discomfort… I think. *)
Play[Sin[1000000 2 Pi t], {t, 0, 1}, SampleRate -> 10000000]
After asking some of my friends to hear them, I'm sure I don't have clairaudience. I think it's probably not the fault of Mathematica, it might be an issue for loudspeaker, but I failed to find an answer by myself and I think it's worth posting a question for this.
Answer
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).
Comments
Post a Comment