I’ve always been amazed at the tunability of whistles, specifically my whistle (with my own lips). I used to stand in front of a mirror and try to see what I was doing with my muscles to be able to whistle up a whole octave. It’s interesting that there’s very little to see.

The frequency of a whistle is a function of air flow and orifice dimensions. Your own muscles control all of that and this post is about how quickly we can set those muscles to achieve a particular pitch.

So what did I do? First I played a random sine wave through my computer’s speakers with the following Mathematica code:

f = RandomReal[{700, 1400}];

pure = Play[Sin[2 \[Pi] f t], {t, 0, 2}]

This frequency was between 700 and 1400 Hz, which is where I felt I could comfortably whistle.

After listening to two seconds of that, I used this Mathematica code to record myself whistling:

` me = SystemDialogInput["RecordSound"]`

That brings up a dialog window with a record and stop button. The result is then brought into Mathematica and you can do all the math you want to on it. It’s pretty nice to be able to do all this in one program rather than using something else to record and then importing that into Mathematica. In fact, this summer one of my research students is going to see if we can replace our LabVIEW-based sound labs with Mathematica-based ones because we have a full site-license for Mathematica but only a 10-seat license for LabVIEW.

Here’s a plot of the sound (really a plot of the pressure at the microphone as a function of time):

The weird stuff at the beginning is an artifact of my crappy builit-in microphone on my laptop but all analysis started at 0.8 seconds or so.

What I wanted to determine was the instantaneous frequency of the whistle as a function of time. This meant having to do a discrete Fourier transform on small portions of the data. If you cut it too small, your frequency accuracy suffers. If you cut it too big, your timing accuracy suffers. Note that this is the plain-old uncertainty principle. It’s called the Heisenberg Uncertainty Principle in quantum mechanics but really it’s just one more application of wave theory to the new wave: matter.

I decided to go with about a tenth of a second. My frequency accuracy was then roughly 5Hz which isn’t too bad in this range given that the Just Noticeable Difference for most humans is something like 6Hz for the frequency of this whistle.

At each point in time, I found the peak of the Discrete Cosine Transform for the nearest 1000 data points (since my sampling frequency was 11025 or 1/4 that of a CD) and took that to be the instantaneous frequency at that point. Here’s a plot:

That’s pretty typical of the results I’ve seen. Here’s a worse one:

For both you can see an oscillatory behavior. I’m not really sure what to make of that but I wonder if it isn’t the telltale signal of a feedback loop.

I don’t think we could possibly have good enough muscle memory to just remember what to do with our lip and diaphragm muscles for every note we’ve ever whistled. Rather, I think we use feedback, listening to our own output and making small adjustments on the fly. I’d love it if someone with more understanding of this could chime in below in the comments.

Lastly, I wanted to see how easy it is to embed audio into this blog, so here are the playable files of both the pure frequency at 1236.16Hz and me whistling (note that I’m a little sharp but not too bad):

I’d like to see how you did the analysis with Mathematica, in addition to how you captured the data.

I love the explanation of the uncertainty principle in terms of wave theory. I hadn’t thought of that in ages, and, in fact, had completely forgotten about it. Thanks!

Hi Mark,

Here’s a screencast of how I did the analysis. I’ll put the nb up on dropbox soon too:

http://screencast.com/t/OTXK7UC4q

Regarding the Uncertainty principle, I spend a lot of time with my students showing them the mundane/non-quantum version of it. One was is to play a very short blast of two sine waves and ask them to figure out which one is higher pitched. If I increase the time of the blasts, they have a much better time figuring out who is higher pitched.

-Andy

cool stuff…my cousin saw this after I posted it on facebook and asked whether you were blowing out or sucking in when you whistled I didn’t know but I went to watch myself in the mirror and realized that I naturally switch from the former to the latter when going down the scale…blowing whistling is better for high notes and sucking whistling is better for low notes—for me anyway…

I almost always whistle out (like these examples), only whistling in when I need a breath. I actually find I can hit the high notes if I puff one cheek out. Weird, I know.

I was thinking you had a natural whistle vibrato…is a vibrato really just a feedback loop, hyperbolized?

I definitely wasn’t trying to do a vibrato. I think what you see in those curves is fast for one, anyways. I know vibratos are definitely done consciously with whistling and other instruments that I play.

Thanks for the comments!