#include "text-def.hh"
#include "command-request.hh"
#include "bar.hh"
+#include "time-description.hh"
Bar_number_grav::Bar_number_grav()
{
- number_i_ =1;
script_p_ =0;
}
Bar_number_grav::acknowledge_element (Score_elem_info i)
{
if (i.origin_grav_l_arr_.size() == 1 &&
- i.elem_l_->is_type_b (Bar::static_name()) && !script_p_)
- {
-
- script_p_ = new Script;
- Text_def *td_p =new Text_def;
- td_p->text_str_ = number_i_++;
- script_p_->specs_l_ = td_p;
- script_p_->breakable_b_ = true;
- script_p_->dir_i_ = 1;
-
- announce_element (Score_elem_info (script_p_, &dummy));
+ i.elem_l_->is_type_b (Bar::static_name()) && !script_p_)
+ {
+ Time_description const * time = get_staff_info().time_C_;
+ if (!time || time->cadenza_b_)
+ return ;
+
+ script_p_ = new Script;
+ Text_def *td_p =new Text_def;
+ td_p->text_str_ = time->bars_i_;
+
+ script_p_->specs_l_ = td_p;
+ script_p_->breakable_b_ = true;
+ script_p_->dir_ = UP;
+
+ announce_element (Score_elem_info (script_p_, &dummy));
}
}
void
Bar_number_grav::do_pre_move_processing()
{
- if ( script_p_)
+ if (script_p_)
{
- typeset_element (script_p_);
- script_p_ =0;
+ typeset_element (script_p_);
+ script_p_ =0;
}
}
IMPLEMENT_IS_TYPE_B1(Cadenza_req, Timing_req);
void
-Cadenza_req::do_print()const
+Cadenza_req::do_print() const
{
#ifndef NPRINT
DOUT << on_b_;
}
bool
-Cadenza_req::do_equal_b (Request*r)const
+Cadenza_req::do_equal_b (Request*r) const
{
Cadenza_req*cad = r->command()->timing ()->cadenza ();
bool
-Bar_req::do_equal_b (Request*r)const
+Bar_req::do_equal_b (Request*r) const
{
Bar_req * b = r->command()->bar ();
return type_str_ == b->type_str_;
}
bool
-Partial_measure_req::do_equal_b (Request* r)const
+Partial_measure_req::do_equal_b (Request* r) const
{
Partial_measure_req *p = r->command()->timing ()->partial ();
IMPLEMENT_IS_TYPE_B1(Timing_req,Command_req);
void
-Timing_req::do_print()const{}
+Timing_req::do_print() const{}
IMPLEMENT_IS_TYPE_B1(Command_req,Request);
void
-Command_req::do_print()const{}
+Command_req::do_print() const{}
IMPLEMENT_IS_TYPE_B1(Disallow_break_req,Command_req);
void
-Disallow_break_req::do_print()const
+Disallow_break_req::do_print() const
{
}
/* *************** */
Barcheck_req::do_print() const{}
bool
-Barcheck_req::do_equal_b (Request*)const
+Barcheck_req::do_equal_b (Request*) const
{
return true;
}
}
bool
-Meter_change_req::do_equal_b (Request * r)const
+Meter_change_req::do_equal_b (Request * r) const
{
Meter_change_req * m = r->command()->timing ()->meterchange ();
return m->beats_i_ == beats_i_
- && one_beat_i_ == m->one_beat_i_;
+ && one_beat_i_ == m->one_beat_i_;
}
Meter_change_req::Meter_change_req()
}
void
-Tempo_req::do_print()const
+Tempo_req::do_print() const
{
DOUT << dur_.str() << " = " <<metronome_i_ ;
}
IMPLEMENT_IS_TYPE_B1(Tempo_req, Timing_req);
bool
-Tempo_req::do_equal_b (Request *r)const
+Tempo_req::do_equal_b (Request *r) const
{
Tempo_req *t = r->command()->timing ()->tempo ();
{
for (int i=0; i < elt_length_arr_.size(); i++)
{
- DOUT << beat_i_arr_[i] <<"*" << elt_length_arr_[i]<<" ";
+ DOUT << beat_i_arr_[i] <<"*" << elt_length_arr_[i]<<" ";
}
}
bool
-Measure_grouping_req::do_equal_b (Request*)const
+Measure_grouping_req::do_equal_b (Request*) const
{
return false; // todo
}
/* *************** */
void
-Key_change_req::transpose (Melodic_req const & d)const
+Key_change_req::transpose (Melodic_req const & d) const
{
WARN << "don't know how to transpose a key. \n";
for (int i=0; i < melodic_p_arr_.size(); i++)
{
- melodic_p_arr_[i]->transpose (d);
+ melodic_p_arr_[i]->transpose (d);
}
}
{
for (int i=0; i < melodic_p_arr_.size(); i++)
{
- melodic_p_arr_[i]->octave_i_ = 0;
+ melodic_p_arr_[i]->octave_i_ = 0;
}
}
#ifndef NPRINT
for (int i=0; i < melodic_p_arr_.size(); i++)
{
- melodic_p_arr_[i]->print();
+ melodic_p_arr_[i]->print();
}
#endif
}
Key_change_req::Key_change_req()
{
- minor_b_ = false;
- multi_octave_b_= false;
+ minor_b_ = false;
+ multi_octave_b_= false;
}
Key_change_req::Key_change_req (Key_change_req const&c)
{
- for (int i=0; i < c.melodic_p_arr_.size(); i++)
- melodic_p_arr_.push (c.melodic_p_arr_[i]->clone()->musical ()->melodic ());
- minor_b_ = c.minor_b_;
- multi_octave_b_ = c.multi_octave_b_;
+ for (int i=0; i < c.melodic_p_arr_.size(); i++)
+ melodic_p_arr_.push (c.melodic_p_arr_[i]->clone()->musical ()->melodic ());
+ minor_b_ = c.minor_b_;
+ multi_octave_b_ = c.multi_octave_b_;
}
Key_change_req::~Key_change_req()
{
- for (int i=0; i < melodic_p_arr_.size(); i++)
- delete melodic_p_arr_[i];
+ for (int i=0; i < melodic_p_arr_.size(); i++)
+ delete melodic_p_arr_[i];
}
int
Key_change_req::flats_i()
{
- int flats_i = 0;
- for ( int i = 0; i < melodic_p_arr_.size(); i++)
- {
- Melodic_req* mel_l = melodic_p_arr_[i]->melodic();
- assert (mel_l);
- if ( mel_l->accidental_i_ < 0)
- flats_i -= mel_l->accidental_i_;
- }
- return flats_i;
+ int flats_i = 0;
+ for (int i = 0; i < melodic_p_arr_.size(); i++)
+ {
+ Melodic_req* mel_l = melodic_p_arr_[i]->melodic();
+ assert (mel_l);
+ if (mel_l->accidental_i_ < 0)
+ flats_i -= mel_l->accidental_i_;
+ }
+ return flats_i;
}
int
Key_change_req::minor_b()
{
- return minor_b_;
+ return minor_b_;
}
int
Key_change_req::sharps_i()
{
- int sharps_i = 0;
- for ( int i = 0; i < melodic_p_arr_.size(); i++)
- {
- Melodic_req* mel_l = melodic_p_arr_[i]->melodic();
- assert (mel_l);
- if ( mel_l->accidental_i_ > 0)
- sharps_i+= mel_l->accidental_i_;
- }
- return sharps_i;
+ int sharps_i = 0;
+ for (int i = 0; i < melodic_p_arr_.size(); i++)
+ {
+ Melodic_req* mel_l = melodic_p_arr_[i]->melodic();
+ assert (mel_l);
+ if (mel_l->accidental_i_ > 0)
+ sharps_i+= mel_l->accidental_i_;
+ }
+ return sharps_i;
}
Dynamic_engraver::Dynamic_engraver()
{
- dir_i_ =0;
+ dir_ = CENTER;
do_post_move_processing();
dynamic_p_ =0;
to_end_cresc_p_ = cresc_p_ = 0;
{
Musical_req * m = r->musical();
if (!m || !m->dynamic())
- return false;
+ return false;
dynamic_req_l_arr_.push (m->dynamic());
return true;
}
Crescendo* new_cresc_p=0;
for (int i=0; i < dynamic_req_l_arr_.size(); i++)
{
- Dynamic_req *dreq_l = dynamic_req_l_arr_[i];
- if (dreq_l->absdynamic())
- {
- Text_def * td_p = new Text_def;
- td_p->align_i_ = 0;
- String loud =Dynamic_req::loudness_str (
- dreq_l->absdynamic()->loudness_);
+ Dynamic_req *dreq_l = dynamic_req_l_arr_[i];
+ if (dreq_l->absdynamic())
+ {
+ Text_def * td_p = new Text_def;
+ td_p->align_i_ = 0;
+ String loud =Dynamic_req::loudness_str (
+ dreq_l->absdynamic()->loudness_);
- td_p->text_str_ = paper()->lookup_l ()->dynamic (loud).tex;
- td_p->style_str_ = "dynamic";
+ td_p->text_str_ = paper()->lookup_l ()->dynamic (loud).tex;
+ td_p->style_str_ = "dynamic";
- assert (!dynamic_p_) ; // TODO
+ assert (!dynamic_p_) ; // TODO
- dynamic_p_ = new Text_item (td_p);
- announce_element (Score_elem_info (dynamic_p_, dreq_l));
- }
- else if (dreq_l->span_dynamic())
- {
+ dynamic_p_ = new Text_item (td_p);
+ announce_element (Score_elem_info (dynamic_p_, dreq_l));
+ }
+ else if (dreq_l->span_dynamic())
+ {
- Span_dynamic_req* span_l = dreq_l->span_dynamic();
- if (span_l->spantype == Span_req::STOP)
- {
- if (!cresc_p_)
- {
- span_l->warning ("Can't find cresc to end ");
- }
- else
- {
- assert (!to_end_cresc_p_);
- to_end_cresc_p_ =cresc_p_;
- cresc_p_ = 0;
- }
- }
- else if (span_l->spantype == Span_req::START)
- {
- cresc_req_l_ = span_l;
- assert (!new_cresc_p);
- new_cresc_p = new Crescendo;
- new_cresc_p->grow_dir_i_ = span_l->dynamic_dir_i_;
- announce_element (Score_elem_info (new_cresc_p, span_l));
- }
- }
+ Span_dynamic_req* span_l = dreq_l->span_dynamic();
+ if (span_l->spantype == Span_req::STOP)
+ {
+ if (!cresc_p_)
+ {
+ span_l->warning ("Can't find cresc to end ");
+ }
+ else
+ {
+ assert (!to_end_cresc_p_);
+ to_end_cresc_p_ =cresc_p_;
+ cresc_p_ = 0;
+ }
+ }
+ else if (span_l->spantype == Span_req::START)
+ {
+ cresc_req_l_ = span_l;
+ assert (!new_cresc_p);
+ new_cresc_p = new Crescendo;
+ new_cresc_p->grow_dir_ = span_l->dynamic_dir_;
+ announce_element (Score_elem_info (new_cresc_p, span_l));
+ }
+ }
}
- if ( new_cresc_p)
+ if (new_cresc_p)
{
- cresc_p_ = new_cresc_p;
- cresc_p_->left_col_l_ = get_staff_info().musical_l ();
- if (dynamic_p_)
- {
- cresc_p_->left_dyn_b_ = true;
- }
+ cresc_p_ = new_cresc_p;
+ cresc_p_->set_bounds(LEFT,get_staff_info().musical_l ());
+ if (dynamic_p_)
+ {
+ cresc_p_->dyn_b_drul_[LEFT] = true;
+ }
}
}
Staff_symbol* s_l = get_staff_info().staff_sym_l_;
if (dynamic_p_)
{
- dynamic_p_->set_staffsym (s_l);
- typeset_element (dynamic_p_);
- dynamic_p_ = 0;
+ dynamic_p_->set_staffsym (s_l);
+ typeset_element (dynamic_p_);
+ dynamic_p_ = 0;
}
- if ( to_end_cresc_p_)
+ if (to_end_cresc_p_)
{
- if (dynamic_p_)
- to_end_cresc_p_->right_dyn_b_=true;
+ if (dynamic_p_)
+ to_end_cresc_p_->dyn_b_drul_[RIGHT]=true;
- to_end_cresc_p_->right_col_l_ = get_staff_info().musical_l ();
- to_end_cresc_p_->set_staffsym (s_l);
- typeset_element (to_end_cresc_p_);
- to_end_cresc_p_ = 0;
+ to_end_cresc_p_->set_bounds(RIGHT,get_staff_info().musical_l ());
+ to_end_cresc_p_->set_staffsym (s_l);
+ typeset_element (to_end_cresc_p_);
+ to_end_cresc_p_ = 0;
}
}
Dynamic_engraver::set_feature (Feature i)
{
if (i.type_ == "vdir")
- dir_i_ = i.value_;
+ dir_ = (Direction) int(i.value_);
}
delete to_end_cresc_p_;
if (cresc_p_)
{
- cresc_req_l_->warning ("unended crescendo");
+ cresc_req_l_->warning ("unended crescendo");
}
delete cresc_p_;
}
{
if (i.elem_l_->name() == Note_column::static_name ())
{
- if (dynamic_p_) dynamic_p_->add_support (i.elem_l_);
- if (to_end_cresc_p_)
- to_end_cresc_p_->add_support (i.elem_l_);
- if (cresc_p_)
- cresc_p_->add_support (i.elem_l_);
+ if (dynamic_p_) dynamic_p_->add_support (i.elem_l_);
+ if (to_end_cresc_p_)
+ to_end_cresc_p_->add_support (i.elem_l_);
+ if (cresc_p_)
+ cresc_p_->add_support (i.elem_l_);
}
}
#include "general-script-def.hh"
#include "debug.hh"
#include "symbol.hh"
-int
-General_script_def::staff_dir_i()const
+Direction
+General_script_def::staff_dir() const
{
- return -1;
+ return DOWN;
}
-int
-General_script_def::rel_stem_dir_i()const
+
+Direction
+General_script_def::rel_stem_dir() const
{
- return 0;
+ return CENTER;
}
int
-General_script_def::priority_i()const
+General_script_def::priority_i() const
{
return 1000;
}
bool
-General_script_def::inside_b()const
+General_script_def::inside_b() const
{
return false;
}
bool
-General_script_def::equal_b (General_script_def const&g)const
+General_script_def::equal_b (General_script_def const&g) const
{
if (name() != g.name ())
- return false;
+ return false;
return do_equal_b (&g);
}
bool
-General_script_def::do_equal_b (General_script_def const*)const
+General_script_def::do_equal_b (General_script_def const*) const
{
return true;
}
}
Atom
-General_script_def::get_atom (Paper_def*, int)const
+General_script_def::get_atom (Paper_def*, Direction) const
{
Symbol s;
return Atom (s);
Head_column::Head_column()
{
stem_l_ = 0;
- dir_i_ =0;
+ dir_ =CENTER;
}
void
Head_column::do_substitute_dependency (Score_elem*o,
- Score_elem*n)
+ Score_elem*n)
{
Script_column::do_substitute_dependency (o,n);
if (o->name() == Note_head::static_name ())
{
- head_l_arr_.substitute ((Note_head*)o->item(),
- (n)? (Note_head*)n->item() : 0);
+ head_l_arr_.substitute ((Note_head*)o->item(),
+ (n)? (Note_head*)n->item() : 0);
}
if (stem_l_ == o)
{
- stem_l_ = n ? (Stem*)n->item():0;
+ stem_l_ = n ? (Stem*)n->item():0;
}
}
{
stem_l_ = stem_l;
Score_elem::add_dependency (stem_l);
- for (int i=0; script_l_arr_.size(); i++)
- script_l_arr_[i]->set_stem (stem_l);
+ for (int i=0; i < script_l_arr_.size(); i++)
+ script_l_arr_[i]->set_stem (stem_l);
}
void
{
Script_column::add (script_l) ;
if (stem_l_)
- script_l->set_stem (stem_l_);
+ script_l->set_stem (stem_l_);
}
void
Head_column::add (Note_head *n_l)
void
Head_column::do_pre_processing()
{
- if (!dir_i_)
+ if (!dir_)
{
- if (stem_l_)
- dir_i_ = stem_l_->dir_i_;
+ if (stem_l_)
+ dir_ = stem_l_->dir_;
}
Script_column::do_pre_processing();
}
--- /dev/null
+/*
+ direction.hh -- declare
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef DIRECTION_HH
+#define DIRECTION_HH
+
+enum Direction
+{
+ UP=1,
+ DOWN=-1,
+ LEFT=-1,
+ RIGHT=1,
+ CENTER=0,
+ SMALLER=-1,
+ BIGGER=1,
+
+};
+
+
+#endif // DIRECTION_HH
--- /dev/null
+/*
+ drul-array.hh -- declare Drul_array
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef DRUL_ARRAY_HH
+#define DRUL_ARRAY_HH
+
+#include "direction.hh"
+
+/**
+ Left/right or Up/down arrays. Drul is nicer sounding than udlr
+ */
+template<class T>
+struct Drul_array
+{
+ T array_[2];
+ T &operator[] (Direction d)
+ {
+ assert (d==1 || d== -1);
+ return array_[(d+1)/2];
+ }
+ T operator[] (Direction d) const
+ {
+ assert (d==1 || d== -1);
+ return array_[(d+1)/2];
+ }
+};
+
+#endif // DRUL_ARRAY_HH
#include "lily-proto.hh"
#include "input.hh"
#include "virtual-methods.hh"
+#include "direction.hh"
+
/**
Definition of anything that is put aside staff/notes.
*/
public:
VIRTUAL_COPY_CONS(General_script_def,General_script_def);
DECLARE_MY_RUNTIME_TYPEINFO;
- virtual int staff_dir_i()const;
+ virtual Direction staff_dir() const;
void print() const;
- virtual int rel_stem_dir_i()const;
- virtual int priority_i()const;
- virtual bool inside_b()const;
- virtual Atom get_atom (Paper_def* p, int dir_i_)const;
- bool equal_b (General_script_def const&)const;
+ virtual Direction rel_stem_dir() const;
+ virtual int priority_i() const;
+ virtual bool inside_b() const;
+ virtual Atom get_atom (Paper_def* p, Direction dir_) const;
+ bool equal_b (General_script_def const&) const;
virtual ~General_script_def() {}
protected:
- virtual bool do_equal_b (General_script_def const *)const;
- virtual void do_print()const;
+ virtual bool do_equal_b (General_script_def const *) const;
+ virtual void do_print() const;
};
#endif // GENERAL_SCRIPT_DEF_HH
#include "real.hh"
#include "string.hh"
#include "moment.hh"
-
+#include "music-output-def.hh"
/**
definitions for midi output. Rather empty
*/
-struct Midi_def {
- // ugh!
- static int den_i_s;
- static int num_i_s;
-
- /// output file name
- String outfile_str_;
-
- Input_translator* itrans_p_;
-
- /// duration of whole note
- Real whole_seconds_f_;
-
- Midi_def();
- Midi_def (Midi_def const& midi_c_r);
- ~Midi_def();
-
- Real duration_to_seconds_f (Moment);
- Global_translator* get_global_translator_p() const;
- int get_tempo_i (Moment moment);
- void print() const;
- void set (Input_translator* itrans_p);
- void set_tempo (Moment moment, int count_per_minute_i);
+class Midi_def : public Music_output_def {
+public:
+ // ugh!
+ static int den_i_s;
+ static int num_i_s;
+ VIRTUAL_COPY_CONS(Midi_def, Music_output_def);
+ DECLARE_MY_RUNTIME_TYPEINFO;
+ Input_translator* itrans_p_;
+
+ /// duration of whole note
+ Real whole_seconds_f_;
+
+ Midi_def();
+ Midi_def (Midi_def const& midi_c_r);
+ ~Midi_def();
+
+ Real duration_to_seconds_f (Moment);
+ int get_tempo_i (Moment moment);
+ void print() const;
+ void set (Input_translator* itrans_p);
+ void set_tempo (Moment moment, int count_per_minute_i);
+protected:
+ virtual Global_translator * get_global_translator_p ();
};
#endif // MIDI_DEF_HH
--- /dev/null
+/*
+ music-output-def.hh -- declare Music_output_def
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef Music_output_DEF_HH
+#define Music_output_DEF_HH
+#include "string.hh"
+#include "lily-proto.hh"
+#include "virtual-methods.hh"
+
+/**
+ Definition of how to output mudela.
+ */
+class Music_output_def
+{
+public:
+ VIRTUAL_COPY_CONS(Music_output_def, Music_output_def);
+ DECLARE_MY_RUNTIME_TYPEINFO;
+ virtual void print () const {}
+ virtual ~Music_output_def () {}
+ virtual Global_translator * get_global_translator_p () { return 0; }
+ String outfile_str_;
+};
+#endif // Music_output_DEF_HH
--- /dev/null
+/*
+ music-output.hh -- declare Music_output
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef Music_output_HH
+#define Music_output_HH
+
+#include "string.hh"
+#include "lily-proto.hh"
+
+/**
+ Output something that was defined in a mudela file.
+ */
+class Music_output
+{
+public:
+ Header * header_l_;
+ String default_out_str_;
+ String origin_str_;
+ int errorlevel_i_;
+
+ virtual void process() {}
+ virtual ~Music_output (){}
+ Music_output()
+ {
+ errorlevel_i_ = 0;
+ }
+
+};
+#endif // Music_output_HH
#include "score-elem.hh"
#include "interval.hh"
+#include "direction.hh"
/** A symbol which sits along a staff.
class Staff_side : virtual Score_elem {
Link_array<Score_elem> support_l_arr_;
int staff_size_i_;
- Interval support_height()const;
+ Interval support_height() const;
Staff_symbol* staff_sym_l_;
- int get_position_i()const;
+ int get_position_i() const;
void read_staff_sym();
public:
/**
Vertical dir of symbol relative to staff. -1 = below staff?
*/
- int dir_i_;
+ Direction dir_;
Interval sym_int_;
/// follow the support inside the staff?
class Text_def : public General_script_def {
protected:
- virtual Atom get_atom (Paper_def* p, int dir_i_)const;
+ virtual Atom get_atom (Paper_def* p, Direction dir_) const;
DECLARE_MY_RUNTIME_TYPEINFO;
VIRTUAL_COPY_CONS(Text_def,General_script_def);
public:
virtual void do_print() const;
virtual ~Text_def() {};
- virtual bool do_equal_b (const General_script_def*)const;
+ virtual bool do_equal_b (const General_script_def*) const;
Text_def();
virtual void print() const;
Interval width (Paper_def*) const;