]> 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 23b8fd4cdcd2e40b4c66388c8b3cd1858c3e0df2..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);
 
 
@@ -79,7 +79,7 @@ String trim_suffix (String &id);
 Lyric_phrasing_engraver::Lyric_phrasing_engraver ()
 {
   voice_alist_ = SCM_EOL;
-  any_notehead_l_ = 0;
+  any_notehead_ = 0;
 }
 
 Lyric_phrasing_engraver::~Lyric_phrasing_engraver ()
@@ -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.ch_C ());
+  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);
          }
@@ -138,8 +141,8 @@ Lyric_phrasing_engraver::record_notehead (const String &context_id,
 {
   Syllable_group * v = lookup_context_id (context_id);
   v->set_notehead (notehead);
-  if (!any_notehead_l_)
-    any_notehead_l_ = notehead;
+  if (!any_notehead_)
+    any_notehead_ = notehead;
 }
   
 void 
@@ -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.ch_C ());
+  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)
 {
@@ -185,18 +193,18 @@ Lyric_phrasing_engraver::acknowledge_grob (Grob_info i)
     return;
 
 
-  Grob *h = i.grob_l_;
+  Grob *h = i.grob_;
 
   if (Note_head::has_interface (h))
     {
       /* caught a note head ... do something with it */
 
       /* what's its Voice context name? */
-      String voice_context_id = get_context_id (i.origin_trans_l_->daddy_trans_l_, "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 ? */
-      if (to_boolean (i.origin_trans_l_->get_property ("melismaEngraverBusy")))
+      if (to_boolean (i.origin_trans_->get_property ("melismaEngraverBusy")))
        {
          record_melisma (voice_context_id);
        }
@@ -209,15 +217,16 @@ Lyric_phrasing_engraver::acknowledge_grob (Grob_info i)
 
       /* what's its LyricsVoice context name? */
       String voice_context_id;
-      SCM voice_context_scm = i.origin_trans_l_->get_property ("associatedVoice");
+      SCM voice_context_scm = i.origin_trans_->get_property ("associatedVoice");
       if (gh_string_p (voice_context_scm))
        {
          voice_context_id = ly_scm2string (voice_context_scm);
        }
-      else {
-       voice_context_id = get_context_id (i.origin_trans_l_->daddy_trans_l_, "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,23 +246,23 @@ 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_l_->daddy_trans_l_, "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_str_ != type)
+  while (ancestor != 0 && !ancestor->is_alias_b(type))
     {
-      ancestor = ancestor->daddy_trans_l_;
+      ancestor = ancestor->daddy_trans_;
     }
 
   if (ancestor != 0)
     {
-      return ancestor->id_str_;
+      return ancestor->id_string_;
     }
 
   return "";
@@ -262,17 +271,17 @@ get_context_id (Translator_group * ancestor, const char *type)
 String 
 trim_suffix (String &id)
 {
-  int index = id.index_i ('-');
+  int index = id.index ('-');
   if (index >= 0)
     {
-      return id.left_str (index);
+      return id.left_string (index);
     }
   return id;
 }
 
 
 void
-Lyric_phrasing_engraver::create_grobs () 
+Lyric_phrasing_engraver::process_acknowledged_grobs () 
 {
   SCM p = get_property ("automaticPhrasing");
   if (!to_boolean (p))
@@ -291,13 +300,14 @@ Lyric_phrasing_engraver::create_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));
 
          /*
            TODO: give context for warning.
          */
-         if (! entry->set_lyric_align (punc.ch_C (), any_notehead_l_))
+         if (! entry->set_lyric_align (punc.to_str0 (), any_notehead_))
            warning (_ ("lyrics found without any matching notehead"));
 
          // is this note melismatic? If so adjust alignment of previous one.
@@ -338,14 +348,19 @@ Lyric_phrasing_engraver::stop_translation_timestep ()
        }
       entry->next_lyric ();
     }
-  any_notehead_l_ = 0;
+  any_notehead_ = 0;
 }
 
 
 
 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 */       "");