]> git.cworth.org Git - scherzo/commitdiff
Take advantage of pango markup to draw superscripted chord names.
authorCarl Worth <cworth@cworth.org>
Wed, 25 Sep 2013 22:07:22 +0000 (15:07 -0700)
committerCarl Worth <cworth@cworth.org>
Wed, 25 Sep 2013 22:07:22 +0000 (15:07 -0700)
Now instead of things like "C Major triad" we have shorter names like
"CM". Instead of "Augmented" we have a superscripted degree symbol,
etc.

scherzo.c

index a7bd785786ede2d57ca13784ad24220db322b8fe..ed62f762a60a2eef8bda0a929e88762a3cca8a60 100644 (file)
--- a/scherzo.c
+++ b/scherzo.c
@@ -639,40 +639,53 @@ scherzo_analyze_chord (scherzo_t *scherzo)
     num_notes = note_group->num_notes;
 
     struct { modified_degree_t degrees[1]; const char *name; } octaves[] = {
-       { {{1, 0}}, "Octave"}
+       { {{1, 0}}, " Octave"}
     };
 
     struct { modified_degree_t degrees[2]; const char *name; } intervals[] = {
-       { {{1, 0}, {2, -1}}, "Minor 2nd"},
-       { {{1, 0}, {2,  0}}, "Major 2nd"},
-       { {{1, 0}, {3, -1}}, "Minor 3rd"},
-       { {{1, 0}, {3,  0}}, "Major 3rd"},
-       { {{1, 0}, {4,  0}}, "Perfect 4th"},
-       { {{1, 0}, {5, -1}}, "Diminished 5th"},
-       { {{1, 0}, {5,  0}}, "Perfect 5th"},
-       { {{1, 0}, {6, -1}}, "Minor 6th"},
-       { {{1, 0}, {6,  0}}, "Major 6th"},
-       { {{1, 0}, {7, -1}}, "Minor 7th"},
-       { {{1, 0}, {7,  0}}, "Major 7th"}
+       { {{1, 0}, {2, -1}}, " Minor 2nd"},
+       { {{1, 0}, {2,  0}}, " Major 2nd"},
+       { {{1, 0}, {3, -1}}, " Minor 3rd"},
+       { {{1, 0}, {3,  0}}, " Major 3rd"},
+       { {{1, 0}, {4,  0}}, " Perfect 4th"},
+       { {{1, 0}, {5, -1}}, " Diminished 5th"},
+       { {{1, 0}, {5,  0}}, " Perfect 5th"},
+       { {{1, 0}, {6, -1}}, " Minor 6th"},
+       { {{1, 0}, {6,  0}}, " Major 6th"},
+       { {{1, 0}, {7, -1}}, " Minor 7th"},
+       { {{1, 0}, {7,  0}}, " Major 7th"}
     };
 
+/* XXX: The superscript rise value should be relative to the current
+ * font size. Best would be for pango to support this. See:
+ *
+ * https://bugzilla.gnome.org/show_bug.cgi?id=708780
+ *
+ * For now, these are emipirically-derived values that look reasonable
+ * at the default size that score.c is using to draw the staff. If the
+ * user scales the staff up or down then these will look wrong.
+ */
+
+#define SUP "<span font='33' rise='30000'>"
+#define PUS "</span>"
+
     struct { modified_degree_t degrees[3]; const char *name; } triads[] = {
-       { {{1, 0}, {3,  0}, {5, +1}}, "Augmented triad" },
-       { {{1, 0}, {3,  0}, {5,  0}}, "Major triad" },
-       { {{1, 0}, {3, -1}, {5,  0}}, "Minor triad" },
-       { {{1, 0}, {3, -1}, {5, -1}}, "Diminished triad" }
+       { {{1, 0}, {3,  0}, {5, +1}}, SUP "+" PUS },
+       { {{1, 0}, {3,  0}, {5,  0}}, "M" },
+       { {{1, 0}, {3, -1}, {5,  0}}, "m" },
+       { {{1, 0}, {3, -1}, {5, -1}}, "°" }
     };
 
     struct { modified_degree_t degrees[4]; const char *name; } sevenths[] = {
-       { {{1, 0}, {3,  0}, {5, +1}, {7,  0}}, "Augmented/major 7" },
-       { {{1, 0}, {3,  0}, {5, +1}, {7, -1}}, "Augmented 7" },
-       { {{1, 0}, {3,  0}, {5,  0}, {7,  0}}, "Major 7" },
-       { {{1, 0}, {3,  0}, {5,  0}, {7, -1}}, "Dominant 7" },
-       { {{1, 0}, {3, -1}, {5,  0}, {7,  0}}, "Minor/major 7" },
-       { {{1, 0}, {3, -1}, {5,  0}, {7, -1}}, "Minor 7" },
-       { {{1, 0}, {3, -1}, {5, -1}, {7,  0}}, "Diminished/major 7" },
-       { {{1, 0}, {3, -1}, {5, -1}, {7, -1}}, "Half-diminished 7" },
-       { {{1, 0}, {3, -1}, {5, -1}, {7, -2}}, "Diminished 7" }
+       { {{1, 0}, {3,  0}, {5, +1}, {7,  0}}, SUP "+M7" PUS },
+       { {{1, 0}, {3,  0}, {5, +1}, {7, -1}}, SUP "+7" PUS },
+       { {{1, 0}, {3,  0}, {5,  0}, {7,  0}}, "M7" },
+       { {{1, 0}, {3,  0}, {5,  0}, {7, -1}}, "7" },
+       { {{1, 0}, {3, -1}, {5,  0}, {7,  0}}, "m" SUP "M7" PUS },
+       { {{1, 0}, {3, -1}, {5,  0}, {7, -1}}, "m7" },
+       { {{1, 0}, {3, -1}, {5, -1}, {7,  0}}, "°" SUP "M7" PUS },
+       { {{1, 0}, {3, -1}, {5, -1}, {7, -1}}, "𝆩" SUP "7" PUS },
+       { {{1, 0}, {3, -1}, {5, -1}, {7, -2}}, "°" SUP "7" PUS }
     };
 
     if (scherzo->chord) {
@@ -802,11 +815,11 @@ scherzo_analyze_chord (scherzo_t *scherzo)
                         inversion);
                exit(1);
            }
-           chord_name = talloc_asprintf (local, "%s %s %s",
+           chord_name = talloc_asprintf (local, "%s%s %s",
                                          _pitch_str (root),
                                          chord_name, inversion_str);
        } else {
-           chord_name = talloc_asprintf (local, "%s %s",
+           chord_name = talloc_asprintf (local, "%s%s",
                                          _pitch_str (root),
                                          chord_name);
        }