Weeknotes 2024 W17: Irrational
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 : 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 and we get A♯₄ with a frequency of approximately 466.16 Hz.5
If we keep multiplying the frequency of A₄ by , we’ll get a list of all frequencies:
- 440.00 Hz (A₄)
- 466.16 Hz (A♯₄)
- 493.88 Hz (B₄)
- 523.25 Hz (C₅)
- 554.37 Hz (C♯₅)
- 587.33 Hz (D₅)
- 622.25 Hz (C♯₅)
- 659.26 Hz (E₅)
- 698.46 Hz (F₅)
- 739.99 Hz (F♯₅)
- 783.99 Hz (G₅)
- 830.61 Hz (G♯₅)
- 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, :
What we are looking for now, though, is the value of makes the following equation true:
To solve for , first take the logarithm of both sides of the equation:
Now move out of the logarithm:
Finally, isolate :
This yields a value of . We can plug this value (or its approximation) in the original formula to verify that this value of is correct:
What is left now, is to figure out the relationship between and . In other words, how big is the drop in pitch between and ? The answer: semitones, or approximately . 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 ? 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 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 to get all the frequencies in this new tuning system:
- 440.00 Hz
- 478.91 Hz
- 521.26 Hz
- 567.36 Hz
- 617.54 Hz
- 672.15 Hz
- 731.59 Hz
- 796.29 Hz
- 866.71 Hz
- 943.36 Hz
This tuning system is peculiar because the value of 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.
-
I added KaTeX integration for mathematical formulas. I needed them — see above! I tried sticking to MathML, but support is not great: MathML renders rather badly in all mainstream browsers (Chrome, Safari, and Firefox).
The Atom feeds use MathML (rendered by KaTeX), which doesn’t look as nice, but at least does not break the feeds.
-
When you now hover over a sidenote reference, the corresponding sidenote is highlighted. This is especially useful for sidenote-heavy notes.10
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:
-
I am probably supposed to like The Left Hand Of Darkness,11 but I find it tedious. There is so much world-building exposition that to me stands in the way of story.
-
I’ve been re-reading Robert W. Chambers’ horror stories in The King In Yellow12 and I’m still impressed by them. The writing style is peculiar: a vibrant, saturated horror of sorts, which no other writer has replicated. What’s strange13 is that Chambers published only four horror short stories in his lifetime, despite being so good at writing them.
-
I replayed Titanfall 2.14 I enjoyed it quite a bit more than in my first playthrough. It’s short but good.
Links:
-
Capitalists Hate Capitalism (Cory Doctorow for Locus magazine): Interesting! This is the first time I’ve seen so clear the distinction between rent and profit.
-
FTC Announces Rule Banning Noncompetes: Huge! Non-compete agreement stifle innovation and harm workers. (This does not affect me directly as I’m not based in the US, but still big news!)
-
When cycling is ‘normalized but marginalized’ (Shifter): This is a good description of what it feels like to cycle in Berlin. Biking is normal here, but it’s very much a second-rate means of transport.
Entertainment links:
-
Reality is Analog: Philosophizing with Stranger Things (J. F. Martel)
-
The Phantom Island of Google Maps (
Map MenMap Man) -
The Dragon Paradox (Curious Archive)
Tech links:
-
Making a flute controlled mouse (Joren Six): I love this nonsense.
-
Ruby might be faster than you think (John Hawthorn): Insightful! I’ve done some Ruby optimization in the past, but this is the first time I’ve seen a discussion of Ruby’s multiple assignment.
-
The Big Sur-ification of macOS Icons (Jim Nielsen)
-
The Bubble Sort Curve (Lines That Connect): I had seen this curve before, and wondered whether it was just a fluke. Turns out it’s not!
-
The oldest piece of software I wrote that I can still find on the Internet dates back to 2003. ↩︎
-
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! ↩︎
-
This assumes twelve-tone equal temperament (12-TET). Other systems exist, but this one is most commonly used nowadays. ↩︎
-
Or B♭₄, which has an identical frequency in 12-TET. ↩︎
-
Does this mean I have quasi-perfect pitch?! Sweet! ↩︎
-
I haven’t verified this. It’s just a gut feeling, with 99% confidence, that is a non-rational real number. Send me your proofs! ↩︎
-
“Did not spend a lot of time” is probably twisting the truth a little, given the entirely of this piece of writing. ↩︎
-
As proof by example, check out the Christmas Microtonal Lo-Fi Hip Hop video by the venerable Adam Neely. ↩︎
-
A good example of this is last week’s weeknotes, where I might have gone a bit overboard with the sidenotes. ↩︎
-
Ursula K. Le Guin, The Left Hand of Darkness (New York: Ace Books, 2019). ↩︎
-
Robert W. Chambers, The King in Yellow (F. Tennyson Neely, 1895). ↩︎
-
But stranger still is lost Carcosa. ↩︎
-
Titanfall 2 (Respawn Entertainment, 2016), published by Electronic Arts. ↩︎