X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=lily%2Fgregorian-ligature-engraver.cc;h=485b97a184460c2b0b6e8651d1a433f65e3ac39c;hb=47db9a3883d726ca53e2133a3b2298f78dd6a32e;hp=049d89d9cf9d1fdac01732705d744bf4ffe6a5da;hpb=a6a4b3fc2009f17a1a48cca0c11bfd3f38645937;p=lilypond.git diff --git a/lily/gregorian-ligature-engraver.cc b/lily/gregorian-ligature-engraver.cc index 049d89d9cf..485b97a184 100644 --- a/lily/gregorian-ligature-engraver.cc +++ b/lily/gregorian-ligature-engraver.cc @@ -1,9 +1,20 @@ /* - gregorian-ligature-engraver.cc -- implement Gregorian_ligature_engraver + This file is part of LilyPond, the GNU music typesetter. - source file of the GNU LilyPond music typesetter + Copyright (C) 2003--2015 Juergen Reuter - (c) 2003--2008 Juergen Reuter + LilyPond is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + LilyPond is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with LilyPond. If not, see . */ #include "gregorian-ligature-engraver.hh" @@ -43,8 +54,8 @@ Gregorian_ligature_engraver::listen_pes_or_flexa (Stream_event *ev) } void fix_prefix (char const *name, int mask, - int *current_set, int min_set, int max_set, - Grob *primitive) + int *current_set, int min_set, int max_set, + Grob *primitive) { bool current = *current_set & mask; bool min = min_set & mask; @@ -82,7 +93,7 @@ void fix_prefix_set (int *current_set, int min_set, int max_set, Grob *primitive fix_prefix ("pes_or_flexa", LINEA, current_set, min_set, max_set, primitive); } -void check_and_fix_all_prefixes (vector primitives) +void check_and_fix_all_prefixes (vector const &primitives) { /* Check for invalid head modifier combinations */ for (vsize i = 0; i < primitives.size (); i++) @@ -91,99 +102,99 @@ void check_and_fix_all_prefixes (vector primitives) /* 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"))); + = (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 */ + auctum and deminutum */ if (prefix_set & DESCENDENS) - { - fix_prefix_set (&prefix_set, - prefix_set & ~ASCENDENS, - prefix_set & ~ASCENDENS, - primitive); - } + { + 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); - } + { + fix_prefix_set (&prefix_set, + prefix_set & ~DEMINUTUM, + prefix_set & ~DEMINUTUM, + primitive); + } /* check: virga, quilisma and oriscus cannot be combined with any - other prefix, but may be part of a pes or flexa */ + 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); - } + { + 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); - } + { + 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); - } + { + 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); - } + { + 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); - } + { + 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 */ + 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); - } + { + 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 */ + upon core punctum */ if (prefix_set & (CAVUM | LINEA)) - { - fix_prefix_set (&prefix_set, - 0, - CAVUM | LINEA, - primitive); - } + { + fix_prefix_set (&prefix_set, + 0, + CAVUM | LINEA, + primitive); + } /* all other combinations should be valid (unless I made a - mistake) */ + mistake) */ primitive->set_property ("prefix-set", scm_from_int (prefix_set)); } @@ -193,7 +204,7 @@ void check_and_fix_all_prefixes (vector primitives) * Marks those heads that participate in a pes or flexa. */ void -provide_context_info (vector primitives) +provide_context_info (vector const &primitives) { Grob *prev_primitive = 0; int prev_prefix_set = 0; @@ -204,32 +215,32 @@ provide_context_info (vector primitives) Grob *primitive = primitives[i].grob (); Stream_event *event_cause = primitives[i].event_cause (); int context_info = 0; - int pitch = unsmob_pitch (event_cause->get_property ("pitch"))->steps (); + int pitch = Pitch::unsmob (event_cause->get_property ("pitch"))->steps (); int prefix_set = scm_to_int (primitive->get_property ("prefix-set")); if (prefix_set & PES_OR_FLEXA) - { - if (!i) // ligature may not start with 2nd head of pes or flexa - primitive->warning (_ ("cannot 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 (_ ("cannot apply `\\~' on heads with identical pitch")); - } + { + if (!i) // ligature may not start with 2nd head of pes or flexa + primitive->warning (_ ("cannot 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 (_ ("cannot apply `\\~' on heads with identical pitch")); + } if (prev_prefix_set & DEMINUTUM) - context_info |= AFTER_DEMINUTUM; + context_info |= AFTER_DEMINUTUM; if (prev_primitive) - prev_primitive->set_property ("context-info", - scm_from_int (prev_context_info)); + prev_primitive->set_property ("context-info", + scm_from_int (prev_context_info)); prev_primitive = primitive; prev_prefix_set = prefix_set; prev_context_info = context_info; @@ -237,12 +248,12 @@ provide_context_info (vector primitives) } if (prev_primitive) prev_primitive->set_property ("context-info", - scm_from_int (prev_context_info)); + scm_from_int (prev_context_info)); } void Gregorian_ligature_engraver::build_ligature (Spanner *ligature, - vector primitives) + vector const &primitives) { // apply style-independent checking and transformation check_and_fix_all_prefixes (primitives);