Blues and Swing
What is swing, and how did the blues, ragtime and the swing band build the language of jazz?
Asked what swing is, jazz musicians say that if you have to ask you will never know; but it can be measured. The part builds the twelve-bar blues, three lines of four with every chord a dominant seventh, and its variants up to the jazz blues; blue notes as regions between minor and major rather than pitches, heard in a phrase with its third bent from 300 to about 385 cents; and the AAB verse, each line answered in the bars it leaves open. Joplin's Maple Leaf Rag (1899), played from its encoding, puts 46 of its first strain's 85 right-hand attacks between the eighths against 3 of 45 in the left hand. A simple swing model, 3:1 at 120 beats a minute falling to 1:1 at 300, the trend Friberg and Sundström measured, keeps the short note near a tenth of a second at fast tempos; late downbeats are a second ingredient, and random deviations are not. The swing band trades riffs between sections. A walking bass is a shortest path under four rules, meeting every chord on its root after a semitone; guide tones, the third and seventh, move two semitones in all through ii-V-I; and a dominant shares its tritone with exactly one other, its substitute, so the bass can slide by semitones. The Tune becomes a twelve-bar blues sung with blue thirds, a rag and a riff chart.
What you need. Part 11 for meter; Part 13 for seventh chords; Part 17 and Part 18 for voice leading and progressions; Part 32 for voice leading as distance; Part 37 for timelines and call and response. Dynamic programming, swing ratios, syncopation measures.
- Ideas, mathematics and history
- the twelve-bar form, blue notes, ragtime, swing ratios measured against tempo, guide tones, ii–V–I, the tritone substitution
- What we build, compute and hear
- a swing model; Joplin rendered; the Tune as a blues and a big-band riff
What you will be able to do
Foundations
- Hear the twelve-bar form, blue notes and an AAB verse, and name what each does.
- Hear a rag's syncopated right hand against its march-like left hand.
- Hear swing change with tempo, and a tritone substitution in the bass.
Full course
- Model swung eighths at any tempo and compute the short note's length.
- Generate a walking bass and guide-tone lines as shortest paths through a progression.
- Prove that exactly two dominant sevenths share a tritone, and count a rag's syncopations.
Research
- Design an experiment to separate what makes a performance swing, and for whom.
Practice
- Walk a bass, voice guide tones and set a drum machine's swing as players and producers do.
Contents
Each chapter has a home level. Choose a track to see what to read and watch: Foundations 25 min · Full course 30 min · Research 33 min · Practice 30 min.
- 0If you have to askFoundations2 min
- 1The twelve-bar bluesFoundations3 min
- 2Blue notesFoundations3 min
- 3Call and response: the blues lyricFoundations2 min
- 4Ragtime and strideFoundations3 min
- 5Swing, measuredFoundations3 min
- 6The swing bandFoundations3 min
- 7Walking bass and the ridePractice3 min
- 8Sevenths and guide tonesPractice3 min
- 9ii-V-I, turnarounds and the tritone substitutionFoundations3 min
- 10Frontier: microtiming and jazz corporaResearch3 min
- Variation 38, recap and problemsAll tracks3 min
Also on this page: Lecture · Key results · Try it · Lab · Problems · Notes and sources · Build the film.
Lecture
The text of each chapter is the film's narration, as it is spoken, so you can read along or revise without the film. The pictures are in the film. A dashed box stands for a number the film computes when it is rendered (hover over it to see what is computed); the README's figures for each chapter, where it lists them, follow the chapter's text.
If you have to askFoundations2 min
What is swing? Before anyone answers, measure it by ear. A line of our own, played over a walking bass and a ride cymbal. Each beat is split into two notes, a long one and a short one. How much longer is the long note than the short: about the same, twice as long, or three times?
About three times. At beats a minute, the long note takes three quarters of the beat and the short one a quarter, about milliseconds. Not the even split of written eighth notes, and not the two-to-one of a triplet either. Here is the same line played straight, for comparison.
What is swing? The proverbial answer, attributed to more than one jazz musician, is that if you have to ask, you will never know. But swing can be measured: the ratio of long to short, and where the notes fall against the band. The ratio is near three to one at slow tempos and falls to even at fast ones. And soloists tend to place their downbeats a little late and their off-beats on time. This part builds the blues, ragtime and the swing band, and a model that swings.
Here is the plan. The twelve-bar blues, its blue notes, and call and response. Ragtime, with Scott Joplin's Maple Leaf Rag played from the score and its syncopations counted. Swing measured: the long-short ratio against tempo, and late downbeats. The swing band, where sections trade riffs. Walking bass lines and guide tones, computed. And the harmony of jazz: two-five-one, turnarounds, and the tritone substitution. Joplin's rag is played from its encoding; every other line, riff and verse is ours.
1The twelve-bar bluesFoundations3 min
Why has one twelve-bar pattern lasted a century?
The blues grew among African Americans in the Deep South around 1900. It drew on field hollers, work songs and spirituals, and on the ballads of travelling songsters. W. C. Handy published The Memphis Blues in 1912 and St. Louis Blues in 1914. In 1920 Mamie Smith's Crazy Blues, the first blues recorded by a Black singer, sold in huge numbers, and record companies went looking for more. They found Ma Rainey and Bessie Smith, and in the Mississippi Delta, Charley Patton and Robert Johnson.
The commonest blues form is twelve bars long, in three lines of four. The first line stays on the tonic chord, C. The second moves to the subdominant, F, and back. The third reaches the dominant, G, falls through F to C, and ends on G to send the music round again. In this basic sketch each chord is a dominant seventh: C seven, F seven, G seven. In Part 18's harmony C seven commonly functions as a dominant of F; in the blues it is simply home.
Hear one chorus, as a blues player calls a time through the form: piano chords on beats two and four, a walking bass, ride cymbal and hi-hat. Follow the bars on the chart.
The form has many variants. The quick change visits F in the second bar. A jazz blues fills the frame with more chords: a two-five into F in bar four, a diminished chord in bar six, a secondary dominant in bar eight, and two-fives back to the top. The skeleton stays the same: twelve bars, the move to the subdominant in bar five, the dominant in bar nine.
Notice what the blues does with the seventh chord. It is the unit, not a dissonance that must resolve. The tonic itself is a dominant seventh, C, E, G, B flat. That B flat, and the melody's blue notes, come from the same place: a scale that is neither major nor minor. Part 18's rules describe one tradition; the blues keeps another. Chapter eight returns to sevenths, and to the tones that define them.
The twelve-bar form runs through jazz, rhythm and blues, rock and roll and soul. Jam sessions use it because everyone knows it: it is a shared map. There are eight- and sixteen-bar blues too, but twelve is the standard. It is a form simple enough to learn in a minute and open enough for a lifetime. Chapter two turns to the notes that give the blues its name.
2Blue notesFoundations3 min
Is the blues in major or in minor?
A question for your ears. One sung phrase of ours, three times, over a C seven chord. Its fourth note is the third above C. In which version is that third neither minor nor major?
The third. The first version sings a minor third, three hundred cents; the second a major third, four hundred. The third version starts at the minor third and bends upwards, stopping short of major. That bent note, neither one nor the other, is a blue note.
Where do blue notes live? In three regions of the scale: the third, between E flat and E; the fifth, which may be flattened towards F sharp; and the lowered-seventh region, whose exact placement and movement vary rather than being restricted to one fixed interval between B flat and B. Singers and guitarists bend into these regions, and the notes are often moving, not fixed. A piano cannot bend, so blues pianists crush the minor and major thirds together, a grace note into the main note, to suggest the pitch between.
Measurements of recorded blues singers find the third spread across the whole region, not fixed at one pitch. Where it falls depends on context: where the melody comes from and goes, and the chord beneath. So is the blues major or minor? The question assumes a grid that the music does not use. Part 35's neutral third, about three hundred and fifty cents, sits in the same region. A blue note is a pitch region, not a pitch.
Jazz teaching boils this down to the blues scale: C, E flat, F, F sharp, G, B flat, C, the minor pentatonic of Part 12 with the flat fifth added. It is a useful simplification, and a simplification: it fixes on the piano's keys what singers bend between them. Played over C seven, its E flat clashes with the chord's E, and that clash is the point.
Where do blue notes come from? Gerhard Kubik, whom we met in Part 37, traced them to West African vocal traditions in his Africa and the Blues of 1999. In his account a scale built on other principles meets European triads and bends to fit them, and the flat seventh, in turn, turns every chord into a dominant seventh. The blues, on this view, is an encounter of two pitch systems, neither giving way. Chapter three turns to how the blues tells a story.
3Call and response: the blues lyricFoundations2 min
How does a twelve-bar verse tell a story?
A blues verse fits the twelve bars in a particular way. Here is a verse of our own. A line is sung, and repeated, usually over the move to the subdominant, so the same words take on a new colour. Then a third line answers it, and rhymes. A, A, B. Each line fills only the first half of its four bars; the second half is left open, for an answer.
Hear the verse's shape, sung by Part 17's model voice, which sings vowels rather than words. Each sung line is answered by a guitar in the bars the voice leaves open. The thirds of the vocal line are blue, between E flat and E.
Who answers? A guitar, a piano, a harmonica, a horn, or the singer's own guitar. It is Part 37's call and response, now inside a single performance. The answer comments on the line: it echoes it, contradicts it, or finishes the thought. In jazz, soloists trade fours, four bars each, answering one another. A conversation built into the form.
The form was carried by singers. The classic blues of the 1920s, Ma Rainey and Bessie Smith, was sung with bands on the vaudeville stage. Country blues was a singer with a guitar, free with the form, adding or dropping beats as the words required. In Chicago in the 1940s and 50s, Muddy Waters and others electrified the blues of the Delta. The twelve-bar form was a norm, not a law, and many early blues bend it. The recordings show the variety; the textbook form is a later average.
Why A, A, B? The repeated line gives the singer time to find the third line, live. It lets the audience join in, and expect the punch line. And the third line lands on the tonic, so the rhyme and the cadence arrive together. It is a form shaped for improvising words, as ragtime's form was shaped for the printed page. Which is the next chapter.
4Ragtime and strideFoundations3 min
What is `ragged' about ragtime?
Alongside the blues grew ragtime, piano music of the 1890s to the 1910s, sold as sheet music for the parlour piano. Its master, Scott Joplin, published the Maple Leaf Rag in Sedalia, Missouri, in 1899, and it sold for years. The name means ragged time: a syncopated right hand over a steady, march-like left hand. Joplin warned in his School of Ragtime of 1908 that it is never right to play ragtime fast. The rag is in the public domain, and we play it from an encoding of the score in the music21 corpus.
Here is the first strain of the Maple Leaf Rag, sixteen bars, played by Part 7's piano model from the score, at a moderate march tempo. Right hand in gold, left hand in blue.
Take the first four bars apart. First the right hand alone: notes that start between the beats and run across them. Then the left hand alone: a bass note on each beat and a chord between, like a march band's tuba and snare. Then both, and the friction between them is the rag.
Monochord splits the encoded notes by a pitch threshold at MIDI sixty-one, a register proxy rather than verified score hand labels, then counts attacks in each group. The left hand plays almost entirely on beats and half-beats: only of its attacks fall between. The right hand puts of its attacks between the eighth notes, on sixteenths. And times a right-hand note starts off the beat and is held across the next stronger position, with nothing new played there: the classic syncopation, the accent arriving early.
A rag is built like a march. Its sections are sixteen-bar strains, each repeated: the Maple Leaf Rag runs A A, B B, A, C C, D D, with the C strain, the trio, in the subdominant, D flat. Published piano rags are composed works; ragtime also developed through oral performance, improvised ragging and practices not preserved on the printed page. Player pianos and their paper rolls spread it, and fixed performances in paper. Part 21's forms, in a new dress.
From ragtime came stride, the Harlem piano style of the 1920s and 30s: faster, improvised, and swung. The left hand strides, a low bass note then a chord in the middle, leaping on every beat. Its masters were James P. Johnson, Fats Waller and Willie The Lion Smith, and then Art Tatum. And the even eighths of ragtime became swung eighths. Chapter five measures that swing.
5Swing, measuredFoundations3 min
Can swing be measured?
Monochord's swing model is deliberately simple. The ratio of long to short is three to one at a hundred and twenty beats a minute and falls in a straight line to one to one, even eighths, at three hundred. That is the trend that Anders Friberg and Johan Sundström measured in 2002 on drummers' ride cymbals in jazz recordings, drawn as a line rather than fitted to their points. Now look at what it implies for the short note: above about a hundred and sixty beats a minute it stays close to a tenth of a second, whatever the tempo. Friberg and Sundström reported the same: at medium and fast tempos the short note keeps a roughly constant length, as if it were a unit of its own.
Hear the model at three tempos: the ride cymbal's pattern, ding, ding-a ding, with walking bass and hi-hat, at a hundred, a hundred and eighty, and two hundred and sixty beats a minute. Watch the short note of each pair: at the slow tempo it hugs the next beat; at the fast tempo it moves nearly to the middle.
What else did the measurements find? Friberg and Sundström measured drummers' ride cymbals in recordings, note by note. The ratio falls as the tempo rises, and soloists often swing less than their drummers. Fernando Benadon found in 2006 that soloists' ratios vary widely even within one solo. So swing is not one ratio but a range, tied to tempo, player and phrase, and the triplet feel written at the top of a jazz chart is a rough guide, not a description.
There is a second ingredient. A 2022 study by Corentin Nelias, Theo Geisel and colleagues measured jazz soloists against their rhythm sections, and reported that soloists' downbeats came slightly late while their off-beats stayed in time with the band; in their listening tests, delaying downbeats made solos swing more. Here is a line of ours played both ways, the second with its on-beat notes thirty milliseconds late, a value chosen to illustrate the idea, not taken from the study.
To many listeners the second version sits back from the beat, the effect players call laid back. Thirty milliseconds can be audible as timing displacement; whether it sounds late, laid back or more swinging depends on the listener, articulation, tempo and context.
The ethnomusicologist Charles Keil argued in 1987 that groove comes from participatory discrepancies, the small timing differences between players. A groove is made of agreements and disagreements about where the beat is. Perfect quantization, every note on the grid, tends to sound stiff. Swing can involve differences of tens of milliseconds, with no universal boundary separating an audible delay from musical feel. Chapter ten asks what large collections of recorded jazz can settle.
6The swing bandFoundations3 min
How do sixteen players swing together?
From the mid-1930s to the mid-1940s, swing was the popular music of America, played by big bands for dancers. Fletcher Henderson's band and its arrangers had set the pattern in New York in the 1920s. Its soloist for a year from 1924 was Louis Armstrong, and his Hot Five records, made in Chicago from 1925, are where many historians hear swing phrasing begin: the band learned to play the way he did. Benny Goodman's success in 1935 carried it everywhere. Duke Ellington, Count Basie, and Chick Webb at Harlem's Savoy Ballroom, where the Lindy Hop was danced, led the great bands. It was music for dancing, written down by arrangers, with room for soloists.
A big band of the swing era had about sixteen players in four sections. Saxophones, usually five; trombones and trumpets, three or four each; and a rhythm section of piano, guitar, bass and drums. The horn sections play as units, in block chords, while the rhythm section keeps four even beats to the bar, and the sections answer one another: call and response again, now between groups of players.
Here is a riff chart of our own on the twelve-bar blues. The saxophones play a two-bar riff, moved with the chords; in its second bar the brass answer with three short punches. The rhythm section swings underneath. Six calls, six answers.
Riff charts came from Kansas City in the 1930s, where bands built pieces from riffs, by ear, in rehearsal and on the stand. These were head arrangements, memorised rather than written. Count Basie's band was the model: a light, even four from the rhythm section, and riffs piled on riffs. A riff is a short figure repeated as the chords move under it. Riffs became the backbone of rhythm and blues and rock and roll.
Behind the bands were arrangers. They voiced each section as a chord moving in parallel, which players call block or soli writing. A typical chart states the tune, opens the form for solos, builds to a full-band shout chorus, and ends with the tune again. Duke Ellington wrote for particular players, and with Billy Strayhorn for particular sounds. It is Part 41's orchestration, applied to sixteen players. Chapter seven opens up the rhythm section.
7Walking bass and the ridePractice3 min
Can a program walk a bass line?
The rhythm section has jobs. The bass walks: one note on every beat, outlining the chords and leading to the next one. The drummer plays the swing pattern on the ride cymbal and closes the hi-hat on beats two and four. The piano or guitar comps, placing chords to answer the soloist; in Basie's band, Freddie Green's guitar played four even chords to every bar. Time kept by four people at once.
Monochord's walking bass follows four rules. On the first beat of each chord, play its root. On the beat before a new chord, play a note a semitone above or below the new root, so the line leans into it. On other beats, play a chord tone, or a note of the chord's scale, and never leap more than a fifth. Among all the lines that obey, minimize a weighted cost: total motion, added penalties for leaps above four semitones and non-chord scale tones, plus a small starting-register preference. Repeated notes are forbidden. That is a shortest-path problem, solved beat by beat like Part 22's parser. Here are the first four bars of a jazz blues in C.
Hear the generated line through two choruses of the jazz blues at a hundred and forty beats a minute: first with only ride and hi-hat, then with the piano comping.
Count the line. Every one of its chord changes is approached by a semitone, and every chord begins on its root, as the rules require. of its moves are steps of one or two semitones. And it is dull: a real bassist varies the rhythm with skips and triplets, shapes the register over a chorus, and surprises.
The bassists made this an art. Walter Page, with Basie, made the even walking four the norm. Jimmy Blanton, with Ellington from 1939 to 1941, made the bass a solo voice. Ray Brown, Paul Chambers and others played lines that are melodies in their own right. And a walking line is improvised, chorus after chorus, while listening to everyone else. Chapter eight turns to the tones a line must find.
8Sevenths and guide tonesPractice3 min
Which two notes of a chord matter most?
Jazz harmony is built from seventh chords. Here are five on C. What tells them apart? The shared root does not distinguish them. The third and seventh identify much of their quality, but not everything: C minor seven and C half-diminished share E flat and B flat, and differ in the fifth. Even with a root, guide tones alone do not uniquely identify every chord. Players call them the guide tones.
Now take the commonest progression in jazz, two-five-one: D minor seven, G seven, C major seven. Monochord's guide-tone solver assigns each chord's third and seventh to two voices so that the total motion is least. The answer: F and C, then F and B, then E and B. Each voice either holds or moves by one semitone; semitones in all. And look at what happens to the roles: D minor's third, F, becomes G seven's seventh, which falls to E, C major's third; D minor's seventh, C, falls to B, G's third, which becomes C major's seventh. The sevenths fall into thirds.
Hear guide tones alone, on piano over the bass's roots: the two-five-one twice, slowly, and then the jazz blues of chapter one, fifteen chords, with the two lines the solver chose. They sound like two voices of a quiet chorale, though they are nothing but thirds and sevenths.
Through the whole jazz blues, the solver's two lines move semitones in all across chord changes, and neither voice ever moves more than . It is Part 32's search for smooth voice leading, restricted to two structurally useful notes, with other chord tones omitted. This is why jazz players practise guide-tone lines: they are the shortest path through the changes, and they can make harmonic movement clear, although guide tones alone leave some chord qualities ambiguous.
Pianists build their voicings on these notes. Shell voicings, root, third and seventh, as bebop pianists such as Bud Powell played them. Rootless voicings, third and seventh with the ninth and thirteenth, leaving the root to the bass, as Bill Evans and others played them. Comping with guide tones leaves room for the bass and the soloist, and a soloist who lands on guide tones at the changes makes the harmony audible even alone. Chapter nine turns to the progressions they move through.
9ii-V-I, turnarounds and the tritone substitutionFoundations3 min
Why can one chord stand in for another a tritone away?
The two-five-one is the backbone of jazz harmony: a minor seventh, a dominant seventh, and the tonic, the roots falling by fifths as in Part 18. The popular songs that jazz players adopted as standards are full of two-fives, often in chains through several keys, and a player hears a tune as a sequence of them and plays through each. The same three chords, endlessly reharmonised. There are two ways to vary them: substitute one chord for another, or add chords.
A question for your ears. Two versions of a two-five-one in C, each played twice, guide tones over the bass. In one of them the bass slides down by semitones into the final chord. Which one, the first or the second?
The second. In the first, the bass falls from D to G and rises to C, by fifths and fourths. In the second the G seven has been replaced by D flat seven, and the bass slides D, D flat, C.
Why does D flat seven stand in for G seven? Draw both on the circle of pitch classes. G seven is G, B, D, F; D flat seven is D flat, F, A flat, and C flat, which is B. They share exactly two notes, F and B, a tritone apart, and those are the guide tones of both: G seven's third is D flat seven's seventh, and its seventh is the other's third. Because a tritone is half an octave, it divides the octave into two equal halves and maps onto itself under transposition by a tritone, so exactly two dominant sevenths contain it. Keep the guide tones, swap the root, and the bass gets a chromatic path.
A turnaround is the two bars at the end of a form that lead back to its start. The plain one is one, six, two, five. Make the six a dominant seventh, a secondary dominant of two, and it pulls harder. Replace both dominants with their tritone substitutes, and the roots slide chromatically: C, E flat, D, D flat, and C again. Hear each twice.
After the swing era came bebop, in New York in the 1940s: Charlie Parker, Dizzy Gillespie, Thelonious Monk. Fast tempos, dense substitutions, and new melodies written over the chords of standards. Writing new melodies on familiar changes produced contrafacts; rights questions depend on the material, arrangement and jurisdiction, rather than a blanket rule that removes every licensing obligation. John Coltrane's Giant Steps, in 1959, moved its key centres by major thirds. Part 39 follows the changes further.
10Frontier: microtiming and jazz corporaResearch3 min
What makes a performance swing?
Is swing in the small timing deviations between players? The evidence is argued over. In 1995 J. A. Prögler measured bass and ride cymbal against each other and found them milliseconds apart. In 2019 George Datseris and colleagues, at the Max Planck Institute in Göttingen, found that removing jazz players' small timing deviations did not make listeners rate the music less swinging. In 2022 the same group reported that soloists' systematically late downbeats did add to swing in their tests. Random deviations and systematic ones are different things, and the debate is about which matters. The measurements are fine; the open question is what listeners use.
Hear the kind of manipulation such experiments use, with values of our own. A line on an additive saxophone, first exactly on the swing model's grid, then with every note shifted at random by a few milliseconds, typically fifteen, at most . Does the second swing more, less, or the same?
Judge the two sketches for yourself; this informal comparison establishes no majority response. The cited experiments distinguish kinds of manipulation in particular performances and listener groups, rather than proving that only systematic timing can matter.
Jazz is now studied as data too. The Weimar Jazz Database holds four hundred and fifty-six transcribed solos, with their beats, chords and annotations, from the Jazzomat project. It can answer how swing ratios, note choices and patterns vary by player and era, and pattern searches find licks that travel between players across decades. What a corpus cannot answer alone is why a performance feels as it does. Parts sixty-one to sixty-three build such tools for audio.
A concrete version. Take solos from a corpus and resynthesise them with controlled changes. Vary the swing ratio, the downbeat delay, dynamics and articulation, one at a time and together. Ask listeners of different experience to rate the swing, and model their ratings. What makes a performance swing, and for whom? An answer would turn a proverb into a model, or show why it cannot be one.
This history has a hard side. Early blues was sold on race records, marketed along the lines of segregation. Many performers were paid a flat fee and no royalties, and publishers often took the credit. Later stars recorded their songs, sometimes without acknowledgement. Who made the music, and who was paid, are part of its history. Part sixty returns to rights and royalties.
Variation 38, recap and problemsAll tracks3 min
Every part ends by doing something to the Tune with what it built. First, its two phrases as a twelve-bar blues: the first phrase over the tonic, again over the subdominant, the second phrase over the last line, sung by the model voice with its thirds bent thirty-five cents flat. Then as a rag: each note of the Tune turned into Joplin's short-long-short figure in the right hand, over an oom-pah left hand, of the right hand's attacks syncopated. And last as a riff chart: the Tune's opening as the saxophones' riff, its cadence as the brass's answer, swung over the rhythm section.
Row thirty-eight of the ledger: seconds; the measurements are the blue third, the rag's syncopations, and the riff's swing ratio.
What did we find? The twelve-bar blues is three lines of four, using seventh chords in this basic version. Blue notes are regions, not pitches, and the lyric is A A B, with room for answers. Ragtime sets a syncopated right hand over a march-like left, as the counts in Joplin's rag show. Swing is about three to one at slow tempos and even at fast ones, with the short note near a tenth of a second. These bass and guide-tone solvers optimize their stated costs and constraints; real players use additional musical goals. And two-five-one, turnarounds, and the tritone that two dominant sevenths share are the material of jazz harmony.
Five problems. One to compute, one to prove, one for your ears, one to build, and a research problem, marked with a star. Solutions are in this part's notes. Pause here.
Where does this come back? Next, in standards, changes and reharmonisation. In the riff, the backbeat and the song. In arranging for a band. In performing and improvising. And in machines that track beats and recognise chords.
And in practice. Jazz students practise guide-tone lines through standards before they solo. Bassists learn to walk by targeting roots and approaching them by semitones. Producers set a drum machine's swing amount, which is a ratio by another name. And pianists learn Joplin from the score, and stride by ear.
The books and papers this part follows. The full list, with notes, is in the README.
Where it goes next. Standards and reharmonisation in Part 39; the riff, backbeat and song in Part 40; arranging in Part 41; performing and improvising in Part 43; beat tracking and chord recognition in Part 62.
Key results
The part's results in one place, for revision.
Try it
Lab 38 · Blues and swing, computed
Swing a line at any tempo; walk a bass and find guide tones through any changes; hear and name tritone substitutions; and count a rag's syncopations.
python -m videos.music.labs 38
needs numpy, scipy, matplotlib · download lab38.py ·
source on GitHubtempo: long-short ratio, short note (ms) 100: 3.22, 142, 140: 2.78, 113, 200: 2.11, 96, 260: 1.44, 94
walking bass, jazz blues in F (first two bars) [53, 51, 48, 47, 46, 44, 43, 42]
approaches into each chord (semitones) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
guide tones through it: total motion, biggest step 32 semitones, 3
your CHANGES' guide tones (upper / lower) [64, 67, 65, 65, 67, 67, 65, 65] / [59, 61, 60, 59, 62, 61, 60, 59]
tritone substitutes of C7, G7, D7 C7 -> F#7, G7 -> Db7, D7 -> Ab7
Maple Leaf Rag, bars 1-16: attacks between the eighths (right / left) 46 of 85 / 3 of 45
ear problem: plain or substitute, in order (listen first) substitute, substitute, plain, plain, plain
The model's short note settles near a tenth of a second at fast tempos; the walking bass meets every chord on its root after a semitone; guide tones through ii-V-I move two semitones in all; and a dominant's tritone substitute shares its third and seventh.
The code (82 lines; it asserts its own result)
"""Lab 38: blues and swing, computed: the swing model at any tempo, a walking bass and guide tones for any changes,
tritone substitutes, and the syncopations of Joplin's Maple Leaf Rag."""
import numpy as np
from videos.coursekit import labs
from explainer.music.monochord import SR, Clip, concat, mix
from explainer.music.monochord import blues as BL
from videos.music.music38 import compute as C
TITLE = "Blues and swing, computed"
GOAL = ("Swing a line at any tempo; walk a bass and find guide tones through any changes; hear and name tritone "
"substitutions; and count a rag's syncopations.")
TASKS = [
"Change TEMPOS. Where does the model's short note stop shrinking? Is that what you hear?",
"Change KEY and VARIANT (basic, quick, jazz). Do the bass's approaches stay a semitone? How far do the guide tones move?",
"Write your own CHANGES as bars of chord symbols and find their guide tones.",
]
TEMPOS = [100, 140, 200, 260]
KEY = "F"
VARIANT = "jazz"
CHANGES = [["Cmaj7"], ["A7"], ["Dm7"], ["G7"], ["Em7"], ["A7"], ["Dm7"], ["G7"]]
def run(seed=0):
rng = np.random.default_rng(seed)
lab = labs.Lab()
lab.row("tempo: long-short ratio, short note (ms)", ", ".join(f"{b}: {BL.swing_ratio(b):.2f}, {BL.short_note_ms(b):.0f}" for b in TEMPOS))
ch = BL.twelve_bar(KEY, VARIANT)
wb = BL.walking_bass(ch)
seq = BL.beats_of(ch)
firsts = [i for i in range(len(seq)) if i == 0 or seq[i] != seq[i - 1]]
assert all(wb[i] % 12 == BL.chord(seq[i])["root"] for i in firsts), "every chord starts on its root"
lab.row(f"walking bass, {VARIANT} blues in {KEY} (first two bars)", str(wb[:8]))
lab.row("approaches into each chord (semitones)", str([abs(wb[i - 1] - wb[i]) for i in firsts]))
syms = [s for b in ch for s in b]
g = BL.guide_tones(syms)
lab.row("guide tones through it: total motion, biggest step", f"{g['total']} semitones, {g['max_step']}")
g2 = BL.guide_tones([s for b in CHANGES for s in b])
lab.row("your CHANGES' guide tones (upper / lower)", f"{g2['upper']} / {g2['lower']}")
lab.row("tritone substitutes of C7, G7, D7", ", ".join(f"{s} -> {BL.tritone_sub(s)}" for s in ("C7", "G7", "D7")))
r = C.load("rag")
lab.row("Maple Leaf Rag, bars 1-16: attacks between the eighths (right / left)",
f"{r['sync_right']['between']} of {r['sync_right']['onsets']} / {r['sync_left']['between']} of {r['sync_left']['onsets']}")
# ear problem: ii-V-I's in random keys, some with the tritone substitute
beat = 60.0 / 90
kinds, clips = [], []
for i in range(5):
k = int(rng.integers(0, 12))
sub = bool(rng.random() < 0.5)
prog = [BL.transpose("Dm7", k), BL.transpose("Db7" if sub else "G7", k), BL.transpose("Cmaj7", k)]
gt = BL.guide_tones(prog)
parts = []
for j, s in enumerate(prog):
for m in (gt["upper"][j], gt["lower"][j]):
parts.append((Clip(C.piano(m, 2 * beat, 0.7), SR), j * 2 * beat, -3.0))
root = BL.chord(s)["root"]
parts.append((Clip(C.bass(root + (36 if root < 6 else 24), 2 * beat), SR), j * 2 * beat, 0.0))
clips.append(Clip(mix(parts, duration=6 * beat + 1.0).y, SR).at_level(-20.0))
kinds.append("substitute" if sub else "plain")
lab.audio = concat(clips, gap=0.8)
lab.row("ear problem: plain or substitute, in order (listen first)", ", ".join(kinds))
fig, (ax1, ax2) = labs.figure(2)
bs = np.arange(80, 321, 5)
ax1.plot(bs, [BL.swing_ratio(b) for b in bs], color=labs.GOLD, label="long : short")
ax1b = ax1.twinx()
ax1b.plot(bs, [BL.short_note_ms(b) for b in bs], color="C0", label="short note (ms)")
ax1.set_xlabel("tempo (beats a minute)")
ax1.set_ylabel("ratio")
ax1b.set_ylabel("short note (ms)")
ax1.set_title("the swing model")
ax2.step(range(len(wb)), wb, where="post", color="C0")
ax2.set_xlabel("beat")
ax2.set_ylabel("key number")
ax2.set_title(f"walking bass, {VARIANT} blues in {KEY}")
lab.fig = fig
lab.note = ("The model's short note settles near a tenth of a second at fast tempos; the walking bass meets every chord "
"on its root after a semitone; guide tones through ii-V-I move two semitones in all; and a dominant's "
"tritone substitute shares its third and seventh.")
return lab
Now change it
- Change TEMPOS. Where does the model's short note stop shrinking? Is that what you hear?
- Change KEY and VARIANT (basic, quick, jazz). Do the bass's approaches stay a semitone? How far do the guide tones move?
- Write your own CHANGES as bars of chord symbols and find their guide tones.
Problems, with solutions
Try each problem before opening its solution.
-
Compute. Using the model, compute the swing ratio and the short note's length at 140 and 240 beats a minute.
Solution
r(140) = 3 − 2 × (140 − 120)/180 ≈ 2.78; a beat is 60/140 ≈ 0.429 s, so the short note is 0.429/(1 + 2.78) ≈ 113 ms. r(240) = 3 − 2 × 120/180 ≈ 1.67; a beat is 0.25 s and the short note 0.25/2.67 ≈ 94 ms. The lab prints any tempo.
-
Prove. Prove that exactly two dominant seventh chords contain any given tritone.
Solution
A dominant seventh on root r has pitch classes r, r + 4, r + 7, r + 10. Of its six pairs only one, (r + 4, r + 10), is six semitones apart, so each dominant seventh holds exactly one tritone, {r + 4, r + 10}. That equals a given tritone {a, a + 6} when r + 4 = a or r + 4 = a + 6, that is r = a − 4 or r = a + 2: two roots, a tritone apart. For {F, B}: G7 and D♭7.
-
Ear. The lab plays ii–V–I's, some with tritone substitutes; say which.
Solution
The lab prints the answers. Listen to the bass: a substitute makes it slide down by semitones into the tonic; the plain progression falls a fifth and rises a fourth.
-
Build. Extend the walking-bass generator with skips and triplets, and keep its rules.
Where to look.
blues.walking_basschooses one note a beat by dynamic programming. Add a second layer that may replace a beat with a swung triplet (a ghost note leading to the next beat) when the step allows a chromatic passing note, keep the root and approach rules on the beats, and check every chord still starts on its root. -
★ What makes a performance swing, and for whom?
Where the frontier is. Take solos from a corpus such as the Weimar Jazz Database, resynthesise them with controlled changes to swing ratio, downbeat delay, dynamics and articulation, one at a time and together, ask listeners of different experience to rate swing, and model the ratings with uncertainty.
Notes and sources
Sources
- G. Kubik, Africa and the Blues (1999); P. Oliver, The Story of the Blues (1969).
- E. A. Berlin, Ragtime: A Musical and Cultural History (1980); S. Joplin, School of Ragtime (1908).
- G. Schuller, Early Jazz (1968) and The Swing Era (1989); P. F. Berliner, Thinking in Jazz (1994); M. Levine, The Jazz Theory Book (1995).
- A. Friberg and J. Sundström, "Swing ratios and ensemble timing in jazz performance: evidence for a common rhythmic pattern", Music Perception (2002); F. Benadon, "Slicing the beat: jazz eighth-notes as expressive microrhythm", Ethnomusicology (2006).
- C. Keil, "Participatory discrepancies and the power of music", Cultural Anthropology (1987); J. A. Prögler, "Searching for swing: participatory discrepancies in the jazz rhythm section", Ethnomusicology (1995).
- G. Datseris and others, "Does it swing? Microtiming deviations and swing feeling in jazz", Scientific Reports (2019); C. Nelias and others, "Downbeat delays are a key component of swing in jazz", Communications Physics (2022).
- M. Pfleiderer, K. Frieler, J. Abeßer, W.-G. Zaddach and B. Burkhart (eds.), Inside the Jazzomat (2017), on the Weimar Jazz Database.
- Part 13 for seventh chords; Part 18 for progressions; Part 32 for voice leading as distance; Part 37 for timelines.
- T. Gioia, The History of Jazz (3rd ed., 2021); L. Armstrong and his Hot Five, the OKeh recordings (Chicago, 1925--28), discussed and not played.
About this partfrom its README
Part 38 of a sixty-eight-part course in music (see the series plan and
the syllabus), the fifth part of Act VI. "What is swing?" The proverbial answer is that if you have to
ask, you will never know; but it can be measured. This part builds the twelve-bar blues and its blue notes, the AAB
verse, ragtime (Joplin's Maple Leaf Rag, played from its score and counted), swing as a ratio that falls with tempo
and as late downbeats, the swing band's riffs, the walking bass and the ride cymbal, guide tones, ii–V–I, turnarounds
and the tritone substitution. The tools are Monochord's (explainer/music/monochord/blues.py): chord symbols, the
twelve-bar forms, a swing model, a walking-bass generator and a guide-tone solver (both shortest paths), tritone
substitutes and a syncopation count. Maple Leaf Rag (1899, in the public domain) is played from its encoding in the
music21 corpus; every other line, riff and verse is ours. Published findings are the ones listed under Sources.
- If you have to ask. An ear question (a swung line: how much longer is the long note?); the same line straight; swing can be measured; the plan.
- 1. The twelve-bar blues. Where the blues came from; the form in C, three lines of four; one chorus, heard, with piano, walking bass, ride and hi-hat; the quick change and a jazz blues; the seventh as home; a shared map.
- 2. Blue notes. An ear question (which third is neither minor nor major?); where blue notes live (third, fifth, seventh); a region, not a note; the blues scale and its limits; Kubik on where blue notes come from.
- 3. Call and response: the blues lyric. An AAB verse of ours; the twelve bars with sung lines and guitar answers, heard; who answers; the singers; why AAB.
- 4. Ragtime and stride. Joplin and ragtime; Maple Leaf Rag, bars 1–16, heard; bars 1–4 hand by hand, heard; the strain counted (right hand: 46 of 85 attack times between the eighths, 8 held across the next stronger position; left hand: 3 of 45 and 2); the march form; stride.
- 5. Swing, measured. The model (3:1 at 120 beats a minute to 1:1 at 300) and the short note it implies (near 100 ms above about 160); the ride pattern at 100, 180 and 260, heard; Friberg and Sundström, Benadon; late downbeats (Nelias and colleagues), a line on time and 30 ms late, heard; groove and participatory discrepancies.
- 6. The swing band. The swing era; the sections; a riff chart of ours on the twelve-bar blues, heard; riffs and Kansas City; the arrangers.
- 7. Walking bass and the ride. The rhythm section's jobs; the generator's four rules (root on each chord's first beat, a semitone approach before it, chord or scale tones between, no leap beyond a fifth; least total motion); two choruses of a jazz blues, heard; the line counted (all 15 changes approached by a semitone; 38 of 47 moves steps); the bassists.
- 8. Sevenths and guide tones. Five seventh chords; guide tones through ii–V–I (F/C, F/B, E/B: 2 semitones in all); guide tones through ii–V–I and the jazz blues, heard; the jazz blues counted (32 semitones over 14 changes, no step above 3); voicings.
- 9. ii–V–I, turnarounds and the tritone substitution. Two-five-one; an ear question (in which version does the bass slide by semitones?); G7 and D♭7 share F and B; a turnaround three ways, heard; bebop and after.
- 10. Frontier: microtiming and jazz corpora. Prögler; Datseris and colleagues (2019); Nelias and colleagues (2022); a line on the grid and with random deviations, heard; the Weimar Jazz Database; ★ research problem: what makes a performance swing, and for whom?; credit and royalties.
- Variation 38, recap and problems. The Tune as a twelve-bar blues sung with thirds 35 cents below E, as a rag (its notes turned into short-long-short figures over an oom-pah left hand: 18 of 44 right-hand attacks syncopated), and as a riff chart (swung 2.7 to 1 at 150 beats a minute); the ledger; what we found; five problems; where it comes back; in practice; references; Part 39.
What is computed and built
python -m videos.music.music38.compute (under a minute) fills .cache/music38/.
| Item | What it computes | Checked against |
|---|---|---|
hook, swing, delay, jitter |
swung lines by the model; the ride pattern at three tempos; late and random timing | the model's formula (tests) |
form, blue, callresp |
the twelve-bar forms; one phrase with three thirds; an AAB verse | — |
rag |
Maple Leaf Rag, bars 1–16, from the encoding; attacks and syncopations by hand | hand counts (tests) |
band |
a riff chart | — |
walking |
the walking-bass generator over a jazz blues | its rules, in every key (tests) |
guide, subs |
guide tones by shortest path; ii–V–I with and without a tritone substitute; turnarounds | brute force (tests) |
tune, variation |
Variation 38 | — |
Monochord's tools are held in tests/music/test_blues.py; this part's claims and clips in
tests/music/test_music38.py.
Sounds. The piano is Part 7's struck string on a soundboard; bass and guitar are Part 35's retuned plucked string
through Part 7's body; the ride cymbal is a modal model with designed, dense treble modes and a stick's click; hi-hat
and snare are filtered noise with Part 9's membrane; the voice is Part 17's model (it sings vowels, not words); the
horns are additive (labelled synthesized). There are no recordings.
What the models are, and are not. The swing model is a straight line through a published trend, not a fit to measured points; real swing varies by player, phrase and tempo. The late-downbeat demonstration uses 30 ms, a value of ours, not the study's. The walking bass obeys four rules and nothing else: real lines vary rhythm and register and surprise. The horns are additive tones, not models of saxophones or trumpets. The blue third is placed by us; sung blue notes move. The ensembles and verses are ours.
Notes
Basic blues sketches use seventh chords, not every blues performance. Blue-note regions are contextual rather than fixed universally bounded pitch bins. The rag hand groups use a MIDI-61 pitch threshold, not ground-truth hand labels, so their counts describe that proxy. Walking-bass optimization includes scale-tone and large-leap penalties, a register preference and a repeated-note ban. Guide tones do not uniquely distinguish Cm7 from Cm7b5: the fifth matters. The swing line and 30-ms delay are illustrative; delay audibility and swing judgments have no universal threshold. Composed published rags coexist with improvised ragtime practices. Contrafacts do not imply a blanket legal exemption.
Companion material in this repository
The syllabus's plan for this partfrom SYLLABUS.md, the plan of record
- Hook: an ear question (how much longer is the long note?); the line straight; swing can be measured; the plan.
- The twelve-bar blues: origins; the form in C; one chorus heard; the quick change and a jazz blues; the seventh as home; a shared map.
- Blue notes: an ear question (which third is neither?); where blue notes live; a region, not a note; the blues scale; Kubik on origins.
- Call and response, the blues lyric: an AAB verse of ours; the verse with guitar answers heard; who answers; the singers; why AAB.
- Ragtime and stride: Joplin; Maple Leaf Rag's first strain heard; bars 1-4 hand by hand heard; the strain counted; the march form; stride.
- Swing, measured: the model and its short note; the ride pattern at three tempos heard; the studies; late downbeats heard; groove.
- The swing band: the era; the sections; a riff chart of ours heard; riffs and Kansas City; the arrangers.
- Walking bass and the ride: the rhythm section; the generator's rules; two choruses heard; the line counted; the bassists.
- Sevenths and guide tones: five seventh chords; guide tones through ii-V-I; guide tones heard; the jazz blues counted; voicings.
- ii-V-I, turnarounds and the tritone substitution: two-five-one; an ear question (which bass slides?); the shared tritone; three turnarounds heard; bebop.
- Frontier: microtiming argued over; random deviations heard; jazz as data; the research problem; credit.
- Variation 38: the Tune as a twelve-bar blues, a rag and a riff chart. Outro: problems, payoffs.
Covers: the twelve-bar form and its harmony; blue notes; call and response; ragtime and stride; the big band;
walking bass and ride pattern; seventh chords as the unit; guide tones; ii–V–I; turnarounds; the tritone
substitution.
Built and computed: monochord/blues.py: chord symbols and the twelve-bar forms; a swing model (3:1 at 120
beats a minute to 1:1 at 300, a line through Friberg and Sundström's trend, not a fit) and its short note (near
100 ms at fast tempos); a walking-bass generator and a guide-tone solver as shortest paths (every change approached
by a semitone; ii–V–I in 2 semitones); tritone substitutes; a syncopation count; Joplin rendered from the score
(46 of 85 right-hand attacks between the eighths in the first strain, against 3 of 45 in the left hand).
Variation 38: the Tune as a twelve-bar blues (thirds 35 cents below E), a rag (18 of 44 right-hand attacks
syncopated) and a riff chart (swung 2.7 to 1).
Frontier: microtiming studies of swing (Datseris and others, 2019; Nelias and others, 2022); jazz corpora.
Rights: Joplin is in the public domain and played from the score; every other line, riff and verse is ours;
later standards only by name (§2.4).
Reading: Kubik, Africa and the Blues; Berlin, Ragtime; Schuller, The Swing Era; Berliner, Thinking in
Jazz; Friberg & Sundström (2002); Benadon (2006).
Build the film
python -m videos.music.music38.compute # the part's numbers, into .cache/music38
python tools/build.py music38 # render and assemble the film
EXPLAINER_TTS=silent python tools/qa_scene.py music38 Hook # one chapter, silent, with a contact sheet
Scenes: videos/music/music38. Setup: see the course page. Source of these notes: the README and the scenes' narration.
Build it
python -m videos.music.music38.compute # numbers and sounds (under a minute)
EXPLAINER_TTS=silent python tools/build.py music38 -q l --fps 15 # a silent-narration preview, with the sounds
python tools/qa_sound.py music38 --sync # the sound gates
python tools/dead_air.py renders/music38_480p.mp4 --sound music38 # no empty screen; no sound over a still one
python tools/lecture_length.py music38 # 30 to 60 minutes, listening included
python tools/build.py music38 # 1080p30, narrated
python -m pytest -q tests/music # Monochord against its references; this part's claims and clips
python -m videos.music.labs 38 # the lab (writes a figure and a short WAV)