Weeknotes 2024 W17: Irrational

April 22​–​28, 2024
2000 words

The job search is going much better lately, surprisingly. I’ll have good news to share soon, if all goes well.

I’ve only got a limited view on the entire market for software engineers, of course, but I’ve had plenty more conversations with recruiters lately. It’s picking up. This certainly is good for me and for everyone else looking for a job!


I can’t help but loathe coding challenges. I’ve been in full-time, hands-on roles for 13–14 years. My first paid software development gig was 16–17 years ago. I’ve been writing software for well over 20 years.1 I have proven myself over and over again, and I’ve got plenty of evidence I can produce.2

And yet, the dreaded code challenge is part of every single interview process in one way or another.


A few weeks ago, I noticed that the macOS alert sounds were about a semitone lower than usual. But not consistently so: more often than not, they’d be at the exact right pitch. Only the alerts were affected; other sounds (like music) would play just fine.

I initially thought it was just my imagination — perhaps I was tired? Then I thought that a recent macOS update had updated all the alert sounds to be a semitone-ish lower. That did not make much sense either: the drop felt more than a semitone, but not enough to be a full tone. Quite off-key!

By the time I was 100% convinced it was not in my mind, I tried finding out whether other people had the same experience, but bizarrely, nobody else was talking about this!

Then, one late night, it occurred to me that this could be caused by a bitrate mismatch. And sure enough, after changing the bitrate for my external speakers (an Audio Engine 2 pair) from 44.1 kHz to 48.0 kHz in Audio MIDI setup, the problem went away:3

Problem solved, right? Right. But I didn’t stop there.


The nerd in me wondered: exactly how large is the drop in pitch associated with a reduction from 48.0 kHz to 44.1 kHz? For this, I went into a bit of a rabbit hole. You’re following me now. Follow me into the rabbit hole. We’re going in.

First, a bit of music theory. An octave contains twelve semitones. Each octave corresponds with a doubling of the frequency, and so to move up a semitone, you multiply the frequency by 212\sqrt[12]{2}: 12 because there are 12 semitones in an octave, and 2 because going up an octave means doubling the frequency.4

For example, take A₄ with a frequency 440 Hz. Multiply that frequency by 212\sqrt[12]{2} and we get A♯₄ with a frequency of approximately 466.16 Hz.5

If we keep multiplying the frequency of A₄ by 212\sqrt[12]{2}, we’ll get a list of all frequencies:

  1. 440.00 Hz (A₄)
  2. 466.16 Hz (A♯₄)
  3. 493.88 Hz (B₄)
  4. 523.25 Hz (C₅)
  5. 554.37 Hz (C♯₅)
  6. 587.33 Hz (D₅)
  7. 622.25 Hz (C♯₅)
  8. 659.26 Hz (E₅)
  9. 698.46 Hz (F₅)
  10. 739.99 Hz (F♯₅)
  11. 783.99 Hz (G₅)
  12. 830.61 Hz (G♯₅)
  13. 880.00 Hz (A₅)

But what we are looking for is a little different. Above, we had the base frequency (440 Hz) and the number of (semi)tones in an octave. What we were looking for was the next frequency, ff:

212=f440\sqrt[12]{2} = \frac{f}{440}

What we are looking for now, though, is the value of rr makes the following equation true:

2r=21/r=4800044100\sqrt[r]{2} = 2^{1/r} = \frac{48000}{44100}

To solve for rr, first take the logarithm of both sides of the equation:

log(21/r)=log(4800044100)\log\left(2^{1/r}\right) = \log\left(\frac{48000}{44100}\right)

Now move 1/r1/r out of the logarithm:

1rlog(2)=log(4800044100)\frac{1}{r} \cdot \log\left(2\right) = \log\left(\frac{48000}{44100}\right)

Finally, isolate rr:

r=log(2)/log(4800044100)r = \log\left(2\right) / \log\left(\frac{48000}{44100}\right)

This yields a value of r8.17957r \approx 8.17957. We can plug this value (or its approximation) in the original formula to verify that this value of rr is correct:

4410021/r=4800044100 \cdot 2^{1/r} = 48000

What is left now, is to figure out the relationship between rr and 1212. In other words, how big is the drop in pitch between 4800048000 and 4410044100? The answer: 12/r12/r semitones, or approximately 1.471.47. Almost one and a half semitones, which is very well aligned with my guess at the beginning:6 more than a semitone; less than a full tone.

We’re done now, right? Problem solved, right? Right?! Right! But I didn’t stop there!


I wondered: could I build a tuning system based on rr? The answer is yes, of course. You might be wondering, rightfully, about the point of this. There is no point. This is just for fun. Aren’t we allowed to have fun anymore?!

Building the tuning system is straightforward once the value of rr is known. Just as we did with 12-TET above, we can start with a base frequency (A₄ at 440 Hz) and keep multiplying by 2r\sqrt[r]{2} to get all the frequencies in this new tuning system:

  1. 440.00 Hz
  2. 478.91 Hz
  3. 521.26 Hz
  4. 567.36 Hz
  5. 617.54 Hz
  6. 672.15 Hz
  7. 731.59 Hz
  8. 796.29 Hz
  9. 866.71 Hz
  10. 943.36 Hz

This tuning system is peculiar because the value of rr is not a rational number,7 let alone a natural number. As a result, all intervals are dissonant. There are no octaves anymore: there is a frequency of 440.00 Hz, but no frequency half or double that; 866.71 Hz is the closest to the next octave up (880.00 Hz), but it’s not quite the same.

In this tuning system, there can be no harmony. It’s awful (subjectively speaking). Nothing should ever be composed in this, and that is why I went ahead anyway and composed Happy Birthday in this bizarre, irrational tuning system. Shield your ears and press play:

Happy birthday to whoever’s birthday it is today. Hope you’re happy with my present.

Apart from the bizarre tuning system, it also doesn’t sound great because of the harsh sine waves. I rushed it; I did not spend a lot of time on making this sound nice and smooth.8

Tuning systems that deviate from 12-TET don’t inherently sound bad. A system built around a natural number like 17 or 19 as opposed to 12 can yield genuinely good music.9 Microtonal music will initially sound strange to western ears, but it’s just a matter of what we’re used to.

It is now time — finally — to move on from this topic.


I’ve made a handful of site improvements.


Fiction writing continues to be difficult.

The problem I’ve been particularly struggling with lately is finding the right words. My English is degrading. How do you say Haltestelle in English again? I don’t even speak German all that well!

Another problem is that I find that most stories don’t really seem worth telling. Most of the stories I start fleshing out, I abandon because they sound fake, boring, silly, trivial. Maybe this is a normal thing writers go through, and I just have to get over it.


Entertainment:


Links:

Entertainment links:

Tech links:


  1. The oldest piece of software I wrote that I can still find on the Internet dates back to 2003. ↩︎

  2. Nanoc has nearly one million downloads! ↩︎

  3. You might be wondering why I have so many audio devices. I don’t know! I only have one Yeti microphone, not four, I swear! ↩︎

  4. This assumes twelve-tone equal temperament (12-TET). Other systems exist, but this one is most commonly used nowadays. ↩︎

  5. Or B♭₄, which has an identical frequency in 12-TET↩︎

  6. Does this mean I have quasi-perfect pitch?! Sweet! ↩︎

  7. I haven’t verified this. It’s just a gut feeling, with 99% confidence, that rr is a non-rational real number. Send me your proofs↩︎

  8. “Did not spend a lot of time” is probably twisting the truth a little, given the entirely of this piece of writing. ↩︎

  9. As proof by example, check out the Christmas Microtonal Lo-Fi Hip Hop video by the venerable Adam Neely. ↩︎

  10. A good example of this is last week’s week­notes, where I might have gone a bit overboard with the sidenotes. ↩︎

  11. Ursula K. Le Guin, The Left Hand of Darkness (New York: Ace Books, 2019). ↩︎

  12. Robert W. Chambers, The King in Yellow (F. Tennyson Neely, 1895). ↩︎

  13. But stranger still is lost Carcosa. ↩︎

  14. Titanfall 2 (Respawn Entertainment, 2016), published by Electronic Arts. ↩︎

You can reply to this weeknotes entry by email. I’d love to hear your thoughts!
If you like what I write, stick your email address below and subscribe. I send out my weeknotes every Sunday morning. Alternatively, you can subscribe to the web feed.