[HN Gopher] Show HN: Just intonation keyboard - play music witho...
       ___________________________________________________________________
        
       Show HN: Just intonation keyboard - play music without knowing
       music
        
       This is a keyboard in just intonation. It can play the notes a
       piano can. The big difference from a piano is that all the notes
       become consonant. At least, when you want to play a dissonant
       chord, you are clearly opting in to it because it's clear which
       notes are dissonant to each other. You won't bump into a dissonant
       note by mistake.  You can play without knowing any music theory.
       Hit arbitrary notes with the rhythm you want, and the pitches will
       work. Not understanding the buttons is fine. Even rolling your
       elbow around your keyboard is fine.  If you are a musician and
       press the wrong key while playing a song, it will still fit. It
       will sound like you made an intelligent, conscious choice to play
       another note, even though you know in your heart it was an
       accident. Beginner jazz musicians rejoice.  It's not an AI making
       choices for you; it's just a very elegant interface. What makes
       this possible is several new discoveries in psychoacoustics about
       how harmony works. While a piano lays out notes in pitch space,
       this keyboard is able to lay out notes in consonance space. When
       you play random notes, they tend to be "close together" on the
       physical keyboard. Distance on the keyboard maps well to distance
       in consonance space, so those random notes are close together in
       consonance space and sound good together.  According to Miles
       Davis, a "wrong" note becomes correct in the right context. If you
       try to play a wrong note, the purple buttons you press will
       automatically land you in the right context, even if you don't know
       what that context is yourself. So you can stumble your way through
       an improv and the keyboard will offer the right notes without
       needing you to think about it.  Harmonic consonance of chords can
       be read directly off the numbers in the keyboard, which implies
       that these numbers are a good language to think about music with.
       It doesn't take years of training, just reading the rules. The key
       harmony insight that you can do on this keyboard, and not on a
       piano, is to add frequencies linearly (like 400 Hz + 300 Hz). The
       reason this matters is that linear combinations of frequencies are
       a major factor of harmony, in lattice tones. So to see how
       dissonant or consonant a chord is, you want to check how distant it
       is from a sum or arithmetic progression. On a piano, to do the
       same, you'd have to memorize fractional approximations of 2^(N/12),
       then add and subtract these fractions, which is very difficult. For
       example, how far is 6/5 + 4/3 from 5/2? Hard to say! But if
       denominators are cleared, it's easy to compare 36 40 45: they're
       off by 1 from an arithmetic progression. This also applies to
       overlapping notes, not just chords. Having all the keys accessible
       on a piano is very convenient, but this translation layer of
       2^(N/12) approximation + fractional arithmetic makes it hard to see
       harmony beyond the pairwise ratios.  The subset of playable songs
       is different from a piano, which means that songs in your existing
       piano repertoire will snip off some notes. Hardware for thumb keys
       would fix this, so you could play your existing piano songs in
       full, plus other songs a piano can't play. I don't have such
       hardware so I haven't implemented this. The other way is to have
       two keyboards and a partner.  The remaining issue is that there is
       no sheet music in just intonation. Unfortunately, I have had no
       success in finding piano sheet music in a common, interpretable
       format. So while I do have a converter from 12 equal temperament to
       just intonation, there are no input files to use it with...
        
       Author : ad8e
       Score  : 147 points
       Date   : 2023-08-19 22:49 UTC (2 days ago)
        
 (HTM) web link (ad8e.pages.dev)
 (TXT) w3m dump (ad8e.pages.dev)
        
       | ktbwrestler wrote:
       | This is really interesting and creative! Did you deliberately
       | make some notes sit outside of the standard 440hz diatonic scale?
       | Even when I click your Debussy demo, you're hitting some notes
       | outside of the normal 440hz scale!
        
         | ad8e wrote:
         | So, there are two things currently going on with the Debussy
         | example.
         | 
         | The first is, yes, some of the notes from Debussy are actually
         | poorly playable on the piano. One is this:
         | https://i.imgur.com/K0Wuu3Q.png. This is a visualization I
         | built (and which can't be ported to web easily, so
         | unfortunately it's just something I have for now). It's like a
         | scrolling player piano with rising notes, and the numbers next
         | to the bars are what the numerators are. Note there are two 7s
         | in the middle, and pianos are not good at 7s. I've verified
         | these numbers are correct manually, so it's supposed to sound
         | like that and the piano has an inaccurate approximation. This
         | corresponds to this location in the score:
         | https://i.imgur.com/24XY8vR.png
         | 
         | The second is, I suspect there is a mistake near the end. This
         | visualization overlaps the original with the twelve-tone
         | version: https://i.imgur.com/tS7WzRg.png. Note how some of the
         | bars are separated from each other. I'm currently in the
         | process of checking these notes. My original 12ET -> Just
         | Intonation conversion was automatic and I fixed up all the
         | errors I could find, but I could have missed one. EDIT: yes,
         | there was. I fixed it now.
         | 
         | The third doesn't happen in this example, but sometimes
         | composers want to deliberately round, such as in the Circle of
         | Fifths. That would create unpleasant commas. I'm kind of lucky
         | that it didn't happen in the demo I chose. The Circle of Fifths
         | is not actually an issue; first, you can't keep old notes
         | persistent across the whole circle; they will interfere. And
         | second, thanks to Diana Deutsch's experiments on pitch memory,
         | we know that if there are more than 16 notes between the old
         | and new note, you shouldn't be able to discern the comma.
         | However, although the Circle is not a big deal, other rounding
         | intervals can become an issue, like 63/64, where the composer
         | would like the rounding to occur somewhere other than the exact
         | pitch repeat. Listeners are effective at detecting when an
         | exact pitch repeat is slightly inexact, while they have a
         | harder time discerning slightly-off harmonies.
        
         | ktbwrestler wrote:
         | To specify, the pitch gets wonky on the first melodic phrase
         | after you introduce the first 4 chords. It's the second note of
         | the melody E A B... A is not tempered at 440hz to the scale!
        
           | ad8e wrote:
           | I'm not sure we're looking at the same thing, but I fixed an
           | issue with the just intonation transcription. Now, the
           | largest non-transient deviation from 440 Hz scale is 0.14
           | semitones, caused by Debussy modulating by a third (5/4).
        
           | ktbwrestler wrote:
           | To clearly show you what sounds off, replicate this
           | 
           | Reload the page
           | 
           | Type .,;m
           | 
           | You'll notice that m is not the "right" temperament as the
           | dom7 in that arpegio
        
             | [deleted]
        
         | slaymaker1907 wrote:
         | With the design of this keyboard, only one note (maximum) can
         | be in tune with the 440Hz equal temperament tuning, at least
         | apart from octaves. No complicated proof of this is necessary
         | since the ratio between any two notes in equal temperament is
         | irrational and every note combination on this keyboard is
         | rational. The irrationality of equal temperament is likely part
         | of the reason why equal temperament was no common until
         | relatively recently in human history.
         | 
         | I think the example also highlights why equal temperament is
         | pretty good if you can't change tuning on the fly. Certain keys
         | (the musical theory kind, not the keyboard kind) will sound
         | completely different. At least equal temperament is equally out
         | of tune from just intonation (how singers and instruments with
         | variable pitch tune chords) for every key.
         | 
         | Something from the well-tempered clavier by Bach would likely
         | work a lot better as a demonstration because it doesn't stray
         | nearly as far from the home key. You could also make it work
         | better by maybe adding in some keybindings to adjust the key
         | like harps use. You probably wouldn't even need to add in 12
         | modes for it since harmonically related keys still work pretty
         | well. Keys like F and Bb work well together because they are
         | close on the circle of fifths, but F and B (natural) will not
         | since they are basically as far apart as possible.
        
       | msephton wrote:
       | This is pretty cool. Does this assist with random music
       | generation in any way?
        
         | ad8e wrote:
         | Yes, there's a secret music generation project if you can find
         | it. If you are asking this without knowing about that secret
         | project, that's a very deep insight.
        
           | msephton wrote:
           | Oh! Thank you. That compliment has made my day. I have no
           | idea about the secret project.
           | 
           | I'm an indie game developer who can do everything other than
           | music, so I often wonder about generating it.
        
       | dsp_person wrote:
       | Very cool! Have you seen music mouse [1]? I wonder in what ways
       | this intonation keyboard concept could be mapped into a 2d touch
       | interface, maybe with some ideas from music mouse. But if it's
       | just a single XY pad, I guess it becomes just a piano again but
       | with tuning presets? Or maybe 2 pads could be used...
       | 
       | [1] https://teropa.info/musicmouse/
        
       | cscheid wrote:
       | This is exceedingly cool, thank you for putting it out there.
       | 
       | A small suggestion: when you press the purple buttons, it would
       | be neat to see the green numbers change by the multiplier (or
       | have an option to do so). This would let you easily see parts of
       | the keyboard transpose correctly vs not, and what new pitches you
       | get access to. Even sweeter would be a quick animation to show
       | "where the numbers went".
       | 
       | I would also like to be able to have the purple buttons be active
       | only when pressing the keys, so that I could quickly modulate up
       | a just fourth and back. Having to remember where I am in the
       | modulation state is a bit much, and very different from typical
       | musical instruments.
       | 
       | But I've been playing with this for a good while, trying to
       | recreate basic stuff like V7 -> I etc and it's very cool, thanks
       | again.
        
       | HPsquared wrote:
       | A fun way to improvise without knowing any harmony on a regular
       | keyboard is to stick to the black keys. This is basically a
       | pentatonic scale and doesn't have any big dissonances.
        
       | fritzo wrote:
       | Neat! reminds me of my old web app https://fritzo.org/keys
        
       | zengid wrote:
       | I want to say first off that this is super cool, and I really
       | applaud you for shipping it. The tones sound pretty great on my
       | machine, and the button pressing is good. I don't detect any jank
       | or latency like I frequently do with web-audio.
       | 
       | That being said I have a few constructive critiques.
       | 
       | First is I wouldn't say it's intuitive. Having the harmonics
       | ascending from right-to-left breaks my brain. Wait, on second
       | look they are kind of scattered about in a somewhat random way?
       | Why are 5 and 3 so far from each other? I might like it if this
       | was laid out in a lattice or some kind of regular structure. I
       | don't doubt that with practice and reading I could learn it but,
       | IMO, if I have to read an instruction manual I'm already checked
       | out..
       | 
       | Second, there needs to be some kind of indication at where I'm at
       | in terms of the internal state of the multiplied ratios. So if
       | I've stacked on 3 consecutive 2/3, the only feedback I get is
       | when I hit a note.. and I might forget where I'm at in the "pitch
       | space". You could just have a simple "stack" at the top that
       | shows the last applied ratio, and maybe the final product or
       | quotient next to it.
        
         | ad8e wrote:
         | Thanks to you asking why it's right to left instead of left to
         | right, I have the opportunity to talk about some interesting
         | design decisions. I agree there should be an organized pattern.
         | For example, 1-30 lexographically. So I'll explain the hidden
         | logic and pattern.
         | 
         | The three necessary primes to represent on the organized
         | lattice are 2, 3, and 5. Given a key like 16, each of these
         | primes should be represented in its adjacent buttons, hopefully
         | in an axis-like manner, because these are the consonant notes
         | to it. Left of 16 is 5/4, right is 3/4, and up-down is 2 and
         | 1/2. But why this way?
         | 
         | Consonant pitches stay within a range - so large leaps in pitch
         | are the least common. That means next to any number, the
         | adjacent keys must have close by numbers. That's why the three
         | primes 2, 3, 5, are converted to 2, 3/4, 5/4 - because these
         | are the closest numbers to 1, after multiplying by a power of
         | 2.
         | 
         | Your hand has a harder time reaching vertically than
         | horizontally. 2 is the largest of these three numbers, which is
         | why 2x is on one of the 4 vertical directions, and 3/4 and 5/4
         | are on the horizontal directions. Furthermore, it means that 2x
         | must be on the 5/4 side, not the 3/4 side - because this keeps
         | pitch distances the smallest.
         | 
         | There's only one remaining decision - why right to left? Your
         | hand has an easier time turning inward than outward. And,
         | whichever way it turns, the horizontal notes should have
         | pitches as close as possible. Thus, 5/4 must be to the left
         | direction.
         | 
         | Luckily, divisors don't exist, so the fact that the 3/4 axis
         | and 5/4 axis are on the same line - rather than 3/4 turning to
         | 4/3 on the opposite side - is perfectly fine.
         | 
         | So thanks to the above, the keyboard is forced to be this way,
         | and every note is in its logical and rightful place, with no
         | subjective choices. Except not, because there's not enough
         | space. And because 7 and 15 can't be on the lattice, so they
         | are just placed wherever there's room. 2 should really be below
         | 1, and 3 should be where 2 is. 30 should be 40, etc. I tried to
         | maintain the structure as much as possible but had to make
         | things fit.
        
           | tofuahdude wrote:
           | Very cool work and explanation!
        
         | Tao3300 wrote:
         | > harmonics ascending from right-to-left breaks my brain
         | 
         | It's not like instruments are totally consistent from one to
         | another in how that sort of thing works. It's not breaking your
         | brain, you just aren't familiar with it yet.
         | 
         | > if I have to read an instruction manual I'm already checked
         | out
         | 
         | Not saying learning this keyboard is necessarily a worthwhile
         | pursuit, but that reads less like criticism and more like an
         | admission that "this just isn't for me". And it raises the
         | question: what kind of instrument _would_ you learn that didn
         | 't involve understanding how it works and acquiring muscle
         | memory?
        
         | ad8e wrote:
         | Showing the internal state is a pretty good idea. I'll see if I
         | can port over my visualization from my desktop version; it'll
         | show the absolute pitches of the notes on a real number line,
         | and how many powers there are of each prime. It won't be soon
         | though.
        
           | zengid wrote:
           | This would be awesome, thanks.
        
           | NikolaNovak wrote:
           | Ooh there's a desktop version?? :-)
        
             | ad8e wrote:
             | There's a desktop version which I unfortunately don't have
             | the time to get in release state, but I'll release the
             | source code for everything eventually (maybe months later).
        
       | zokier wrote:
       | I think you need far more basic practical examples how to play
       | the thing, just figuring out a random major chord was a hassle
       | and I still have no idea how to play some specific chord like for
       | example the most basic C major chord. And if I understand it
       | correctly, moving from e.g. major to minor chord requires
       | transposing the right hand with the left-hand keys?
       | 
       | Of course the instrument having hidden state makes all this far
       | more complicated. Would be neat if the key labels would also
       | indicate the absolute note so I wouldn't need to do mental
       | arithmetic here.
        
         | adrianmonk wrote:
         | I don't know how practical that is, but you can figure it out
         | analytically.
         | 
         | In equal temperament, you can find the frequency ratio of two
         | notes in an interval by raising 2 to the power of X/12, where X
         | is the number of semitones.
         | 
         | Once you know that, you can look for some green numbers that,
         | when divided, would have that same ratio.
         | 
         | So to make a chord, you figure out the ratios. Here's an
         | example for major triads. First, some math to go from equal
         | temperament to ratios. A major third is 4 semitones, so that's
         | 2*(4/12), and a perfect fifth is 7 semitones, so that's
         | 2*(7/12). Those work out to 1.2599 and 1.4983.
         | 
         | They're really "supposed"[1] to be 1.25 and 1.5, i.e. 5/4 and
         | 3/2.
         | 
         | So now that you know these ratios, you can look for 3 numbers
         | that satisfy the two ratios. If you change 3/2 into 4/6, then
         | it becomes pretty clear that 4 and 5 will satisfy the 5/4 ratio
         | (giving you a major third) and that 4 and 6 will satisfy the
         | 6/4 ratio (giving you a perfect fifth). So to get a major
         | triad, you can play 4, 5, and 6.
         | 
         | With similar reasoning, you can figure out that 10, 12, and 15
         | form a minor triad.
         | 
         | ----
         | 
         | [1] If you look at equal temperament as a compromise that
         | doesn't get quite the "right" ratios.
        
         | ad8e wrote:
         | If you know your chord's format in just intonation, there's a
         | (not-so-)secret converter. Type in "play_on_keyboard('4-5-6
         | 15/2 12 10 20/3')" in the F12 console to produce fingering and
         | play it on the keyboard. Maybe I should make this clearer by
         | adding a text box.
         | 
         | EDIT: thanks to your feedback, I added a textbox below the
         | keyboard. It will show how to play things if you can write the
         | ratios of the notes. This may be a helpful map for turning 12
         | ET into just intonation:
         | 
         | C 16/15 D9/8 6/5 E5/4 F4/3 7/5 G3/2 8/5 A5/3 16/9 B15/8 2
        
       | quickthrower2 wrote:
       | Well that was marvellous to play with! Thank you.
        
       | jcpst wrote:
       | Fantastic, this is great work. Takes me back to my undergrad days
       | studying Ben Johnston's JI systems for my own compositions.
        
       | IndySun wrote:
       | A very interesting and educational musical experiment. Are you
       | planning to expand, maybe to a plugin? Max4Live would likely be
       | viable. Thank you.
        
         | ad8e wrote:
         | Unfortunately, I won't have time to expand on this project
         | unless someone hires me to work on it. For now, it's just to
         | educate people and let them copy it.
        
       | Pr0ject217 wrote:
       | This is super cool!
       | 
       | It would be awesome to be able to record the notes to a
       | sequencer, and then play them back, optionally sending via Web
       | MIDI API[1], so that one could control an external synthesizer or
       | VST.
       | 
       | [1]https://developer.mozilla.org/en-
       | US/docs/Web/API/Web_MIDI_AP...
        
       | aidenn0 wrote:
       | If you are interested in novel keyboard layouts, there are many
       | 2-dimensional chromatic layouts where transposition is isomorphic
       | (i.e. playing in a different key only requires changing where you
       | start). In one notable example, all major and minor triads can be
       | played with a single finger[1], because 5ths and major/minor
       | thirds are always adjacent.
       | 
       | 1: http://www.shapeofmusic.com/note-pattern.php
        
       ___________________________________________________________________
       (page generated 2023-08-21 23:00 UTC)