X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fgregorian-ligature-engraver.cc;h=7af8430ade27393fc6be2993f0f93383cb4b80d7;hb=20d2040d6608a0d5e575b517e69237c1e3d2adf8;hp=68cc9ceb7c962a338e025896e25718eadc59c9d2;hpb=63bd790abbe3fa267409b515c63796cae37e5ad9;p=lilypond.git diff --git a/lily/gregorian-ligature-engraver.cc b/lily/gregorian-ligature-engraver.cc index 68cc9ceb7c..7af8430ade 100644 --- a/lily/gregorian-ligature-engraver.cc +++ b/lily/gregorian-ligature-engraver.cc @@ -1,14 +1,14 @@ /* gregorian-ligature-engraver.cc -- implement Gregorian_ligature_engraver - + source file of the GNU LilyPond music typesetter - - (c) 2003 Juergen Reuter - */ + + (c) 2003--2005 Juergen Reuter +*/ #include "gregorian-ligature-engraver.hh" + #include "gregorian-ligature.hh" -#include "item.hh" #include "warn.hh" #include "staff-symbol-referencer.hh" #include "spanner.hh" @@ -85,109 +85,108 @@ void fix_prefix_set (int *current_set, int min_set, int max_set, Grob *primitive void check_and_fix_all_prefixes (Array primitives) { /* Check for illegal head modifier combinations */ - for (int i = 0; i < primitives.size(); i++) + for (int i = 0; i < primitives.size (); i++) { - Grob *primitive = primitives[i].grob_; + Grob *primitive = primitives[i].grob (); - /* compute head prefix set by inspecting primitive grob properties */ - int prefix_set = - (VIRGA * to_boolean (primitive->get_grob_property ("virga"))) | - (STROPHA * to_boolean (primitive->get_grob_property ("stropha"))) | - (INCLINATUM * to_boolean (primitive->get_grob_property ("inclinatum"))) | - (AUCTUM * to_boolean (primitive->get_grob_property ("auctum"))) | - (DESCENDENS * to_boolean (primitive->get_grob_property ("descendens"))) | - (ASCENDENS * to_boolean (primitive->get_grob_property ("ascendens"))) | - (ORISCUS * to_boolean (primitive->get_grob_property ("oriscus"))) | - (QUILISMA * to_boolean (primitive->get_grob_property ("quilisma"))) | - (DEMINUTUM * to_boolean (primitive->get_grob_property ("deminutum"))) | - (CAVUM * to_boolean (primitive->get_grob_property ("cavum"))) | - (LINEA * to_boolean (primitive->get_grob_property ("linea"))) | - (PES_OR_FLEXA * to_boolean (primitive->get_grob_property ("pes-or-flexa"))); + /* compute head prefix set by inspecting primitive grob properties */ + int prefix_set + = (VIRGA *to_boolean (primitive->get_property ("virga"))) + | (STROPHA *to_boolean (primitive->get_property ("stropha"))) + | (INCLINATUM *to_boolean (primitive->get_property ("inclinatum"))) + | (AUCTUM *to_boolean (primitive->get_property ("auctum"))) + | (DESCENDENS *to_boolean (primitive->get_property ("descendens"))) + | (ASCENDENS *to_boolean (primitive->get_property ("ascendens"))) + | (ORISCUS *to_boolean (primitive->get_property ("oriscus"))) + | (QUILISMA *to_boolean (primitive->get_property ("quilisma"))) + | (DEMINUTUM *to_boolean (primitive->get_property ("deminutum"))) + | (CAVUM *to_boolean (primitive->get_property ("cavum"))) + | (LINEA *to_boolean (primitive->get_property ("linea"))) + | (PES_OR_FLEXA *to_boolean (primitive->get_property ("pes-or-flexa"))); - /* check: ascendens and descendens exclude each other; same with - auctum and deminutum */ - if (prefix_set & DESCENDENS) - { - fix_prefix_set (&prefix_set, - prefix_set & ~ASCENDENS, - prefix_set & ~ASCENDENS, - primitive); - } - if (prefix_set & AUCTUM) - { - fix_prefix_set (&prefix_set, - prefix_set & ~DEMINUTUM, - prefix_set & ~DEMINUTUM, - primitive); - } - - /* check: virga, quilisma and oriscus can not be combined with any - other prefix, but may be part of a pes or flexa */ - if (prefix_set & VIRGA) - { - fix_prefix_set (&prefix_set, - VIRGA, - VIRGA | PES_OR_FLEXA, - primitive); - } - if (prefix_set & QUILISMA) - { - fix_prefix_set (&prefix_set, - QUILISMA, - QUILISMA | PES_OR_FLEXA, - primitive); - } - if (prefix_set & ORISCUS) - { - fix_prefix_set (&prefix_set, - ORISCUS, - ORISCUS | PES_OR_FLEXA, - primitive); - } + /* check: ascendens and descendens exclude each other; same with + auctum and deminutum */ + if (prefix_set & DESCENDENS) + { + fix_prefix_set (&prefix_set, + prefix_set & ~ASCENDENS, + prefix_set & ~ASCENDENS, + primitive); + } + if (prefix_set & AUCTUM) + { + fix_prefix_set (&prefix_set, + prefix_set & ~DEMINUTUM, + prefix_set & ~DEMINUTUM, + primitive); + } - /* check: auctum is the only valid optional prefix for stropha */ - if (prefix_set & STROPHA) - { - fix_prefix_set (&prefix_set, - STROPHA, - STROPHA | AUCTUM, - primitive); - } + /* check: virga, quilisma and oriscus cannot be combined with any + other prefix, but may be part of a pes or flexa */ + if (prefix_set & VIRGA) + { + fix_prefix_set (&prefix_set, + VIRGA, + VIRGA | PES_OR_FLEXA, + primitive); + } + if (prefix_set & QUILISMA) + { + fix_prefix_set (&prefix_set, + QUILISMA, + QUILISMA | PES_OR_FLEXA, + primitive); + } + if (prefix_set & ORISCUS) + { + fix_prefix_set (&prefix_set, + ORISCUS, + ORISCUS | PES_OR_FLEXA, + primitive); + } + /* check: auctum is the only valid optional prefix for stropha */ + if (prefix_set & STROPHA) + { + fix_prefix_set (&prefix_set, + STROPHA, + STROPHA | AUCTUM, + primitive); + } - /* check: inclinatum may be prefixed with auctum or deminutum only */ - if (prefix_set & INCLINATUM) - { - fix_prefix_set (&prefix_set, - INCLINATUM, - INCLINATUM | AUCTUM | DEMINUTUM, - primitive); - } - /* check: semivocalis (deminutum but not inclinatum) must occur in - combination with and only with pes or flexa */ - else if (prefix_set & DEMINUTUM) - { - fix_prefix_set (&prefix_set, - DEMINUTUM | PES_OR_FLEXA, - DEMINUTUM | PES_OR_FLEXA, - primitive); - } + /* check: inclinatum may be prefixed with auctum or deminutum only */ + if (prefix_set & INCLINATUM) + { + fix_prefix_set (&prefix_set, + INCLINATUM, + INCLINATUM | AUCTUM | DEMINUTUM, + primitive); + } + /* check: semivocalis (deminutum but not inclinatum) must occur in + combination with and only with pes or flexa */ + else if (prefix_set & DEMINUTUM) + { + fix_prefix_set (&prefix_set, + DEMINUTUM | PES_OR_FLEXA, + DEMINUTUM | PES_OR_FLEXA, + primitive); + } - /* check: cavum and linea (either or both) may be applied only - upon core punctum */ - if (prefix_set & (CAVUM | LINEA)) - { - fix_prefix_set (&prefix_set, - 0, - CAVUM | LINEA, - primitive); - } + /* check: cavum and linea (either or both) may be applied only + upon core punctum */ + if (prefix_set & (CAVUM | LINEA)) + { + fix_prefix_set (&prefix_set, + 0, + CAVUM | LINEA, + primitive); + } - /* all other combinations should be valid (unless I made a - mistake) */ + /* all other combinations should be valid (unless I made a + mistake) */ - primitive->set_grob_property ("prefix-set", gh_int2scm (prefix_set)); - } + primitive->set_property ("prefix-set", scm_int2num (prefix_set)); + } } /* @@ -200,45 +199,49 @@ provide_context_info (Array primitives) int prev_prefix_set = 0; int prev_context_info = 0; int prev_pitch = 0; - for (int i = 0; i < primitives.size(); i++) { - Grob *primitive = primitives[i].grob_; - Music *music_cause = primitives[i].music_cause (); - int context_info = 0; - int pitch = unsmob_pitch (music_cause->get_mus_property ("pitch"))->steps (); - int prefix_set = gh_scm2int (primitive->get_grob_property ("prefix-set")); + for (int i = 0; i < primitives.size (); i++) + { + Grob *primitive = primitives[i].grob (); + Music *music_cause = primitives[i].music_cause (); + int context_info = 0; + int pitch = unsmob_pitch (music_cause->get_property ("pitch"))->steps (); + int prefix_set = scm_to_int (primitive->get_property ("prefix-set")); - if (prefix_set & PES_OR_FLEXA) - if (pitch > prev_pitch) // pes - { - prev_context_info |= PES_LOWER; - context_info |= PES_UPPER; - } - else if (pitch < prev_pitch) // flexa + if (prefix_set & PES_OR_FLEXA) + if (!i) // ligature may not start with 2nd head of pes or flexa + { + primitive->warning (_ ( "can't apply `\\~' on first head of ligature")); + } + else if (pitch > prev_pitch) // pes + { + prev_context_info |= PES_LOWER; + context_info |= PES_UPPER; + } + else if (pitch < prev_pitch) // flexa + { + prev_context_info |= FLEXA_LEFT; + context_info |= FLEXA_RIGHT; + } + else // (pitch == prev_pitch) + { + primitive->warning (_ ("can't apply `\\~' on heads with identical pitch")); + } + if (prev_prefix_set & DEMINUTUM) { - prev_context_info |= FLEXA_LEFT; - context_info |= FLEXA_RIGHT; + context_info |= AFTER_DEMINUTUM; } - else // (pitch == prev_pitch) - { - primitive->warning ("may not apply `\\~' on heads with " - "identical pitch; ignoring `\\~'"); - } - if (prev_prefix_set & VIRGA) - { - context_info |= AFTER_VIRGA; - } - if (prev_primitive) - prev_primitive->set_grob_property ("context-info", - gh_int2scm (prev_context_info)); - prev_primitive = primitive; - prev_prefix_set = prefix_set; - prev_context_info = context_info; - prev_pitch = pitch; - } + if (prev_primitive) + prev_primitive->set_property ("context-info", + scm_int2num (prev_context_info)); + prev_primitive = primitive; + prev_prefix_set = prefix_set; + prev_context_info = context_info; + prev_pitch = pitch; + } if (prev_primitive) - prev_primitive->set_grob_property ("context-info", - gh_int2scm (prev_context_info)); + prev_primitive->set_property ("context-info", + scm_int2num (prev_context_info)); } void @@ -263,16 +266,16 @@ Gregorian_ligature_engraver::build_ligature (Spanner *ligature, } void -Gregorian_ligature_engraver::start_translation_timestep () +Gregorian_ligature_engraver::stop_translation_timestep () { - Ligature_engraver::start_translation_timestep (); + Ligature_engraver::stop_translation_timestep (); pes_or_flexa_req_ = 0; } -ENTER_DESCRIPTION (Gregorian_ligature_engraver, -/* descr */ "This is an abstract class. Subclasses such as Vaticana_ligature_engraver handle ligatures by glueing special ligature heads together.", -/* creats*/ "", -/* accepts */ "ligature-event abort-event", -/* acks */ "note-head-interface rest-interface", -/* reads */ "", -/* write */ ""); +ADD_TRANSLATOR (Gregorian_ligature_engraver, + /* descr */ "This is an abstract class. Subclasses such as Vaticana_ligature_engraver handle ligatures by glueing special ligature heads together.", + /* creats*/ "", + /* accepts */ "ligature-event", + /* acks */ "note-head-interface rest-interface", + /* reads */ "", + /* write */ "");