]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.103
authorfred <fred>
Wed, 27 Mar 2002 00:02:05 +0000 (00:02 +0000)
committerfred <fred>
Wed, 27 Mar 2002 00:02:05 +0000 (00:02 +0000)
13 files changed:
input/test/music-apply.ly [new file with mode: 0644]
lily/beam-engraver.cc
lily/dynamic-engraver.cc
lily/include/request.hh
lily/lyric-combine-music-iterator.cc
lily/multi-measure-rest-engraver.cc
lily/musical-request.cc
lily/parser.yy
lily/piano-pedal-performer.cc
lily/request.cc
lily/slur-engraver.cc
lily/span-dynamic-performer.cc
lily/text-spanner-engraver.cc

diff --git a/input/test/music-apply.ly b/input/test/music-apply.ly
new file mode 100644 (file)
index 0000000..a61ea1a
--- /dev/null
@@ -0,0 +1,26 @@
+
+mus = \notes { c'4 d'4( e'4 f'4  }
+
+#(define (reverse-music mus)
+  (let* (
+       (es (ly-get-mus-property mus 'elements))
+       (reved (reverse es))
+       (sd (ly-get-mus-property mus 'span-direction))
+       )
+       (ly-set-mus-property
+               mus
+               'elements
+               reved
+       )
+       (if (dir? sd)
+               (ly-set-mus-property mus 'span-direction (- sd))) 
+       (map reverse-music reved)
+       mus)
+)
+
+\score {
+       \context Voice {
+               \mus
+               \apply #reverse-music \mus
+       }
+}
index 29c50059745a6ec0127ab27ac8ef1b72ae8d3c42..8b01712e9a71299b9a4fb1005abce061010de7f1 100644 (file)
@@ -77,7 +77,7 @@ Beam_engraver::do_try_music (Music *m)
       else if (c->span_type_str_ == "beam")
        {
       
-         Direction d =c->span_dir_;
+         Direction d =c->get_span_dir ();
 
          if (d == STOP && !beam_p_)
            {
index 9befc70458d23fc62a47614b32c7e87e051c5335..4a9e01eab7daa9b9285a2b336f70b31d478b9898 100644 (file)
@@ -112,7 +112,7 @@ Dynamic_engraver::do_try_music (Music * m)
       else if ((s->span_type_str_ == "crescendo"
           || s->span_type_str_ == "decrescendo"))
        {
-         accepted_spanreqs_drul_[s->span_dir_] = s;
+         accepted_spanreqs_drul_[s->get_span_dir()] = s;
          return true;
        }
     }
@@ -219,7 +219,7 @@ Dynamic_engraver::do_process_music ()
       if (current_cresc_req_)
        {
          accepted_spanreqs_drul_[START]->origin ()->warning
-           (current_cresc_req_->span_dir_ == 1
+           (current_cresc_req_->get_span_dir() == 1
             ? _ ("already have a crescendo")
             : _ ("already have a decrescendo"));
        }
index 31cf4f8cb0f01afb770a588e0e6fb439e037abca..f5ab252a5284ffc640a302a3b2ea378d543c96fd 100644 (file)
@@ -53,12 +53,13 @@ public:
 */
 class Span_req  : public virtual Request  {
 public:
-  /// should the spanner start or stop, or is it unwanted?
-  Direction span_dir_;
   String span_type_str_;
+  void set_span_dir (Direction d);
+  Direction get_span_dir () const;  
   
   Span_req();
 protected:
+  
   virtual bool do_equal_b (Request const*) const;
 
   VIRTUAL_COPY_CONS(Music);
index 035b83b7c8d05547b47158bebd952bf2288000b7..8ab8f2920a494a6d8dae31a25440f031167dc9f4 100644 (file)
@@ -29,8 +29,8 @@ Lyric_combine_music_iterator::Lyric_combine_music_iterator ()
       melisma_stop_req = new Melisma_req;
       melisma_start_req = new Melisma_req;      
     }
-  melisma_start_req->span_dir_ = START;
-  melisma_stop_req->span_dir_ = STOP;
+  melisma_start_req->set_span_dir (START);
+  melisma_stop_req->set_span_dir (STOP);
   
   music_iter_p_ =0;
   lyric_iter_p_ =0;
index be25b4ab48afc01a11a040aec50f0ce41afe5da1..f8d23f7906c2306262731a1d5d4f7dfbec49f1d1 100644 (file)
@@ -75,11 +75,11 @@ Multi_measure_rest_engraver::do_try_music (Music* req_l)
     {
       if (sp->span_type_str_ == "rest")
        {
-         if (sp->span_dir_ == STOP)
+         if (sp->get_span_dir() == STOP)
            {
              stop_req_l_ = sp;
            }
-         else if (sp->span_dir_ == START && !new_req_l_)
+         else if (sp->get_span_dir() == START && !new_req_l_)
            {
              new_req_l_ = sp;
            }
index 43b238f8772f1bbc95776db833aeaa6c551a0f78..6cadceb906db71c07e61bd0c80469ffa37e55973 100644 (file)
@@ -30,8 +30,6 @@ Melodic_req::transpose (Musical_pitch delta)
     }
 }
 
-
-
 bool
 Melodic_req::do_equal_b (Request const* r) const
 {
@@ -45,10 +43,6 @@ Melodic_req::compare (Melodic_req const &m1 , Melodic_req const&m2)
   return Musical_pitch::compare (m1.pitch_, m2.pitch_);
 }
 
-
-
-
-
 int
 Rhythmic_req::compare (Rhythmic_req const &r1, Rhythmic_req const &r2)
 {
@@ -101,12 +95,11 @@ bool
 Span_req::do_equal_b (Request const*r) const
 {
   Span_req const* s = dynamic_cast <Span_req const*> (r);
-  return s && span_dir_ == s->span_dir_;
+  return s && get_span_dir () == s->get_span_dir ();
 }
 
 Span_req::Span_req ()
 {
-  span_dir_ = CENTER;
 }
 
 
index 10242bfdfe0e4c877306016be28ed9e4a8ccf855..e3026961200be8a7eab8801f0b8be6db1b402709 100644 (file)
@@ -127,6 +127,7 @@ yylex (YYSTYPE *s,  void * v_l)
 
 /* tokens which are not keywords */
 %token AUTOCHANGE
+%token APPLY
 %token ARPEGGIO
 %token DYNAMICSCRIPT
 %token TEXTSCRIPT
@@ -772,6 +773,15 @@ Composite_music:
                $$ = new Transposed_music ($3, *$2);
                delete $2; // ugh
        }
+       | APPLY embedded_scm Music  {
+               SCM ret = gh_call1 ($2, $3->self_scm ());
+               Music *m = unsmob_music (ret);
+               if (!m) {
+                       THIS->parser_error ("\\apply must return a Music");
+                       m = new Music ();
+                       }
+               $$ = m;
+       }
        | NOTES
                { THIS->lexer_p_->push_note_state (); }
        Music
@@ -935,13 +945,13 @@ shorthand_command_req:
        }
        | '['           {
                Span_req*b= new Span_req;
-               b->span_dir_ = START;
+               b->set_span_dir(START);
                b->span_type_str_ = "beam";
                $$ =b;
        }
        | ']'           {
             Span_req*b= new Span_req;
-            b->span_dir_ = STOP;
+            b->set_span_dir( STOP);
             b->span_type_str_ = "beam";
             $$ = b;
        }
@@ -958,7 +968,7 @@ verbose_command_req:
        }
        | COMMANDSPANREQUEST bare_int STRING {
                Span_req * sp_p = new Span_req;
-               sp_p-> span_dir_  = Direction($2);
+               sp_p-> set_span_dir ( Direction($2));
                sp_p->span_type_str_ = ly_scm2string ($3);
                sp_p->set_spot (THIS->here_input ());
                $$ = sp_p;
@@ -1080,7 +1090,7 @@ verbose_request:
        }
        | SPANREQUEST bare_int STRING {
                Span_req * sp_p = new Span_req;
-               sp_p->span_dir_  = Direction($2);
+               sp_p->set_span_dir( Direction($2));
                sp_p->span_type_str_ = ly_scm2string ($3);
                sp_p->set_spot (THIS->here_input ());
                $$ = sp_p;
@@ -1196,7 +1206,7 @@ hyphen_req:
 close_request:
        close_request_parens {
                $$ = $1;
-               dynamic_cast<Span_req*> ($$)->span_dir_ = START;
+               dynamic_cast<Span_req*> ($$)->set_span_dir ( START);
        }
        
 close_request_parens:
@@ -1221,7 +1231,7 @@ close_request_parens:
 open_request:
        open_request_parens {
                $$ = $1;
-               dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
+               dynamic_cast<Span_req*> ($$)->set_span_dir ( STOP);
        }
        ;
 
@@ -1416,8 +1426,8 @@ simple_element:
 
                Span_req *sp1 = new Span_req;
                Span_req *sp2 = new Span_req;
-               sp1-> span_dir_ = START;
-               sp2-> span_dir_ = STOP;
+               sp1-> set_span_dir ( START);
+               sp2-> set_span_dir ( STOP);
                sp1->span_type_str_ = sp2->span_type_str_ = "rest";
 
                Request_chord * rqc1 = new Request_chord (gh_list (sp1->self_scm (), SCM_UNDEFINED));
index 6b1efab4358068a5129548572eb6d9b4570d124f..9bd045aed87b11af6750441ebefe268173c8a63c 100644 (file)
@@ -134,7 +134,7 @@ Piano_pedal_performer::do_try_music (Music* r)
        {
          if (s->span_type_str_ == String (p->name_))
            {
-             p->req_l_drul_[s->span_dir_] = s;
+             p->req_l_drul_[s->get_span_dir()] = s;
              return true;
            }
        }
index 90831a5cab5d42db3d7b11f74fd94e8ca2cb69ce..d10693e898f88a1896afaed6dc7fcfe97a572521 100644 (file)
@@ -51,3 +51,19 @@ Script_req::get_direction () const
 }
 
 
+Direction
+Span_req::get_span_dir () const
+{
+  SCM d = get_mus_property ("span-direction");
+
+  return (isdir_b (d)) ?  to_dir (d) : CENTER;
+}
+
+void
+Span_req::set_span_dir (Direction d)
+{
+  set_mus_property ("span-direction", gh_int2scm (d));
+}
+
+
+
index ef3d6f062b6b8808bcb11628963aab4c50d44f3c..d59cbbe23318ccb6229b960a557fd739b1548c77 100644 (file)
@@ -66,7 +66,7 @@ Slur_engraver::do_try_music (Music *req_l)
          /*
            Let's not start more than one slur per moment.
           */
-         if (sl->span_dir_ == START)
+         if (sl->get_span_dir() == START)
            {
              if (now_mom () > last_start_)
                {
@@ -136,7 +136,7 @@ Slur_engraver::do_process_music ()
     {
       Span_req* slur_req_l = new_slur_req_l_arr_[i];
       // end slur: move the slur to other array
-      if (slur_req_l->span_dir_ == STOP)
+      if (slur_req_l->get_span_dir() == STOP)
        {
          if (slur_l_stack_.empty ())
            slur_req_l->origin ()->warning (_f ("can't find start of slur"));
@@ -152,7 +152,7 @@ Slur_engraver::do_process_music ()
              requests_arr_.pop ();
            }
        }
-      else  if (slur_req_l->span_dir_ == START)
+      else  if (slur_req_l->get_span_dir() == START)
        {
          // push a new slur onto stack.
          // (use temp. array to wait for all slur STOPs)
index 38bc89117df6efb3ebb2136327c3597c07fe26b6..ccf0d0823465c4e1067235aeab16cfa62d50ebb7 100644 (file)
@@ -183,7 +183,7 @@ Span_dynamic_performer::do_try_music (Music* r)
       if (s-> span_type_str_ == "crescendo"
          || s->span_type_str_ == "decrescendo")
        {
-         span_req_l_drul_[s->span_dir_] = s;
+         span_req_l_drul_[s->get_span_dir()] = s;
          return true;
        }
     }
index 911aadeb0b982dae2596a51059fb38769cd204d0..fe89e752bc6630db731e334c4307bc895be76451 100644 (file)
@@ -75,7 +75,7 @@ Text_spanner_engraver::do_try_music (Music *m)
        }
       else if (s->span_type_str_ == "text")
        {
-         req_drul_[s->span_dir_] = s;
+         req_drul_[s->get_span_dir()] = s;
          return true;
        }
     }