void set_spot (Input const &);
Input spot () const;
String location_str () const;
+ String line_number_str () const;
Input (Source_file*, char const*);
Input ();
};
return "(" + _ ("position unknown") + ")";
}
+String
+Input::line_number_str () const
+{
+ if (source_file_l_)
+ return to_str (source_file_l_->line_i (defined_ch_C_));
+ else
+ return "?";
+}
{
}
-Mark_req::Mark_req (String s)
-{
- str_ = s;
-}
void
Mark_req::do_print () const
{
DEBUG_OUT << str_;
}
+
+bool
+Mark_req::do_equal_b (Request const * r) const
+{
+ Mark_req const * other = dynamic_cast<Mark_req const*> (r);
+ return other && other->str_ == str_;
+}
+
void
Key_change_req::transpose (Musical_pitch p)
{
virtual void do_process_requests();
virtual void do_pre_move_processing();
virtual void do_post_move_processing();
+ virtual void typeset_element (Score_element*);
};
text_p_->set_elt_property ("style", gh_str02scm ("dynamic"));
text_p_->set_elt_property ("script-priority",
gh_int2scm (100));
- text_p_->set_elt_property ("staff-support", SCM_BOOL_T);
Side_position_interface (text_p_).set_axis (Y_AXIS);
->set_elt_property ("grow-direction",
gh_int2scm ((span_l->span_type_str_ == "crescendo") ? BIGGER : SMALLER));
- new_cresc_p->set_elt_property ("staff-support", SCM_BOOL_T);
-
-
- Side_position_interface (new_cresc_p).set_axis (Y_AXIS);
+ side_position (new_cresc_p).set_axis (Y_AXIS);
announce_element (Score_element_info (new_cresc_p, span_l));
}
}
{
::warning (_ ("Too many crescendi here"));
-
typeset_element (cresc_p_);
cresc_p_ = 0;
}
}
+void
+Dynamic_engraver::typeset_element (Score_element * e)
+{
+ side_position(e).add_staff_support ();
+ Engraver::typeset_element (e);
+}
void
Dynamic_engraver::acknowledge_element (Score_element_info i)
class Mark_req : public Request {
public:
- Mark_req (String);
String str_;
protected:
+ virtual bool do_equal_b (Request const*) const;
virtual void do_print () const;
VIRTUAL_COPY_CONS(Music);
};
VIRTUAL_COPY_CONS(Music);
};
-/**
- Part: typeset a measure with the number of measures rest
- Score: typeset all individual measures as full rests
- */
-class Multi_measure_rest_req : public Rhythmic_req {
-public:
- VIRTUAL_COPY_CONS(Music);
-};
-
-/**
- Typeset a repetition sign in each bar.
- */
-class Repetitions_req : public Rhythmic_req {
-public:
- VIRTUAL_COPY_CONS(Music);
-};
/// an extender line
class Extender_req : public Request {
bool supported_b () const;
bool has_interface_b () const;
void add_support (Score_element*);
-
+
+ void add_staff_support ();
Direction get_direction () const;
void set_direction (Direction);
};
+Side_position_interface side_position (Score_element*);
#endif /* SIDE_POSITION_INTERFACE_HH */
--- /dev/null
+/*
+ line-number-engraver.cc -- implement Line_number_engraver
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+#include "engraver.hh"
+#include "text-item.hh"
+#include "side-position-interface.hh"
+#include "note-head.hh"
+#include "stem.hh"
+
+/**
+ Annotate output with line numbers. Creates text-items when it
+ catches note heads. */
+class Line_number_engraver : public Engraver
+{
+ Array<Score_element_info> interesting_;
+ Link_array<Score_element> support_;
+ Item * text_item_p_;
+ String last_text_;
+public:
+ Line_number_engraver ();
+ VIRTUAL_COPY_CONS (Translator);
+protected:
+ virtual void do_pre_move_processing ();
+ virtual void acknowledge_element (Score_element_info);
+ virtual void process_acknowledged ();
+};
+
+void
+Line_number_engraver::process_acknowledged ()
+{
+ if (!text_item_p_ && interesting_.size ())
+ {
+ text_item_p_ = new Text_item;
+ Side_position_interface si (text_item_p_);
+ si.set_axis (Y_AXIS);
+ text_item_p_->set_parent (interesting_[0].elem_l_, Y_AXIS);
+
+ si.set_direction (UP);
+ announce_element (Score_element_info (text_item_p_, 0));
+ }
+}
+
+void
+Line_number_engraver::acknowledge_element (Score_element_info inf)
+{
+ if (dynamic_cast<Note_head*> (inf.elem_l_))
+ {
+ interesting_.push (inf);
+ support_.push (inf.elem_l_);
+ }
+ if (dynamic_cast<Stem*> (inf.elem_l_))
+ {
+ support_.push (inf.elem_l_);
+ }
+}
+
+void
+Line_number_engraver::do_pre_move_processing ()
+{
+ if (text_item_p_)
+ {
+ String s;
+ Side_position_interface si (text_item_p_);
+ for (int i=0; i < interesting_.size (); i++)
+ {
+ if (i)
+ s += ",";
+
+ s += interesting_[i].req_l_->line_number_str ();
+
+ }
+
+ for (int j= support_.size (); j--; )
+ {
+ si.add_support (support_[j]);
+ }
+ if (s != last_text_)
+ {
+ text_item_p_->set_elt_property ("text", ly_str02scm (s.ch_C()));
+ last_text_ =s;
+ }
+
+ typeset_element (text_item_p_);
+ text_item_p_ =0;
+ }
+ interesting_.clear ();
+ support_.clear ();
+}
+
+Line_number_engraver::Line_number_engraver ()
+{
+ text_item_p_ =0;
+}
+
+ADD_THIS_TRANSLATOR(Line_number_engraver);
{
if (Mark_req *mr = dynamic_cast <Mark_req *> (r_l))
{
+
+ if (mark_req_l_ && mr->equal_b (mark_req_l_))
+ return true;
+ if (mark_req_l_)
+ return false;
mark_req_l_ = mr;
return true;
}
{
public:
VIRTUAL_COPY_CONS(Translator);
-
Multi_measure_rest_engraver ();
protected:
virtual bool do_try_music (Music*);
virtual void do_pre_move_processing ();
virtual void do_post_move_processing ();
-
+ virtual void do_removal_processing ();
private:
- Drul_array<Moment> rest_moments_;
-
+ Span_req * new_req_l_;
+ Span_req * busy_span_req_l_;
+ Span_req * stop_req_l_;
int start_measure_i_;
- Rhythmic_req* multi_measure_req_l_;
- Multi_measure_rest* mmrest_p_;
- Multi_measure_rest* lastrest_p_;
+ Moment start_moment_;
+
+ Multi_measure_rest *mmrest_p_;
+ Multi_measure_rest *lastrest_p_;
};
ADD_THIS_TRANSLATOR (Multi_measure_rest_engraver);
Multi_measure_rest_engraver::Multi_measure_rest_engraver ()
{
start_measure_i_ = 0;
- rest_moments_[START] =
- rest_moments_[STOP] =0;
- multi_measure_req_l_ = 0;
-
- lastrest_p_ =0;
- mmrest_p_ = 0;
+ mmrest_p_ = lastrest_p_ =0;
+ new_req_l_ = busy_span_req_l_ = stop_req_l_ =0;
}
void
{
if (Bar *c = dynamic_cast<Bar*> (i.elem_l_))
{
- if (mmrest_p_)
+ if (mmrest_p_)
mmrest_p_->add_column (c);
if (lastrest_p_)
lastrest_p_->add_column (c);
bool
Multi_measure_rest_engraver::do_try_music (Music* req_l)
{
- Rhythmic_req *r=0;
- if (Multi_measure_rest_req *mr =
- dynamic_cast<Multi_measure_rest_req *> (req_l))
- r=mr;
- else if (Repetitions_req *rr =
- dynamic_cast<Repetitions_req *> (req_l))
- r=rr;
- if (r)
+ if (Span_req * sp = dynamic_cast<Span_req*> (req_l))
{
- if (multi_measure_req_l_)
- if (!multi_measure_req_l_->equal_b (r)
- || rest_moments_[START] != now_mom ())
- return false;
-
- multi_measure_req_l_ = r;
- rest_moments_[START] = now_mom ();
-
- rest_moments_[STOP] = rest_moments_[START] +
- multi_measure_req_l_->duration_.length_mom ();
- return true;
+ if (sp->span_type_str_ == "rest")
+ {
+ if (sp->span_dir_ == STOP)
+ {
+ stop_req_l_ = sp;
+ }
+ else if (sp->span_dir_ == START && !new_req_l_)
+ {
+ new_req_l_ = sp;
+ }
+ return true;
+ }
}
return false;
}
+
+
void
Multi_measure_rest_engraver::do_process_requests ()
{
- if (multi_measure_req_l_ && !mmrest_p_)
+ if (new_req_l_ && stop_req_l_)
+ stop_req_l_ = 0;
+
+ if (new_req_l_)
+ start_moment_ = now_mom ();
+
+ if (stop_req_l_)
+ {
+ busy_span_req_l_ =0;
+ stop_req_l_ = 0;
+ }
+
+ if (new_req_l_)
{
+ busy_span_req_l_ = new_req_l_;
+ new_req_l_ =0;
+ }
+ if (busy_span_req_l_ && !mmrest_p_)
+ {
Translator * tr = daddy_grav_l()->get_simple_translator ("Timing_engraver"); // ugh
Timing_translator * time = dynamic_cast<Timing_translator*> (tr);
Staff_symbol_referencer_interface si (mmrest_p_);
si.set_interface ();
-
- /*
- UGH. JUNKME
- */
- if(dynamic_cast<Repetitions_req *> (multi_measure_req_l_))
- mmrest_p_->set_elt_property ("alt-symbol",
- ly_str02scm ("scripts-repeatsign"));
- announce_element (Score_element_info (mmrest_p_, multi_measure_req_l_));
+ announce_element (Score_element_info (mmrest_p_, busy_span_req_l_));
start_measure_i_
= gh_scm2int (time->get_property ("currentBarNumber", 0));
}
Translator * tr = daddy_grav_l()->get_simple_translator ("Timing_engraver"); // ugh
Timing_translator * time = dynamic_cast<Timing_translator*> (tr);
-
- if (mmrest_p_ && (now >= rest_moments_[START])
+ if (mmrest_p_ && (now >= start_moment_)
&& !time->measure_position ()
&& (scm_ilength (mmrest_p_->get_elt_property ("columns")) >= 2))
{
typeset_element (lastrest_p_);
lastrest_p_ = 0;
}
+
+ if (new_req_l_)
+ {
+ busy_span_req_l_ = new_req_l_;
+ new_req_l_ =0;
+ }
+
}
void
= gh_scm2int (time->get_property ("currentBarNumber", 0)) - start_measure_i_;
mmrest_p_ = 0;
}
-
- if (now >= rest_moments_[STOP])
- {
- multi_measure_req_l_ = 0;
- mmrest_p_ = 0;
- }
}
+void
+Multi_measure_rest_engraver::do_removal_processing ()
+{
+ if (mmrest_p_)
+ typeset_element (mmrest_p_);
+ if (lastrest_p_)
+ typeset_element (lastrest_p_);
+}
static Keyword_ent the_key_tab[]={
{"autochange", AUTOCHANGE},
{"spanrequest", SPANREQUEST},
+ {"commandspanrequest", COMMANDSPANREQUEST},
{"simultaneous", SIMULTANEOUS},
{"sequential", SEQUENTIAL},
{"accepts", ACCEPTS},
%token SCRIPT
%token SKIP
%token SPANREQUEST
+%token COMMANDSPANREQUEST
%token TEMPO
%token TIME_T
%token TIMES
request_chord:
pre_requests simple_element post_requests {
Music_sequence *l = dynamic_cast<Music_sequence*>($2);
- for (int i=0; i < $1->size(); i++)
- l->add_music ($1->elem(i));
- for (int i=0; i < $3->size(); i++)
- l->add_music ($3->elem(i));
+ if (l) {
+ for (int i=0; i < $1->size(); i++)
+ l->add_music ($1->elem(i));
+ for (int i=0; i < $3->size(); i++)
+ l->add_music ($3->elem(i));
+ }
+ else
+ programming_error ("Need Sequence to add music to");
$$ = $2;
}
verbose_command_req:
+
BAR STRING {
$$ = new Bar_req (ly_scm2string ($2));
}
+ | COMMANDSPANREQUEST int STRING {
+ Span_req * sp_p = new Span_req;
+ sp_p-> span_dir_ = Direction($2);
+ sp_p->span_type_str_ = ly_scm2string ($3);
+ sp_p->set_spot (THIS->here_input ());
+ $$ = sp_p;
+ }
| MARK STRING {
- $$ = new Mark_req (ly_scm2string ($2));
+ Mark_req *m = new Mark_req;
+ m->str_ = ly_scm2string ($2);
+ $$ = m;
}
| MARK unsigned {
- $$ = new Mark_req (to_str ($2));
+ Mark_req *m = new Mark_req;
+ m->str_ = to_str ($2);
+ $$ = m;
}
| TIME_T unsigned '/' unsigned {
Time_signature_change_req *m = new Time_signature_change_req;
$$ = key_p;
delete $2;
}
-
;
post_requests:
Note_req *n = new Note_req;
n->pitch_ = *$1;
- delete $1;
n->duration_ = *$4;
- delete $4;
if (THIS->abbrev_beam_type_i_)
{
if (n->duration_.plet_b ())
n->forceacc_b_ = $2 % 2 || n->cautionary_b_;
Simultaneous_music*v = new Request_chord;
- v->set_spot (THIS->here_input ());
- n->set_spot (THIS->here_input ());
+ v->set_spot ($1->spot ());
+ n->set_spot ($1->spot ());
v->add_music (n);
$$ = v;
- }
- | RESTNAME optional_notemode_duration {
- Simultaneous_music* velt_p = new Request_chord;
- velt_p->set_spot (THIS->here_input());
- if (ly_scm2string ($1) =="s")
- { /* Space */
- Skip_req * skip_p = new Skip_req;
- skip_p->duration_ = *$2;
+ delete $1;
+ delete $4;
- skip_p->set_spot (THIS->here_input());
- velt_p->add_music (skip_p);
- }
- else
- {
- Rest_req * rest_req_p = new Rest_req;
- rest_req_p->duration_ = *$2;
- rest_req_p->set_spot (THIS->here_input());
+ }
+ | RESTNAME optional_notemode_duration {
+ Simultaneous_music* velt_p = new Request_chord;
+ velt_p->set_spot (THIS->here_input());
- velt_p->add_music (rest_req_p);
- }
+ if (ly_scm2string ($1) =="s")
+ { /* Space */
+ Skip_req * skip_p = new Skip_req;
+ skip_p->duration_ = *$2;
- delete $2;
- $$ = velt_p;
+ skip_p->set_spot (THIS->here_input());
+ velt_p->add_music (skip_p);
+ }
+ else
+ {
+ Rest_req * rest_req_p = new Rest_req;
+ rest_req_p->duration_ = *$2;
+ rest_req_p->set_spot (THIS->here_input());
+ velt_p->add_music (rest_req_p);
+ }
+ delete $2;
+ $$ = velt_p;
}
| MEASURES optional_notemode_duration {
- Multi_measure_rest_req* m = new Multi_measure_rest_req;
- m->duration_ = *$2;
- delete $2;
-
- Simultaneous_music*velt_p = new Request_chord;
- velt_p->set_spot (THIS->here_input ());
- velt_p->add_music (m);
- $$ = velt_p;
- }
- | REPETITIONS optional_notemode_duration {
- Repetitions_req* r = new Repetitions_req;
- r->duration_ = *$2;
- delete $2;
+ Skip_req * sk = new Skip_req;
+ sk->duration_ = *$2;
+ Music_list * ms = new Music_list;
+ Request_chord * rqc1 = new Request_chord;
+ Request_chord * rqc2 = new Request_chord;
+ Request_chord * rqc3 = new Request_chord;
+
+ Span_req *sp1 = new Span_req;
+ Span_req *sp2 = new Span_req;
+ sp1-> span_dir_ = START;
+ sp2-> span_dir_ = STOP;
+ sp1->span_type_str_ = sp2->span_type_str_ = "rest";
+ rqc1->add_music (sp1);
+ rqc2->add_music (sk);
+ rqc3->add_music (sp2);
+
+ ms->add_music (rqc1);
+ ms->add_music (rqc2);
+ ms->add_music (rqc3);
- Simultaneous_music*velt_p = new Request_chord;
- velt_p->set_spot (THIS->here_input ());
- velt_p->add_music (r);
- $$ = velt_p;
+ $$ = new Sequential_music (ms);
}
| STRING optional_notemode_duration {
if (!THIS->lexer_p_->lyric_state_b ())
(c) 1997--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "script-engraver.hh"
+
#include "script.hh"
#include "side-position-interface.hh"
#include "musical-request.hh"
#include "rhythmic-head.hh"
#include "dimension-cache.hh"
+#include "engraver.hh"
+
+class Script_engraver : public Engraver {
+ Link_array<Script> script_p_arr_;
+ Link_array<Articulation_req> script_req_l_arr_;
+
+public:
+ VIRTUAL_COPY_CONS(Translator);
+
+ Script_engraver();
+protected:
+ virtual bool do_try_music (Music*);
+ virtual void do_process_requests ();
+ virtual void do_pre_move_processing ();
+ virtual void do_post_move_processing ();
+ virtual void acknowledge_element (Score_element_info);
+};
+
+
Script_engraver::Script_engraver()
{
do_post_move_processing();
{
for (int i=0; i < script_p_arr_.size(); i++)
{
+ if (to_boolean (script_p_arr_[i]->remove_elt_property ("staff-support")))
+ side_position (script_p_arr_[i]).add_staff_support ();
typeset_element (script_p_arr_[i]);
}
script_p_arr_.clear();
return o;
}
-
-
+void
+Side_position_interface::add_staff_support ()
+{
+ Staff_symbol_referencer_interface si (elt_l_);
+ if (si.staff_symbol_l ())
+ {
+ add_support (si.staff_symbol_l ());
+ }
+}
void
Side_position_interface::set_axis (Axis a)
SCM s =elt_l_->get_elt_property ("side-support");
return s != SCM_UNDEFINED && s != SCM_EOL;
}
+
+
+Side_position_interface
+side_position (Score_element* e)
+{
+ Side_position_interface si (e);
+ return si;
+}
{
s.elem_l_->set_elt_property ("staff-symbol", span_p_->self_scm_);
s.elem_l_->add_dependency (span_p_); // UGH. UGH. UGH
-
- SCM ss =s.elem_l_->remove_elt_property ("staff-support");
- if (to_boolean (ss))
- {
- Side_position_interface si (s.elem_l_);
- if (si.has_interface_b ())
- si.add_support (span_p_);
- }
}
(c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
-#include "dimension-cache.hh"
+#include "dimension-cache.hh"
#include "engraver.hh"
#include "side-position-interface.hh"
#include "text-item.hh"
{
for (int i=0; i < texts_.size (); i++)
{
+ side_position (texts_[i]).add_staff_support ();
typeset_element (texts_[i]);
}
texts_.clear ();
%time3_4beamAutoBegin_32 = #(make-moment 1 8)
time3_4beamAutoEnd_32 = #(make-moment 1 8)
-time3_8beamAutoBegin = #(make-moment 1 8)
+time3_8beamAutoBegin_16 = #(make-moment 1 8)
time3_8beamAutoEnd = #(make-moment 3 8)
% in common time: