]> git.donarmstrong.com Git - lilypond.git/commitdiff
* lily/auto-beam-engraver.cc (try_music): accept and process
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 20 Feb 2004 21:47:01 +0000 (21:47 +0000)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Fri, 20 Feb 2004 21:47:01 +0000 (21:47 +0000)
beam-forbid-event.

* input/regression/auto-beam-no-beam.ly: new file.

ChangeLog
Documentation/topdocs/NEWS.texi
Documentation/user/refman.itely
input/regression/auto-beam-no-beam.ly [new file with mode: 0644]
lily/auto-beam-engraver.cc
lily/parser.yy
ly/declarations-init.ly
scm/define-music-types.scm

index 30eae2552ee0b8ee4fcab424127612733d58a4bf..b8e7a5c27b6aefbf44e804a9e35fe2da3b8b3fda 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2004-02-20  Han-Wen Nienhuys   <hanwen@xs4all.nl>
+
+       * 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  <mabe@drongo.s3.kth.se>
 
        * lily/accidental.cc (print): Change font-relative-size ->
index 155fce522c827457ee8b9c6940b1885254b74b1e..97bccdc2c6a7ef9d81d73e9455effda922be3a3f 100644 (file)
@@ -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,
index dad049a9051370a5e8b5477af534684ea4a20499..eeed902fad5e999d53e213ea9ecb434310e7445f 100644 (file)
@@ -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 (file)
index 0000000..f1a6e4d
--- /dev/null
@@ -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 }
+    }
index d7eb017a1734fe98dfcc3dec1aa8634be2884f02..4156afeffa886b7426a8f02f3d163df35b6d9537 100644 (file)
@@ -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 */       "");
index 0aa5803a0a88e03d7233591aff6bafa024091c89..f4998c7c6b6a1df36ea42db93d1f95e101d46f36 100644 (file)
@@ -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));
        }
        ;
 
index 69510dbb9d07ab4fedf41fab98400b64c2ba8d5a..9405e8985c3e976554158f95befe4a139acf54d3 100644 (file)
@@ -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)
index 178efa4743a49f7ed6bd7980addc6822226a5bf7..5d7bb57b29d8fad338003b520c6f95f119d35aaa 100644 (file)
@@ -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.")