From: hanwen Date: Fri, 20 Feb 2004 21:47:01 +0000 (+0000) Subject: * lily/auto-beam-engraver.cc (try_music): accept and process X-Git-Tag: release/2.1.27~23 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=64883b1fe75af0cb0f9978a246acdefb9147b34f;p=lilypond.git * lily/auto-beam-engraver.cc (try_music): accept and process beam-forbid-event. * input/regression/auto-beam-no-beam.ly: new file. --- diff --git a/ChangeLog b/ChangeLog index 30eae2552e..b8e7a5c27b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-02-20 Han-Wen Nienhuys + + * lily/auto-beam-engraver.cc (try_music): accept and process + beam-forbid-event. + + * input/regression/auto-beam-no-beam.ly: new file. + 2004-02-20 Mats Bengtsson * lily/accidental.cc (print): Change font-relative-size -> diff --git a/Documentation/topdocs/NEWS.texi b/Documentation/topdocs/NEWS.texi index 155fce522c..97bccdc2c6 100644 --- a/Documentation/topdocs/NEWS.texi +++ b/Documentation/topdocs/NEWS.texi @@ -18,6 +18,15 @@ Version 2.1.13 @itemize @bullet +@item Notes can be excluded from auto-beaming, by marking them with +@code{\noBeam}: +@example + c8 c \noBeam c c +@end example + +@noindent +will print two separate eighth notes, and two beamed notes. + @item Translators and contexts have been split. The result of this internal cleanup is that @code{Score} no longer is the top context; @code{Score} is contained in the @code{Global} context. Consequently, diff --git a/Documentation/user/refman.itely b/Documentation/user/refman.itely index dad049a905..eeed902fad 100644 --- a/Documentation/user/refman.itely +++ b/Documentation/user/refman.itely @@ -1322,6 +1322,14 @@ When these automatic decisions are not good enough, beaming can be entered explicitly. It is also possible to define beaming patterns that differ from the defaults. +Individual notes may be marked with @code{\noBeam}, to prevent them +from being beamed: + +@lilypond[fragment,verbatim,relative=2] + \time 2/4 c8 c\noBeam c c +@end lilypond + + @seealso Internals: @internalsref{Beam}. diff --git a/input/regression/auto-beam-no-beam.ly b/input/regression/auto-beam-no-beam.ly new file mode 100644 index 0000000000..f1a6e4ddaf --- /dev/null +++ b/input/regression/auto-beam-no-beam.ly @@ -0,0 +1,12 @@ +\header { + + texidoc = "The autobeamer may be switched off for a single note + with @code{\noBeam}." + + + } +\version "2.1.25" + +\score { + \notes { c8 c-\noBeam c c } + } diff --git a/lily/auto-beam-engraver.cc b/lily/auto-beam-engraver.cc index d7eb017a17..4156afeffa 100644 --- a/lily/auto-beam-engraver.cc +++ b/lily/auto-beam-engraver.cc @@ -22,8 +22,6 @@ #include "context.hh" /* - TODO: figure what to do in grace? - TODO: documentme. */ class Auto_beam_engraver : public Engraver @@ -33,6 +31,7 @@ protected: virtual void stop_translation_timestep (); virtual void start_translation_timestep (); virtual void process_music (); + virtual bool try_music (Music*); virtual void finalize (); virtual void acknowledge_grob (Grob_info); virtual void process_acknowledged_grobs (); @@ -48,6 +47,7 @@ private: bool is_same_grace_state (Grob* e); void typeset_beam (); + Music *forbid_; /* shortest_mom is the shortest note in the beam. */ @@ -83,11 +83,18 @@ Auto_beam_engraver::process_music () consider_end (shortest_mom_); junk_beam (); } + + if (forbid_) + { + consider_end (shortest_mom_); + junk_beam (); + } } Auto_beam_engraver::Auto_beam_engraver () { + forbid_ = 0; count_ = 0; stems_ = 0; shortest_mom_ = Moment (Rational (1, 8)); @@ -97,6 +104,19 @@ Auto_beam_engraver::Auto_beam_engraver () beam_settings_ = SCM_EOL; } + +bool +Auto_beam_engraver::try_music (Music*m) +{ + if (m->is_mus_type ("beam-forbid-event")) + { + forbid_ = m; + return true; + } + + return false; +} + /* Determine end moment for auto beaming (or begin moment, but mostly 0==anywhere) In order of increasing priority: @@ -220,7 +240,8 @@ void Auto_beam_engraver::consider_begin (Moment test_mom) { bool on = to_boolean (get_property ("autoBeaming")); - if (!stems_ && on) + if (!stems_ && on + && !forbid_) { bool b = test_moment (START, test_mom); if (b) @@ -353,6 +374,7 @@ Auto_beam_engraver::start_translation_timestep () end_beam (); } } + forbid_ = 0; } void @@ -511,7 +533,7 @@ ENTER_DESCRIPTION (Auto_beam_engraver, "stemRightBeamCount. " , /* creats*/ "Beam", -/* accepts */ "", +/* accepts */ "beam-forbid-event", /* acks */ "stem-interface rest-interface beam-interface bar-line-interface", /* reads */ "autoBeaming autoBeamSettings beatLength subdivideBeams", /* write */ ""); diff --git a/lily/parser.yy b/lily/parser.yy index 0aa5803a0a..f4998c7c6b 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -139,7 +139,7 @@ make_simple_markup (SCM a) if (!simple) simple = scm_c_eval_string ("simple-markup"); - return scm_list_n (simple, a, SCM_UNDEFINED); + return scm_list_2 (simple, a); } @@ -579,8 +579,8 @@ translator_spec_body: SCM tag = gh_caar (p); /* TODO: should make new tag "grob-definition" ? */ - td->add_context_mod (scm_list_n (ly_symbol2scm ("assign"), - tag, gh_cons (ly_cdar (p), SCM_EOL), SCM_UNDEFINED)); + td->add_context_mod (scm_list_3 (ly_symbol2scm ("assign"), + tag, gh_cons (ly_cdar (p), SCM_EOL))); } } | translator_spec_body context_mod { @@ -1126,20 +1126,20 @@ context_change: property_operation: STRING '=' scalar { - $$ = scm_list_n (ly_symbol2scm ("assign"), - scm_string_to_symbol ($1), $3, SCM_UNDEFINED); + $$ = scm_list_3 (ly_symbol2scm ("assign"), + scm_string_to_symbol ($1), $3); } | UNSET STRING { - $$ = scm_list_n (ly_symbol2scm ("unset"), - scm_string_to_symbol ($2), SCM_UNDEFINED); + $$ = scm_list_2 (ly_symbol2scm ("unset"), + scm_string_to_symbol ($2)); } | OVERRIDE STRING embedded_scm '=' embedded_scm { - $$ = scm_list_n (ly_symbol2scm ("push"), - scm_string_to_symbol ($2), $3, $5, SCM_UNDEFINED); + $$ = scm_list_4 (ly_symbol2scm ("push"), + scm_string_to_symbol ($2), $3, $5); } | REVERT STRING embedded_scm { - $$ = scm_list_n (ly_symbol2scm ("pop"), - scm_string_to_symbol ($2), $3, SCM_UNDEFINED); + $$ = scm_list_3 (ly_symbol2scm ("pop"), + scm_string_to_symbol ($2), $3); } ; @@ -1160,46 +1160,46 @@ translator_mod: context_mod: property_operation { $$ = $1; } | translator_mod STRING { - $$ = scm_list_n ($1, $2, SCM_UNDEFINED); + $$ = scm_list_2 ($1, $2); } ; context_prop_spec: STRING { - $$ = scm_list_n (ly_symbol2scm ("Bottom"), scm_string_to_symbol ($1), SCM_UNDEFINED); + $$ = scm_list_2 (ly_symbol2scm ("Bottom"), scm_string_to_symbol ($1)); } | STRING '.' STRING { - $$ = scm_list_n (scm_string_to_symbol ($1), scm_string_to_symbol ($3), SCM_UNDEFINED); + $$ = scm_list_2 (scm_string_to_symbol ($1), scm_string_to_symbol ($3)); } ; music_property_def: OVERRIDE context_prop_spec embedded_scm '=' scalar { - $$ = property_op_to_music (scm_list_n ( + $$ = property_op_to_music (scm_list_4 ( ly_symbol2scm ("poppush"), gh_cadr ($2), - $3, $5, SCM_UNDEFINED)); + $3, $5)); $$= context_spec_music (gh_car ($2), SCM_UNDEFINED, $$, SCM_EOL); } | REVERT context_prop_spec embedded_scm { - $$ = property_op_to_music (scm_list_n ( + $$ = property_op_to_music (scm_list_3 ( ly_symbol2scm ("pop"), gh_cadr ($2), - $3, SCM_UNDEFINED)); + $3)); $$= context_spec_music (gh_car ($2), SCM_UNDEFINED, $$, SCM_EOL); } | SET context_prop_spec '=' scalar { - $$ = property_op_to_music (scm_list_n ( + $$ = property_op_to_music (scm_list_3 ( ly_symbol2scm ("assign"), gh_cadr ($2), - $4, SCM_UNDEFINED)); + $4)); $$= context_spec_music (gh_car ($2), SCM_UNDEFINED, $$, SCM_EOL); } | UNSET context_prop_spec { - $$ = property_op_to_music (scm_list_n ( + $$ = property_op_to_music (scm_list_2 ( ly_symbol2scm ("unset"), - gh_cadr ($2), SCM_UNDEFINED)); + gh_cadr ($2))); $$= context_spec_music (gh_car ($2), SCM_UNDEFINED, $$, SCM_EOL); } | ONCE music_property_def { @@ -1966,7 +1966,7 @@ simple_element: n->set_mus_property ("force-accidental", SCM_BOOL_T); Music *v = MY_MAKE_MUSIC("EventChord"); - v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED)); + v->set_mus_property ("elements", scm_list_1 (n->self_scm ())); scm_gc_unprotect_object (n->self_scm()); v->set_spot (i); @@ -1981,7 +1981,7 @@ simple_element: n->set_mus_property ("drum-type" , $1); Music *v = MY_MAKE_MUSIC("EventChord"); - v->set_mus_property ("elements", scm_list_n (n->self_scm (), SCM_UNDEFINED)); + v->set_mus_property ("elements", scm_list_1 (n->self_scm ())); scm_gc_unprotect_object (n->self_scm()); v->set_spot (i); n->set_spot (i); @@ -2013,7 +2013,7 @@ simple_element: ev->set_mus_property ("duration" ,$2); ev->set_spot (i); Music * velt = MY_MAKE_MUSIC("EventChord"); - velt->set_mus_property ("elements", scm_list_n (ev->self_scm (),SCM_UNDEFINED)); + velt->set_mus_property ("elements", scm_list_1 (ev->self_scm ())); velt->set_spot (i); scm_gc_unprotect_object (ev->self_scm()); @@ -2043,7 +2043,7 @@ simple_element: lreq->set_mus_property ("duration",$2); lreq->set_spot (i); Music * velt = MY_MAKE_MUSIC("EventChord"); - velt->set_mus_property ("elements", scm_list_n (lreq->self_scm (), SCM_UNDEFINED)); + velt->set_mus_property ("elements", scm_list_1 (lreq->self_scm ())); $$= velt; } @@ -2088,10 +2088,10 @@ chord_separator: $$ = ly_symbol2scm ("chord-caret"); } | CHORD_SLASH steno_tonic_pitch { - $$ = scm_list_n (ly_symbol2scm ("chord-slash"), $2, SCM_UNDEFINED); + $$ = scm_list_2 (ly_symbol2scm ("chord-slash"), $2); } | CHORD_BASS steno_tonic_pitch { - $$ = scm_list_n (ly_symbol2scm ("chord-bass"), $2, SCM_UNDEFINED); + $$ = scm_list_2 (ly_symbol2scm ("chord-bass"), $2); } ; @@ -2216,7 +2216,7 @@ string: $$ = $1; } | string '+' string { - $$ = scm_string_append (scm_list_n ($1, $3, SCM_UNDEFINED)); + $$ = scm_string_append (scm_list_2 ($1, $3)); } ; @@ -2254,34 +2254,34 @@ markup: $$ = make_simple_markup ($1); } | MARKUP_HEAD_EMPTY { - $$ = scm_list_n ($1, SCM_UNDEFINED); + $$ = scm_list_1 ($1); } | MARKUP_HEAD_MARKUP0 markup { - $$ = scm_list_n ($1, $2, SCM_UNDEFINED); + $$ = scm_list_2 ($1, $2); } | MARKUP_HEAD_MARKUP0_MARKUP1 markup markup { - $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED); + $$ = scm_list_3 ($1, $2, $3); } | MARKUP_HEAD_SCM0_MARKUP1 SCM_T markup { - $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED); + $$ = scm_list_3 ($1, $2, $3); } | markup_line { $$ = $1; } | MARKUP_HEAD_LIST0 markup_list { - $$ = scm_list_n ($1,$2, SCM_UNDEFINED); + $$ = scm_list_2 ($1,$2); } | MARKUP_HEAD_SCM0 embedded_scm { - $$ = scm_list_n ($1, $2, SCM_UNDEFINED); + $$ = scm_list_2 ($1, $2); } | MARKUP_HEAD_SCM0_SCM1_MARKUP2 embedded_scm embedded_scm markup { - $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED); + $$ = scm_list_4 ($1, $2, $3, $4); } | MARKUP_HEAD_SCM0_SCM1_SCM2 embedded_scm embedded_scm embedded_scm { - $$ = scm_list_n ($1, $2, $3, $4, SCM_UNDEFINED); + $$ = scm_list_4 ($1, $2, $3, $4); } | MARKUP_HEAD_SCM0_SCM1 embedded_scm embedded_scm { - $$ = scm_list_n ($1, $2, $3, SCM_UNDEFINED); + $$ = scm_list_3 ($1, $2, $3); } | MARKUP_IDENTIFIER { $$ = $1; @@ -2299,7 +2299,7 @@ markup_line: if (!line) line = scm_c_eval_string ("line-markup"); - $$ = scm_list_n (line, scm_reverse_x ($2, SCM_EOL), SCM_UNDEFINED); + $$ = scm_list_2 (line, scm_reverse_x ($2, SCM_EOL)); } ; diff --git a/ly/declarations-init.ly b/ly/declarations-init.ly index 69510dbb9d..9405e8985c 100644 --- a/ly/declarations-init.ly +++ b/ly/declarations-init.ly @@ -30,6 +30,8 @@ working with lyric sections) break =#(make-event-chord (list (make-penalty-music -10001))) noBreak = #(make-event-chord (list (make-penalty-music 10001))) +noBeam = #(make-music-by-name 'BeamForbidEvent) + \include "scale-definitions-init.ly" melisma = #(make-span-event 'ManualMelismaEvent START) diff --git a/scm/define-music-types.scm b/scm/define-music-types.scm index 178efa4743..5d7bb57b29 100644 --- a/scm/define-music-types.scm +++ b/scm/define-music-types.scm @@ -160,6 +160,12 @@ c8-[ c c-] c8") (internal-class-name . "Event") (types . (general-music fingering-event event)) )) + (BeamForbidEvent + . ( + (description . "Specify that a note may not auto-beamed ") + (internal-class-name . "Event") + (types . (general-music event beam-forbid-event)) + )) (GlissandoEvent . ( (description . "Start a glissando on this note.")