digital harmony

midi => harmony

harmonypartition works simply and cleanly with MIDI files.

Using the music21 package, harmonypartition is able to analyze a MIDI file in exactly the same way it analyzes an audio file.

Results from MIDI are cleaner than those from audio – though not necessarily better, since resonance and continuity play such a key role in analysis, performance, and understanding. But MIDI is an important and stable reference in music notation, and provides invaluable information on many levels.

analysing a MIDI file

Below is an analysis of the same progression as on the previous pages: vi-ii-V-I in C Major, from a MIDI file:

bin_a, kpdve_a = pt_analyzeMIDI.analyze_notation_file("vi_ii_V_I.mid", beats_per_slice=2)

This analysis (like all analyses in harmonypartition yields two crucial pieces of information. The first is a binary ‘punch card’ of pitches. The second is an analysis of probable function. These can be seen below. First, in binary (with analysis given below):

Second, coded by proximity and most probable (or, more to the point, laziest possible) harmonic function:

harmonypartition analysis, with chords (large blocks) in C Major (bottom stripe)

This analysis is very close to what derives from the Fourier analysis of a live performance of the same music, here played on a lightly out-of-tune piano:

vi-ii-V-I live on funky piano

further examples: MAESTRO dataset

Then, to take a leap away from the vi-ii-V-I, here is a somewhat more sophisticated examples: Prelude and Fugue in A Minor, WTC II, BWV 889 (Johann Sebastian Bach), from the MAESTRO dataset. First an analysis of the audio recording:

Audio/Harmony analysis: Prelude and Fugue in A Minor, WTC II, BWV 889 (Johann Sebastian Bach) — using librosa stft

And here an analysis of the MIDI version of the same performance:

MIDI/Harmony analysis: Prelude and Fugue in A Minor, WTC II, BWV 889 (Johann Sebastian Bach) — using music21 for chord extraction.

These analyses could use some smoothing and statistical comparison, but all in all, it’s not bad for pure binary logic – which seems like a good, rooted place to have a meeting point.

digital harmony


I’ve built the harmonypartition system to generate harmonic sequences with just a few small numbers. Here is a simple one, built from simple piles of sine waves. Later they can of course expand to MIDI and DAW systems.

harmony as a sequence

So to begin: the following sequence:

base_seq = [4,3,2,1]

…can generate this chord sequence:

vi-ii-V-1 in C Major

This is not such a big deal, but it is already interesting that a harmonic parametrization can be rendered as simply as a melodic contour.

What is interesting is that the system underneath is much more than usually flexible. Change one parameter:

p = 5

… and you get this:

vi-ii-V-1 in C minor

This means, for example, that you could change the entire harmonic atmosphere of music (e.g in a game or film) according to easily structured parameters.

Intuitive relationships among these parameters would allow harmonic atmospheres to change meaningfully based on the motion of a joystick, a changing of levels, or other measurable conditions.

minimal encoding

And the encoding is very small, but non-trivial: it gives not only the notes but the function of each chord, which allows for improvisation. Here, for example is the encoding for the chords of ‘Blue in Green’:


…which sounds like this (with its bass line calculated from the encoding):

blue in green – analyzed chord cycle

…and like this with a field of (mathematically extrapolated, and slightly hysterical) notes above it:

I also use these small generated files (looped, and longer) to help violin students play over chords. Also, the encoding of a chord is small enough (32 bits) that the sharing of harmonic sequences over software (and IoT) could be rigorous on the one hand (for systems), and flexible (for people) on the other.

flexible decompression

What’s curious is that the system employs a type of compression which can be flexibly decompressed – delivering a world of sensible possibilities rather than a single unambiguous solution. This ambiguity derives from the fundamental ternary treatment of the byte.

digital harmony

audio => harmony

harmonypartition can harmonically analyze audio files by dynamically seeking and organizing tonal continuities.

In a great many musical cases, these continuities take the form of familiar keys and chords.

example: vi-ii-V-I

Here, for example, is a vi-ii-V-I progression in C major, generated from fourier analysis of a .wav file:

C Major vi-ii-V-I in sine waves, derived from synthesized audio

Here is the same progression, analyzed from my own lightly out-of-tune piano, with a different voicing:

C Major vi-ii-V-I on piano, live audio

Although the underpinnings and overtones (shown below and atop the central graphs) are shaken by the realities of live sound, the central analysis holds equally.

generating graphs

We can generate graphs with the following python code from the harmonypartition modules:

audio_kpdve_graph.graph_audio_file("C_6251_live.wav", chroma_threshold=0.3)

A firm, unchanging mathematical system undergirds the analysis, working within the idea of number, group, and ternary rather than with statistical operations. In the course of this method, the harmonic system functions as a hybrid, highly efficient form of neural network, using a miniature backpropagation to find meaningful (and maximally lazy) tonal centers.

It is possible in this manner to analyze any audio file for music-harmonic content, exposing large-scale structures in the musical works. Examples of this type of analysis can be seen in the “Audio and Insights” pages at the Charlottesville Chamber Music Festival.

Beethoven: Sonata No. 1 for Violin and Piano in D Major, Op. 12, No. 1, Mvt. 3 with Jennifer Frautschi, violin, and Max Levinson, piano

Schubert: Fantasie for Violin and Piano, D934, excerpts with James Ehnes, violin, and Inon Barnatan, piano

Beethoven: Sonata No. 10 for Violin and Piano in G Major, Op. 96, mvt. 4, with Timothy Summers, violin, and Benjamin Hochman, piano

The same process can be applied to MIDI and to live-streamed audio. The next post will address the process in MIDI.

Please send along any files for analysis — I would be happy to experiment with them in the course of further development, and discuss results.

The fourier analyses use the librosa package for pitch detection.

digital harmony

a new direction

Harmonic analysis of Schubert Fantasie, D. 934, opening bars.

The power of electronic music – even the most dedicated analogue instrumentalist must admit – is beyond question.

Though they do not cover the same musical ground as a finger on a string or breath in a column of air, the filters, echoes, synthesizers, and effects applied to waveforms in electronic music have enormous effect.

Harmony, however, remains insufficiently parametrized. This leaves an important dimension under-explored, and also stifles the integration of digital and acoustic instruments. Tonality guides our own real fingers with memory and prediction, and the methods of electronic music do not well or fully take this into account.

I have been working as a performer of mostly classical music at the Mahler Chamber Orchestra for the past fifteen years, and teaching at the Universität der Künste in Berlin. This work should bridge live performance and musical study in the analog/print style with performance around parameterised digital criteria.

parametrising harmony

I will work to address the process of parametrising harmony over the next weeks and months, exposing a tiny algorithm which back-propagates over a small set of bits, treating the bit as ternary rather than binary. This algorithm, being developed at GitHub as harmony partition, efficiently and flexibly describes a wide range of conventional harmonic usage.

I will document the process of making and using it here, and I hope I can build for you a proper guide, through a series of Jupyter notebooks which outline the theory and applications of this idea. Some of these steps will be pragmatic, some music-theoretical, and some just playful explorations. The main thing is to see if a community and musical language can build around this musical process.

A proper Pypi package will be available in mid-January 2021.


Initial results of the use of this algorithm can be seen at work at the Charlottesville Chamber Music Festival. To begin: Beethoven Sonata, Op. 111, played by Conor Hanick, an analysis of the second movement.

This blog will cover not only the theory, but also the implementation of the algorithm for use in musical practise.

Posture and Composure RightAndLeftHand String Yoga

Feet on the Ground

As you start to play, aim for solidity in left and right hand.

Your left hand should feel full, fat contact with the string; the hairs of the bow should sit thickly and exactly on the string..

Compare the solidity of contact in your hands with the solidity of your feet on the ground.

Try it with double stops as well.

LeftHand Posture and Composure RightAndLeftHand RightHand String Yoga

Practising with a Mirror

Practising with a mirror is extremely useful – for both hands.

However, one must not become too self-obsessed.

When practising with a mirror, try to position yourself so you do not see your own face.

You will gain much in the way of objectivity

Intonation LeftHand String Yoga

Your Fingers are Sightless Animals

The fingers of your left hand cannot see.

You must give them eyes with your ears.

Play any passage, concentrating on how your fingers depend on your ears for guidance.

Posture and Composure RightAndLeftHand String Yoga

The mysterious energy of Pac Man

As you play, your left and right hand are brought together not only by the bow and the string.

Your arms, the bow, and the string make a complete circuit with a Pac-Man shape.

Energy can flow freely in this circuit.

Intonation LeftHand String Yoga Uncategorized

Tuning the violin like a drum

Every time you use your left hand to choose a pitch, you must be confident in its tuning.

It is as though you are playing the timpani: once you tune it, you can concentrate much more clearly on how it is struck, and how it makes sound.

And know, when you start playing, that what’s done is done.

Dynamic Posture and Composure RightHand Sound Quality String Yoga

Drawing the string as a bow

Play a slow scale, watching the small part of the string between the bridge and the bow hair.

Each time you draw the bow, you will see the string push to the left (for up bow) or the right (for down bow).

Do your best to maintain this angle in the string as you play, like an archer in perpetual preparation to shoot an arrow. The string will take care of the rest.

The string is the bow; the sound is the arrow.