--- /dev/null
+
+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
+ }
+}
else if (c->span_type_str_ == "beam")
{
- Direction d =c->span_dir_;
+ Direction d =c->get_span_dir ();
if (d == STOP && !beam_p_)
{
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;
}
}
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"));
}
*/
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);
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;
{
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;
}
}
}
-
-
bool
Melodic_req::do_equal_b (Request const* r) const
{
return Musical_pitch::compare (m1.pitch_, m2.pitch_);
}
-
-
-
-
int
Rhythmic_req::compare (Rhythmic_req const &r1, Rhythmic_req const &r2)
{
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;
}
/* tokens which are not keywords */
%token AUTOCHANGE
+%token APPLY
%token ARPEGGIO
%token DYNAMICSCRIPT
%token TEXTSCRIPT
$$ = 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
}
| '[' {
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;
}
}
| 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;
}
| 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;
close_request:
close_request_parens {
$$ = $1;
- dynamic_cast<Span_req*> ($$)->span_dir_ = START;
+ dynamic_cast<Span_req*> ($$)->set_span_dir ( START);
}
close_request_parens:
open_request:
open_request_parens {
$$ = $1;
- dynamic_cast<Span_req*> ($$)->span_dir_ = STOP;
+ dynamic_cast<Span_req*> ($$)->set_span_dir ( STOP);
}
;
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));
{
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;
}
}
}
+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));
+}
+
+
+
/*
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_)
{
{
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"));
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)
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;
}
}
}
else if (s->span_type_str_ == "text")
{
- req_drul_[s->span_dir_] = s;
+ req_drul_[s->get_span_dir()] = s;
return true;
}
}