Sunday, 28 October 2018

Human Hearing Frequency Range Test


The other day I came across an article on human hearing which sparked my curiosity on what my audible frequency range was.

Human ear can usually detect sounds ranging from frequencies from 20Hz to 20KHz. However, as we grow up, the auditory organ loses capabilities and the dynamic range gets narrower. I wondered what my current dynamic range was, and I wrote this simple Python script to test it.

The script makes use of PyAudio, a Python Package which gives us access to the sound card. The code saves a number of num_samples of sound samples into a NumPy matrix. Each sample is generated from a sinusoidal signal of a different frequency, specified in the frequencies list. 

Once the different waves have been saved, each frequency in a row of the matrix waves, we play the sounds by writing into the stream object created from PyAudio module.

The script starts by playing a sinusoidal sound of 5Hz, and increases step by step the frequency of the samples. Each frequency is played for 5secs. In my case, I start hearing sounds after the 20Hz tone. As the frequency increases beyond the 20Hz, even if the intensity is kept constant in the script, my ear response to the different frequencies is not the same, giving us the illusion of a different intensity for each tone. After the 14KHz barrier, I was unable to hear any signal.

If you have pets around, try to test this scripts by increasing the frequency beyond the 22KHz. Observe however that if you increase the frequency beyond 22KHz, you should increase as well the sample rate, to satisfy the requirements imposed by Nyquist sampling theorem.



No comments:

Post a comment