Hi Claire,
I created a tool called "semitones" which should do what you want, and it will be useful since extracting semitone intervals is a generally useful thing that warrants a dedicated tool. It is part of the
humlib repository so that it can also be used in
Verovio Humdrum Viewer.
Example use:
humcat h://chorales/chor001.krn | semitones
**kern **tti **kern **tti **kern **tti **kern **tti
*k[f#] *k[f#] *k[f#] *k[f#] *k[f#] *k[f#] *k[f#] *k[f#]
*M3/4 *M3/4 *M3/4 *M3/4 *M3/4 *M3/4 *M3/4 *M3/4
4GG 12 4B 0 4d 0 4g 0
=1 =1 =1 =1 =1 =1 =1 =1
4G -3 4B 1 4d 2 2g 7
4E 2 8cL -1 4e -2 . .
. . 8BJ -2 . . . .
4F# 1 4A -2 4d 0 4dd -3
=2 =2 =2 =2 =2 =2 =2 =2
4G -5 4G -1 2d -3 4.b -2
4D 2 4F# 1 . . . .
. . . . . . 8a -2
4E -4 4G 5 4B 5 4g 0
=3 =3 =3 =3 =3 =3 =3 =3
4C -1 8cL -1 8eL -2 4.g 2
. . 8BJ 1 8d 2 . .
8BBL -2 4c 2 8e 2 . .
8AAJ -2 . . 8f#J 1 8a 2
4GG 7 4d 0 4g -1 4b -2
=4 =4 =4 =4 =4 =4 =4 =4
2D; -7 2d; 0 2f#; 1 2a; 2
4GG -1 4d -5 4g -5 4b 3
=5 =5 =5 =5 =5 =5 =5 =5
The semitone intervals are placed in spines called *tti (meaning twelve-tone intervals). The interval is placed at the note attack of the first note in the interval, with a positive value meaning the following note is above the current pitch, and negative being below, and 0 meaning a repeated note. If a rest follows a note, an "r" is placed at the last note
before the rest (this is useful for avoiding calculating intervals across rests). The first note in a chord is the only note considered, and secondary tied notes are ignored. Data can contain spine splits, although there will be corner cases such as when an interval is intervened by a spine split, the interval is calculated to the left subspine after the split. If a merge splits the interval, then both notes (or more) before the merger will share the ending note after the merger.
To extract just the data spines:
humcat h://chorales/chor001.krn | semitones | extract -i **tti
or
humcat h://chorales/chor001.krn | semitones | extractx -i tti
**tti **tti **tti **tti
*clefF4 *clefGv2 *clefG2 *clefG2
*k[f#] *k[f#] *k[f#] *k[f#]
*M3/4 *M3/4 *M3/4 *M3/4
12 0 0 0
=1 =1 =1 =1
-3 1 2 7
2 -1 -2 .
. -2 . .
1 -2 0 -3
=2 =2 =2 =2
-5 -1 -3 -2
2 1 . .
. . . -2
-4 5 5 0
=3 =3 =3 =3
-1 -1 -2 2
. 1 2 .
-2 2 2 .
-2 . 1 2
7 0 -1 -2
=4 =4 =4 =4
-7 0 1 2
-1 -5 -5 3
=5 =5 =5 =5
The humdrum extras tool "serialize" can be used to create a monophonic sequence out of such data. Here is a pipeline to create a histogram of the melodic semitones found in the chorale:
humcat h://chorales/chor001.krn | semitones | extractx -i tti | serialize | ridx -H | sortcount
52 -2
45 2
31 -1
26 0
25 1
7 -4
6 5
5 7
5 3
4 4
4 -3
4 -7
4 -5
1 12
The most common interval is -2 and the least common is +12.
The -m option can be given to list the MIDI note number of the note in the parallel **kern spine (only the first note in a chord will be considered):
humcat h://chorales/chor001.krn | semitones -m
**kern **mnn **kern **mnn **kern **mnn **kern **mnn
*clefF4 *clefF4 *clefGv2 *clefGv2 *clefG2 *clefG2 *clefG2 *clefG2
*k[f#] *k[f#] *k[f#] *k[f#] *k[f#] *k[f#] *k[f#] *k[f#]
*M3/4 *M3/4 *M3/4 *M3/4 *M3/4 *M3/4 *M3/4 *M3/4
4GG 43 4B 59 4d 62 4g 67
=1 =1 =1 =1 =1 =1 =1 =1
4G 55 4B 59 4d 62 2g 67
4E 52 8cL 60 4e 64 . .
. . 8BJ 59 . . . .
4F# 54 4A 57 4d 62 4dd 74
=2 =2 =2 =2 =2 =2 =2 =2
4G 55 4G 55 2d 62 4.b 71
4D 50 4F# 54 . . . .
. . . . . . 8a 69
4E 52 4G 55 4B 59 4g 67
=3 =3 =3 =3 =3 =3 =3 =3
4C 48 8cL 60 8eL 64 4.g 67
. . 8BJ 59 8d 62 . .
8BBL 47 4c 60 8e 64 . .
8AAJ 45 . . 8f#J 66 8a 69
4GG 43 4d 62 4g 67 4b 71
=4 =4 =4 =4 =4 =4 =4 =4
2D; 50 2d; 62 2f#; 66 2a; 69
4GG 43 4d 62 4g 67 4b 71
=5 =5 =5 =5 =5 =5 =5 =5
With **mnn meaning "MIDI note number". **tti and **mnn are impromptu spine types and can be adjusted to a more formal exiting spine type if needed. The main thing is that both have an "r", with "r" in **tti meaning that there is a rest present after the note so no interval can be calculated, and in **mnn, the "r" means that the associated **kern token is a rest.
To download humlib and install:
cd humlib
make
make install
If you already have humlib downloaded, then go to that directory and type:
git pull
make
make install
Check to see if semitones is available:
which semitones
and the computer should reply
/usr/local/bin/semitones
Source code for the semitones tool:
=================
I implemented this in humlib so that it can be used in VHV to display the semitone intervals above the notes in the graphical score:
Direct link to the data used in the above example:
Go to the
filter toolbar and type "
semitones -c" then press enter to activate the filter (or click on the filter icon which is highlighted in yellow in the above image, which indicates that the filter is currently active. You can alternatively add this line anywhere in the input data to show the semiton intervals in the notation to display the semitone intervals above the notes:
!!!filter: semitones -c
The -c option is used to make the spine type be **cdata rather than **tti. **cdata means "chord-like data" which will cause the data in that spine to be printed as text above the staff (otherwise **tti is not known to VHV and will be ignored).
Here is the MIDI note number data, using the filter "semitones -mc":
-=+Craig