A_Grammatical_Approach_to_Automatic_Impr
A_Grammatical_Approach_to_Automatic_Impr
A_Grammatical_Approach_to_Automatic_Impr
A Grammatical Approach to
Automatic Improvisation
Robert M. Keller, David R. Morrison
Harvey Mudd College
Claremont, California, USA
[email protected], [email protected]
Abstract— We describe an approach to the automatic context-free grammar, as it occurs in computer science
generation of convincing jazz melodies using probabilistic and linguistics. Then we show how a grammar can be used
grammars. Uses of this approach include a software tool for to generate plausible rhythmic and melodic sequences for
assisting a soloist in the creation of a jazz solo over chord
progressions. The method also shows promise as a means of jazz. Playable examples will be presented that show the
automatically improvising complete solos in real-time. Our effectiveness of the approach. Our approach has been
approach has been implemented and demonstrated in a free implemented and has been tested in the past year as
software tool. part of a broader educational software tool, which proved
Keywords— jazz, improvisation, educational software, beneficial in a jazz improvisation course taught by the first
probabilistic context-free grammar, melody generator.
author and has also been used by various third parties.
I. I NTRODUCTION
Our group set out to develop a tool for assisting III. R ELATED W ORK
improvisors in creating jazz solos in the context of given
chord progressions (“changes” in jazz musicians’ parlance The motivation for our use of grammar was based
(JMP)). An initial approach involved creating a large primarily on implementation needs. It was only during
database of existing melodic fragments (“licks” in JMP) writing the final version of this paper that we became
from which the user could choose, to help create melodic aware of the many references that suggested using gram-
lines or fill gaps in these lines. One problem with this ap- mars in one form or another for various aspects of
proach is that there are many different chord progressions, music analysis and synthesis. Early work includes that
even when normalized to a given tonal center, which of Winograd [3], Lindblom and Sundberg [4], Longuet-
would thus require an extremely large database. Moreover, Higgins [5] and Roads [6], to name a few. Rader’s work
the database needed to be manually created, which was [7] used probabilistic grammars to generate traditional
very labor-intensive, albeit instructive to the creator. melodies. Hughes [8] surveyed the use of grammars for
An alternate approach that does not have the above non-western musics, and Bel and Kippen [9] used them
difficulties is to have the software dynamically generate for patterns in Indian drumming. Please see Roads and
novel licks. While this idea has great appeal, it is less Strawn [10], Cope [11], and McCormack [12] for more
than obvious how to make it work so that the results thorough surveys, the latter including use of L-systems
sound like convincing jazz solos. Choices of notes that and Markov chains. Recent work of Assayag and Dubnov
are largely random, even ones drawn entirely from the [13] demonstrate the use of factor oracles to generate
chords, tend not to sound good, especially rhythmically. improvised sequences.
Some additional structuring method is required to make Lerdahl and Jackendoff [14] used a generative gram-
the notes fit together in a manner that will be pleasing to mar theory for music analysis, which is referenced by
the ear. Horowitz [15] as an approach to jazz analysis. Steed-
We have developed an approach based on the idea man [16] described the use of a grammar for analyzing
of a formal grammar, augmented with certain pragmatic jazz chord progressions, but not melodies, and Johnson-
devices, which seems to be largely successful in achieving Laird [17] elaborated on this approach. Earlier work by
our objective of creating good-sounding melodic lines. Johnson-Laird [18] also suggests using regular grammars
The approach has been realized as a feature of a free soft- for explaining rhythmic sequences. Despite this large set
ware tool for assisting improvisors in the creation of better of references, we believe that the particular way in which
solos. The tool is called Impro-Visor (for “Improvisation we employ grammars and the meaning we assign to
Advisor”) and has been available on the world-wide web the terminal symbols has adequate elements of novelty.
since January 2006 [1]. A preliminary paper describing Because we use probabilistic grammars, we mention
our tool was presented in [2]. Temperley’s recent book [19], which describes wide uses
of probabilistic models for music analysis, including both
II. S TRUCTURE OF THE PAPER pitch and rhythm. The work of Ulrich [20] and, although
Having reviewed the background and motivation of it does not use grammars, Grachten [21] seem to share
our project, we will briefly review the concept of a some of the spirit of our own approach.
330
Proceedings SMC'07, 4th Sound and Music Computing Conference, 11-13 July 2007, Lefkada, Greece
331
Proceedings SMC'07, 4th Sound and Music Computing Conference, 11-13 July 2007, Lefkada, Greece
332
Proceedings SMC'07, 4th Sound and Music Computing Conference, 11-13 July 2007, Lefkada, Greece
2) Color tones: complementary tones for the current Other possible constraints will be considered in the
chord. These are tones that are not in the chord, but future.
which are individually sonorous with it. They are
XI. A S AMPLE G RAMMAR
also often called “tensions” in JMP.
3) Approach tones: non-chord tones that make good Here is an example of a grammar that seems to be
transitions to chord-tones or color tones. very workable for contemporary jazz licks. It is the
4) Other: tones that do not fall into one of the cate- current default in our tool. As mentioned earlier, an
gories above. added advantage of using a grammar is that the user
These characterizations are similar to ones used by jazz can change it to suit, for example, to make the generated
players. The corresponding notes, in the context of chords, melodies simpler or more complicated. The terminals in
provide the tension-release aspect common to professional the grammar consist of the note class symbols followed
jazz solos. We use a distinct symbol for each of the first by a duration value. These representations are chosen to
three types of tones, and four additional terminals, as be natural for the musician, who can also use the same
follows: notation in other parts of the software tool, such as in
accompaniment style specifications. The duration values
1) C a chord tone.
are designated as follows:
2) L a color tone.
• 1 a whole-note
3) A an approach tone.
• 2 a half-note
4) H a “helpful” tone, defined to be any of one of the
• 4 a quarter-note
above.
• 4. a dotted quarter-note
5) S a scale tone, a member of a scale designated as
• 8 an eighth-note
being compatible with the chord.
• 16 a sixteenth-note
6) X an arbitrary tone.
• 4/3 a quarter-note triplet
7) R a rest.
• 8/3 an eighth-note triplet
Approach tones currently force the following tone to
• 16/3 a sixteenth-note triplet
be a chord tone, even if its designation is otherwise. The
definitions of chord, color, approach, and scale tones is For example A8/3 designates an approach tone with a
given on a per-chord basis in a separate vocabulary spec- duration of a eighth note triplet. Note that we did not
ification. All vocabulary information is user specifiable include dotted eighth-notes and sixteenth-notes, as they
as a text file of S-expressions [26]. The later provide a don’t occur frequently enough in jazz. A pair of eighth
readable way to communicate structure, in comparison to notes, however, is usually “swung”, that is articulated so
alternatives such as XML or proprietary formats. that the note on the beat is about 2/3 of a beat long,
For example, the grammar might generate a sequence and the following note about 1/3 of a beat long. This
(A8 L8 S8 C8 H4. S8). Based on the current chord, the swing ratio is implied from the ambient style, rather than
symbols would be replaced with actual pitches, to become being shown in the grammar explicitly. Hence the same
a note sequence, such as (f#+8 g+8 e+8 d+8 b4. g8), grammar works well for both swing tunes and for latin
representing the notes shown in the first staff of Fig. 2 tunes, where the eighth notes are more nearly equal. If
(Note: All staves in this paper are treble clef.). Here 8 ordinary dotting is desired, a dot after a terminal symbol
refers to eighth-note duration, 4. means a dotted quarter- denotes lengthening the normal value by 1/2.
The terminal set of the example grammar, where each
note duration, and + means to raise the pitch one octave
item separated by commas counts as a single symbol, is:
from its default position, the octave just above middle
C. Although the second note class in the sequence is X2, X4, X4., X8, X16, X4/3, X8/3,
specified as a color tone, this is actually over-ridden to H2, H4, H4., H8, H16, H4/3, H8/3,
be a chord tone, due to the previous note class being an A4, A8, A16, A8/3, C2, C4, C8,
approach tone. (This is the current operative convention, L4, L8, R4, R8, S4, S8
but it could be changed.) The following section elaborates Auxiliary symbos, such as P below, can be endowed
on the overall process. with parameters, to permit generation of melodies to fit a
certain number of beats. A parameter of N beats on the
X. A DDITIONAL C ONSTRAINTS left-hand side of a production is sub-divided using arith-
We allow the user to apply additional constraints to metic on the right-hand side to enable a coarse skeletal
increase the likelihood that the pitch sequence is melodic. layout, which is further refined with other productions.
Although this information could be provided with an The first group of productions below are parameterized.
extension of the current grammar notation, this is left for With P (N ) as the start symbol, where N is an argument
future exploration. The specific controllable constraints indicating the length of the overall sequence in beats,
are as follows: the productions, with their assigned weights in square
1) Minimum and maximum pitch values. brackets, are (where the Q′ s are auxiliary symbols that
2) Minimum and maximum interval between pitches. expand into a sequence occupying the indicated number
3) A probability of using an interval outside the above of beats):
specification, i.e. for a “leap”. 1) P (0) → empty [ 1 ]
333
Proceedings SMC'07, 4th Sound and Music Computing Conference, 11-13 July 2007, Lefkada, Greece
2) P (1) → Q1 [1]
3) P (2) → Q2 [1]
4) P (3) → Q2 Q1 [ 1 ]
5) P (n) → Q2 P (n − 2) [ .25 ]
6) P (n) → Q4 P (n − 4) [ .75 ]
An example initial derivation sequence might be
334
Proceedings SMC'07, 4th Sound and Music Computing Conference, 11-13 July 2007, Lefkada, Greece
335
Proceedings SMC'07, 4th Sound and Music Computing Conference, 11-13 July 2007, Lefkada, Greece
336
Proceedings SMC'07, 4th Sound and Music Computing Conference, 11-13 July 2007, Lefkada, Greece
337