7

Show HN: Just intonation keyboard – play music without knowing music

 1 year ago
source link: https://ad8e.pages.dev/keyboard
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

A novel keyboard for music

This layout is a natural mapping to harmony. Click this to play Debussy's Passepied.

Press green keys on your keyboard to play sounds, and occasionally press a purple key to change the harmony. These green text links will play sound. (Make sure your sound is on. If you're on mobile, you will have to tap once before it'll let you play, and make sure the Silent Mode switch is off.)

The biggest difference from a piano is that you can play all the notes together (volume warning). This is a unique set of notes. As a consequence, random keys harmonize with each other, and even rolling your elbow over the keyboard or sweeping your mouse will sound pleasant. If you hold 3 notes and don't hear the 3rd note, then your keyboard can only handle 2 keys at a time, which is unfortunately common. In that case, use the mouse and keyboard simultaneously. On mobile, horizontal view will make the buttons bigger.

The pitch of a green key is its number. The purple numbers multiply all the pitches, and purple numbers on the left (7/6) are more exotic than ones on the right (1/2). The colored bars show how many powers of each prime are active (2, 3, 5, 7), but you can ignore them if you don't understand them. Black keys are like purple keys, but only active when held down.

An amusing exercise is to start the Debussy Passepied demo at the top, then press random black keys to interfere (for this exercise, use the black keys in the middle; avoid 1/2, 2/1, 6/7). It's like involuntarily reharmonizing the performer.

Computer keyboards don't have enough thumb keys for this instrument. With those thumb keys, this instrument would be able to play everything a piano can. This is from research on harmony, described in a later section. The principle is that harmonic pitches in a region can be multiples of at most 2 fundamentals, and are more consonant if there's only 1 fundamental. The green keys have all the relevant multiples of a fundamental, and thumb keys would enable two fundamentals. In practice, 1 fundamental is enough to play the consonant chords and most of the moderately dissonant chords. The extra fundamental is for things like embedded tritones and minor-major chords.

The fundamental captures the harmonic context, very similar to what tonality is. There's a logical pattern to the green keys that accords with consonance, described at this link. This combination of fundamental and pattern creates a wonderful map: the distance between keys on the keyboard represents how dissonant they are with each other. Purple keys increase distance.

In improv and composition, this distance frees you to think about harmony rather than calculate intervals, since you can tell without calculation or memorization what the consonance will be and which notes will work. This is even more helpful for beginners, who may not know the correct intervals; the keyboard reveals them.

With these numbers, you can read consonance without memorizing chords, even for complex chords like stacked and secondary chords. Broadly, a chord is consonant if it has small numbers in its reduced fractions. For example, 8 6 is consonant because 8/6 = 4/3 has small numbers. 4 7 is dissonant because 4/7 has the large number 7. A further condition for consonance is that linear combinations of numbers should be either exactly at 0 or far from 0. So ratios close to 1 are dissonant (like 15 16). Arithmetic sequences are consonant when exact (12 16 20, 12-16=16-20) and dissonant when inexact (12 15 20). Sums are consonant when exact (6 10 16, 6+10=16) and dissonant when inexact (6 10 15).

The specific harmony insight that this instrument enables is these linear combinations. For example, if you want to compare a minor chord and major chord, they have the same semitones, hence the same pairwise ratios: 4:5:6. However, you know that in the major chord, these are in an arithmetic progression and hence are consonant, while the minor chord is not, and hence is more dissonant. Spotting these arithmetic progressions is easy with numbers, but it is much more difficult on a piano.

An example is the chord 8 10 12 15 18. This is dissonant, even though its pairwise intervals are fine - two 4 5 6 chords stacked on each other. It even sounds consonant as a sequence. What makes it dissonant is that it's two arithmetic progressions with different spacing. On the other hand, 8 10 12 14 16 is consonant, because it's a single arithmetic progression, while its sequence has tension in the fourth note. This flip-flopping square of comparisons is easy to see on this instrument, and hard to see on a piano. It's more fun and satisfying to understand the reason behind these behaviors than to memorize them.

This instrument has a slight accuracy advantage over a piano, since it uses just intonation instead of 12 equal temperament. 12 equal temperament rounds intervals to enable modulation. This instrument modulates using the purple keys, so it doesn't need rounding to modulate. The biggest accuracy improvement is with 7: 5 6 7 is cleaner than the diminished triad, and 4 5 6 7 is cleaner than the dominant 7th. It's more audible at high volume, because roughness scales nonlinearly with volume.

For performances, there's no reaching, so you can play fast and wide intervals without trouble. You can also press multiple keys with one finger; fat-fingering makes sense here, which is uncommon on a piano. The downside is that harmony changes cost an extra 30% (purple) keys to play the same song. You must also worry about availability of sheet music and carry your own instrument around.

A custom-designed keyboard would fix most of the instrument's disadvantages. 2 copies of the green keys would let you use two hands to play notes without interference, with harmony change keys under the thumbs. This fixes the fingering awkwardness, since any note can be played by either hand. 6 additional harmony change keys 1/2x - 1/7x would modify the left copy of green keys when held down, thus creating a second fundamental and capturing the full power of a piano. The only remaining disadvantage is that harmony changes still cause 20% more keypresses than a piano. However, since both hands have full range and can simultaneously play the melody, I believe you can actually play faster than a piano. As a neat trick, the left and right hands can play the timbres of different instruments, and the voices will stay coherent. However, building hardware is out of my reach, so I have no product to sell. In lieu of a custom keyboard, you could use a second keyboard below the first for the extra keys, although it would be clumsy, and I have not implemented this.

The purple keys are ratios, because ratios like 5/4 are faster than integers like 5. They need fewer presses for the same modulation. Plus, ratios move pitch less, so random ratios sound good and random integers do not.

This instrument is very suitable for jazz because of its ease of improvisation and improved accuracy for 7ths.

If you want to try playing existing songs, there are some rough and tedious steps at this link.

You can edit this keyboard directly on this page, or at this git repository. If you can design your interface, consider using this layout over a piano. If you're simulating a piano on a computer keyboard, this instrument is way better. If desired, it can produce 12 ET instead of just intonation.

Discussion: Hacker News, Tildes
Author: Kevin Yin. I'm looking for a remote job, and my resume is here (Aug 2023). I'm good at C++, game design, music research, and research in general.

Why the instrument works

You probably don't want to bother reading this section unless you are really interested in music; it is technical and relies on many new findings in harmony. The moral of the story is that the instrument can play almost all tonal music, minus a few dissonant chords. A custom keyboard with thumb buttons would complete the remaining chords.

A musical sound is a sum of sines with distinct frequencies. I define a sound as "locally consonant" if perturbing any of these frequencies makes it more dissonant. This means it is the most consonant sound in a small region.

The instrument can play any chord whose notes are reasonable multiples of a single fundamental. We'll show that this usually holds for locally consonant sounds. If there are only two frequencies, they are in an integer ratio by prime-ratio harmony, so clearing denominators makes them multiples of a fundamental. If there are three or more frequencies, and the frequencies are close enough like 4-5.2-6.2, then lattice tones force them to be in an arithmetic sequence, like 4-5.1-6.2. If two of the numbers are in a small-enough ratio, like 4/6.2 ~ 2/3, then lattice tones, prime-ratio harmony, and overtones will push them to be exactly that small ratio, like 4-5-6.

That means the instrument can play everything with the following exceptions:

  1. The minor triad is locally consonant: 1/4, 1/5, 1/6. Its prime-ratio harmony is consonant enough to create a maximum despite dissonance from lattice tones. Octave transformations of these notes also retain this property. Thus, 20 and 24 have been added to the instrument. I ran out of space for 40 and 48.
  2. If the lattice tones do not overlap the frequencies, there can be large denominators, and pitch rounding works. For example, 2 and 12/5 and 12 and 10-16 are consonant. These pairs are less consonant when put together, but they are far apart in frequency, so their lattice tones barely interact, and their amalgam is locally consonant. Note that if we doubled the pitch of the first phrase to 4 and 24/5, the amalgam would be very dissonant.
  3. If you play notes very quietly, lattice tones scale faster than prime-ratio harmony and hence disappear. So while 1/6, 1/7, 1/8 is very dissonant, it is not dissonant if played quietly. This is how bells and marimbas work; their inharmonic partials decay fast enough to not be an issue.
  4. You might not care about local maxima of consonance. For example, 1.1 10 12 is not locally consonant, because moving 1.1 to 1 makes it more consonant. However, 1.1 interacts weakly enough with the other frequencies that the sound is consonant overall. Composers sometimes seek to maximize dissonance, such as with the tritone.
  5. After aligning lattice tones, some arithmetic sequences are far from small ratios, so the pushing force is small. For example, 5 7 9 and 4.9 7 9.1 are similar in behavior, and so are 5 7 8 and 5.1 7 7.95. The piano can't play any of these variations either.

Most of the cases are unimportant or can be played anyway. For example, in the Passepied demo, the chords that can't be played are a minor chord out of range (15 40 48), the tritone at an octave (>2.83< 8 9), and the tritone repeating a prior note (15 >21.6< 40 48). The minor chord is fixed with more keys, but the tritones are not. Debussy bridges the Romantic and Modern eras, so this demo is mildly explorative in dissonance.

Tritones are chosen by composers because they are maximally dissonant, so it's no surprise they cause trouble for a consonant instrument. Tritones can be played as either 7/5 = 1.4 ≈ 1.414, 10/7 = 1.429, or 45/32 = 1.406. As notes are added to a chord, these approximations may be blocked. The diminished seventh is especially dissonant, and there's no hope for rational approximation there.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK