]> git.donarmstrong.com Git - lilypond.git/blobdiff - lily/lyric-phrasing-engraver.cc
* THANKS: Create skeleton for 2.1.
[lilypond.git] / lily / lyric-phrasing-engraver.cc
index 483d85d2c4317d247a67ac292fba7703458ca72f..fab2a8e607c9f4a5ab010b4cd02512b3e95658e4 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  2000 Glen Prideaux <glenprideaux@iname.com>
+  (c)  2000--2003 Glen Prideaux <glenprideaux@iname.com>
 */
 #include <string.h>
 
@@ -14,7 +14,7 @@
 #include "warn.hh"
 
 
-String get_context_id (Translator_group * ancestor, const char * type);
+String get_context_id (Translator_group * ancestor, SCM);
 String trim_suffix (String &id);
 
 
@@ -103,7 +103,7 @@ Lyric_phrasing_engraver::finalize ()
 Syllable_group * 
 Lyric_phrasing_engraver::lookup_context_id (const String &context_id)
 {
-  SCM key = ly_str02scm (context_id.to_str0 ());
+  SCM key = scm_makfrom0str (context_id.to_str0 ());
   if (! gh_null_p (voice_alist_))
     {
       SCM s = scm_assoc (key, voice_alist_);
@@ -112,12 +112,15 @@ Lyric_phrasing_engraver::lookup_context_id (const String &context_id)
          /* match found */
          // (key . ((alist_entry . old_entry) . previous_entry))
          if (to_boolean (ly_cdadr (s)))
-           { // it's an old entry ... make it a new one
+           {
+             // it's an old entry ... make it a new one
              SCM val = gh_cons (gh_cons (ly_caadr (s), SCM_BOOL_F), ly_cddr (s)); 
              voice_alist_ = scm_assoc_set_x (voice_alist_, ly_car (s), val);
              return unsmob_voice_entry (ly_caar (val));
            }
-         else { // the entry is current ... return it.
+         else
+           {
+             // the entry is current ... return it.
            SCM entry_scm = ly_caadr (s);
            return unsmob_voice_entry (entry_scm);
          }
@@ -152,7 +155,7 @@ Lyric_phrasing_engraver::record_lyric (const String &context_id, Grob * lyric)
 void 
 Lyric_phrasing_engraver::record_extender (const String &context_id, Grob * extender)
 {
-  SCM key = ly_str02scm (context_id.to_str0 ());
+  SCM key = scm_makfrom0str (context_id.to_str0 ());
   if (! gh_null_p (voice_alist_))
     {
       SCM s = scm_assoc (key, voice_alist_);
@@ -176,7 +179,12 @@ Lyric_phrasing_engraver::record_melisma (const String &context_id)
   Syllable_group * v = lookup_context_id (context_id);
   v->set_melisma ();
 }
-  
+
+/*
+  TODO: this engraver is always on, also for orchestral scores. That
+  is a waste of time and space. This should be switched on
+  automatically at the first Lyrics found.
+ */
 void
 Lyric_phrasing_engraver::acknowledge_grob (Grob_info i)
 {
@@ -192,7 +200,7 @@ Lyric_phrasing_engraver::acknowledge_grob (Grob_info i)
       /* caught a note head ... do something with it */
 
       /* what's its Voice context name? */
-      String voice_context_id = get_context_id (i.origin_trans_->daddy_trans_, "Voice");
+      String voice_context_id = get_context_id (i.origin_trans_->daddy_trans_, ly_symbol2scm ("Voice"));
       record_notehead (voice_context_id, h);
 
       /* is it in a melisma ? */
@@ -214,10 +222,11 @@ Lyric_phrasing_engraver::acknowledge_grob (Grob_info i)
        {
          voice_context_id = ly_scm2string (voice_context_scm);
        }
-      else {
-       voice_context_id = get_context_id (i.origin_trans_->daddy_trans_, "LyricsVoice");
-       voice_context_id = trim_suffix (voice_context_id);
-      }
+      else
+       {
+         voice_context_id = get_context_id (i.origin_trans_->daddy_trans_,ly_symbol2scm ( "LyricsVoice"));
+         voice_context_id = trim_suffix (voice_context_id);
+       }
       record_lyric (voice_context_id, h);
       return;
     }
@@ -228,7 +237,7 @@ Lyric_phrasing_engraver::acknowledge_grob (Grob_info i)
      This has the effect of finishing the extender under the last note
      of the melisma, instead of extending it to the next lyric.
      
-     Problem: the extender request is thrown at the same moment as the next lyric,
+     Problem: the extender event is thrown at the same moment as the next lyric,
      by which time we have already passed the last note of the melisma.
      However, the Lyric_phrasing_engraver remembers the last note, so just 
      attach it to that, provided it was melismatic. If it was not melismatic, 
@@ -237,16 +246,16 @@ Lyric_phrasing_engraver::acknowledge_grob (Grob_info i)
   */
   if (h->internal_has_interface (ly_symbol2scm ("lyric-extender-interface")))
     {
-      String voice_context_id = get_context_id (i.origin_trans_->daddy_trans_, "LyricsVoice");
+      String voice_context_id = get_context_id (i.origin_trans_->daddy_trans_, ly_symbol2scm ("LyricsVoice"));
       record_extender (trim_suffix (voice_context_id), h);
       return;
     }
 }
 
 String 
-get_context_id (Translator_group * ancestor, const char *type)
+get_context_id (Translator_group * ancestor, SCM  type)
 {
-  while (ancestor != 0 && ancestor->type_string_ != type)
+  while (ancestor != 0 && !ancestor->is_alias_b(type))
     {
       ancestor = ancestor->daddy_trans_;
     }
@@ -291,7 +300,8 @@ Lyric_phrasing_engraver::process_acknowledged_grobs ()
       SCM v_entry = ly_cdar (v);
       // ((current . oldflag) . previous)
       if (!to_boolean (ly_cdar (v_entry)))
-       { // not an old entry left over from a prior note ...
+       { 
+         // not an old entry left over from a prior note ...
          Syllable_group *entry = unsmob_voice_entry (ly_caar (v_entry));
 
          /*
@@ -344,8 +354,13 @@ Lyric_phrasing_engraver::stop_translation_timestep ()
 
 
 ENTER_DESCRIPTION(Lyric_phrasing_engraver,
-                 /* descr */       "",
+                 /* descr */       
+"This engraver combines note heads and lyrics for alignment. "
+"\n\n"
+"This engraver is switched on by default. Turn it off for faster " 
+"processing of orchestral scores. ",
                  /* creats*/       "",
-                 /* acks  */       "lyric-syllable-interface note-head-interface lyric-extender-interface",
+                 /* accepts */     "",
+/* acks  */      "lyric-syllable-interface note-head-interface lyric-extender-interface",
                  /* reads */       "automaticPhrasing melismaEngraverBusy associatedVoice phrasingPunctuation",
                  /* write */       "");