From: fred Date: Wed, 27 Mar 2002 00:02:05 +0000 (+0000) Subject: lilypond-1.3.103 X-Git-Tag: release/1.5.59~1175 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=fa8b81a921f69797da24b2c0a9838dc3d715f98d;p=lilypond.git lilypond-1.3.103 --- diff --git a/input/test/music-apply.ly b/input/test/music-apply.ly new file mode 100644 index 0000000000..a61ea1a7a1 --- /dev/null +++ b/input/test/music-apply.ly @@ -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 + } +} diff --git a/lily/beam-engraver.cc b/lily/beam-engraver.cc index 29c5005974..8b01712e9a 100644 --- a/lily/beam-engraver.cc +++ b/lily/beam-engraver.cc @@ -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_) { diff --git a/lily/dynamic-engraver.cc b/lily/dynamic-engraver.cc index 9befc70458..4a9e01eab7 100644 --- a/lily/dynamic-engraver.cc +++ b/lily/dynamic-engraver.cc @@ -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")); } diff --git a/lily/include/request.hh b/lily/include/request.hh index 31cf4f8cb0..f5ab252a52 100644 --- a/lily/include/request.hh +++ b/lily/include/request.hh @@ -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); diff --git a/lily/lyric-combine-music-iterator.cc b/lily/lyric-combine-music-iterator.cc index 035b83b7c8..8ab8f2920a 100644 --- a/lily/lyric-combine-music-iterator.cc +++ b/lily/lyric-combine-music-iterator.cc @@ -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; diff --git a/lily/multi-measure-rest-engraver.cc b/lily/multi-measure-rest-engraver.cc index be25b4ab48..f8d23f7906 100644 --- a/lily/multi-measure-rest-engraver.cc +++ b/lily/multi-measure-rest-engraver.cc @@ -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; } diff --git a/lily/musical-request.cc b/lily/musical-request.cc index 43b238f877..6cadceb906 100644 --- a/lily/musical-request.cc +++ b/lily/musical-request.cc @@ -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 (r); - return s && span_dir_ == s->span_dir_; + return s && get_span_dir () == s->get_span_dir (); } Span_req::Span_req () { - span_dir_ = CENTER; } diff --git a/lily/parser.yy b/lily/parser.yy index 10242bfdfe..e302696120 100644 --- a/lily/parser.yy +++ b/lily/parser.yy @@ -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_dir_ = START; + dynamic_cast ($$)->set_span_dir ( START); } close_request_parens: @@ -1221,7 +1231,7 @@ close_request_parens: open_request: open_request_parens { $$ = $1; - dynamic_cast ($$)->span_dir_ = STOP; + dynamic_cast ($$)->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)); diff --git a/lily/piano-pedal-performer.cc b/lily/piano-pedal-performer.cc index 6b1efab435..9bd045aed8 100644 --- a/lily/piano-pedal-performer.cc +++ b/lily/piano-pedal-performer.cc @@ -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; } } diff --git a/lily/request.cc b/lily/request.cc index 90831a5cab..d10693e898 100644 --- a/lily/request.cc +++ b/lily/request.cc @@ -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)); +} + + + diff --git a/lily/slur-engraver.cc b/lily/slur-engraver.cc index ef3d6f062b..d59cbbe233 100644 --- a/lily/slur-engraver.cc +++ b/lily/slur-engraver.cc @@ -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) diff --git a/lily/span-dynamic-performer.cc b/lily/span-dynamic-performer.cc index 38bc89117d..ccf0d08234 100644 --- a/lily/span-dynamic-performer.cc +++ b/lily/span-dynamic-performer.cc @@ -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; } } diff --git a/lily/text-spanner-engraver.cc b/lily/text-spanner-engraver.cc index 911aadeb0b..fe89e752bc 100644 --- a/lily/text-spanner-engraver.cc +++ b/lily/text-spanner-engraver.cc @@ -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; } }