VAMP: Introduction and Examples

    Copyright 2002-2004, Stanley M. Swanson.
      latest revision: 10 June 2004
 
    This information is distributed under the terms of the
    GNU Free Documentation License.  legalities
 
VAMP was written to produce music suitable for contra dance and
square dance from traditional melodies.  A (public domain) melody
and dance chords are specified with "abc" notation, then merged with
chord sequence and rhythm-accent information to produce a MIDI
file.  The three aspects (melody, chords, accent/phrasing) can be
specified with simple text lines and varied independently.  There are
limitations to this structuring of the musical information, since
it is harder to tweak individual notes than in a GUI type composing
program, but the specifications are more compact and less tedious
to change.  Other aspects of a performance such as tempo, staccato,
and instrument selection can also be specified.  The resultant
MIDI file is played (or converted to WAV format for a CD)
by a multimedia player (I use TiMidity++ on Linux).

Typically an old time public domain melody comes without chords,
so the harmony command suggests appropriate chord choices.


                             
Input
Example 1: Petronella, a reel
Example 2: Pop Goes the Weasel, a jig
Chord Assignment

                             
Input to the program is command line (text) oriented and can be given
in immediate mode or taken from pre-edited files.  A more complete
discussion of the commands is in the file vamp_commands.html.

Sample commands in the examples come in two flavors: 
container type commands where the data appears sandwiched
between a "command" line and its matching terminator "/command" 
  ( "melody", "chords", "vamp", "accent", "phrase" )
and one-liners with a command followed by data 
  ( "tempo", "instrument", "generate", "harmony", "param").
The line oriented format of "abc" notation is retained for
data lines in "melody", and "vamp".

Commands can be abbreviated so long as they remain unambiguous
(presently single letters for most commands).
Commands are case insensitive.  File names, chord names, and ID's for
melodies, chord sequences, and accent patterns ARE case sensitive.

There are several other input lines which can be viewed as "one-liners":
comment lines beginning with "#" and the indirect file designator
"@path/filename" which switches input immediately to the file until
an EOF is read.  The "abc" convention of "%" marking the rest of
a line as comment is generally observed.
                                    contents

---------------------------
EXAMPLES

To illustrate the basic command structure for input, two
examples are given below: the reel "Petronella" and the jig
"Pop goes the Weasel".

The commands below were entered into two files, "petronella"
and "popgoestheweasel".  Then the program was run twice with
the indirect file references:

                      
@petronella     % input from indirect file
quit            % exit program

@popgoestheweasel
quit
                         

                             

Input to the program is indicated in red, output by blue, and
commentary in black.

                          
melody
T: Petronella
C: traditional
B: Ryan's Mammoth Collection (1882) 
B: Patrick Sky's facsimile edition,  p. 174 (MelBay 1995)
M: 2/4
L: 1/16
K: G
% as transcribed:
%  : gd | B2dB A2dB  | G2G2G2 B,D  | G2CE A2G2  | FAGE D2gd |
%         B2dB A2dB  | G2G2G2 B,D  | G2Ce A2F2  | G2G2G2   :|
%  : dB | G2gd B2d'b | c'2c'a fdcA | F2af d2c'a | b2bg dgdB |
%         G2gd B2d'b | c'2c'a fdcA | F2af fc'af | g2g2g2   :|
% modify to accomodate lead in notes gd, dB ...
% the very first "gd" lead-in appears in the vamp "intro" (see below)
    |: B2dB A2dB  | G2G2G2 B,D  | G2CE A2G2  |   FAGE D2gd |
       B2dB A2dB  | G2G2G2 B,D  | G2Ce A2F2  |[1 G2G2 G2gd :|[2 G2G2 G2dB |
    |: G2gd B2d'b | c'2c'a fdcA | F2af d2c'a |   b2bg dgdB |
       G2gd B2d'b | c'2c'a fdcA | F2af fc'af |[1 g2g2 g2dB :|[2 g2g2 g4 |
/melody

                     
Musical note input in "abc" format:

For insertion of music description in abc format, we retain the 
historical .abc line oriented file format, but bracket
the abc text with the "melody" and "/melody" command lines:
For a complete specification, see the web site of Chris Walshaw, who
originated the notation:  www.gre.ac.uk/~c.walshaw/abc

A capital letter followed by a colon in column 2 specifies information.
  T: the title of the tune (transferred to the MIDI file)
  B: source book (ignored as a comment)
  M: meter
  L: default length of a note (a sixteenth note in this case)
  K: key (G major)
There are many more possibilities, which are ignored as comments.

The music itself is given by letters separated by bar lines "|".
An ascending seven note  scale starting with middle C is given with 
capital letters: "CDEFGAB"; the octave above that is in lower case: 
"cdefgab".  The total range recognized by VAMP is six octaves, specified 
by appending commas to lower notes and apostrophes to higher notes:
 C,,, ... B,,,C,, ... B,,C, ... B,C ... Bc ... bc' ... b'c'' ... b'' .

In this example, a few notes are longer than the default value (1/16):
for instance, B2 is an eighth note and G4 is a quarter note. 

Repeat structure is indicated by |: ... :| and alternate endings by
|[1  ... :|[2 ... |.  Some rearrangement was necessary to conform
the lead-in notes "gd" and "dB" at the beginning of the repeats to
the chord structure given by the vamp and chord commands below.

                      
vamp
L: 1/8  % to give 2 quarter notes (beats) per measure
K: C
intro  | [G] [z] | [G] [z] | [G] [z] | [G] [g/2] [d/2] |  % note first gd
%
 g   | [G,,G,]   [B,DG]  [D,,D,]    [B,DG]  |   % i  I   tonic
 c   | [C,,C,]   [G,CE]  [G,,,G,,]  [G,CE]  |   % u  IV  major subdominant
 d   | [D,,D,]   [A,D^F] [A,,,A,,]  [A,D^F] |   % v  V   major dominant
 em  | [E,,E,]   [BEG]   [B,,,B,,]  [BEG]   |   % w  VI  minor tonic
 am  | [A,,A,]   [CEA]   [E,,E,]    [CEA]   |   % j  II  minor subdominant
 bm  | [B,,,B,,] [B,D^F] [^F,,^F,]  [B,D^F] |   % t  III minor dominant
 gend | [G,,G,]  [B,DG]  [G,,2G,2]          |   % i  I   coda
/vamp

                      
Vamping is a term out of the jazz lexicon which means to produce
a simple, typically improvised, chord accompaniment to a melody.
There is a characteristic "boom chick boom chick" sound to dance
accompaniment which comes from a unison chord on the downbeat and 
a triad chord on the upbeat.  For contra music, the dancers take 
a step on each "boom". Peter Barnes has written a comprehensive 
discussion of basic vamping and variations in his book "Interview 
with a Vamper".

I have used the key of C and made the F sharps explicit (^F)
using the "abc" notation for a sharped note.  The square brackets
enclose notes sounded simultaneously in a chord.  Each vamp measure
is preceded by a symbolic name (e.g. g c d em ...) and is
written as a single line of text.  The comments explain my 
lowercase single letter chord abbreviations used above in the
harmony command.  The special sequence "gend" furnishes a final
coda with a long unison chord.  The "intro" sequence specifies four 
beats preceding the music for the caller to give the first call, and
also includes the first lead-in sixteenth notes "g/2 d/2" omitted by
rewriting the repeat structure in the melody above.  Note that in
the melody, with L:1/16, the lead-in is written "gd", whereas in
the vamp, with L:1/8, we write it as "[g/2][d/2]", also enclosing
the single notes in the chord brackets "[ ]".

                      
chords top
    g g  c d  g g  c g        g g  c d  g g  c g    
    g am d g  g am d g        g am d g  g am d gend      
/chords

                      
Once the vamp sequences are defined, the chords for a melody
are very compactly stated.  No repeat symbols are defined in
the chord command, so explicit vamping for all 32 measures
of this melody must be given.  Different named chord sequences 
can be played on subsequent repeats of the melody by using the
"event" or "variations" command.

                      
accent  softchord
   100 1050 80 1050 85 1050 80 1050  90 1050 80 1050 85 1050 80 1050
/accent

                      
An alternate notation has been added to the program, with the
staccato indicated by leading periods:
                      
accent  % equivalent to "softchord"
   100 .50 80 .50 85 .50 80 .50   90 .50 80 .50 85 .50 80 .50
/accent

                      

Normally phrasing is indicated by varying the volume of the notes
played, with a major accent on the first note of a measure and
a lesser accent on the middle note in 2/4 meter.  VAMP gives control 
over the volume of the  chords with the accent command.  Additional
control over the dynamics of the melody is being developed in a
"phrase" command.

For the 8 beats (4 measures) of a dance phrase, the unisons on the 
steps are stressed
 ( 100 80 85 80 90 80 85 80 ) and the triads are relatively quiet (50).
Moreover, the triad chords are deemphasized even more by being
shortened (staccato) by half (to 30 out of their 60 MIDI ticks)
as indicated by the 1000 added to the 50.  Without staccato, the
MIDI velocities (volumes) would be: 
 |  100 50 80 50  |  85 50 80 50  |  90 50 80 50  |  85 50 80 50  |
(bar lines have been supplied for clarity).

Other games can be played.  One of the goals of this project was to
mark the cueing point for a beginning caller.  A strategy that
may work is to supress the triad after the 4th beat, giving a
subtle indication of the 5th beat for the cue.

The relation of velocity to volume is normally logarithmic; the examples
in this file work with TiMidity++, version 2.11 or earlier where the
relation was linear.  The mathematical details are discussed in greater 
detail in vamp_commands:volume.

                      
instrument  111 1
tempo 120.0  
parameter  10 30
% the following lines marked with '#' will appear in the generated MIDI file 
# melody on fiddle, chords on piano, staccato 30 on chords
# tempo 120, g major coda in last measure
generate 2 petronella_one.midi

                      
Finally we have some miscellaneous one-liners.  "Instrument" gives
the melody and accompaniment instruments by their general MIDI (gm)
numbers.  The default is fiddle and piano (111 and 1) as given above.
The number of quarter notes (dance steps) per minute can be changed
from the default 120.0 by the "tempo" command.  The first two numbers
in a parameter command set the number of staccato ticks for melody
(10) and vamp (30).  I have found that a slightly staccato fiddle
with short silences between the notes sounds better than notes
run into each other.   Two "#" comment lines will be retained as
text in the MIDI file.

A MIDI file is produced by a "generate" command which also gives
an output file name.  The digit 2 says to use both the melody and
the chords.  "gen 0 melody.midi" would play just the tune (no chords)
on the fiddle, and is available before any chords have been assigned.

On Linux, a MIDI file is written to disk and "timidity" is spawned to
play the file immediately.  "quit" exits the program.

                                    contents
-----------------

                             

As our second example, consider "Pop goes the Weasel" in 6/8 time:

                      

melody
T:Pop goes the Weasel
B:Ryan's Mammoth Collection (1882) p. 264, 
B: from Patrick Sky's facsimile edition p.173 , Mel Bay 1995?
L:1/8
M:6/8
R:Jig
K:G
  |: G2G A2A | BdB G2z | G2G A2c | B3 G2z  | 
  |  G2G A2A | BdB G2z | e3  A2c | B3 G2z :|
  |: g3  e2g | faf d3  | g2g e2g | f3 d2B  |
  |  c2B c2d | e2f g2z | ez2 A2c | B3 G2z :|
/melody
                      
The abc notation and the repeat structure is somewhat simpler.  
Observe the quarter-eighth note pairs often found in jigs 
(G2G, c2B, ...) and the symbol "z" for a rest.


In 6/8 compound meter, the measure appears to be 360 ticks or
three quarter notes long.  In order to have 120 dance steps per
minute, the tempo must be set to 180.0 bpm (see below).
                      

vamp
% jigvamp.g   % modify reel vamp to 6/8 time: unison 2 chord 1...
K: C
 g   | [G,,2G,2]   [B,DG]  [D,,2D,2]    [B,DG]  |   % i  I   tonic
 c   | [C,,2C,2]   [G,CE]  [G,,,2G,,2]  [G,CE]  |   % u  IV  major subdominant
 d   | [D,,2D,2]   [A,D^F] [A,,,2A,,2]  [A,D^F] |   % v  V   major dominant
 em  | [E,,2E,2]   [BEG]   [B,,,2B,,2]  [BEG]   |   % w  VI  minor tonic
 am  | [A,,2A,2]   [CEA]   [E,,2E,2]    [CEA]   |   % j  II  minor subdominant
 bm  | [B,,,2B,,2] [B,D^F] [^F,,2^F,2]  [B,D^F] |   % t  III minor dominant
/vamp
                      

The basic vamp structure has a different rhythm (quarter-eighth) to
match the 6/8 jig meter.
                      

chords
 g g c g   g g am g   g g c g  g g c g
 c d c bm  c c am g   c d c d  c c c g
/chords  % from harmony analysis...
                      

These chords were taken from the output of "harmony" which gives some
minor chords.  The minor chords were replaced by the highest ranking
major chord in the second repeat for each part.  (see harmony discussion
below)

                      
% convert jig triplets to dance tempo at 120 half measures per minute.
tempo 180.0   
accent
   100 .40  70 .40    85 .40  70 .40
%  100 1040 70 1040  85 1040 70 1040   %% old syntax
/accent
parameter 10 20
generate 2 weasel.midi

                      
Once the melody, vamp, and chords are input, one can change
instrumentation, tempo, number of repeats, staccato and so on,
then generate modified versions of the MIDI file.  Timidity can 
also modify tempo, volume, and other performance parameters
during the playing of an existing MIDI file.

                                    contents
-----------------------
ANALYSIS OF HARMONY (chord assignment)
                             
Here is an example with the first 8 measures from Petronella, with
guitar chords supplied from a previous analyis (harm all bound)

The first eight bars from Petronella (first repeat of strain A):

                                
melody petro
  ....
    |: "G"B2dB A2dB  | "G"G2G2G2 B,D  | "C"G2CE A2G2  |   "D"FAGE D2gd  |
       "G"B2dB A2dB  | "G"G2G2G2 B,D  | "C"G2Ce A2F2  |[1 "G"G2G2 G2gd :|
  ...
/melody
                                
 
                                
harmony norestrict guitar nodetail nolog 15
                                

Note that the number "15" is interpreted as specifying the preference
schema and the tone weighting when "nokey" is in effect.
[more details on harmony analysis]


Predicted chords for all measures (GD means G and D played for a half measure each)

                      
  GD    G     C     DG    GD    G     CD    G
  GD    G     C     DG    GD    G     CD    G
  G    AmD    D     G     G    AmD    D     G
  G    AmD    D     G     G    AmD    D     G
                                
 
A command with option 0 will print the indicated guitar chords;
                                
harmony norestrict guitar 0

                      
select_note key:  G 7  center  G 7
  G     G     C     D     G     G     C     G
  G     G     C     D     G     G     C     G
  G    Am     D     G     G    Am     D     G
  G    Am     D     G     G    Am     D     G
                                
 
[  Note on detail levels:  "nodetail" just gives the
[  short 4 line 32 chord summaries.  "detail" also prints the
[  measure lines for which flag1 is not ".". "d d" prints
[  information for all measures, one line per measure (see below).

Part of the result from "harm[ony] d[etail] d[detail] 15"

                      
 1.    G   186  |  G   126  D    95 ..  + G      186 126
 2.    G   246  |  G   126  G   126 ..    G      246 126
 3.    C   184  |  C   124  G    66 ..  * C      184 124
 4-    G   156  |  D    65  G   126 ..  + D      155  65
 5.    G   186  |  G   126  D    95 ..  + G      186 126
 6.    G   246  |  G   126  G   126 ..    G      246 126
 7-    D   125  |  C   124  D   125 ..  + C      124 124
 8.    G   246  |  G   126  G   126 ..    G      246 126
 ....
                                

Format: measure number, flag1, flag2, full measure chord and score "|"
        half measure chords and scores ".." flag3, guitar chords,
        guitar chord scores (full, half_1, (half_2 if two guitar chords) )
 
 flag1:  "."    full or half measure predictions agree with guitar chords
              If one guitar chord given:
         "-"    prediction and guitar scores same except for preference
         ">"    prediction > (at least not == ) to guitar score
              If two guitar chords given:
         "~"   raw scores same, preference weighting makes choice different
         "#"   more complicated differences
 
 flag2:  " "   all notes in measure are in designated key
         "@"   one or more notes are accidentals.

Thus the measures with flag1 other than "." are of specific interest.
 
 flag3:  " "   both half measure predictions identical to full measure
         "*"   half measure predictions not identical, sum of scores <= full
         "+"   sum of half measure scores > full measure score
                  (indicating that this measure may do better with two chords)
 


Some summary statistics on how well the predicted chords agree with guitar chords

                      
28 match,  18 identical,   8 nonpreferred,  15 opt
exact  28   0   sum  32   0   gtr   0   0
                                
 
Here 28 out of 32 measures give either the exact guitar chords or
a single guitar chord matches one or the other of a double chord.

An example of an older analysis:

                      
harmony log all
                      

 i   G     u   C     v   D     w   Em    j   Am    t   Bm   
 measure   1 [ 1803  1803]    i t w v j u   G 
 measure   2 [ 2403  2102]    i w u t v j   G 
 measure   3 [ 1803  1503]    u w i j v t   C 
 measure   4 [ 1503  1501]    v i t u w j   D 
 measure   5 [ 1803  1803]    i t w v j u   G 
 measure   6 [ 2403  2102]    i w u t v j   G 
 measure   7 [ 1202  1201]    u v j w i t   C 
 measure   8 [ 2403  2102]    i u w v t j   G 

  .... (measures 9-16 are repeats of 1-8)

 measure  17 [ 2403  1803]    i w t u v j   G 
 measure  18 [ 1803  1202]    j u v t i w   Am
 measure  19 [ 2103  1502]    v t j i u w   D 
 measure  20 [ 2403  1803]    i w t u v j   G 
 measure  21 [ 2403  1803]    i w t u v j   G 
 measure  22 [ 1803  1202]    j u v t i w   Am
 measure  23 [ 2103  1503]    v t j u i w   D 
 measure  24 [ 2403  2103]    i w u t v j   G 

 .... (measures 25-32 repeat 17-24)

i i u i i i u i i i u i i i u i i j v i i j v i i j v i i j v i 

t w w v t w v u t w w v t w v w w u t w w u t w w u t w w u t u 

                     

Typically an old time public domain melody comes without chords.
The harmony command matches the notes in a measure to the 
three notes in six possible triad chords: [major tonic(i), 
subdominant(u), and dominant(v); minor tonic(w), subdominant(j)
and dominant(w)].  The chord whose notes have the longest total 
duration in the melodic measure is written at the end of the line. 
 
All six chords are ranked in the shorthand notation i j t u v w.
The line before measure 0 gives the correspondence between
this shorthand and the conventional chords in the key of G. 
The first and second ranked chord sequences are printed at the end.

The bracketed numbers are the ranks for the top two chords.
This algorithm seems to agree with human chosen chords about
70% to 80% of the time.  See vamp_commands.html for more details.
The option "log" records the screen output in a log file.

                     
harmony statistics

                     
measure ticks  240 occurences   18
ticks in modal measure  240,  max ticks in measure 240
tonal_center  G   key_signature  G   mode_delta 0
 relative pitch, tonic 7
   30    0   13    0   17   10    0   20    0    3    0   10
intervals    0 < -12,    6 > 12
    0    0    0    0    2    4    0    7    8   27    7    1   16
   16    4    1    5    1    6    1    1    1    0    1    0    3    6

                     

The option "statistics" gives counts of the key tonic-relative 
semitones and semitone intervals for all the notes in the piece.  
It also gives a summary of measure lengths in MIDI ticks.

                      
harmony center

                     
tonal_center  G   mode delta 0  key_signature  G
    C   C#    D   Eb    E    F   F#    G   Ab    A   Bb    B
   67   40   78   58   59   46   45   80   35   55   54   65 center 7  G
  for strains A,B 
   62   38   81   52   64   48   45   82   35   56   52   67 center 7  G
   57   37   79   55   59   56   58   71   42   59   45   64 center 2  D

                     

The harmony option "center" matches each of the twelve semitones
in the scale to the notes in the melody,  using a consonance/dissonance 
measure of intervals due to Malmberg (1918).  A higher number indicates
more consonance, a lower number more dissonance.  For tunes in a major key,
the center should match the key signature.  It may be useful for
identifying modes other than major or minor (e.g. Dorian, Mixolydian).
The first line of numbers is for the entire piece, the two following
lines are for the two parts (strains) A and B, assuming a standard 
AABB structure.

                                    contents
------------------

Some harmony analysis applied to Pop Goes the Weasel.

                      

harmony log all

                      
 i   G     u   C     v   D     w   Em    j   Am    t   Bm   
 measure   1 [ 1802  1802]    i u w v j t   G 
 measure   2 [ 3002  2402]    i w t u v j   G 
 measure   3 [ 2403  1802]    u i w j v t   C 
 measure   4 [ 3002  3002]    i w t u v j   G 
 measure   5 [ 1802  1802]    i u w v j t   G 
 measure   6 [ 3002  2402]    i w t u v j   G 
 measure   7 [ 3603  2403]    j u w v i t   Am
 measure   8 [ 3002  3002]    i w t u v j   G 

 .... (measures 9-16 repeat)

 measure  17 [ 3603  3603]    u w i j v t   C 
 measure  18 [ 3603  3003]    v t i j u w   D 
 measure  19 [ 3603  3603]    u w i j v t   C 
 measure  20 [ 3603  3002]    t v i w u j   Bm
 measure  21 [ 2402  2402]    u j i t v w   C 
 measure  22 [ 2402  2402]    u w j i v t   C 
 measure  23 [ 2403  1203]    j u v w i t   Am
 measure  24 [ 3002  3002]    i w t u v j   G 

 .... (measures 25-32 repeat)

 i   G     u   C     v   D     w   Em    j   Am    t   Bm   

i i u i i i j i i i u i i i j i u v u t u u j i u v u t u u j i 

u w i w u w u w u w i w u w u w w t w v j w u w w t w v j w u w 

                      
Without alternate endings, measures 9-16 are identical to 1-8
and 25-32 are the same as 17-24; those 16 lines have been deleted 
manually for this example.

                      
harmony center

                      
tonal_center  G   mode delta 0  key_signature  G
    C   C#    D   Eb    E    F   F#    G   Ab    A   Bb    B
   69   43   72   54   68   44   44   77   37   59   49   65 center 7  G
  for strains A,B 
   73   43   79   62   68   45   38   79   30   52   48   65 center 7  G
   62   44   73   46   56   35   50   78   37   65   64   71 center 7  G

                      
The tonal center is consistent with the G major key signature.

                      
harmony statistics

                      
measure ticks  360 occurences   16
ticks in modal measure  360,  max ticks in measure 360
tonal_center  G   key_signature  G   mode_delta 0
 relative pitch, tonic 7
   17    0    8    0    9    5    0    5    0    5    0    4
intervals    0 < -12,    0 > 12
    0    0    0    0    0    2    0    0    7    7    0    6    8
    8    3    8    8    0    1    0    0    0    1    0    0    1    0
                      

                                    contents



                                
 
    Copyright 2002-2004, Stanley M. Swanson.
      12 Sept. 2002; revised 24 Dec. 2002, 10 Feb. 2003, 17 May 2003,
                       31 July 2003, 8 Aug 2003, 2 Mar. 2004, 10 June 2004
 
    This information is distributed under the terms of the
    GNU Free Documentation License (with no invariant sections, or cover
    requirements).  The accompanying program, VAMP, is distributed under 
    the terms of the GNU General Public License, version 2 or later.
    NO WARANTEES are made for either the documentation or the software.
    For the full text of the licenses, refer to the Free Software Foundation:
     GNU licenses