- SCM pitches = ly_car (chord_);
- SCM modifiers = ly_cdr (chord_);
- SCM inversion = modifiers == SCM_EOL ? SCM_EOL : ly_car (modifiers);
- SCM bass = modifiers == SCM_EOL ? SCM_EOL : ly_cdr (modifiers);
+ notes_.push (n);
+}
+
+void
+Chord_name_engraver::process_music ()
+{
+ if (!notes_.size() )
+ return;
+
+ SCM bass = SCM_EOL;
+ SCM inversion = SCM_EOL;
+ SCM pitches = SCM_EOL;
+
+ Music* inversion_event = 0;
+ for (int i =0 ; i < notes_.size (); i++)
+ {
+ Music *n = notes_[i];
+ SCM p = n->get_mus_property ("pitch");
+ if (!unsmob_pitch (p))
+ continue;
+
+ if (n->get_mus_property ("inversion") == SCM_BOOL_T)
+ {
+ inversion_event = n;
+ inversion = p;
+ }
+ else if (n->get_mus_property ("bass") == SCM_BOOL_T)
+ bass = p;
+ else
+ pitches = gh_cons (p, pitches);
+ }
+
+ if (inversion_event)
+ {
+ SCM oct = inversion_event->get_mus_property ("octavation");
+ if (gh_number_p (oct))
+ {
+ Pitch *p = unsmob_pitch (inversion_event->get_mus_property ("pitch"));
+ int octavation = gh_scm2int (oct);
+ Pitch orig = p->transposed (Pitch (-octavation, 0,0));
+
+ pitches= gh_cons (orig.smobbed_copy (), pitches);
+ }
+ else
+ programming_error ("Inversion does not have original pitch.");
+ }
+
+ pitches = scm_sort_list (pitches, Pitch::less_p_proc);
+
+ SCM name_proc = get_property ("chordNameFunction");
+ SCM markup = scm_call_4 (name_proc, pitches, bass, inversion,
+ daddy_trans_->self_scm());
+
+ /*
+ Ugh.
+ */
+ SCM chord_as_scm = gh_cons (pitches, gh_cons (bass, inversion));