Category Archives: Music

The limits of Human Hearing II

Yesterday, we looked at sounds near the bottom of human hearing and found a lot of water. Today, we’ll look upwards. Who knows what elements we’ll find?

As you may recall, we started with a sine wave at 100Hz:

To me, this sounds almost like your canonical computer generated sound, something you might hear in a hearing test, or at the Science Center in the 1980s.

Let’s go up an octave to 200Hz:

Same kind of feel, a little higher, feels a little louder (probably again because of ‘equal-loudness contours‘).

Now, 400Hz:

This is starting to get into painful territory for me (at least through headphones).

800Hz:

This is starting to sound like an alarm.

Warning: We’re now getting into sounds that might start hurting or make your ears ring. I recommend that if you’re going to play these, that you play them at low volume first, and step them up in volume slowly.

1600Hz:

This is most definitely an alarm sound. About 2.5 octaves above middle C, it is above the normal soprano range, and therefore might reasonably be normally interpreted as an exclamation/scream, or alarm by early humans.

3200Hz:

An alarm, or medical beep.

6400Hz:

Many people would find this painful. I don’t think pitches this high are used for very much at all[1]. Probably only in movies to show a painful sound. (My right ear rang briefly after playing this sound.) It also sounds like we’re starting to reach the limitations of 44100Hz[2] sampling, as you will probably be able to hear the distortion in this clip.

12800Hz:

This is getting into the range of where humans might stop being able to hear things. It sounds (to me) like something out of place, or ear ringing (which is happening right now after playing it)[3].

25600Hz:

We’re now probably above what we can reproduce with 44,100Hz sampling. This sound seems to be inaudible at normal volumes, but when you turn it up, you’ll hear something very high-pitched, probably a lower (but still high) pitch caused by aliasing.

51200Hz:

We should not be able to hear anything here, due to it being above the sampling rate. I hear it as a loud sound a major third above the (quieter) 12800Hz .wav above. This suggests that the aliasing is producing a pitch of around 16,000Hz, which is about 1/3, or an octave and a fifth lower than the 51200 we attempted to make. (It still hurts, though.)

Next time, we’ll look at some different-shaped waveforms. Stay intuned!

[1]We’re talking about the fundamental frequency in a constellation of frequencies. I’m sure that 6400Hz occurs often, but there are generally lower pitches which it helps ‘fill out’.

[2]44,100Hz is one of the standard sampling rates, apparently chosen for Compact Discs by Sony in the Red Book standard. The article also mentions that 44,100 was chosen for Nyquist Sampling reasons to be >2x the commonly accepted threshold of human hearing (20kHz), plus a guard band for low-pass filtering. Also, for those of you who love prime factors and easy divisibility, 44100 = 2*2*3*3*5*5*7*7.

[3]Is it sympathetic? Is it because the ears or processing mechanisms are now expecting it? Are guarding against it?

The limits of Human Hearing I

Now that we’ve generated a .wav file from our sine wave, let’s take a look at some of the limitations of music as it’s written for the human ear[1].

We’ll start with the low end of human perception.

As you may recall, last time, we made a 100Hz sine wave:

This is near the bottom of what most humans can hear (and close to the bottom of what I can sing), but there’s still plenty of room to explore.

One octave down, we have 50Hz:

This is as low as I can comfortably hear (and sing!). Below this, for various reasons, things get much quieter[2] and more difficult to produce.

25Hz:

At normal volumes (halfway up on my laptop) sounds quite soft, but still audible. At louder volumes, it sounds like something you might hear in the 8-bit audio of a game from the early ’90s, perhaps in a dungeon to tell you something is oozing out of the wall.

12.5Hz:

To me, this is inaudible at normal volumes. At high volumes, it feels like what gargling would sound like in an 8-bit world.

6.25Hz:

At normal volumes, still inaudible. At high volumes, almost like water.

3.125Hz:

If the previous one sounded almost like water, this is the real deal. Still inaudible (as you would expect) at normal volumes.

1.0675Hz:

I totally did not expect to go this low in frequency. This sounds perhaps even more like water at high volumes. I wonder why all of these do. Maybe it’s some other effect unrelated to the actual frequency of the sinewave, perhaps waves (and water) do actually make sounds at such low frequencies, or those low frequencies make secondary effects/harmonics at high amplitudes.

Next time, we’ll look at the high end of human hearing. Stay tuned[3]!

[1]I’m leaving out discussion of making music to be felt by other parts of the body, although that is probably a large part of why dance clubs are so popular. We could also talk about different species, using devices, perhaps mediated human listening to music, but that is outside of scope.

[2]I had assumed it had to do with the amount of energy being transmitted being non-linear with the frequency, but apparently it has more to do with human hearing. ‘Equal-loudness contours‘ will show you the way.

[3]Hee.

If you wish to make a song from scratch, you must first Invent the Universe…

To write some music, you must first invent some instruments. To do this, one might start with a simple sine wave, then do modulations and superpositions to make various ‘instruments’.

To this end, I did a little bit of research (thanks, soledadpeandes!), and put/cribbed together some python code to make arbitrary .wav files:
# Written 2016-12-26, with special thanks to:
# https://soledadpenades.com/2009/10/29/fastest-way-to-generate-wav-files-in-python-using-the-wave-module/

import wave
import struct
import math

SAMPLING_RATE = 44100
WAV_FILE_LEN = SAMPLING_RATE * 1 # 44.1KHz sampling rate, 5 seconds
MAX_AMP = 32767
CORR_FACTOR = 10
SIN_WAV_FREQ = 100 * CORR_FACTOR # Sine wave frequency, in Hz*10 for some reason, 1000 gives 100Hz

output_file = wave.open('test.wav', 'w')
output_file.setparams((2, 2, 44100, 0, 'NONE', 'not compressed'))

for i in range (0,WAV_FILE_LEN):

data = MAX_AMP*math.sin(i*float(SIN_WAV_FREQ)/float(SAMPLING_RATE)/(math.pi/float(2)))
print data
packed_data = struct.pack('h', data)
output_file.writeframes(packed_data)
output_file.writeframes(packed_data)

output_file.close

For those who are curious, this generates a 100Hz sine wave: .

Next up, some experimentation with different pitches, perhaps different timbres. Stay tuned*!

*Also 100Hz.

Why the Headphone Jack Must Stay

Yesterday, we had a date night, and over dinner, we thought “Wouldn’t it be nice to watch Contact? Neither of us have seen it since it came out, almost 20 years ago.”

First, we opened up Netflix, and searched for ‘Contact’. It wasn’t available there, but Netflix said it could show us movies similar to it. (It also showed us ‘Star Trek: First Contact” as an option, more on that later.)

So, we try iTunes. We’re trying it on my computer, because S’s Mac has mysteriously stopped talking to our USB speakers. Fast-forwarding through the standard iTunes bad user experience[1], we eventually figure out how to rent ‘Contact’, the movie, in HD for $4.99. It starts downloading. We hook up the projector, start the movie, and we see the following screen:

This is what happens when you try to use iTunes with your projector.  (Not shown: Our USB speakers stopped working just then, too.)
This is what happens when you try to use iTunes with your projector. (Not shown: Our USB speakers stopped working just then, too.)

The movie that we just paid money to rent will not play on a display that iTunes was more than happy to play on just a couple of years ago.

Think about what just happened here. We went to the extra effort of purchasing a movie rental, and it is treating us like we’re trying to pirate it.

Doing some quick googling, we determine that we might be able to get the SD version to work with our setup, but iTunes won’t let us change from HD to SD (and keeps trying to download the HD version, despite the fact that this will overfill the hard drive).

So, back to Netflix. We eventually settle on Firefly (a really interesting concept, more on this in a later post). Netflix just works.

Or at least Netflix tries to work. Somewhere during this process, my Mac has silently decided that it should no longer talk to the USB speakers. There being no useful way to debug this in the ‘System Preferences’ menu, we end up lugging my sound system from my computer, which has a headphone jack connector like so:

Headphone jack to RCA adapter.  The best way to get sound from your computer to serious speakers.
Headphone jack to RCA adapter. The best way to get sound from your computer to serious speakers.

The headphone jack connect works. We finally start to relax, I start watching Firefly for the first time, then we watch the masterpiece which is Star Trek: First Contact, and go to sleep happy.

Apple has a lot of power, through its massive market share and avid user base. This power can be used for good, such as when it is used to push for selling DRM-free music, but it can also be used for evil, such as when Apple Music deletes music that you have composed.

With the iPhone 7, Apple is using this power to no longer include a standard headphone jack. Now all music, audio, Stripe payments, what have you, will be streamed digitally. It will probably work, it might even work perfectly and for a long time. But at some point, someone will decide to add DRM to that stream, and all of a sudden your music will stop working.

All because Apple decided to remove your headphone jack.

Cory Doctorow also has some thoughts about this.

[1]iTunes standard bad experience:
– You have to search twice in the search bar for it to actually search
– The search function has a pre-defined list of types of media, and it will always show them to you in that order. Compare with the Google search for ‘Contact’.
– If you start downloading a rented HD movie, you can’t switch to the SD version, even if you realize you don’t have enough hard drive space, or the HD movie won’t play because of the HDCP DRM.
– And don’t get me started on how slow it always is.

BoF III: Keybeards and Bagpopes:

S Writes:
“But see, if they play the pipes near other people, they’ll be arrested.”
“Arrested? By whom?”
“… by the Scottish bagpipe police?”
“Piffle! No such thing! In fact, there is a Scottish bagpipe brigade whose job it is to ensure that the pipes are played often and loudly. They must conform to the exacting standards set forth by the…”
(at this point, B blows up my pantleg, and I pause.)
“… Bagpope.”

“The Bag Pope?”

“Imagine the mass! Every parishioner plays the pipes, and the church has to be burned to the ground after every service.”
“Wait, why? Does it seep into the stones?”
“IT IS RUINED.”