Coloring successive intervals

This scheme engraver searches for specified successive intervals in a voice, e.g. a minor third. If the interval occurs somewhere, the note heads of both notes defining the interval are colored. The engraver can be added to every Voice context.

Usage: \color_interval_engraver #intervaldefs #debug? #intervals-given

intervaldefs: alist containing information about semitonical distances for certain intervals, diatonical distance is calculated in the engraver using `string-diatonic-semi-tonic-list`, relying on the key.

debug?: (optional) boolean, if true, output information about the processed pitches

intervals-given: list of the form


#`((interval1 ,dir1 enh1 ,color1)
   (interval2 ,dir2 enh2 ,color2)
    ...
   (intervalN ,dirN enhN ,colorN))
with
intervalN: string - specifying the interval to search after
dirN: integer - UP (=1) DOWN (=-1) or 0 (up and down)
enhN: boolean - search for enharmonically equivalent intervals, too?
colorN: lilypond color value, see NR A.7.

Example:

\layout {
   \context {
     \Voice
     \consists \color_interval_engraver #intervaldefs
       #`(("2--" ,UP #f ,green)
          ("3+" ,DOWN #t ,blue))
   }
}
Debug mode:

With debug? set to #t, the engraver does output

Warnings:

The engraver tries to provide helpful warning messages when fed with invalid input or if other issues prevent the engraver from working correctly.

Some examples: