From e590acdf36f87d36f68b322c08246664c9a7297a Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sat, 14 Nov 1998 01:51:46 +0100 Subject: [PATCH] patch::: 1.1.5.jcn2: extender pl5.jcn2 - extender-*, see input/test/extender.ly - bf: half-beam length (urg) - fixes: standchen, star --- NEWS | 5 ++ TODO | 4 - VERSION | 2 +- init/engraver.ly | 2 + init/lily.scm | 4 + init/table16.ly | 1 + init/table20.ly | 1 + input/test/extender.ly | 6 ++ input/test/hara-kiri.ly | 5 ++ input/test/stars-and-stripes.ly | 71 ++++++++-------- lily/beam.cc | 9 ++- lily/extender-engraver.cc | 96 ++++++++++++++++++++++ lily/extender-spanner.cc | 129 ++++++++++++++++++++++++++++++ lily/include/extender-engraver.hh | 40 +++++++++ lily/include/extender-spanner.hh | 59 ++++++++++++++ lily/include/lily-proto.hh | 2 + lily/include/lookup.hh | 1 + lily/include/musical-request.hh | 9 ++- lily/include/my-lily-parser.hh | 1 + lily/lexer.ll | 5 ++ lily/lookup.cc | 12 +++ lily/musical-request.cc | 11 +++ lily/my-lily-lexer.cc | 1 + lily/my-lily-parser.cc | 1 + lily/parser.yy | 27 ++++++- mutopia/standchen.ly | 18 +++-- ps/lilyponddefs.ps | 11 ++- tex/lily-ps-defs.tex | 4 +- tex/lilyponddefs.tex | 2 +- 29 files changed, 488 insertions(+), 51 deletions(-) create mode 100644 input/test/extender.ly create mode 100644 lily/extender-engraver.cc create mode 100644 lily/extender-spanner.cc create mode 100644 lily/include/extender-engraver.hh create mode 100644 lily/include/extender-spanner.hh diff --git a/NEWS b/NEWS index 8758586337..98a312d98a 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,8 @@ +pl5.jcn2 + - extender-*, see input/test/extender.ly + - bf: half-beam length (urg) + - fixes: standchen, star + pl5.jcn1 - tex/lily-ps-defs.tex fixes - lily.ps diff --git a/TODO b/TODO index 6b8dc778be..daf8fa83e6 100644 --- a/TODO +++ b/TODO @@ -12,8 +12,6 @@ BUGS: * latex bla.tex broken (titles / \lilyfooter stuff?) - * acc placement: \score { \notes \key G; \transpose\notes { a b c } } - * --safe: disallow backslashes, disallow \include. * msgfmt -o check? @@ -88,8 +86,6 @@ BUGS: * zip target for binary windows dist (JBR) - * text continuations - * revise documentation * abbrev -> tremolo diff --git a/VERSION b/VERSION index 1124932284..95a012f617 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=1 PATCH_LEVEL=5 -MY_PATCH_LEVEL=jcn1 +MY_PATCH_LEVEL=jcn2 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/init/engraver.ly b/init/engraver.ly index aa3a5382be..91db39ae70 100644 --- a/init/engraver.ly +++ b/init/engraver.ly @@ -135,6 +135,7 @@ GrandStaffContext=\translator{ \name LyricVoice ; \consists "Separating_line_group_engraver"; \consists "Lyric_engraver"; + \consists "Extender_engraver"; \consists "Beam_req_swallow_translator"; \consists "Plet_swallow_engraver"; } @@ -217,6 +218,7 @@ HaraKiriStaffContext = \translator { \accepts "Voice"; }; +% huh, Score should do HaraKiri, not Part yes? OrchestralPartStaffContext = \translator { \HaraKiriStaffContext barColumnPriority = "0"; diff --git a/init/lily.scm b/init/lily.scm index 8cd3f0eabe..aadf071f12 100644 --- a/init/lily.scm +++ b/init/lily.scm @@ -159,6 +159,10 @@ (define (experimental-on-tex) "\\turnOnExperimentalFeatures") +(define + (extender o h) + ((invoke-output o "invoke-dim1") "extender" h)) + (define (fatdoublebar o h) ((invoke-output o "invoke-dim1") "fatdoublebar" h)) diff --git a/init/table16.ly b/init/table16.ly index df5ae32e8c..d535ebcc10 100644 --- a/init/table16.ly +++ b/init/table16.ly @@ -64,6 +64,7 @@ table_sixteen= "param" = \table { "brace" "pianobrace" 1 0.0\pt 0.0\pt 32.0\pt 80.0\pt "bracket" "staffbracket" 1 0.0\pt 4.0\pt 16.0\pt 128.0\pt + "extender" "extender" 1 0.0\pt 0.0\pt 1.0\pt 160.0\pt "time_signature" "generalmeter" 2 0.0\pt 10.0\pt -8.0\pt 8.0\pt "rule" "rulesym" 2 "stem" "stem" 2 diff --git a/init/table20.ly b/init/table20.ly index 2ba7508064..001fce9429 100644 --- a/init/table20.ly +++ b/init/table20.ly @@ -67,6 +67,7 @@ table_twenty = % dims ignored for this table "param" = \table { "bracket" "staffbracket" 1 0.0\pt 0.0\pt 20.0\pt 160.0\pt + "extender" "extender" 1 0.0\pt 0.0\pt 1.0\pt 160.0\pt "rule" "rulesym" 2 "brace" "pianobrace" 1 0.0\pt 0.0\pt 40.0\pt 100.0\pt "time_signature" "generalmeter" 2 0.0\pt 10.0\pt -5.0\pt 5.0\pt diff --git a/input/test/extender.ly b/input/test/extender.ly new file mode 100644 index 0000000000..ed33ea2913 --- /dev/null +++ b/input/test/extender.ly @@ -0,0 +1,6 @@ +\score{ + < + \type Staff \notes { c () c () c c } + \type Lyrics \lyrics { bla __ alb xxx __ yyy } + > +} diff --git a/input/test/hara-kiri.ly b/input/test/hara-kiri.ly index 49af9b64fd..89b6cb0682 100644 --- a/input/test/hara-kiri.ly +++ b/input/test/hara-kiri.ly @@ -79,6 +79,11 @@ zagers = \type GrandStaff < > > \paper{ + \translator { \HaraKiriStaffContext } +%uh? +% \translator { \OrchestralScoreContext } +% \translator { \OrchestralPartStaffContext } + } linewidth = 40.0\mm; } } diff --git a/input/test/stars-and-stripes.ly b/input/test/stars-and-stripes.ly index 8c9f99f515..9dbecdeb71 100644 --- a/input/test/stars-and-stripes.ly +++ b/input/test/stars-and-stripes.ly @@ -14,49 +14,58 @@ copyright="public domain"; } $staff1_voice_1 = \notes { - [a8.()fis16] d4 fis4 a4 d'2 [fis'8. e'16] d'4 fis4 gis4 a2 [a8 a8] fis'4. e'8 - d'4 cis'2 [b8. cis'16] d'4 d'4 a4 fis4 d4 [a8. fis16] fis4 d4 [fis'8. - fis'16] fis'4 g'4 a'4 a'2 [g'8 fis'8] e'4 fis'4 g'4 g'2 g'4 fis'4. e'8 d'4 - cis'2 [b8. cis'16] d'4 fis4 gis4 a2 a4 d'4 d'4 [d'8()cis'8] b4 b4 b4 e'4 [g'8 -()fis'8] [e'8()d'8] d'4~cis'4 [a8. a16] d'4.~e'8 [fis'8 g'8] a'2 [d'8 e'8] - fis'4. g'8 e'4 d'2 s4 } + [a8.()fis16] d4 fis4 a4 d'2 [fis'8. e'16] d'4 fis4 gis4 a2 [a8 a8] + fis'4. e'8 d'4 cis'2 [b8. cis'16] d'4 d'4 a4 fis4 d4 [a8. fis16] + fis4 d4 [fis'8. fis'16] fis'4 g'4 a'4 a'2 [g'8 fis'8] e'4 fis'4 + g'4 g'2 g'4 fis'4. e'8 d'4 cis'2 [b8. cis'16] d'4 fis4 gis4 a2 a4 + d'4 d'4 [d'8()cis'8] b4 b4 b4 e'4 [g'8 ()fis'8] [e'8()d'8] + d'4~cis'4 [a8. a16] d'4.~e'8 [fis'8 g'8] a'2 [d'8 e'8] fis'4. g'8 + e'4 d'2 s4 +} $staff1_voice_2 = \notes { - [a8.()fis16] a,4 d4 e4 d4~fis4 [fis8. fis16] fis4 d4 d4 cis2 [e8 e8] a4. a8 - a4 a2 [a8. a16] a4 a4 a4 fis4 d4 [a8. fis16] fis4 d4 r4 a4 a4 d'4 d'2 - [a8 a8] cis'4 cis'4 cis'4 cis'2 a4 a4. a8 a4 a2 [a8. a16] d4 d4 d4 - cis2 e4 fis4 e4 d4 d4 d4 dis4 g4 [g8()dis8] e4 e2 [e8. e16] d4.~a8 [a8 a8] - a2 [g8 g8] a4. a8 g4 fis2 s4 } + [a8.()fis16] a,4 d4 e4 d4~fis4 [fis8. fis16] fis4 d4 d4 cis2 [e8 + e8] a4. a8 a4 a2 [a8. a16] a4 a4 a4 fis4 d4 [a8. fis16] fis4 d4 r4 + a4 a4 d'4 d'2 [a8 a8] cis'4 cis'4 cis'4 cis'2 a4 a4. a8 a4 a2 [a8. + a16] d4 d4 d4 cis2 e4 fis4 e4 d4 d4 d4 dis4 g4 [g8()dis8] e4 e2 + [e8. e16] d4.~a8 [a8 a8] a2 [g8 g8] a4. a8 g4 fis2 s4 +} $staff2_voice_1 = \notes { - r4 fis4 a4 a4 b2 [cis'8. cis'16] b4 b4 b4 a2 [cis'8 cis'8] d'4. cis'8 - d'4 e'2 [e'8. e'16] d'4 d'4 a4 fis4 d4 r4 fis4 d4 r4 d4 e4 fis4 fis'2 - [e'8 d'8] e'4 e'4 e'4 e'2 cis'4 d'4. cis'8 d'4 e'2 [e'8. e'16] a4 a4 - e4 e2 cis'4 a4 a4 a4 g4 g4 b4 b4 b4 b4 a2 [cis'8. cis'16] a4.~cis'8 - [d'8 d'8] d'2 [d'8 d'8] d'4. d'8 cis'4 a2 s4 } + r4 fis4 a4 a4 b2 [cis'8. cis'16] b4 b4 b4 a2 [cis'8 cis'8] d'4. + cis'8 d'4 e'2 [e'8. e'16] d'4 d'4 a4 fis4 d4 r4 fis4 d4 r4 d4 e4 + fis4 fis'2 [e'8 d'8] e'4 e'4 e'4 e'2 cis'4 d'4. cis'8 d'4 e'2 + [e'8. e'16] a4 a4 e4 e2 cis'4 a4 a4 a4 g4 g4 b4 b4 b4 b4 a2 + [cis'8. cis'16] a4.~cis'8 [d'8 d'8] d'2 [d'8 d'8] d'4. d'8 cis'4 + a2 s4 +} $staff2_voice_2 = \notes { - r4 d4 d4 cis4 b,2 [ais,8. ais,16] b,4 b,4 e4 a,2 [a8 a8] d4. e8 [fis8 g8] - a2 [g8. g16] fis4 fis4 a4 fis4 d4 r4 fis4 d4 r4 d4 d4 d4 d2 [d8 d8] a4 - a4 a4 a2 a,4 d4. e8 [fis8 g8] a2 [g8. g16] fis4 d4 e4 a,2 a4 d4 e4 fis4 - g4 g4 fis4 e4 [e8()fis8] [g8()gis8] a2 [g8. g16] fis4.~a,8 [d8 e8] fis2 [b8 b8] - a4. a8 a,4 d2 s4 } + r4 d4 d4 cis4 b,2 [ais,8. ais,16] b,4 b,4 e4 a,2 [a8 a8] d4. e8 + [fis8 g8] a2 [g8. g16] fis4 fis4 a4 fis4 d4 r4 fis4 d4 r4 d4 d4 d4 + d2 [d8 d8] a4 a4 a4 a2 a,4 d4. e8 [fis8 g8] a2 [g8. g16] fis4 d4 + e4 a,2 a4 d4 e4 fis4 g4 g4 fis4 e4 [e8()fis8] [g8()gis8] a2 [g8. + g16] fis4.~a,8 [d8 e8] fis2 [b8 b8] a4. a8 a,4 d2 s4 +} $text1 = \lyrics{ - Oh4 say. can you see,2 by8. the16 dawn's4 ear- ly light2 What8 so8 proud-4. ly8 we4 hailed,2 - At8. the16 twi-4 light's last gleam- ing. Whose8. broad16 + Oh4 __ say. can you see,2 by8. the16 dawn's4 ear- ly light2 What8 + so8 proud-4. ly8 we4 hailed,2 At8. the16 twi-4 light's last gleam- + ing. Whose8. broad16 } $text2 = \lyrics{ - _4 stripes and bright stars,2 through8 the8 per-4 il- ous fight,2 O'er8 the8 ram-4. parts8 - we4 watched,2 were8. so16 gal-4 lant- ly _ _ _ + _4 stripes and bright stars,2 through8 the8 per-4 il- ous fight,2 + O'er8 the8 ram-4. parts8 we4 watched,2 were8. so16 gal-4 lant- ly + _ _ _ } $text3 = \lyrics{ - stream-4 ing. And8. the16 rock-4 ets' red glare,2 the8 bombs8 burst-4 ing in air,2 gave4 - proof4. through8 the4 night2 that8. our16 flag4 was still there,2 Oh4 say, does that - star- span- gled ban- ner yet wave,2 O'er8. the16 land2 of8 the8 free2 and8 the8 - home4. of8 the4 brave.2 + stream-4 ing. And8. the16 rock-4 ets' red glare,2 the8 bombs8 + burst-4 ing in air,2 gave4 proof4. through8 the4 night2 that8. + our16 flag4 was still there,2 Oh4 say, does that star- span- + gled ban- ner yet wave,2 __ O'er8. the16 land2 __ of8 the8 free2 + and8 the8 home4. of8 the4 brave.2 } global = \notes { @@ -77,9 +86,7 @@ global = \notes { \score{ \type GrandStaff < \type Staff=staffA < - % urg, ugly bug - %\global - \notes \transpose c'' \global + \global \notes \transpose c'' {\voiceone \$staff1_voice_1 } \notes \transpose c'' {\voicetwo \$staff1_voice_2 } > diff --git a/lily/beam.cc b/lily/beam.cc index 4982dd3937..95151fdf5b 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -641,6 +641,9 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const Molecule leftbeams; Molecule rightbeams; + // UGH + Real nw_f = paper ()->note_width () * 0.8; + /* half beams extending to the left. */ if (prev) { @@ -651,7 +654,7 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const but let's make sure two half-beams never touch */ Real w = here->hpos_f () - prev->hpos_f (); - w = w/2 note_width (); + w = w/2 beam (sl, w, beam_f); @@ -684,7 +687,7 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const rightbeams.add_atom (b); } // TODO: notehead widths differ for different types - gap_f = paper ()->note_width () / 2; + gap_f = nw_f / 2; w -= 2 * gap_f; a = lookup_l ()->beam (sl, w + stemdx, beam_f); } @@ -696,7 +699,7 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const rightbeams.add_atom (b); } - w = w/2 note_width (); + w = w/2 beam (sl, w, beam_f); diff --git a/lily/extender-engraver.cc b/lily/extender-engraver.cc new file mode 100644 index 0000000000..92018629d9 --- /dev/null +++ b/lily/extender-engraver.cc @@ -0,0 +1,96 @@ +/* + extender-engraver.cc -- implement Extender_engraver + + (c) 1998 Jan Nieuwenhuizen +*/ + +#include "proto.hh" +#include "musical-request.hh" +#include "extender-engraver.hh" +#include "extender-spanner.hh" +#include "text-def.hh" +#include "score-column.hh" +#include "text-item.hh" + +IMPLEMENT_IS_TYPE_B1 (Extender_engraver,Engraver); +ADD_THIS_TRANSLATOR (Extender_engraver); + +Extender_engraver::Extender_engraver () +{ + extender_spanner_p_ = 0; + span_reqs_drul_[RIGHT] = span_reqs_drul_[LEFT] = 0; +} + +void +Extender_engraver::acknowledge_element (Score_element_info i) +{ + Text_item* t = (dynamic_cast (i.elem_l_)); + if (!t) + return; + if (!extender_spanner_p_) + return; + if (!span_reqs_drul_[LEFT]) + return; + + if (!extender_spanner_p_->textitem_l_drul_[LEFT]) + extender_spanner_p_->set_textitem (LEFT, t); + else + if (span_reqs_drul_[RIGHT] && !extender_spanner_p_->textitem_l_drul_[RIGHT]) + extender_spanner_p_->set_textitem (RIGHT, t); +} + +bool +Extender_engraver::do_try_request (Request* req_l) +{ + Extender_req* p = dynamic_cast (req_l); + if (!p) + return false; + + if (bool (extender_spanner_p_) == bool (p->spantype == Span_req::START)) + return false; + + Direction d = (!extender_spanner_p_) ? LEFT : RIGHT; + if (span_reqs_drul_[d] && !span_reqs_drul_[d]->equal_b (req_l)) + return false; + + span_reqs_drul_[d] = p; + span_mom_drul_[d] = get_staff_info ().musical_l ()->when (); + return true; +} + +void +Extender_engraver::do_removal_processing () +{ + if (extender_spanner_p_) + { + span_reqs_drul_[LEFT]->warning (_ ("unterminated extender")); + extender_spanner_p_->unlink (); + delete extender_spanner_p_; + extender_spanner_p_ = 0; + span_reqs_drul_[RIGHT] = span_reqs_drul_[LEFT] = 0; + } +} + +void +Extender_engraver::do_process_requests () +{ + if (extender_spanner_p_ || !span_reqs_drul_[LEFT]) + return; + + extender_spanner_p_ = new Extender_spanner; + + announce_element (Score_element_info (extender_spanner_p_, span_reqs_drul_[LEFT])); +} + +void +Extender_engraver::do_pre_move_processing () +{ + if (!extender_spanner_p_ || !span_reqs_drul_[RIGHT]) + return; + + typeset_element (extender_spanner_p_); + + extender_spanner_p_ = 0; + span_reqs_drul_[RIGHT] = span_reqs_drul_[LEFT] = 0; +} + diff --git a/lily/extender-spanner.cc b/lily/extender-spanner.cc new file mode 100644 index 0000000000..d7617894a5 --- /dev/null +++ b/lily/extender-spanner.cc @@ -0,0 +1,129 @@ +/* + extender-spanner.cc -- implement Extender_spanner + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#include "atom.hh" +#include "box.hh" +#include "debug.hh" +#include "lookup.hh" +#include "molecule.hh" +#include "p-col.hh" +#include "paper-def.hh" +#include "extender-spanner.hh" +#include "text-item.hh" +#include "text-def.hh" + +IMPLEMENT_IS_TYPE_B1 (Extender_spanner, Directional_spanner); + +Extender_spanner::Extender_spanner () + : Directional_spanner () +{ + textitem_l_drul_[LEFT] = textitem_l_drul_[RIGHT] = 0; + dy_f_drul_[LEFT] = dy_f_drul_[RIGHT] = 0.0; + dx_f_drul_[LEFT] = dx_f_drul_[RIGHT] = 0.0; +} + +Extender_spanner::Extender_spanner (Extender_spanner const& c) + : Directional_spanner (c) +{ + textitem_l_drul_ = c.textitem_l_drul_; + dy_f_drul_ = c.dy_f_drul_; + dx_f_drul_ = c.dx_f_drul_; +} + +Extender_spanner::~Extender_spanner () +{ +} + +Offset +Extender_spanner::center () const +{ + Real dx = width ().length (); + + return Offset (dx / 2, 0); +} + +Molecule* +Extender_spanner::brew_molecule_p () const +{ + Molecule* mol_p = new Molecule; + + Real w = width ().length (); + + w += (dx_f_drul_[RIGHT] - dx_f_drul_[LEFT]); + + Atom a = lookup_l ()->extender (w); + + a.translate (Offset (dx_f_drul_[LEFT], dy_f_drul_[LEFT])); + + mol_p->add_atom (a); + + return mol_p; +} + +void +Extender_spanner::do_add_processing () +{ + Direction d = LEFT; + Drul_array new_textitem_drul = textitem_l_drul_; + do { + if (!textitem_l_drul_[d]) + new_textitem_drul[d] = textitem_l_drul_[(Direction)-d]; + } while (flip(&d) != LEFT); + textitem_l_drul_ = new_textitem_drul; +} + +Interval +Extender_spanner::do_height () const +{ + return Interval (0,0); +} + +void +Extender_spanner::do_post_processing () +{ + assert (textitem_l_drul_[LEFT] || textitem_l_drul_[RIGHT]); + + // UGH + Real nw_f = paper ()->note_width () * 0.8; + + Direction d = LEFT; + do + { + Text_item* t = textitem_l_drul_[d] ? textitem_l_drul_[d] : textitem_l_drul_[(Direction)-d]; + + dy_f_drul_[d] += t->height ().length () / 2; + if (d == LEFT) + dx_f_drul_[d] += t->width ().length (); + else + dx_f_drul_[d] -= d * nw_f / 2; + +// dx_f_drul_[d] -= d * nw_f / 4; + } + while (flip(&d) != LEFT); +} + +void +Extender_spanner::do_substitute_dependency (Score_element* o, Score_element* n) +{ + Text_item* new_l = n ? dynamic_cast (n) : 0; + if (dynamic_cast (o) == textitem_l_drul_[LEFT]) + textitem_l_drul_[LEFT] = new_l; + else if (dynamic_cast (o) == textitem_l_drul_[RIGHT]) + textitem_l_drul_[RIGHT] = new_l; +} + +void +Extender_spanner::set_textitem (Direction d, Text_item* textitem_l) +{ + assert (!textitem_l_drul_[d]); + textitem_l_drul_[d] = textitem_l; + set_bounds (d, textitem_l); + + add_dependency (textitem_l); +} + diff --git a/lily/include/extender-engraver.hh b/lily/include/extender-engraver.hh new file mode 100644 index 0000000000..e5bb774dbc --- /dev/null +++ b/lily/include/extender-engraver.hh @@ -0,0 +1,40 @@ +/* + extender-engraver.hh -- declare Extender_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1998 Jan Nieuwenhuizen +*/ + +#ifndef EXTENDER_ENGRAVER_HH +#define EXTENDER_ENGRAVER_HH + +#include "engraver.hh" +#include "drul-array.hh" +#include "extender-spanner.hh" + +/** + Generate an extender. + Should make an Extender_spanner that typesets a nice extender line. + */ +class Extender_engraver : public Engraver +{ +public: + TRANSLATOR_CLONE(Extender_engraver); + DECLARE_MY_RUNTIME_TYPEINFO; + Extender_engraver (); + +protected: + virtual void acknowledge_element (Score_element_info); + virtual void do_removal_processing(); + virtual void do_process_requests(); + virtual bool do_try_request (Request*); + virtual void do_pre_move_processing(); + +private: + Drul_array span_reqs_drul_; + Drul_array span_mom_drul_; + Extender_spanner* extender_spanner_p_; +}; + +#endif // EXTENDER_ENGRAVER_HH diff --git a/lily/include/extender-spanner.hh b/lily/include/extender-spanner.hh new file mode 100644 index 0000000000..e158237c87 --- /dev/null +++ b/lily/include/extender-spanner.hh @@ -0,0 +1,59 @@ +/* + extender-spanner.hh -- part of GNU LilyPond + + (c) 1998 Jan Nieuwenhuizen +*/ + +#ifndef EXTENDER_SPANNER_HH +#define EXTENDER_SPANNER_HH + +#include "directional-spanner.hh" + +/** + simple extender line + + The extender is a simple line at the baseline of the lyric + that helps show the length of a melissima (tied/slurred note). + + Extenders must be entered manually for now. + + Although it would be possible for Lily to determine where to + put extender lines, it's quite a tricky thing to do. Also, + this would demand quite strict lyrics entries. + + Note: the extender is only used for one-syllable words, or + for on a word's last syllable. The extender should be aligned + with the left side of the last note of the melissima, and not + extend beond, lasting the whole duration of the melissima + (as in MUP, urg). + */ + +class Extender_spanner : public Directional_spanner +{ +public: + Extender_spanner (); + virtual ~Extender_spanner (); + + Offset center () const; + void set_textitem (Direction, Text_item*); + + Drul_array textitem_l_drul_; + +protected: + virtual Molecule* brew_molecule_p () const; + void do_add_processing (); + Interval do_height () const; + void do_substitute_dependency (Score_element* o, Score_element* n); + void do_post_processing (); + + DECLARE_MY_RUNTIME_TYPEINFO; + SCORE_ELEMENT_CLONE(Extender_spanner); + + Extender_spanner (Extender_spanner const&); + + Drul_array dy_f_drul_; + Drul_array dx_f_drul_; +}; + +#endif // EXTENDER_SPANNER_HH + diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index 0ac8ebf0cc..52f3674b52 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -75,6 +75,8 @@ struct Dynamic_req; struct Element_group; struct Element_group_item; struct Engraver_group_engraver; +struct Extender; +struct Extender_req; struct General_script_def; struct Graphical_element; diff --git a/lily/include/lookup.hh b/lily/include/lookup.hh index 9b00615622..5b5685a40c 100644 --- a/lily/include/lookup.hh +++ b/lily/include/lookup.hh @@ -40,6 +40,7 @@ public: Atom dashed_slur (Array controls, Real thick, Real dash) const; Atom dots () const; Atom dynamic (String) const; + Atom extender (Real) const; Atom fill (Box b) const; Atom flag (int, Direction) const; Atom hairpin (Real width, bool decresc, bool continued) const; diff --git a/lily/include/musical-request.hh b/lily/include/musical-request.hh index 1891986303..c88ef382c4 100644 --- a/lily/include/musical-request.hh +++ b/lily/include/musical-request.hh @@ -174,7 +174,7 @@ public: }; -/// a plet (bracket with) number +/// a tuplet (bracket with) number class Plet_req : public Musical_span_req { public: int plet_i_; @@ -183,6 +183,13 @@ public: Plet_req (); }; +/// an extender line +class Extender_req : public Musical_span_req { +public: + REQUESTMETHODS(Extender_req); + Extender_req (); +}; + class Musical_script_req : public Musical_req, public Script_req { public: REQUESTMETHODS(Musical_script_req); diff --git a/lily/include/my-lily-parser.hh b/lily/include/my-lily-parser.hh index 8024bb552e..4e82dc909e 100644 --- a/lily/include/my-lily-parser.hh +++ b/lily/include/my-lily-parser.hh @@ -39,6 +39,7 @@ public: int abbrev_beam_type_i_; int default_abbrev_i_; Duration default_duration_; + Extender_req* extender_req; Plet plet_; Scope *default_header_p_; diff --git a/lily/lexer.ll b/lily/lexer.ll index b61c4c1975..551cf48aec 100644 --- a/lily/lexer.ll +++ b/lily/lexer.ll @@ -93,6 +93,7 @@ LYRICS ({AA}|{TEX})[^0-9 \t\n\f]* ESCAPED [nt\\'"] PLET \\\[ TELP \\\] +EXTENDER [_][_] %% @@ -262,6 +263,8 @@ TELP \\\] {LYRICS} { /* ugr. This sux. */ String s (YYText ()); + if (s == "__") + return yylval.i = EXTENDER; int i = 0; while ((i=s.index_i ("_")) != -1) // change word binding "_" to " " *(s.ch_l () + i) = ' '; @@ -286,6 +289,8 @@ TELP \\\] yyterminate (); // can't move this, since it actually rets a YY_NULL } } + + {WORD} { return scan_bare_word (YYText ()); } diff --git a/lily/lookup.cc b/lily/lookup.cc index 35d9774c14..63259a3cc7 100644 --- a/lily/lookup.cc +++ b/lily/lookup.cc @@ -203,6 +203,18 @@ Lookup::dynamic (String st) const return (*symtables_p_) ("dynamics")->lookup (st); } +Atom +Lookup::extender (Real width) const +{ + Atom a = (*symtables_p_) ("param")->lookup ("extender"); + Array arr; + arr.push (width); + a.lambda_ = (lambda_scm (a.str_, arr)); + a.str_ = "extender"; + a.font_ = font_; + return a; +} + Atom Lookup::fill (Box b) const { diff --git a/lily/musical-request.cc b/lily/musical-request.cc index e02877ad31..07582ead8c 100644 --- a/lily/musical-request.cc +++ b/lily/musical-request.cc @@ -263,6 +263,17 @@ Plet_req::do_print () const { } +IMPLEMENT_IS_TYPE_B1 (Extender_req,Span_req); + +Extender_req::Extender_req () +{ +} + +void +Extender_req::do_print () const +{ +} + bool Span_req::do_equal_b (Request*r) const diff --git a/lily/my-lily-lexer.cc b/lily/my-lily-lexer.cc index bbe54c7ec6..61c1cd028c 100644 --- a/lily/my-lily-lexer.cc +++ b/lily/my-lily-lexer.cc @@ -31,6 +31,7 @@ static Keyword_ent the_key_tab[]={ {"cm", CM_T}, {"consists", CONSISTS}, {"duration", DURATION}, +// {"_", EXTENDER}, {"font", FONT}, {"grouping", GROUPING}, {"header", HEADER}, diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index a024f0dd68..86270bf7c3 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -29,6 +29,7 @@ My_lily_parser::My_lily_parser (Sources * source_l) default_duration_.durlog_i_ = 2; default_abbrev_i_ = 0; error_level_i_ = 0; + extender_req = 0; fatal_error_i_ = 0; default_header_p_ =0; } diff --git a/lily/parser.yy b/lily/parser.yy index e8779bce9d..344abe68b2 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -46,7 +46,7 @@ // mmm Mudela_version oldest_version ("1.0.7"); -Mudela_version version ("1.0.8"); +Mudela_version version ("1.0.9"); // needed for bison.simple's malloc() and free() @@ -166,6 +166,7 @@ yylex (YYSTYPE *s, void * v_l) %token CONSISTS %token DURATION %token END +%token EXTENDER %token FONT %token GROUPING %token HEADER @@ -273,7 +274,7 @@ yylex (YYSTYPE *s, void * v_l) %type post_request structured_post_request %type plet_fraction %type command_req verbose_command_req -%type script_req dynamic_req +%type script_req dynamic_req extender_req %type string %type score_block score_body %type shape_array @@ -973,6 +974,9 @@ post_request: a->type_i_ = $1; $$ = a; } + | extender_req { + $$ = $1; + } ; optional_modality: @@ -1062,6 +1066,16 @@ explicit_duration: } ; +extender_req: + EXTENDER { + if (!THIS->lexer_p_->lyric_state_b ()) + THIS->parser_error (_ ("have to be in Lyric mode for lyrics")); + Extender_req * e_p = new Extender_req; + e_p->spantype = Span_req::START; + $$ = e_p; + THIS->extender_req = e_p; + }; + dynamic_req: ABSDYNAMIC '{' unsigned '}' { Absolute_dynamic_req *ad_p = new Absolute_dynamic_req; @@ -1260,8 +1274,17 @@ script_dir: pre_requests: { + if (THIS->extender_req) + { + Extender_req * e_p = new Extender_req; + e_p->spantype = Span_req::STOP; + THIS->pre_reqs.push (e_p); + THIS->extender_req = 0; + } + } | pre_requests open_request_parens { + Array& r = *THIS->get_parens_request ($2); for (int i = 0; i < r.size (); i++ ) r[i]->set_spot (THIS->here_input ()); diff --git a/mutopia/standchen.ly b/mutopia/standchen.ly index 0110e36652..a70465726d 100644 --- a/mutopia/standchen.ly +++ b/mutopia/standchen.ly @@ -125,7 +125,7 @@ $lyric_verse2 = \lyrics{ \[/3 Mit4 der8 \] T\"o-4. ne8 \[/3 s\"u-4 "\ss{}en"8 \] Kla-4. gen8 Fleh-4. en8 \[/3 sie4 f\"ur8 \] - mich.2 _4 + mich2 _4 _4_ _ _4_ _ @@ -159,7 +159,7 @@ $lyric_through = \lyrics{ \[/3 Komm4 be-8 \] gl\"u4. cke8 | mich!2. | \[/3 Komm4 be-8 \] gl\"u4. cke8 | - mich!2. | + mich,2. __ | _2 be-4 | gl\"u-2. | cke2. | @@ -444,11 +444,19 @@ $grand_staff = \type GrandStaff< % To get original, \transpose d' % \transpose a gives a' to d'' (for basses, who sing an octave down) < - { \notes \transpose a { \$vocal_staff } } +% kjoet, but i like the original better -- jcn +% { \notes \transpose a { \$vocal_staff } } +% \$lyric_staff +% { \notes \transpose a { \$grand_staff } } + { \notes { \$vocal_staff } } \$lyric_staff - { \notes \transpose a { \$grand_staff } } + { \notes { \$grand_staff } } > - \paper { \translator { \OrchestralScoreContext }} + \paper { +% \translator { \OrchestralScoreContext } +% \translator { \OrchestralPartStaffContext } + \translator { \HaraKiriStaffContext } + } \midi{ \tempo 4 = 54; } diff --git a/ps/lilyponddefs.ps b/ps/lilyponddefs.ps index 48b4bfb7b7..2641a26ab9 100644 --- a/ps/lilyponddefs.ps +++ b/ps/lilyponddefs.ps @@ -5,7 +5,7 @@ /xoffset 30 def /yoffset 700 def -/staffrulethickness 1 def +/stafflinethickness 1 def /staffheight 20 def /placebox @@ -68,6 +68,15 @@ grestore } bind def +/extender % width +{ + gsave + 0 0 moveto + stafflinethickness 0.8 mul setlinewidth + 0 lineto stroke + grestore +} bind def + /widthbar % height width { gsave diff --git a/tex/lily-ps-defs.tex b/tex/lily-ps-defs.tex index 32e3d9bafa..6872156755 100644 --- a/tex/lily-ps-defs.tex +++ b/tex/lily-ps-defs.tex @@ -46,7 +46,9 @@ \def\filedef#1#2{%#1=command name, #2=file name \openin\defin=#2\relax\def#1{} \ifeof\defin - \message{***************** CAN NOT OPEN #2 ********************} + \message{***************************************} + \message{lily-ps-defs.tex: can't open `#2'} + \message{***************************************} \end \fi \loop\ifnot{\ifeof\defin}\read\defin to\tempfiledef diff --git a/tex/lilyponddefs.tex b/tex/lilyponddefs.tex index 9066a06522..22ec06fd8f 100644 --- a/tex/lilyponddefs.tex +++ b/tex/lilyponddefs.tex @@ -184,7 +184,7 @@ \def\finishbar#1{\rightalign{\thinbar{#1}\kern\smallspace\thickbar{#1}}} \def\fatdoublebar#1{\hbox{\phantom{\repeatcolon\kern2\smallspace}\thickbar{#1}\kern\smallspace\thickbar{#1}}} - +\def\extender#1{\vrule width#1 height .8\stafflinethickness} % ugh % see e.g. input/test/beam-pos.ly -- 2.39.2