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>
#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);
Lyric_phrasing_engraver::Lyric_phrasing_engraver ()
{
voice_alist_ = SCM_EOL;
- any_notehead_l_ = 0;
+ any_notehead_ = 0;
}
Lyric_phrasing_engraver::~Lyric_phrasing_engraver ()
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_);
/* 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);
}
{
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
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_);
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)
{
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);
}
/* 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;
}
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,
*/
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 "";
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))
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.
}
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 */ "");