source file of the GNU LilyPond music typesetter
- (c) 1998--1999 Jan Nieuwenhuizen <janneke@gnu.org>
+ (c) 1998--2000 Jan Nieuwenhuizen <janneke@gnu.org>
*/
-#include "repeat-engraver.hh"
+#include "engraver.hh"
+#include "cons.hh"
#include "bar.hh"
#include "bar-engraver.hh"
#include "musical-request.hh"
#include "multi-measure-rest.hh"
#include "command-request.hh"
-#include "time-description.hh"
+#include "timing-translator.hh"
#include "engraver-group-engraver.hh"
#include "repeated-music.hh"
-#include "time-description.hh"
+#include "timing-translator.hh"
#include "volta-spanner.hh"
#include "note-column.hh"
#include "paper-def.hh"
#include "music-list.hh"
+#include "side-position-interface.hh"
+#include "spanner.hh"
+#include "note-column.hh"
+
+struct Bar_create_event
+{
+ Moment when_;
+ bool bar_b_;
+ bool last_b_;
+ String type_;
+ Bar_create_event();
+ Bar_create_event (Moment w, String s);
+ Bar_create_event (Moment w, int i, int j);
+};
+
+int compare (Bar_create_event const & c1, Bar_create_event const &c2)
+{
+ return (c1.when_ - c2.when_).sign();
+}
+
+/**
+ Generate repeat-bars |: :| for repeated-music
+ */
+class Repeat_engraver : public Engraver
+{
+public:
+ VIRTUAL_COPY_CONS(Translator);
+ Repeat_engraver ();
+protected:
+ virtual void acknowledge_element (Score_element_info i);
+ virtual void do_removal_processing ();
+ virtual bool do_try_music (Music *req_l);
+ virtual void do_process_music();
+ virtual void do_pre_move_processing();
+ virtual void do_post_move_processing ();
+ void queue_events ();
+
+private:
+ Repeated_music *repeated_music_l_;
+ bool done_this_one_b_;
+
+ /*
+ Royal_brackla_create_queue is only two Whiskies away. :-)
+ */
+ Cons<Bar_create_event> *create_barmoments_queue_;
+
+ Spanner * volta_span_p_;
+ Spanner* end_volta_span_p_;
+};
+
+
+
ADD_THIS_TRANSLATOR (Repeat_engraver);
We acknowledge other types of unfolded music as well, to
get auto context selection right.
*/
- return true;
+ if (r->type_ == "volta" || r->type_ == "unfolded")
+ return true;
}
return false;
/**
Walk through repeat music, and generate events for appropriate times.
+
+ UGH. Should use Music_iteration for this.
+
+ Should also queue some event to get timing information reset during
+ 2nd and following voltas.
*/
void
Repeat_engraver::queue_events ()
{
- Music_sequence* alt = repeated_music_l_->alternatives_p_;
- Moment walk_mom = now_mom () + repeated_music_l_->repeat_body_p_->length_mom ();
+ Music_sequence* alt = repeated_music_l_->alternatives ();
+ Moment walk_mom = now_mom () + repeated_music_l_->body ()->length_mom ();
- bool create_volta = ! get_property ("noVoltaBraces",0).to_bool ();
+ SCM novolta = get_property ("noVoltaBraces");
+ bool create_volta = !to_boolean (novolta);
Cons_list<Bar_create_event> becel;
becel.append (new Bar_create_event (now_mom (), "|:"));
appropriate timestamps. The volta spanner event (a number string)
happens at the begin of the alt. The :| bar event at the ending.
*/
- for (Cons<Music> *i = alt->music_p_list_p_->head_; i; i = i->next_)
+
+ for (SCM s = repeated_music_l_->alternatives ()->music_list ();
+ gh_pair_p (s); s = gh_cdr (s))
{
+ Music *mus =unsmob_music (gh_car (s));
/*
some idiot might typeset a repeat not starting on a
Bar_create_event * c = new Bar_create_event (walk_mom, last_number+ 1,
volta_number);
- if (!i->next_)
+ if (!gh_pair_p (gh_cdr (s)))
c->last_b_ = true;
becel.append (c);
last_number = volta_number;
volta_number ++;
- Scalar l (get_property ("voltaSpannerDuration", 0));
- if (l.length_i ()) // voltaSpannerDuration OK?
- {
-
- Moment vSD_mom = l.to_rat();
- if ( vSD_mom < i->car_->length_mom() ) // terminate volta early ?
- {
- vSD_mom += walk_mom;
- c->last_b_ = true;
- becel.append (new Bar_create_event (vSD_mom, "stop"));
- }
- }
+ SCM l (get_property ("voltaSpannerDuration"));
+ if (unsmob_moment(l))
+ {
+ Moment vSD_mom = *unsmob_moment (l);
+ if ( vSD_mom < mus->length_mom() ) // terminate volta early ?
+ {
+ vSD_mom += walk_mom;
+ c->last_b_ = true;
+ becel.append (new Bar_create_event (vSD_mom, "stop"));
+ }
+ }
}
- walk_mom += i->car_->length_mom();
+ walk_mom += mus->length_mom();
- if (i->next_)
+ if (gh_pair_p (gh_cdr (s)))
becel.append (new Bar_create_event (walk_mom, ":|"));
else
becel.append (new Bar_create_event (walk_mom, "stop"));
}
}
- Cons<Bar_create_event> *&tail = create_barmoments_queue_
- ? last_cons (create_barmoments_queue_)->next_
- : create_barmoments_queue_;
+ /*
+ ugh, should merge :| and |: here.
+ */
+ Cons<Bar_create_event> * last = last_cons (create_barmoments_queue_);
+ Cons<Bar_create_event> **tail = last? & last->next_
+ : & create_barmoments_queue_;
- tail = becel.head_ ;
+ *tail = becel.head_ ;
+
becel.head_ = 0;
}
void
-Repeat_engraver::do_process_requests ()
+Repeat_engraver::do_process_music ()
{
if (repeated_music_l_ && !done_this_one_b_)
{
}
- Cons<Bar_create_event> * head = create_barmoments_queue_;
+ Cons<Bar_create_event> * head = create_barmoments_queue_;
if (!head)
return;
- Bar_engraver* bar_engraver_l = dynamic_cast <Bar_engraver*>
- (daddy_grav_l ()->get_simple_translator ("Bar_engraver"));
-
/*
Do all the events that need to be done now.
*/
{
create_barmoments_queue_ = create_barmoments_queue_->next_;
head->next_ =0;
- if (bar_engraver_l)
+ String t = head->car_->type_;
+ if (head->car_->bar_b_)
{
- String t = head->car_->type_;
- if (head->car_->bar_b_)
+ if (t == "stop" || t == ":|")
{
- if (t == "stop" || t == ":|")
- {
- end_volta_span_p_ = volta_span_p_;
- volta_span_p_ =0;
- }
-
- if (t != "stop")
- bar_engraver_l->request_bar (t);
- else
- bar_engraver_l->request_bar ("");
+ end_volta_span_p_ = volta_span_p_;
+ volta_span_p_ =0;
}
- else
+
+ SCM whsym = ly_symbol2scm ("whichBar");
+ Translator_group* where = daddy_trans_l_->where_defined (whsym);
+ SCM which = where->get_property (whsym);
+
+ /*
+ Should use symbols for bar glyphs.
+ */
+ if (t == "stop" && which == SCM_UNDEFINED)
+ which = ly_str02scm ("");
+ else if (t != "stop")
{
- assert (!volta_span_p_);
- volta_span_p_ = new Volta_spanner;
- announce_element (Score_element_info (volta_span_p_,0));
- volta_span_p_->number_str_ = t;
- volta_span_p_->last_b_ = head->car_->last_b_;
- // voltaSpannerDuration stuff here.
- // other property stuff here.
+ SCM l = ly_str02scm (":|");
+ SCM r = ly_str02scm ("|:");
+
+ if ( (t == "|:" && scm_equal_p (which, l) == SCM_BOOL_T)
+ || (t == ":|" && scm_equal_p (which, r)== SCM_BOOL_T))
+ t = ":|:";
+
+ if (t != "" || !gh_string_p (which))
+ which = ly_str02scm (t.ch_C());
}
-
+ where->set_property (whsym, which);
}
else
{
- warning (_ ("No bar engraver found. Ignoring repeats."));
+ assert (!volta_span_p_);
+ volta_span_p_ = new Spanner (get_property ("basicVoltaSpannerProperties"));
+ Volta_spanner::set_interface (volta_span_p_);
+ announce_element (volta_span_p_,0);
+ volta_span_p_->set_elt_property ("text",
+ ly_str02scm (t.ch_C()));
+ volta_span_p_->set_elt_property ("last-volta",
+ gh_bool2scm (head->car_->last_b_));
+ // voltaSpannerDuration stuff here.
+ // other property stuff here.
}
+
delete head->car_;
delete head;
void
Repeat_engraver::acknowledge_element (Score_element_info i)
{
- if (Note_column *c = dynamic_cast<Note_column *> (i.elem_l_))
+ if (Item* item = dynamic_cast<Item*> (i.elem_l_))
{
- if (volta_span_p_)
- volta_span_p_->add_column (c);
- if (end_volta_span_p_)
- end_volta_span_p_->add_column (c);
- }
- if (Bar *c = dynamic_cast<Bar*> (i.elem_l_))
- {
- if (volta_span_p_)
- volta_span_p_->add_bar (c);
- if (end_volta_span_p_)
- end_volta_span_p_ ->add_bar(c);
+ if (Note_column::has_interface (item))
+ {
+ if (volta_span_p_)
+ Volta_spanner::add_column (volta_span_p_,item);
+ if (end_volta_span_p_)
+ Volta_spanner::add_column (end_volta_span_p_,item);
+ }
+ if (Bar::has_interface (item))
+ {
+ if (volta_span_p_)
+ Volta_spanner::add_bar (volta_span_p_, item);
+ if (end_volta_span_p_)
+ Volta_spanner::add_bar(end_volta_span_p_ , item);
+ }
}
}
-
void
Repeat_engraver::do_removal_processing ()
{
{
if (end_volta_span_p_)
{
+ Side_position::add_staff_support (end_volta_span_p_);
+
typeset_element (end_volta_span_p_ );
end_volta_span_p_ =0;
}