HNHacker News
TopNewBestAskShowJobs

strenholme

1,682 karma · joined March 5, 2019

Single parent. Electronic musician. Lua and open source developer. https://samboy.github.io/ — https://github.com/samboy

  #include<stdio.h>//RadioGatun
  #include<stdint.h>/*32-bit\*/
  #define b(z) for(c=0;c<z;c++)
  uint32_t c,e[42],f[42],g=19,h
  =13,n[45],i,j,k;void m(){j=0;
  b(12)f[c+c%3*h]^=e[c+1];b(g){
  i=c*7%g;k=e[i++];k^=e[i%g]|~e
  [(i+1)%g];j=j+c;n[c]=n[c+g]=k
  >>j%32|k<<-j%32;}for(i=39;i--
  ;f[i+1]=f[i])e[i]=n[i]^n[i+1]
  ^n[i+4];b(3)e[c+h]^=f[c*h]=f[
  c*h+h];*e^=1;}int main(int c,
  char**v){char*q=v[--c];for(;;
  m()){b(3){for(j=0;j<4;){f[c*h
  ]^=k=(*q?255&*q:1)<<8*j++;e[c
  +16]^=k;if(!*q++){b(18)m();b(
  8){j=c;b(4)printf("%02x",(e[1
  +j%2]>>8*c)&255);c=j;if(c%2)m
  ();}return 0&puts("");}}}}}//
submissionscomments
strenholme··on AMD's random number generator can't generate a 0?
Yes, /dev/(u)random is supposed to do that, but what if there’s a bug in a kernel (e.g. some embedded system which may not even be running Linux) which causes /dev/(u)ramdom to be less than secure? There’s also issues where, for example, it may no longer be possible to read /dev/(u)random after putting the process in a chroot() sandbox (chroot() isn’t defined in POSIX so its behavior is not guaranteed to be consistent across multiple operating systems).

getrandom() is often times suggested, but alas isn’t a standardized function, i.e. it’s not part of the POSIX specification. Considering how the C23 changes to the C specification caused a lot of perfectly good C code to no longer compile, I’m very anal about sticking to specs; I use '-std=C99' for my code these days (even though it can compile as C23 code) and stick to POSIX functions (except chroot() and setgroups(), but both of those predate POSIX, and even here I have a compile-time option to compile my code without those non-POSIX syscalls).

The code using a secure XOF (the algorithm was developed by the same team which later on made SHA-3, and includes people who helped make AES) has been around for nearly two decades (the code where I roll my own RNG to make secure random numbers has been around for over 25 years, but used AES before XOFs existed) and not one security problem has found with the RNG code has ever been found. [1] “Don’t roll your own RNG” is a suggestion, but it is possible to do so securely if one knows what they are doing (i.e. they have read Applied Cryptography and keep current with cryptographic developments).

For anything vibe coded (my code is 100% human written, for the record), rolling one’s own RNG is a really bad idea.

[1] There was a theoretical issue with cache timing attacks over two decades ago, so I put mitigations in place, and then chose to use an XOF for newer code.

[2] There was an issue where a separate implementation I made of this XOF would generate incorrect test vectors in clang, but only at some optimization levels. I now test the XOF in both GCC and clang at multiple optimization levels to make sure it acts correctly.

strenholme··on AMD's random number generator can't generate a 0?
This is why I use, in security critical contents of my software (where the numbers have to be computationally infeasible to produce), a type of random number generator called an XOF (extendable-output function).

It takes entropy from multiple different sources, makes it all input to the XOF, then the XOF uses cryptography to output a stream that has as much entropy as the combined entropy of all of its sources of randomness. So if an XOF, for example, takes 100 runs of rdrand16, along with the system time in microseconds and the number of milliseconds between receiving 100 packets over the network, the XOF will output a completely random stream without artifacts like never returning 0x0000, even if rdrand16 never outputs 0x0000.

strenholme··on What Sun got wrong
Back in 2010, Linux in fact had Zones: It was called OpenVZ, and by early 2011 a bunch of tiny web hosting providers were giving people root on OpenVZ Linux virtual servers for $15 a year. I still have two KVM Linux virtual servers which cost me only about $40 a year.
strenholme··on What Sun got wrong
Here is my experience with Sun and why they failed in the 00s: Linux

The only way you could get people with Solaris experience was to hire people from colleges where students had access to expensive hard to access servers. This limited the number of people a company could hire to handle their Solaris servers.

I remember being told by the now forgotten snap.com—back when snap.com was a web portal business owned by NBC (these days it’s owned by Snapchat but is a completely different company)—to pound sand because I had Linux but not Solaris experience. There was a certain elitism among Solaris users at the time that Linux was a toy operating system. [1]

I already knew that wasn’t true; I remember, before the height of the dot-com wave, installing Linux on my desktop PC at work because the Sun servers we logged in to to run X applications were overloaded and difficult to access, so I just had a local instance of Slackware (and later on RedHat) so I could run X applications locally and just telnet in to the Sun servers, which was a good deal faster.

A few years after my unpleasant experience being interviewed by the NBC portal incarnation of snap.com, I saw that the company folded and went under—which didn’t surprise me because they weren’t being economical about the servers they were running. The company I was at was running a couple of Dell RedHat Linux servers, which kept us on the Internet cheaply and reliably.

It didn’t surprise me that Linux soon overtook Solaris and ate them for breakfast.

[1] Bryan Cantrill—the person who wrote the blog this thread is about—infamously said “Have you ever kissed a girl” to a Linux Kernel developer who explained why Linux was more efficient that Solaris on Sparc (and was easier to get support for); this is the prime example of the snobbishness Sun users had at the time.

[2] https://landley.net/history/mirror/linux/kissedagirl.html

strenholme··on UTF-8000: Unlimited UTF-8
Another extension to this encoding: If we have an 0b11xx_xxxx byte which isn’t proceeded by a 0b10xx_xxxx byte, the numeric value of the byte is its corresponding codepoint. This gives us all of the accented letters western European languages use, allowing us to represent all of ASCII and all western European letters with only one byte.

This also means that the top half of ISO 8859-1 will have two representations with this encoding, but since they are letters, with the only symbols being × (multiplication) and ÷ (division), this should not be a security risk, unless one programs in Raku (which, ugh, gives meta significance to non-ASCII Unicode symbols).

strenholme··on UTF-8000: Unlimited UTF-8
Actually, my proposed encoding only needs to add 64 to the code point (or subtract 64 when encoding a code point), not 128. That in mind, ♥ is encoded as follows:

♥ → 0b0010_0110_0110_0101 → 0b0010_0110_0010_0101 (subtract 64) → 0b10_00_0010 0b10_0110_00 0b11_10_0101

Code point 128 is encoded as follows:

128 → 0b1000_0000 → 0b0100_0000 (subtract 64) → 0b10_0000_01 0b11_00_0000

C99 can do up to over 10 bytes long (uint64_t) without a bignum library since 10 bytes gives us 60 bits. C23 gives us a bignum library so the sky’s the limit.

Again, I only need 7 bits to represent every character the font for my blog has.

strenholme··on UTF-8000: Unlimited UTF-8
“completely new backwards-incompatible standards”

A reasonable person would assume you’re talking about UTF-8000. It’s not completely new: RFC2279, the original UTF-8 proposal, worked exactly like UTF-8000 for codepoints 31 bits or smaller in size. It’s not backwards-incompatible: UTF-8000 is exactly like UTF-8 for 1, 2, and 3-byte long codepoints, and like UTF-8 codepoints for 4-byte long codepoints with a value of 0x10_ffff or smaller (so all UTF-8 codepoints encoded with the first byte being 0b1111_00xx or starting with the bytes 0b1111_0100 0b1000_xxxx).

It’s a backwards compatible way of encoding numbers in UTF-8 larger than 0x10_ffff or (0x7fff_ffff with the original RFC2279 proposal).

I agree that C isn’t the best language to start a new programming project in. There are things I don’t like about Rust, mainly that there’s only one implementation of it, but if I were to start a new project needing the speed of a system programming language, it makes a lot of sense.

strenholme··on UTF-8000: Unlimited UTF-8
I agree C has a lot of problems. The nice thing about C is that it’s a rigorous standard (C90, C99, C23, etc.) with multiple actively maintained implementations (GCC, LLVM/clang, TCC, etc.) so standards compliant C code should (in theory) compile and run for the foreseeable future.

Python, Rust, Perl, etc. are all languages with a single actively maintained implementation and haven’t had the rigorous standardization C and POSIX utilities (Awk, /bin/sh, sed, etc.) have had.

strenholme··on UTF-8000: Unlimited UTF-8
That’s a pretty harsh comparison.

It’s a fairly simple encoding which is UTF-8 compatible and allows codepoints to be arbitrarily large. It’s a real encoding proposal with a simple rigorous specification. I don’t have a use case for needing arbitrarily large codepoints, but for people who do, this makes more sense than hacks such as having surrogates in Unicode’s hi-bit private use area.

strenholme··on UTF-8000: Unlimited UTF-8
I have entertained ideas like this every since becoming familiar with the original RFC2279 UTF-8 well over two decades ago, before UTF-8 was subsequently restricted to 21 bits.

Another idea that would work is to start an encoding with 0b10xxxxxx have subsequent 0b10xxxxxx bytes continue the encoding, and end it with 11xxxxxx. 0b1000_0000 (i.e. 128) is not allowed for the first byte of this sequence, and we add 127 to the resulting number (so each code point has only one representation) This way, the ♥ symbol (that’s 0x2665 or 9829 in decimal) would be represented as follows:

♥ → 0b0010_0110_0110_0101 → 0b0010_0101_1110_0110 (subtract 127) → 0b10_00_0010 0b10_0101_11 0b11_10_0110

This allows 18 bits to be encoded in three bytes, and, like UTF-8000, allows arbitrarily long sequences.

In the real world, the last time I needed to have a custom encoding, I went the other way and converted Unicode in to a 7-bit ASCII compatible encoding, where most ASCII control characters were converted into glyphs, as follows:

    0123456789abcdef
  0 .ÁÉÍÑÓÚÜ¡..—..«»
  1 •áéíñóúü¿‘’.→“”©
  2 .!"#$%&'()*+,-./
  3 0123456789:;<=>?
  4 @ABCDEFGHIJKLMNO
  5 PQRSTUVWXYZ[\]^_
  6 `abcdefghijklmno
  7 pqrstuvwxyz{|}~♥
The reason for this encoding is that it allows me to write stuff in languages I am actually fluent in (English and Spanish), and adds a handful of useful non-ASCII punctuation (smart quotes, etc.).

“.” represents a control character here; only “null” (0x00), “line feed” (0x0a), “form feed” (0x0c), “tab” (0x09), “carriage return” (0x0d), and “escape” (0x1b) are control characters; the rest are printable glyphs. I used this character set for my blog, since my blog is processed using HTMLDOC (which I learned the hard way is buggy with full Unicode) and my own Lua script.

With Lua, Unicode regexes are not readily supported because its regular expression engine assumes a codepoint is only one byte long when forming character classes such as %u for upper case letters. My Lua code has character classes for the non-ASCII glyphs such as %t for all letters in this custom encoding.

I have made this encoding 7 bits because that gives me the option to use the eight bit for future expansion.

The real reason for so few glyphs is because, in addition to having things work nicely with code which assumes 8-bit codepoints, with the modern web, I need to send to the viewer the font a page will be rendered with (it would had been nice if Microsoft had open sourced Verdana, Georgia, and the rest of the core fonts, and had those fonts became a part of the browser standards, so we could have cross-platform font stacks, but oh well) [1], so I aggressively subset the font to minimize the page load time.

[1] I still wish for the day when Apple, Google, Microsoft, and Mozilla come together, decide to include “Noto” and “Noto Serif” with their browsers, so “font-family: Noto (Serif)” always renders the exact same font without having to download a font over the network when loading a web page.

strenholme··on Music Theory for the 21st-Century Classroom
I don’t think anyone said anything about having only three hours to learn music theory. First principles should be taught to computer programmers, who have the needed math (e.g. knowing what a square root is) to understand music from that perspective.

More discussion: https://news.ycombinator.com/item?id=49541888

strenholme··on Music Theory for the 21st-Century Classroom
Yeah, I think a good discussion on music theory is starting from first principles, explaining Pythagorean tuning, then explaining 5-limit just intonation, the explaining we compromised on 12-tone equal temperament because it made tuning and changing keys a lot simpler, at the expenses of some notes being slightly out of tune (e.g. the minor and major thirds deviate by about 15 cents from their 5-limit just intonated “ideal” tunings).
strenholme··on Music Theory for the 21st-Century Classroom
Yeah, that guy tried to argue that Grade 5 ABRSM [1] is “very basic”. Like, excuse me no. “Very basic” is knowing the notes in a major key, and knowing the I IV V chord progression, as well as a basic 4/4 rhythm (8th note hi hats, quarter note kick drum, snare on alternating quarter notes).

I IV V chord progressions and major scales are basic enough I can explain them in a 400 word post from first principles (where no music theory exists except the assertion that the human ear finds the pitch ratios of 2/1, 3/2, 4/3, 5/4, and 6/5 pleasing to the ear, that the human ear wants at least three notes in a chord, and that the human ear wants at least three chords in a progression).

Those books get very complicated very quickly, and cover music that only a relatively few people actually listen to. It was pure gatekeeping, and I’m disappointed people pointing that out were voted down. Not a good moment for Hacker News. It would be like me recommending Lisp or Forth for one’s first programming language.

[1] https://www.abrsm.org/sites/default/files/2023-09/music-theo...

strenholme··on Music Theory for the 21st-Century Classroom
We recently had a long discussion about this. I come from the “music theory makes a lot more sense once one understands that 2:1, 3:2, 4:3 sound really whole and good to the human ear, 5:4 has a little more tension, and 6:5 has even more tension” school of thought [1] but for other people it is a distraction from understanding basic stuff like “this is a minor scale”. See here for the long discussion: https://news.ycombinator.com/item?id=49541888

[1] I understand ancient scales were 3-limit instead of 5-limit scales, and that modern equal temperament has thirds which significantly deviate from 5:4 and 6:5, but once polyphony became a thing, 5-limit temperament made a lot more sense because they reduce beating.

strenholme··on Stockfish 19
Here is what I see typing this is Stockfish 18 and Stockfish 19:

  position fen 1b3r2/8/4P3/2pP2k1/3nB2p/3P3P/5PP1/5KRR b - - 0 1
  d
  go depth 35
In Stockfish 18: Black is 3.9 pawns ahead, and it wants to play Bg3

In Stockfish 19: Black is 1.2 pawns ahead, and it wants to play Rxf2!

So, yes, here Stockfish 18 can’t find Rxf2!, but Stockfish 19 does starting at depth 13.

strenholme··on Stockfish 19
Click on the switch to the left of the evaluation to run a local Stockfish 19 eval of the position.

Showing Black winning in that position is clearly a bug; at 20 ply Stockfish 19 sees a +0.3 edge for White (which is also wrong; it’s about +5 for White, i.e. clearly winning) and only a +0.6 edge at 24 ply.

To be fair, Topalov, right after this game (1999, so before modern computer analysis), analyzed the game for hours with his second and thought Black still had strong drawing chances after accepting the rook sacrifice.

strenholme··on Stockfish 19
Alpha Zero Chess never made their code or models public. Leela is based on the same ideas as Alpha Zero Chess, but its model and code are public and uses crowd sourcing to generate and refine the model.

Stockfish uses a combination of classic Alpha-Beta pruning along with a type of AI called NNUE to evaluate positions.

strenholme··on Stockfish 19
Interesting bug or regression.

Let’s take the very famous game Kasparov - Topalov, Wijk aan Zee 1999 and look at the position just after Topalov accepts Kasparov’s Rook Sacrifice:

https://samboy.github.io/blog/Kasparov.html#RookSacAccepted - https://lichess.org/lwiPq9wB#48 - White to move

FEN: b2r3r/k4p1p/p2q1np1/Np1P4/3p1Q2/P4PPB/1PP4P/1K2R3 w - - 0 25

Run the above position in Stockfish 18 with a depth of 25: [1] It shows that White is 3.53 pawns ahead—i.e. White is clearly winning.

Run the above position in Stockfish 19, however, and Stockfish 19 at depth 25 says that, while White is ahead, it’s only a 1.2 pawn edge—Black supposedly still has good drawing chances.

At a depth of 35 ply, Stockfish 19 sees that it’s a clear White victory (6.79 pawns ahead), but it takes far deeper search for Stockfish 19 to see the win compared to Stockfish 18.

[1] To run the position, I type the following commands:

  position fen b2r3r/k4p1p/p2q1np1/Np1P4/3p1Q2/P4PPB/1PP4P/1K2R3 w - - 0 25
  d
  go depth 25
I also see the issue on Lichess’s GUI by going to this URL:

https://lichess.org/lwiPq9wB#48

strenholme··on Hang on to Your Firefox
Here’s that sentence in context:

>>>People know that ICE is bad, that law enforcement has a troubled history in this country. Yet when they see Democratic electeds treat riots with kid gloves, they’ll support an authoritarian right over the specter of anarchy and chaos.<<<

As per https://www.npr.org/2026/02/05/nx-s1-5699413/poll-trump-ice-... 60% of Americans don’t approve of ICE, so “people know that ICE is bad” is a reasonable summary of public opinion.

strenholme··on I've factored the RSA keys of a Certificate Authority from the 90s
In addition to the overhead of a /dev/urandom read(), since my programs run in a chroot() sandbox, there’s the possibility that the file descriptor to /dev/urandom will no longer function—since chroot() is not part of POSIX, there’s no rigorous standard on how chroot() is supposed to behave with a given operating system.

getrandom() is another possible solution, but the problem with getrandom() is that it’s also not part of the POSIX spec, and my program needs to compile in an anally POSIX compliant system: While my programs use chroot() and setgroups(), both of which aren’t part of the POSIX spec, it has a configure time option to disable both chroot() and setgroups() so everything will compile as long as the underlying system follows POSIX.

The reason for this strict compliance with POSIX is because the changes to the C compilers (gcc and clang) between 2022 and 2026 made previous versions of MaraDNS have issues compiling everything, and, indeed, with these C23 changes to C compilers, unpatched djbdns no longer even compiles with a modern compiler. I changed everything to work with the new C23 spec, then I changed the compile flags to compile with a strictly compliant C99 compiler, but to get that to work, I had to make the program strictly POSIX compliant (with the exceptions of chroot() and setgroups()).

This way, should MaraDNS not compile in the future (remember: The post-C23 changes broke a lot of programs that used to compile just fine), it’s a bug with the compiler not following C99 and/or POSIX, and not a bug with MaraDNS.

Hence, my homegrown secure pseudo random number generator, so I can make strong random numbers while remaining POSIX compliant (we seed the PRNG before entering the chroot() sandbox). Of course, /dev/urandom is also not part of POSIX, but it’s on pretty much any modern *NIX, and trying to open /dev/urandom is not going to raise compile-time errors.

strenholme··on I've factored the RSA keys of a Certificate Authority from the 90s
Linux kernel crypto code has resulted in security issues, e.g. CVE-2026-31431.

The advantage of using a cryptographically secure stream cipher [1] is that we only need about 128-256 bits of good entropy to generate an arbitrary large number of secure random numbers, across multiple systems (e.g. MaraDNS has a native Windows port where /dev/urandom randomness is instead done with proprietary Windows API calls). It can even give us some level of protection on systems where the OS level random API is compromised: Some people are wary of RDRAND because they think Intel might actually use an insecure PRNG for the numbers, and Coldcard Bitcoin seed generators were compromised a little over a month ago because their version of /dev/urandom was completely insecure on some of their devices.

[1] Yes, libsodium supports them: https://libsodium.gitbook.io/doc/advanced/stream_ciphers

strenholme··on I've factored the RSA keys of a Certificate Authority from the 90s
“Rolling your own crypto libraries is always a bad idea”

Absolutes like this aren’t absolutely true.

It’s interesting because in a related comment, someone claimed that I was “rolling my own crypto” https://news.ycombinator.com/item?id=37368245

>>>a few odd coding decisions, such as rolling your own crypto (RNG)<<<

Let me give some context here. MaraDNS is a DNS server that’s been around for a very long time, since 2001. There has never been, in those 25 years, any security holes found having to do with the RNG code used by MaraDNS. MaraDNS originally used an AES variant for the RNG; when DJB found cache timing attacks a little over two decades ago, I revised the AES-based RNG code to minimize the impact of such impacts, making the code slower and more complicated. So, about two decades ago, I implemented a new RNG based on RadioGatún, an algorithm which isn’t vulnerable to cache timing attacks and, indeed, has no known attacks which break its cryptographic claims, even though those claims were made over two decades ago.

My code has been extensively audited by multiple AI-based security researchers, and while they found two minor issues with the DNS-over-TCP code in the recursive resolver, and a minor issue with the RFC8482 reply in the recursive resolver, no issues have ever been found with the RNG code in MaraDNS (except the issue with possible cache timing attacks I fixed myself after learning about them). [1]

In the same time period, OpenSSL has had a large number of security issues, security advisories, and so on. OpenSSL has had countless security holes and patches in the last two decades (Heartbleed, etc.); MaraDNS has had precisely 0 known issues with its RNG code in the same time period. If I had relied on OpenSSL to keep MaraDNS’s cryptography secure, it would had been exposed to many more attacks than it has, since the code I rolled myself ended up being far more secure than using the code in a third party library.

Point being, it is possible for someone to roll their own secure RNG. I wouldn’t do so in a corporate context, for the simple reason management often times puts unreasonable time constraints on developers, but for an open source project developed on my own timeline, it can be, in fact it has been very secure.

Also: I was never exposed to the Lastpass breach because, instead of using Lastpass, I rolled my own secure website password generator. [2]

[1] https://samboy.github.io/MaraDNS/webpage/security.html

[2] https://github.com/samboy/PassGen

strenholme··on Music Theory for Programmers
Talking to myself, some research here.

https://www.medieval.org/emfaq/harmony/pyth5.html

>>>Around 1300, the English theorist Walter Odington proposes that major and minor thirds (81:64, 32:27) have ratios close to 5:4 and 6:5 respectively, and that singers lean toward these simpler ratios. His observation may reflect the style of much English polyphony of the period, where thirds often have a pervasive role in the texture and may even serve as closing sonorities.<<<

https://casfaculty.case.edu/ross-duffin/just-intonation-in-r...

>>>Beginning with Ramos de Pareja in 1482,Fn11 the simple ratios of Just intonation began to be cited by theorists and used in their divisions of the monochord. [...] an octave is 2:1, a fifth is 3:2, a fourth is 4:3, a pure major third is 5:4, a pure minor third is 6:5. These “six-limit” ratios—the senarius, or senario, as Zarlino calls them—are the basic harmonic intervals. Zarlino attributed almost mystical significance to the senario<<<

https://en.wikipedia.org/wiki/Gioseffo_Zarlino

https://journals.sagepub.com/doi/10.1177/000313131706700215?...

This article is paywalled, but to summarize, it makes the case that the 5:4 and 6:5 ratios are ratios musicians naturally drift towards in polyphonic contexts.

strenholme··on Music Theory for Programmers
It’s actually an open question of whether “natural” tuning is 3-limit or 5-limit tuning. Five limit tuning, which I discuss above and use to form a major scale, goes back to Ptolemy: https://en.wikipedia.org/wiki/Ptolemy's_intense_diatonic_sca...

Other ancient tuning systems are based on three limit tuning:

https://en.wikipedia.org/wiki/Shi%27er_l%C3%BC

https://en.wikipedia.org/wiki/Pythagorean_tuning

Whether the human ear naturally prefers 5/4 (5-limit) over 81/64 (Pythagorean) for the major third, and 6/5 over 32/27 for the minor third, is still something I don’t have solid research on.

As it turns out, the modern western scale is more closely aligned with Pythagorean tuning than with five-limit tuning. In particular, the Pythagorean thirds are closer to modern 12-tone equal tempered thirds than they are to five limit thirds.

strenholme··on Music Theory for Programmers
https://web.archive.org/web/20150610163042/http://www.axs.co...

“"Safe and Sound's" trumpet line is partly responsible for the popularity Capital Cities is currently enjoying”

>>>The trumpet line in ‘Safe and Sound’, for example, didn’t appear in the production until nine versions into the song. The final version, on a whim, we decided to try using a trumpet, a live trumpet, to play that line and it stuck. We ended up actually using the trumpet a lot throughout the album after we included it in ‘Safe and Sound’.

"It was trial and error, right? We felt like that line was an epic line and we thought about different instruments that sounded epic, and the trumpet is obviously one of them,<<<

The thing about trumpets is this: Their fifth is a little “sharp” because it’s a perfect just intonated fifth (i.e. a perfect 3/2 ratio).

strenholme··on Music Theory for Programmers
Indeed. Bobby McFerrin has a demonstration where, regardless of culture, the pentatonic scale is universal. For the record, a just major pentatonic scale is the notes with the intervals (from the root note) 1, 9/8, 5/4, 3/2, and 5/3.

https://www.youtube.com/watch?v=ne6tB2KiZuk

strenholme··on Music Theory for Programmers
If we teach theory without first principles, all we have to do is say “C + E + G make up a major triad”; we may go as far as to explain that, in a major key, the I, IV, and V chords are major chords, the ii, iii, and vi chords are minor chords, and the vii chord is a very dissonant diminished chord.

However, first principles explain “why” a major chord sounds the way it does, and “why” a minor chord has more tension.

Let’s look at the five-limit just intervals: 2/1, 3/2, 4/3, 5/4, and 6/5. 2/1 is a perfect interval; two notes an octave apart sound nearly the same. 3/2 and 4/3 are also perfect intervals, but there’s a little more tension and beating than with 2/1. 5/4 has a little more tension than 4/3, and 6/5 has even more tension. I just explained, using first principles, the octave, perfect fifth, perfect fourth, major third, and minor third. That’s most of the scale right there.

Now, let’s make a chord. Experience has shown that three notes is more interesting to the human ear than just two notes. That in mind, we want three distinct notes where the intervals between notes have a minimum of tension. Take the root, take 5/4 of that, then take 3/2 of the root. That’s a major chord. The reason we use 5/4 instead of 4/3 is because the interval between 5/4 and 3/2 is 6/5; the interval between 4/3 and 3/2 is 9/8. Since 9/8 has more tension than 6/5, that gives us a suspended chord, and it’s better to use a major chord with less tension to make a simple chord progression.

Now that we have our first chord, we can hear that having a 1-chord song becomes repetitive very quickly to the human ear. We can make the song more dynamic and interesting by giving it three chords: I, IV, and V. Take that chord: 1, 5/4, and 3/2 (a major chord). Move all three notes up 4/3, because 4/3 is a perfect interval with a minimum of tension. That’s our IV chord (F chord in the key of C major) Next, from the root position, instead of moving up the chord 4/3, we instead move it up 3/2. That’s a V (or dominant) chord—a G chord when played in the key of C major.

Now, from first principles, namely that the intervals 3/2, 4/3, and 5/4 sound pleasant to the human ear, that 6/5 has more tension, and 9/8 has even more tension (so we avoid suspended chords for now), we have a I IV V chord progression, which is the basis for countless rock and popular songs.

If we take all of the individual notes from the I IV V chord progression, that gives us the seven notes of the major scale, after explaining that, once we cross the octave threshold, we can transpose an octave down without affecting the musicality of the notes. We might even explain chord inversions here.

So instead of just parroting “I IV V makes a nice simple chord progression”, we now know the underlying physics which make I IV V sound so nice to the human ear, and how to get the major scale from those chords. I prefer understanding both the why and the how.

(I would have used two slightly detuned sawtooth waves instead of a sine wave for most of the examples if I were to write an article like the one this discussion links to, explaining this has a more pleasant, piano or violin like sound to it. Maybe even a low pass filter to tame the harmonics. Another option is to run a single sawtooth wave through a Solina style chorus, but explaining two detuned sawtooth waves is easier than trying to explain the Solina chorus effect)

strenholme··on Music Theory for Programmers
Until we have an established scale, unless one has perfect pitch, one note is the same as another arbitrary note. It’s the ratios between notes that make up music.
strenholme··on Music Theory for Programmers
I’m convinced that “Safe and Sound” by Capital Cities became a major hit because it uses an actual trumpet for the lead, causing the perfect intervals to be exact instead of the every so slightly off intervals 12-tone equal temperament has.

The linked article makes the case for equal temperament by showing that 12 just fifths played in sequence is flat compared to seven octaves.

strenholme··on Your intellectual fly is open when you use an LLM to author a post (2025)
Copyright only covers distribution, but I distribute the AI summaries on my blog. With paywalled articles and the usual archives having serious reliability issues, it allows readers of my blog to get context about articles I comment on.

Here’s an example: https://samboy.github.io/blog/entries/2026-08-28.html

The links are AI summaries, which, in turn, link to the original articles, but, in some cases, the original articles are paywalled. For the ones which aren’t paywalled, having a local summary prevents link rot.

Fair use covers quoting someone to comment on them. For example, in New Era Publications International, ApS v. Henry Holt and Co., it was ruled that quoting Hubbard saying “The trouble with China is, there are too many Chinks here.” was fair use, since the book in question was commenting on Hubbard’s personality, and could only reasonably do so by directly quoting him.

From that decision:

>>> these brief quotations from unpublished copyrighted work display a compelling fair use purpose. [...] These quotations are in mockery, to show Hubbard's bigotry, bias and coarse lack of taste. This is not an instance of the biographer/critic free riding on the creative talent of the subject. <<<

← PreviousPage 3 of 20Next →