Hacker News new | ask | show | jobs
by jancsika 1883 days ago
It can be tricky to deal with the intersection of music and programming. For example:

> The chromatic scale is the easiest scale possible

So far so good-- in both programming and music we're just stepping through the smallest values (half step for music, the integer "1" in programming). So "easy" definitely applies to both domains.

> We can generate a chromatic scale for any given key very easily

For programming, sure-- you just find your offset and go to town.

For music, however, this is a wrong warp. The chromatic scale is a special case of a symmetric scale which cannot be transposed. There's literally only one such scale-- each transposition brings you back to the same exact set of pitch classes.

Figuring out what it means to have a chromatic scale "for a given key" is advanced music theory. In fact, I can only think of a few places where that makes sense:

* studying the complex harmony of late-19th century Romantic music

* studying the choice of accidentals in chromatic passages of Bach, Beethoven, etc. to infer the implied harmony

Those are important things, but they are definitely advanced concepts.

Long story short for programming, the author moves logically from an array to stepping through an array. But in terms of music, they start with the simplest possible scale and then jump to a third year undergrad theory concept.

3 comments

> Figuring out what it means to have a chromatic scale "for a given key" is advanced music theory

Interesting... Do you have any links for learning more about this - maybe some analyses?

My take on chromatic scales (in the context of this post) is that the very existence of a(n equally tempered 12 tone) chromatic scale is the axiom the OP is using but not stated - hence a comment further up/down about P5s not necessarily being equivalent to d6 in other tunings.

My take on chromatic scales (outside the context of this post) is that there is only one, like there are only two whole-tone scales, etc, and that it wouldn't necessarily make sense to say "the E chromatic scale" - instead you'd say "playing a chromatic scale over an E major harmony" (for example).

However, if there are cases where it's useful to be more specific I'd be really keen to go deeper.

> My take on chromatic scales (in the context of this post) is that the very existence of a(n equally tempered 12 tone) chromatic scale is the axiom the OP is using but not stated - hence a comment further up/down about P5s not necessarily being equivalent to d6 in other tunings.

Ooh, good catch-- I completely left out tuning systems!

But again-- the point of "basic" music theory is to simplify the practice of discussing music. In that context, the fundamental purpose of the chromatic scale is to introduce the complete set of note names, as well as the range of the piano pitches. This gives the student a full set from which to derive all other concepts like scales, keys, triads, and all the other fundaments of the common practice period.

So again, if you start with a chromatic scale and then start talking about the differences in half-step intervals along it-- boom. Huge conceptual warp.

Honestly, I don't know much about the intersection between symmetric scales and alternate tuning systems. Personally, it seems like it would be an incredibly esoteric niche, although I can imagine some funny musical jokes with the idea. :)

> The chromatic scale is a special case of a symmetric scale which cannot be transposed.

I would not agree here. I think you can transpose a chromatic scale, but you end up with the same "set" of pitches. (So you _can_ transpose, but if you only consider the _set of pitches_ you end up with a invariant.

But scales are not just a set of pitches, but also have a root note.

You can establish the key of C and play a chromatic scale from c' up to c'' and there would be the feeling to accept C as the root of the scale.

So the chromatic scale is kind of a _total_ (all 12 pitch names) and _trivial_ example, as you pointed out, very symmetric and usually not so interesting for analysis if you want to detect and describe structure.

In general it depends on the music. If the music is based on diatonics, then a major scale or it's modes will be a fitting primitive for analysis, considering chromatic notes something like side notes.

On the other hand 12-tone music uses a chromatic scale as a basis, negating the structure and hierarchy of diatonic scales.

So I don't see a problem with transposing a chromatic scale, it's useful and necessary for mathematical sound systems (helpful for computation) to define operations, even if there is no direct gain (functionally speaking - identity / mempty etc.) :

1 + 0 = 1

I don't think this is really anything to do with music vs programming. The author just used the wrong words... it's pretty clear they meant "generate a chromatic scale starting at any note" ;)

Thanks for bringing up the connection with symmetric scales -- these are really interesting!

If you want to go further down the rabbit hole of symmetrical scales, checkout Olivier Messiaen's modes of limited transposition https://en.wikipedia.org/wiki/Mode_of_limited_transposition. For a given set of pitches within an octave there are a limited number of times those pitches can be transposed before you wind up with the same set of pitches. And the modes in that scale must also be fewer in number than the number of pitches in the scale, meaning at least two modes of the scale must have the same interval spelling. The simplest example is the whole tone scale. Up a half step I get the same set of pitches, another half step and I get the same pitches I started with, so it is 'limited' to one transposition. And there is only one mode of the whole tone scale, since no matter where I start I always have the same set of intervals.
Shtaaap, you’re headed for the Totient Function! Collision immanent, abort, abort!