From 439b9eae8f830918d62c7374d4f72a1079334316 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 5 Sep 1997 09:44:56 +0200 Subject: [PATCH] patch::: 0.1.12.jcn2: kliener pats pl 12.jcn2 - typesetting abbreviation beams; abbreviation-* - some simple abbrev fixes + code cleanup (dank je, lieverd) pl 12.jcn1 - typesetting simple abbreviations: c4:16 === [c16 c c c] --- Documentation/lilypond.pod | 40 ++-- NEWS | 7 + VERSION | 2 +- bin/convert-mudela.in | 8 +- init/engraver.ly | 3 +- init/paper20.ly | 2 +- init/symbol.ly | 2 +- input/abbrev.ly | 40 ++++ input/cadenza.ly | 2 +- input/collisions.ly | 2 +- input/coriolan-alto.ly | 2 +- input/fugue1.ly | 2 +- input/keys.ly | 2 +- input/kortjakje.ly | 2 +- input/multi.ly | 2 +- input/pedal.ly | 2 +- input/prelude1.ly | 2 +- input/rhythm.ly | 2 +- input/scales.ly | 2 +- input/scripts.ly | 2 +- input/scsii-menuetto.ly | 2 +- input/slurs.ly | 2 +- input/standchen.ly | 2 +- input/toccata-fuga-E.ly | 2 +- input/twinkle-pop.ly | 2 +- input/twinkle.ly | 2 +- input/wohltemperirt.ly | 2 +- lily/abbreviation-beam-engraver.cc | 99 +++++++++ lily/abbreviation-beam.cc | 84 +++++++ lily/beam-grav.cc | 44 ++-- lily/beam.cc | 208 ++++++------------ lily/include/abbreviation-beam-engraver.hh | 41 ++++ lily/include/abbreviation-beam.hh | 33 +++ lily/include/beam.hh | 14 +- lily/include/lily-proto.hh | 4 + lily/include/musical-request.hh | 21 ++ lily/include/my-lily-parser.hh | 5 + lily/include/stem-grav.hh | 2 + lily/include/stem-info.hh | 26 +++ lily/include/stem.hh | 16 +- lily/musical-request.cc | 47 +++- lily/my-lily-parser.cc | 86 +++++--- lily/parser.y | 52 ++++- lily/stem-grav.cc | 33 ++- lily/stem-info.cc | 67 ++++++ lily/stem.cc | 243 ++++++++++++--------- mi2mu/mudela-stream.cc | 2 +- 47 files changed, 909 insertions(+), 360 deletions(-) create mode 100644 input/abbrev.ly create mode 100644 lily/abbreviation-beam-engraver.cc create mode 100644 lily/abbreviation-beam.cc create mode 100644 lily/include/abbreviation-beam-engraver.hh create mode 100644 lily/include/abbreviation-beam.hh create mode 100644 lily/include/stem-info.hh create mode 100644 lily/stem-info.cc diff --git a/Documentation/lilypond.pod b/Documentation/lilypond.pod index c2d2656935..1142476eb9 100644 --- a/Documentation/lilypond.pod +++ b/Documentation/lilypond.pod @@ -43,17 +43,17 @@ Set the default output file to F. Show a summary of usage. -=item B<-i,--init=>F +=item B<-i,--init=>F, -set init file to F (default: F). +Set init file to F (default: F). -=item B<--include, -I>=F +=item B<--include, -I>=F, -add F to the search path for input files. +Add F to the search path for input files. -=item B<--ignore-version, -V> +=item B<--ignore-version, -V>, -make incompatible mudela version non-fatal. +Make incompatible mudela version non-fatal. =back @@ -79,27 +79,27 @@ MIDI to Mudela conversion through the mi2mu program. =item * -Multiple staffs in one score. Each staff can have a different meters. +Multiple staffs in one score. Each staff can have different meters. =item * -beams, slurs, ties, chords, super/subscripts (accents and text), +Beams, slurs, ties, chords, super/subscripts (accents and text) triplets, general n-plet (triplet, quadruplets, etc.), lyrics, -transposition dynamics (both absolute and hairpin style) +transposition dynamics (both absolute and hairpin style). =item * -multiple voices within one staff; beams optionally shared +Multiple voices within one staff; beams optionally shared between voices. Up to four voices is handled cleanly. =item * -multiple scores within one input file. Each score is output to +Multiple scores within one input file. Each score is output to a different file. =item * -clef changes, meter changes, cadenza-mode, key changes, repeat bars +Clef changes, meter changes, cadenza-mode, key changes, repeat bars. =back @@ -139,11 +139,11 @@ general, try to find out =item * -if the bug has been fixed in a newer release. +If the bug has been fixed in a newer release. =item * -if the bug has been found earlier, consult F and F +If the bug has been found earlier, consult F and F. =back @@ -152,20 +152,20 @@ If you have found a bug, then you should send a bugreport. =over 4 =item * -send a copy of the input which causes the error +Send a copy of the input which causes the error. =item * -send a description of the platform you use +Send a description of the platform you use. =item * -send a description of the LilyPond version you use (with -compile/configure options please) +Send a description of the LilyPond version you use (with +compile/configure options please). =item * -send a description of the bug itself. +Send a description of the bug itself. =item * -send it to bug-gnu-music@vuse.vanderbilt.edu +Send it to bug-gnu-music@vuse.vanderbilt.edu. =back diff --git a/NEWS b/NEWS index d86ec1c927..a40a867874 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,10 @@ +pl 12.jcn2 + - typesetting abbreviation beams; abbreviation-* + - some simple abbrev fixes + code cleanup (dank je, lieverd) + +pl 12.jcn1 + - typesetting simple abbreviations: c4:16 === [c16 c c c] + pl 12 - bf: don't redefine tex primitives like \textfont and \mathfont - nicer broken slurs (?) diff --git a/VERSION b/VERSION index 1ae5036c7d..d02c76a40a 100644 --- a/VERSION +++ b/VERSION @@ -3,4 +3,4 @@ TOPLEVEL_MINOR_VERSION = 1 TOPLEVEL_PATCH_LEVEL = 12 # use to send patches, always empty for released version: -TOPLEVEL_MY_PATCH_LEVEL = +TOPLEVEL_MY_PATCH_LEVEL = .jcn2 diff --git a/bin/convert-mudela.in b/bin/convert-mudela.in index bad1df51ec..98d858a308 100644 --- a/bin/convert-mudela.in +++ b/bin/convert-mudela.in @@ -19,7 +19,7 @@ Ugh . Perl sux. Anybody for Python? -$convert_mudela_version = "0.1.1"; +$convert_mudela_version = "0.1.2"; use Getopt::Long; @@ -110,6 +110,7 @@ sub convert_0_1_0_to_0_1_1 { s/\\tempo (.*):(.*);/\\tempo $1 = $2;/g } + ############################################################### sub last_conversion @@ -135,7 +136,7 @@ sub identify . " -h, --help print this help\n" . " -o, --output=FILE name output file\n" . " -s, --show-rules print all known conversion rules\n" - . " -t, --to=VERSION convert to version VERSION\n" + . " -t, --to=VERSION convert to version VERSION\n" } @@ -150,7 +151,8 @@ my %minor_conversions = ("0.0.50" => \&no_conv, "0.0.59" => \&convert_0_0_58_to_0_0_59, "0.0.60" => \&convert_0_0_59_to_0_0_60, "0.0.61" => \&convert_0_0_60_to_0_0_61, - "0.1.1" => \&convert_0_1_0_to_0_1_1 + "0.1.1" => \&convert_0_1_0_to_0_1_1, + "0.1.2" => \&no_conv ); diff --git a/init/engraver.ly b/init/engraver.ly index 359667459f..3c291a9113 100644 --- a/init/engraver.ly +++ b/init/engraver.ly @@ -20,7 +20,8 @@ staff_engraver = \requesttranslator { \alias "Voice_group"; \consists "Dynamic_engraver"; \consists "Stem_engraver"; - \consists "Beam_engraver"; + \consists "Beam_engraver"; + \consists "Abbreviation_beam_engraver"; \consists "Script_engraver"; \consists "Note_column_engraver"; \consists "Slur_engraver"; diff --git a/init/paper20.ly b/init/paper20.ly index e2878e6de7..159628e570 100644 --- a/init/paper20.ly +++ b/init/paper20.ly @@ -19,7 +19,7 @@ paper_twenty = \paper { arithmetic_multiplier = 6.\pt; % - interbeam = 2.667\pt; + interbeam = 3.333\pt; gourlay_energybound = 100000.; gourlay_maxmeasures = 12.; diff --git a/init/symbol.ly b/init/symbol.ly index 2474f20c43..3062d2d961 100644 --- a/init/symbol.ly +++ b/init/symbol.ly @@ -1,6 +1,6 @@ % symbol.ly -\version "0.1.1"; +\version "0.1.2"; breve = \duration { -1 0 } longa = \duration { -2 0 } diff --git a/input/abbrev.ly b/input/abbrev.ly new file mode 100644 index 0000000000..d417267205 --- /dev/null +++ b/input/abbrev.ly @@ -0,0 +1,40 @@ +%{MudelaHeader + + filename: abbrev.ly + title: + description: + composer(s): + entered-by: jcn + copyright: PD + + Tested Features: simple abbreviations +EndMudelaHeader +%} + +\version "0.1.2"; + +\score{ + \melodic{ + \octave c''; + \meter 4/4; + 'a1 + 'a1:32 + 'c4:8 c' 'c4:16 c' + [ 'c8:16 'c 'c 'c ] [ a a a a ] + [ 'c 'f 'b e ] + [ 'c16:32 'c 'c 'c ] [ a16:32 a a a ] +%% % there's still some hairy beam bugfixing todo +%% [ c'8:16 g d 'a ] +%% [ c'16:32 g d 'a ] +%% [ 'c8:32 'f 'b e ] + [:16 c4 e] + [:16 e4 g] + [:16 e2 g] + [:16 e1 g] + } + \paper{ + } +% oeps + \midi{ } +} + diff --git a/input/cadenza.ly b/input/cadenza.ly index 9c96602041..d817aea062 100644 --- a/input/cadenza.ly +++ b/input/cadenza.ly @@ -11,7 +11,7 @@ copyright public domain Tested Features: cadenza mode %} -\version "0.1.1"; +\version "0.1.2"; cad = \melodic {\id "Staff" "french horn"; diff --git a/input/collisions.ly b/input/collisions.ly index 2a9505752b..4bf20ce8c8 100644 --- a/input/collisions.ly +++ b/input/collisions.ly @@ -10,7 +10,7 @@ Tested Features:test the Collision resolution EndMudelaHeader %} -\version "0.1.1"; +\version "0.1.2"; diff --git a/input/coriolan-alto.ly b/input/coriolan-alto.ly index 8dc5c69796..ffee788c29 100644 --- a/input/coriolan-alto.ly +++ b/input/coriolan-alto.ly @@ -17,7 +17,7 @@ EndMudelaHeader % (maybe even sooner :-) % -\version "0.1.1"; +\version "0.1.2"; alto = \melodic{ diff --git a/input/fugue1.ly b/input/fugue1.ly index f3d8fb0c03..bc1ac70735 100644 --- a/input/fugue1.ly +++ b/input/fugue1.ly @@ -11,7 +11,7 @@ copyright Public Domain %{ %} -\version "0.1.1"; +\version "0.1.2"; global = diff --git a/input/keys.ly b/input/keys.ly index 5d79a70223..1b82f12361 100644 --- a/input/keys.ly +++ b/input/keys.ly @@ -10,7 +10,7 @@ Tested Features: local key, key, forced accidentals EndMudelaHeader %} -\version "0.1.1"; +\version "0.1.2"; blah = \melodic{ diff --git a/input/kortjakje.ly b/input/kortjakje.ly index acba0091eb..236d53ad36 100644 --- a/input/kortjakje.ly +++ b/input/kortjakje.ly @@ -11,7 +11,7 @@ copyright public domain Tested Features: example file with comments %} -\version "0.1.1"; +\version "0.1.2"; % the % is a comment. diff --git a/input/multi.ly b/input/multi.ly index 6c0a8fe03f..de46690d5b 100644 --- a/input/multi.ly +++ b/input/multi.ly @@ -10,7 +10,7 @@ Tested Features: \multi %} -\version "0.1.1"; +\version "0.1.2"; \score{ \melodic diff --git a/input/pedal.ly b/input/pedal.ly index 76ef376884..60ad7e1244 100644 --- a/input/pedal.ly +++ b/input/pedal.ly @@ -24,7 +24,7 @@ % \lbheel \lbheel \lfheel \lftoe % \rbheel \rbtoe \rfheel \rftoe -\version "0.1.1"; +\version "0.1.2"; \score{ \melodic { diff --git a/input/prelude1.ly b/input/prelude1.ly index da66d87d81..a032b943fa 100644 --- a/input/prelude1.ly +++ b/input/prelude1.ly @@ -9,7 +9,7 @@ enteredby Shay Rojansky copyright Public Domain" } -\version "0.1.1"; +\version "0.1.2"; % should add \need{dutch.ini} for % correct parsing of note names diff --git a/input/rhythm.ly b/input/rhythm.ly index 8f897af126..75c5f54e05 100644 --- a/input/rhythm.ly +++ b/input/rhythm.ly @@ -12,7 +12,7 @@ has to be revised for 0.1.12 -\version "0.1.1"; +\version "0.1.2"; ritme = \melodic{ %\octave ; \partial 8; diff --git a/input/scales.ly b/input/scales.ly index ce2c3ba854..86a8721c39 100644 --- a/input/scales.ly +++ b/input/scales.ly @@ -12,7 +12,7 @@ EndMudelaHeader % scales with accents. % -\version "0.1.1"; +\version "0.1.2"; blah = \melodic { \meter 6/8; \octave 'c ; diff --git a/input/scripts.ly b/input/scripts.ly index 8e005edee9..9e2cf7ab60 100644 --- a/input/scripts.ly +++ b/input/scripts.ly @@ -10,7 +10,7 @@ Tested Features: scripts, text. EndMudelaHeader %} -\version "0.1.1"; +\version "0.1.2"; blah = \melodic { diff --git a/input/scsii-menuetto.ly b/input/scsii-menuetto.ly index 72d61415a1..36af5c2cb7 100644 --- a/input/scsii-menuetto.ly +++ b/input/scsii-menuetto.ly @@ -13,7 +13,7 @@ copyright public domain Tested Features:breaking algorithm, chords, multivoice, accents %} -\version "0.1.1"; +\version "0.1.2"; %% Stuff from MPP version % \lefttitle{Menuetto} diff --git a/input/slurs.ly b/input/slurs.ly index b49616ff9e..0113beffe2 100644 --- a/input/slurs.ly +++ b/input/slurs.ly @@ -11,7 +11,7 @@ EndMudelaHeader %} -\version "0.1.1"; +\version "0.1.2"; \score{ \melodic{\octave c'; diff --git a/input/standchen.ly b/input/standchen.ly index 23bac1d862..53ad10aa95 100644 --- a/input/standchen.ly +++ b/input/standchen.ly @@ -13,7 +13,7 @@ copyright public domain multiple \paper{}s in one \score %} -\version "0.1.1"; +\version "0.1.2"; commands = \melodic{ \skip 2.*4; diff --git a/input/toccata-fuga-E.ly b/input/toccata-fuga-E.ly index 4e75271f8f..15aa64a7c0 100644 --- a/input/toccata-fuga-E.ly +++ b/input/toccata-fuga-E.ly @@ -21,7 +21,7 @@ copyright public domain %} -\version "0.1.1"; +\version "0.1.2"; toccata_commands = \melodic{ \meter 4/4; diff --git a/input/twinkle-pop.ly b/input/twinkle-pop.ly index 1feeeb2eec..0d2af26e6c 100644 --- a/input/twinkle-pop.ly +++ b/input/twinkle-pop.ly @@ -12,7 +12,7 @@ copyright public domain Tested Features lyrics and chords %} -\version "0.1.1"; +\version "0.1.2"; melodie = \melodic { \clef"violin"; diff --git a/input/twinkle.ly b/input/twinkle.ly index 588b26a33e..0a77e1fcb4 100644 --- a/input/twinkle.ly +++ b/input/twinkle.ly @@ -14,7 +14,7 @@ copyright public domain Tested Features: lyrics %} -\version "0.1.1"; +\version "0.1.2"; melody = \melodic{ \clef violin; diff --git a/input/wohltemperirt.ly b/input/wohltemperirt.ly index b3443e8a65..9159ed93bf 100644 --- a/input/wohltemperirt.ly +++ b/input/wohltemperirt.ly @@ -12,7 +12,7 @@ copyright Public Domain Tested Features: stem direction, multivoice, forced accidentals. %} -\version "0.1.1"; +\version "0.1.2"; % should add \need{dutch.ini} for % correct parsing of note names diff --git a/lily/abbreviation-beam-engraver.cc b/lily/abbreviation-beam-engraver.cc new file mode 100644 index 0000000000..76d4e7e3ef --- /dev/null +++ b/lily/abbreviation-beam-engraver.cc @@ -0,0 +1,99 @@ +/* + abbreviation-beam-engraver.cc -- implement Abbreviation_beam_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys + Jan Nieuwenhuizen +*/ + +#include "duration-convert.hh" +#include "time-description.hh" +#include "abbreviation-beam-engraver.hh" +#include "stem.hh" +#include "abbreviation-beam.hh" +#include "musical-request.hh" +#include "misc.hh" + +IMPLEMENT_IS_TYPE_B1 (Abbreviation_beam_engraver, Engraver); +ADD_THIS_ENGRAVER (Abbreviation_beam_engraver); + +Abbreviation_beam_engraver::Abbreviation_beam_engraver () +{ + span_reqs_drul_[LEFT] = span_reqs_drul_[RIGHT] = 0; + abeam_p_ = 0; +} + +bool +Abbreviation_beam_engraver::do_try_request (Request*r) +{ + Musical_req* mus_l = r->musical (); + if (!mus_l) + return false; + + Abbreviation_beam_req * b = mus_l->abbrev_beam (); + + if (!b) + return false; + + if (bool (abeam_p_) == bool (b->spantype == Span_req::START)) + return false; + + Direction d = (!abeam_p_) ? LEFT : RIGHT; + if (span_reqs_drul_[d] && !span_reqs_drul_[d]->equal_b (mus_l)) + return false; + + span_reqs_drul_[d] = b; + return true; +} + +void +Abbreviation_beam_engraver::do_process_requests () +{ + if (!abeam_p_ && span_reqs_drul_[LEFT]) { + abeam_p_ = new Abbreviation_beam; + announce_element (Score_elem_info (abeam_p_, span_reqs_drul_[LEFT])); + } +} + +void +Abbreviation_beam_engraver::do_pre_move_processing () +{ + if (abeam_p_ && span_reqs_drul_[RIGHT]) { + typeset_element (abeam_p_); + abeam_p_ = 0; + + span_reqs_drul_[RIGHT] = + span_reqs_drul_[LEFT] = 0; + } +} + +void +Abbreviation_beam_engraver::do_removal_processing () +{ + if (abeam_p_) + { + span_reqs_drul_[LEFT]->warning ("unterminated beam"); + typeset_element (abeam_p_); + abeam_p_ = 0; + } +} + + +void +Abbreviation_beam_engraver::acknowledge_element (Score_elem_info i) +{ + if (!abeam_p_ || !i.elem_l_->is_type_b (Stem::static_name ())) + return; + + Stem* s = (Stem*)i.elem_l_->item (); +// Rhythmic_req *rhythmic_req = i.req_l_->musical ()->rhythmic (); +// s->flag_i_ = Duration_convert::type2_i (rhythmic_req->duration_.durlog_i_); + int type_i = span_reqs_drul_[LEFT]->type_i_; + s->flag_i_ = intlog2 (type_i) - 2; + if (span_reqs_drul_[RIGHT]) + s->beams_left_i_ = s->flag_i_; + else + s->beams_right_i_ = s->flag_i_; + abeam_p_->add (s); +} diff --git a/lily/abbreviation-beam.cc b/lily/abbreviation-beam.cc new file mode 100644 index 0000000000..e47407cdc7 --- /dev/null +++ b/lily/abbreviation-beam.cc @@ -0,0 +1,84 @@ +/* + abbreviation-beam.cc -- implement Abbreviation_beam + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys + Jan Nieuwenhuizen +*/ + +#include "p-col.hh" +#include "varray.hh" +#include "proto.hh" +#include "dimen.hh" +#include "abbreviation-beam.hh" +#include "misc.hh" +#include "debug.hh" +#include "symbol.hh" +#include "molecule.hh" +#include "leastsquares.hh" +#include "stem.hh" +#include "paper-def.hh" +#include "lookup.hh" +#include "stem-info.hh" + + +IMPLEMENT_IS_TYPE_B1 (Abbreviation_beam, Spanner); + +Abbreviation_beam::Abbreviation_beam () + : Beam () +{ +} + +Molecule* +Abbreviation_beam::brew_molecule_p () const +{ + /* + todo + */ + return Beam::brew_molecule_p (); +#if 0 + Molecule *mol_p = new Molecule; + // huh? inter-what + // Real inter_f = paper ()->interbeam_f (); + Real inter_f = paper ()->internote_f (); + Real x0 = stems[0]->hpos_f (); + for (int j=0; j 0)? stems[j-1] : 0; + Stem * next = (j < stems.size ()-1) ? stems[j+1] :0; + + Molecule sb = stem_beams (i, next, prev); + Real x = i->hpos_f ()-x0; + sb.translate (Offset (x, (x * slope + left_pos)* inter_f)); + mol_p->add (sb); + } + mol_p->translate (x0 - spanned_drul_[LEFT]->absolute_coordinate (X_AXIS), X_AXIS); + return mol_p; +#endif +} + +void +Abbreviation_beam::do_print () const +{ +#ifndef NPRINT + Beam::do_print (); + Spanner::do_print (); +#endif +} + +/* + beams to go with one stem. + */ +Molecule +Abbreviation_beam::stem_beams (Stem *here, Stem *next, Stem *prev) const +{ + /* + todo + - shorter beams (not reaching outer "stems") + for [:16 c4 c4] and [:16 c1 c1] + - centered beam on [:16 c1 c1] heads, rather than "stems" + */ + return Beam::stem_beams (here, next, prev); +} diff --git a/lily/beam-grav.cc b/lily/beam-grav.cc index dcdce82975..d3fa191a6c 100644 --- a/lily/beam-grav.cc +++ b/lily/beam-grav.cc @@ -100,31 +100,29 @@ Beam_engraver::do_removal_processing() void Beam_engraver::acknowledge_element (Score_elem_info i) { - if (beam_p_ && i.elem_l_->is_type_b (Stem::static_name())) + if (!beam_p_ || !i.elem_l_->is_type_b (Stem::static_name ())) + return; + + Stem* s = (Stem*)i.elem_l_->item(); + Rhythmic_req *rhythmic_req = i.req_l_->musical ()->rhythmic (); + if (rhythmic_req->duration_.durlog_i_<= 2) { - Stem * s = (Stem*)i.elem_l_->item(); - Rhythmic_req *rhythmic_req = i.req_l_->musical ()->rhythmic (); - if (rhythmic_req->duration_.durlog_i_<= 2) - { - rhythmic_req->warning ("Stem doesn't fit in Beam"); - return ; - } - - /* - TODO: do something sensible if it doesn't fit in the beam. - */ - current_grouping_p_->add_child (get_staff_info().time_C_->whole_in_measure_, - rhythmic_req->duration()); - /* - TODO - should change rep. of flags too.k - */ - s->flag_i_ = Duration_convert::type2_i - (rhythmic_req->duration_.durlog_i_); - s->print_flag_b_ = false; - beam_p_->add (s); + rhythmic_req->warning ("Stem doesn't fit in Beam"); + return; } + + /* + TODO: do something sensible if it doesn't fit in the beam. + */ + current_grouping_p_->add_child (get_staff_info().time_C_->whole_in_measure_, + rhythmic_req->duration ()); + /* + TODO + should change repr. of flags too. + */ + s->flag_i_ = Duration_convert::type2_i (rhythmic_req->duration_.durlog_i_); + beam_p_->add (s); } - + IMPLEMENT_IS_TYPE_B1(Beam_engraver, Engraver); ADD_THIS_ENGRAVER(Beam_engraver); diff --git a/lily/beam.cc b/lily/beam.cc index 927d85cd8d..b2b2bc4f4f 100644 --- a/lily/beam.cc +++ b/lily/beam.cc @@ -27,67 +27,51 @@ #include "paper-def.hh" #include "lookup.hh" #include "grouping.hh" +#include "stem-info.hh" +IMPLEMENT_IS_TYPE_B1(Beam, Spanner); -struct Stem_info { - Real x; - int dir_; - Real idealy_f_; - Real miny_f_; - int beams_i_; - - Stem_info(){} - Stem_info (Stem const *); -}; - -Stem_info::Stem_info (Stem const *s) +Beam::Beam() { - x = s->hpos_f(); - dir_ = s->dir_; - beams_i_ = intlog2(s->flag_i_) - 2; + slope = 0; + left_pos = 0.0; +} - /* - [todo] - * get algorithm - * runtime - - Breitkopf + H\"artel: - miny_f_ = interline + #beams * interbeam - ideal8 = 2 * interline + interbeam - ideal16,32,64,128 = 1.5 * interline + #beams * interbeam - - * B\"arenreiter: - miny_f_ = interline + #beams * interbeam - ideal8,16 = 2 interline + #beams * interbeam - ideal32,64,128 = 1.5 interline + #beams * interbeam - - */ +void +Beam::add (Stem*s) +{ + stems.push (s); + s->add_dependency (this); + s->beam_l_ = this; - Real notehead_y = s->paper()->interline_f (); - // huh? why do i need the / 2 - // Real interbeam_f = s->paper()->interbeam_f (); - Real interbeam_f = s->paper()->interbeam_f () / 2; - - /* well eh, huh? - idealy_f_ = dir_ * s->stem_start_f() + beams_i_ * interbeam_f; - if (beams_i_ < 3) - idealy_f_ += 2 * interline_f; - else - idealy_f_ += 1.5 * interline_f; - */ - - idealy_f_ = dir_ * s->stem_end_f(); - - miny_f_ = dir_ * s->stem_start_f() + notehead_y + beams_i_ * interbeam_f; - - idealy_f_ = miny_f_ >? idealy_f_; - // assert (miny_f_ <= idealy_f_); + if (!spanned_drul_[LEFT]) + set_bounds(LEFT,s); + set_bounds(RIGHT,s); } +Molecule* +Beam::brew_molecule_p() const +{ + Molecule *mol_p = new Molecule; + // huh? inter-what + // Real inter_f = paper()->interbeam_f (); + Real inter_f = paper()->internote_f (); + Real x0 = stems[0]->hpos_f(); + for (int j=0; j 0)? stems[j-1] : 0; + Stem * next = (j < stems.size()-1) ? stems[j+1] :0; -/* *************** */ - + Molecule sb = stem_beams (i, next, prev); + Real x = i->hpos_f()-x0; + sb.translate (Offset (x, (x * slope + left_pos)* inter_f)); + mol_p->add (sb); + } + mol_p->translate (x0 - spanned_drul_[LEFT]->absolute_coordinate(X_AXIS), X_AXIS); + return mol_p; +} Offset Beam::center() const @@ -96,23 +80,47 @@ Beam::center() const return Offset (w, (left_pos + w* slope)*paper()->internote_f ()); } +void +Beam::do_pre_processing() +{ + if (!dir_) + set_default_dir(); +} -Beam::Beam() +void +Beam::do_print() const { - slope = 0; - left_pos = 0.0; +#ifndef NPRINT + DOUT << "slope " <add_dependency (this); - s->print_flag_b_ = false; + if (stems.size() < 2) + { + warning ("Beam with less than 2 stems"); + transparent_b_ = true; + return ; + } + solve_slope(); + set_stemlens(); +} - if (!spanned_drul_[LEFT]) - set_bounds(LEFT,s); - set_bounds(RIGHT,s); +void +Beam::do_substitute_dependent (Score_elem*o,Score_elem*n) +{ + if (o->is_type_b (Stem::static_name())) + stems.substitute ((Stem*)o->item(), n?(Stem*) n->item ():0); +} + +Interval +Beam::do_width() const +{ + return Interval (stems[0]->hpos_f(), + stems.top()->hpos_f ()); } void @@ -236,20 +244,6 @@ Beam::set_stemlens() } } - -void -Beam::do_post_processing() -{ - if (stems.size() < 2) - { - warning ("Beam with less than 2 stems"); - transparent_b_ = true; - return ; - } - solve_slope(); - set_stemlens(); -} - void Beam::set_grouping (Rhythmic_grouping def, Rhythmic_grouping cur) { @@ -285,22 +279,6 @@ Beam::set_grouping (Rhythmic_grouping def, Rhythmic_grouping cur) } } -void -Beam::do_pre_processing() -{ - if (!dir_) - set_default_dir(); - -} - - -Interval -Beam::do_width() const -{ - return Interval (stems[0]->hpos_f(), - stems.top()->hpos_f ()); -} - /* beams to go with one stem. */ @@ -368,49 +346,3 @@ Beam::stem_beams (Stem *here, Stem *next, Stem *prev) const leftbeams.add (rightbeams); return leftbeams; } - - -Molecule* -Beam::brew_molecule_p() const -{ - - Molecule *mol_p = new Molecule; - // huh? inter-what - // Real inter_f = paper()->interbeam_f (); - Real inter_f = paper()->internote_f (); - Real x0 = stems[0]->hpos_f(); - for (int j=0; j 0)? stems[j-1] : 0; - Stem * next = (j < stems.size()-1) ? stems[j+1] :0; - - Molecule sb = stem_beams (i, next, prev); - Real x = i->hpos_f()-x0; - sb.translate (Offset (x, (x * slope + left_pos)* inter_f)); - mol_p->add (sb); - } - mol_p->translate (x0 - spanned_drul_[LEFT]->absolute_coordinate(X_AXIS), X_AXIS); - return mol_p; -} - - -IMPLEMENT_IS_TYPE_B1(Beam, Spanner); - -void -Beam::do_print() const -{ -#ifndef NPRINT - DOUT << "slope " <is_type_b (Stem::static_name())) - { - stems.substitute ((Stem*)o->item(), n?(Stem*) n->item ():0); - } -} diff --git a/lily/include/abbreviation-beam-engraver.hh b/lily/include/abbreviation-beam-engraver.hh new file mode 100644 index 0000000000..ddea124250 --- /dev/null +++ b/lily/include/abbreviation-beam-engraver.hh @@ -0,0 +1,41 @@ +/* + abbreviation-beam-engraver.hh -- declare Abbreviation_beam_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys + Jan Nieuwenhuizen +*/ + + +#ifndef ABBREVIATION_BEAM_ENGRAVER_HH +#define ABBREVIATION_BEAM_ENGRAVER_HH + +#include "engraver.hh" +#include "drul-array.hh" + +class Abbreviation_beam; // move me to lily-proto + +/** + Generate an abbreviation beam. Eat stems. + */ +class Abbreviation_beam_engraver : public Engraver +{ +public: + DECLARE_MY_RUNTIME_TYPEINFO; + + Abbreviation_beam_engraver(); + +protected: + virtual void do_removal_processing(); + virtual void do_process_requests(); + virtual bool do_try_request (Request*); + virtual void acknowledge_element (Score_elem_info); + virtual void do_pre_move_processing(); + +private: + Drul_array span_reqs_drul_; + Abbreviation_beam* abeam_p_; +}; + +#endif // ABBREVIATION_BEAM_ENGRAVER_HH diff --git a/lily/include/abbreviation-beam.hh b/lily/include/abbreviation-beam.hh new file mode 100644 index 0000000000..9a29de18af --- /dev/null +++ b/lily/include/abbreviation-beam.hh @@ -0,0 +1,33 @@ +/* + abbreviation-beam-engraver.hh -- declare Abbreviation_beam_engraver + + source file of the GNU LilyPond music typesetter + + (c) 1997 Han-Wen Nienhuys + Jan Nieuwenhuizen +*/ + +#ifndef ABBREVIATION_BEAM_HH +#define ABBREVIATION_BEAM_HH + +#include "beam.hh" + +/** a beam connects multiple stems Beam adjusts the stems its owns to + make sure that they reach the beam and that point in the correct + direction */ +class Abbreviation_beam : public Beam { +public: + DECLARE_MY_RUNTIME_TYPEINFO; + + Abbreviation_beam(); + + SCORE_ELEM_CLONE(Abbreviation_beam); + +protected: + virtual void do_print() const; + virtual Molecule stem_beams (Stem *here, Stem *next, Stem *prev) const; + virtual Molecule* brew_molecule_p() const; +}; + +#endif // ABBREVIATION_BEAM_HH + diff --git a/lily/include/beam.hh b/lily/include/beam.hh index ad775b7a3c..c1b1b971b9 100644 --- a/lily/include/beam.hh +++ b/lily/include/beam.hh @@ -31,20 +31,20 @@ public: void set_grouping (Rhythmic_grouping def, Rhythmic_grouping current); void set_stemlens(); SCORE_ELEM_CLONE(Beam); + protected: - virtual Interval do_width() const; - virtual Offset center() const; - virtual void set_default_dir(); + Interval do_width() const; + Offset center() const; + void set_default_dir(); virtual void do_pre_processing(); virtual void do_post_processing(); virtual void do_substitute_dependent (Score_elem*, Score_elem*); virtual void do_print() const; -private: - Molecule stem_beams (Stem *here, Stem *next, Stem *prev) const; - void solve_slope(); - Molecule*brew_molecule_p() const; + virtual Molecule stem_beams (Stem *here, Stem *next, Stem *prev) const; + virtual void solve_slope(); + virtual Molecule*brew_molecule_p() const; }; #endif // BEAM_HH diff --git a/lily/include/lily-proto.hh b/lily/include/lily-proto.hh index f5aa4f56c9..8e7c46c50a 100644 --- a/lily/include/lily-proto.hh +++ b/lily/include/lily-proto.hh @@ -12,6 +12,9 @@ struct Absolute_dynamic_req; +struct Abbreviation_req; +struct Abbreviation_beam_req; +struct Abbreviation_beam_engraver; struct Axis_group_element; struct Axis_group; struct Translator; @@ -33,6 +36,7 @@ struct Bar_engraver; struct Bar_req; struct Barcheck_req; struct Beam; +struct Beam_engraver; struct Beam_req; struct Blank_req; struct Box; diff --git a/lily/include/musical-request.hh b/lily/include/musical-request.hh index 64328afc97..4531ff82cf 100644 --- a/lily/include/musical-request.hh +++ b/lily/include/musical-request.hh @@ -28,6 +28,7 @@ public: virtual Melodic_req *melodic() { return 0; } virtual Slur_req *slur() { return 0 ; } virtual Beam_req *beam() { return 0 ; } + virtual Abbreviation_beam_req* abbrev_beam() { return 0 ; } virtual Rhythmic_req*rhythmic() { return 0; } virtual Musical_script_req*musicalscript() { return 0; } virtual Text_req*text() { return 0; } @@ -37,6 +38,7 @@ public: virtual Absolute_dynamic_req * absdynamic() { return 0; } virtual Tie_req * tie() { return 0; } virtual Span_dynamic_req * span_dynamic() { return 0; } + virtual Abbreviation_req* abbrev() { return 0; } REQUESTMETHODS(Musical_req, musical); }; @@ -62,6 +64,7 @@ class Skip_req : public Rhythmic_req { public: REQUESTMETHODS(Skip_req, skip); }; + struct Spacing_req :virtual Request { Moment next; Real distance; @@ -71,6 +74,12 @@ struct Spacing_req :virtual Request { REQUESTMETHODS(Spacing_req, spacing); }; +struct Abbreviation_req : public Musical_req { + REQUESTMETHODS (Abbreviation_req, abbrev); + Abbreviation_req (); + int type_i_; +}; + class Blank_req : public Spacing_req, Rhythmic_req { public: REQUESTMETHODS(Spacing_req, spacing); @@ -177,6 +186,18 @@ public: Beam_req(); }; +/** + Start / stop an abbreviation beam at this note. + */ +class Abbreviation_beam_req : public Span_req { +public: + REQUESTMETHODS (Abbreviation_beam_req, abbrev_beam); + + Abbreviation_beam_req (); + + int type_i_; +}; + /** Start a tie at this voice element, end it at the next */ diff --git a/lily/include/my-lily-parser.hh b/lily/include/my-lily-parser.hh index 7930c9c7a2..d1a4b77914 100644 --- a/lily/include/my-lily-parser.hh +++ b/lily/include/my-lily-parser.hh @@ -33,9 +33,14 @@ class My_lily_parser { void set_last_duration (Duration const *); void set_default_duration (Duration const *); + void set_last_abbrev (int type_i); + void set_abbrev_beam (int type_i); void set_duration_mode (String s); friend int yyparse (void*); + public: + int abbrev_beam_type_i_; + int default_abbrev_type_i_; int default_octave_i_; Duration default_duration_; Plet plet_; diff --git a/lily/include/stem-grav.hh b/lily/include/stem-grav.hh index c5807f70be..36a3a0971c 100644 --- a/lily/include/stem-grav.hh +++ b/lily/include/stem-grav.hh @@ -20,9 +20,11 @@ class Stem_engraver : public Engraver Direction dir_; Stem *stem_p_; Rhythmic_req *rhythmic_req_l_; + Abbreviation_req* abbrev_req_l_; protected: virtual void acknowledge_element (Score_elem_info); virtual void do_pre_move_processing (); + virtual bool do_try_request (Request*); virtual void set_feature (Feature dir_i_); public: diff --git a/lily/include/stem-info.hh b/lily/include/stem-info.hh new file mode 100644 index 0000000000..5fa4da6461 --- /dev/null +++ b/lily/include/stem-info.hh @@ -0,0 +1,26 @@ +/* + stem-info.hh -- declare Stem_info + + source file of the GNU LilyPond music typesetter + + (c) 1997 Jan Nieuwenhuizen +*/ + + +#ifndef STEM_INFO_HH +#define STEM_INFO_HH + +#include "real.hh" + +struct Stem_info { + Real x; + int dir_; + Real idealy_f_; + Real miny_f_; + int beams_i_; + + Stem_info(); + Stem_info (Stem const *); +}; + +#endif // STEM_INFO_HH diff --git a/lily/include/stem.hh b/lily/include/stem.hh index 4cf67df0e2..12380ae48b 100644 --- a/lily/include/stem.hh +++ b/lily/include/stem.hh @@ -9,6 +9,7 @@ #include "item.hh" #include "varray.hh" #include "moment.hh" +#include "molecule.hh" /**the rule attached to the ball. @@ -27,6 +28,8 @@ Stem size depends on flag. */ class Stem : public Item { + + Molecule abbrev_mol () const; Real stem_bottom_f_, stem_top_f_; @@ -52,17 +55,22 @@ class Stem : public Item { Link_array rest_l_arr_; public: + /// abbrev flag? + count + int abbrev_flag_i_; + /// flagtype? 4 none, 8 8th flag, 0 = beam. int flag_i_; + /** + don't print flag when in beam. + our beam, for aligning abbrev flags + */ + Beam* beam_l_; + int beams_left_i_; int beams_right_i_; - /// false if in beam - bool print_flag_b_; - Direction dir_; - /* *************** */ Stem (); diff --git a/lily/musical-request.cc b/lily/musical-request.cc index 9ffd4f494c..f574813927 100644 --- a/lily/musical-request.cc +++ b/lily/musical-request.cc @@ -37,6 +37,8 @@ Span_req::do_print() const #endif } +IMPLEMENT_IS_TYPE_B1(Spacing_req,Request); + Spacing_req::Spacing_req() { next = 0; @@ -44,8 +46,6 @@ Spacing_req::Spacing_req() strength = 0; } -IMPLEMENT_IS_TYPE_B1(Spacing_req,Request); - void Spacing_req::do_print() const { @@ -54,6 +54,21 @@ Spacing_req::do_print() const #endif } +IMPLEMENT_IS_TYPE_B1 (Abbreviation_req, Musical_req); + +Abbreviation_req::Abbreviation_req () +{ + type_i_ = 0; +} + +void +Abbreviation_req::do_print() const +{ +#ifndef NPRINT + DOUT << "type " << type_i_ << "\n"; +#endif +} + IMPLEMENT_IS_TYPE_B2(Blank_req,Spacing_req,Rhythmic_req); @@ -243,21 +258,41 @@ Rest_req::do_print() const } /* *************** */ + +IMPLEMENT_IS_TYPE_B1(Beam_req,Span_req); + Beam_req::Beam_req() { nplet = 0; } -IMPLEMENT_IS_TYPE_B1(Beam_req,Span_req); void -Beam_req::do_print() const{} +Beam_req::do_print() const +{ +} + /* *************** */ +IMPLEMENT_IS_TYPE_B1 (Abbreviation_beam_req, Span_req); + +Abbreviation_beam_req::Abbreviation_beam_req () +{ + type_i_ = 0; +} + +void +Abbreviation_beam_req::do_print () const +{ +} + IMPLEMENT_IS_TYPE_B1(Slur_req,Span_req); + void -Slur_req::do_print() const{} -/* *************** */ +Slur_req::do_print() const +{ +} +/* *************** */ bool Span_req:: do_equal_b (Request*r) const diff --git a/lily/my-lily-parser.cc b/lily/my-lily-parser.cc index 1f4d430f17..9878369e16 100644 --- a/lily/my-lily-parser.cc +++ b/lily/my-lily-parser.cc @@ -17,11 +17,35 @@ #include "header.hh" +My_lily_parser::My_lily_parser (Sources * source_l) +{ + first_b_ = true; + source_l_ = source_l; + lexer_p_ = 0; + abbrev_beam_type_i_ = 0; + default_abbrev_type_i_ = 0; + default_duration_.durlog_i_ = 2; + default_octave_i_ = 0; + textstyle_str_="roman"; // in lexer? + error_level_i_ = 0; + last_duration_mode_b_ = true; + fatal_error_i_ = 0; + default_header_p_ =0; +} + +My_lily_parser::~My_lily_parser() +{ + delete lexer_p_; + delete default_header_p_; +} + + void My_lily_parser::clear_notenames() { lexer_p_->clear_notenames(); } + void My_lily_parser::set_version_check (bool ig) { @@ -82,12 +106,6 @@ My_lily_parser::parse_file (String init, String s) } } -My_lily_parser::~My_lily_parser() -{ - delete lexer_p_; - delete default_header_p_; -} - void My_lily_parser::remember_spot() { @@ -116,11 +134,24 @@ My_lily_parser::set_duration_mode (String s) last_duration_mode_b_ = (s== "LAST"); } +void +My_lily_parser::set_abbrev_beam (int type_i) +{ + abbrev_beam_type_i_ = type_i; +} + +void +My_lily_parser::set_last_abbrev (int type_i) +{ + default_abbrev_type_i_ = type_i; +} + void My_lily_parser::set_default_duration (Duration const *d) { last_duration_mode_b_ = false; default_duration_ = *d; + set_last_abbrev (0); } @@ -129,6 +160,7 @@ My_lily_parser::set_last_duration (Duration const *d) { if (last_duration_mode_b_) default_duration_ = *d; + set_last_abbrev (0); } @@ -183,6 +215,13 @@ My_lily_parser::get_note_element (Note_req *rq, Duration * duration_p) v->add (rq); + // too bad parser reads (default) duration via member access, + // this hack will do for now.. + if (abbrev_beam_type_i_) + { + assert (!duration_p->plet_b ()); + duration_p->set_plet (1, 2); + } rq->set_duration (*duration_p); rq->set_spot (here_input()); delete duration_p ; @@ -202,11 +241,22 @@ My_lily_parser::get_parens_request (char c) case '[': case ']': { - Beam_req*b = new Beam_req; - int p_i=plet_.type_i_ ; // ugh . Should junk? - if (p_i!= 1) - b->nplet = p_i; - req_p = b; + if (!abbrev_beam_type_i_) + { + Beam_req*b = new Beam_req; + int p_i=plet_.type_i_ ; // ugh . Should junk? + if (p_i!= 1) + b->nplet = p_i; + req_p = b; + } + else + { + Abbreviation_beam_req* a = new Abbreviation_beam_req; + a->type_i_ = abbrev_beam_type_i_; + if (c==']') + abbrev_beam_type_i_ = 0; + req_p = a; + } } break; @@ -253,20 +303,6 @@ My_lily_parser::get_parens_request (char c) return req_p; } -My_lily_parser::My_lily_parser (Sources * source_l) -{ - first_b_ = true; - source_l_ = source_l; - lexer_p_ = 0; - default_duration_.durlog_i_ = 2; - default_octave_i_ = 0; - textstyle_str_="roman"; // in lexer? - error_level_i_ = 0; - last_duration_mode_b_ = true; - fatal_error_i_ = 0; - default_header_p_ =0; -} - void My_lily_parser::add_requests (Chord*v) { diff --git a/lily/parser.y b/lily/parser.y index a8612c44d4..48aee8d856 100644 --- a/lily/parser.y +++ b/lily/parser.y @@ -12,7 +12,7 @@ #include // mmm -#define MUDELA_VERSION "0.1.1" +#define MUDELA_VERSION "0.1.2" #include "script-def.hh" #include "symtable.hh" @@ -68,6 +68,7 @@ Interval *interval; Lookup*lookup; Melodic_req * melreq; + Musical_req* musreq; Music_output_def * outputdef; Midi_def* midi; Moment *moment; @@ -188,8 +189,10 @@ yylex(YYSTYPE *s, void * v_l) %type
mudela_header mudela_header_body %type box %type open_request_parens close_request_parens +%type open_abbrev_parens %type open_plet_parens close_plet_parens %type simple_element music_elt full_element lyrics_elt command_elt +%type abbrev_type %type int %type script_dir %type identifier_init @@ -210,8 +213,8 @@ yylex(YYSTYPE *s, void * v_l) %type paper_block paper_body %type dim real %type unit -%type post_request pre_request command_req verbose_command_req %type abbrev_command_req +%type post_request pre_request command_req verbose_command_req %type script_req dynamic_req %type score_block score_body %type