+/* Remove an exactly-matching pitch from 'group'
+ * See also: pitch_group_remove_pitch_enharmonic
+ *
+static void
+pitch_group_remove_pitch (pitch_group_t *group, pitch_t pitch)
+{
+ int i;
+
+ for (i = 0; i < group->num_pitches; i++)
+ if (group->pitches[i] == pitch)
+ pitch_group_remove_pitch_at (group, i);
+}
+*/
+
+/* Remove all pitches from a pitch_group_t */
+static void
+pitch_group_remove_pitches (pitch_group_t *group)
+{
+ talloc_free (group->pitches);
+ pitch_group_init (group->ctx, group);
+}
+
+static void
+scherzo_update_notes_and_chord (scherzo_t *scherzo)
+{
+ void *local = talloc_new (NULL);
+ pitch_group_t *chord;
+ chord_signature_t *signature;
+ char *chord_name = NULL;
+ pitch_t *root;
+ int i;
+
+ /* Remove all notes/chords from score, then add current notes. */
+ score_remove_notes (scherzo->score);
+ score_remove_chords (scherzo->score);
+
+ if (scherzo->pedal_pressed)
+ chord = &scherzo->notes_pedaled;
+ else
+ chord = &scherzo->notes_pressed;
+
+ _analyze_chord (chord, &signature, &root);
+
+ if (signature) {
+ /* Don't print root pitch for octaves and inversions,
+ * (since a pitch name alone looks like a major triad) */
+ if (signature->num_degrees < 3) {
+ /* In fact, don't print anything for octaves and
+ * inversions for now. It leads to a bit of flashing when
+ * playing chords.
+ *
+ * FIXME: What I'd like to have here is a small timeout,
+ * such that names only appear once an interval has been
+ * held for at least 100 ms or so. With that, it would be
+ * nice to display the interval names once again.
+ *
+ chord_name = talloc_strdup (local, signature->name);
+ */
+ } else {
+ _spell_chord_by_signature (&scherzo->notes_pressed,
+ signature, *root);
+ _spell_chord_by_signature (&scherzo->notes_pedaled,
+ signature, *root);
+
+ chord_name = talloc_asprintf (local, "%s%s",
+ pitch_string (*root),
+ signature->name);