]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/new-chord-name-engraver.cc
(process_music): use octavation
[lilypond.git] / lily / new-chord-name-engraver.cc
index d76e288fc4d12e8c82045cd86032d62c78e4e5c1..65620defe69c2c00dfedef7d5fedfb07df5b4572 100644 (file)
@@ -8,7 +8,6 @@
 
 #include "engraver.hh"
 #include "chord-name.hh"
-#include "chord.hh"
 #include "event.hh"
 #include "paper-def.hh"
 #include "font-interface.hh"
@@ -18,6 +17,8 @@
 #include "item.hh"
 #include "pitch.hh"
 #include "protected-scm.hh"
+#include "translator-group.hh"
+#include "warn.hh"
 
 class New_chord_name_engraver : public Engraver 
 {
@@ -60,24 +61,45 @@ New_chord_name_engraver::process_music ()
   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");;
+      SCM p = n->get_mus_property ("pitch");
+      if (!unsmob_pitch (p))
+       continue;
+      
       if (n->get_mus_property ("inversion") == SCM_BOOL_T)
-       inversion = p;
+       {
+         inversion_event = n;
+         inversion = p;
+       }
       else if (n->get_mus_property ("bass") == SCM_BOOL_T)
        bass = p;
       else
        pitches = gh_cons (p, pitches);
     }
 
-  pitches = scm_sort_list (pitches, Pitch::less_p_proc);
+  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 exceptions = get_property ("chordNameExceptions");
-  SCM markup = scm_call_4 (name_proc, pitches, bass, inversion, exceptions);
+  SCM markup = scm_call_4 (name_proc, pitches, bass, inversion,
+                          daddy_trans_->self_scm());
 
   /*
     Ugh.