#ifndef BREAK_HH
#define BREAK_HH
-#include "vray.hh"
+#include "varray.hh"
#include "proto.hh"
-typedef svec<PCol*> Line_of_cols;
+typedef Array<PCol*> Line_of_cols;
struct Col_configuration {
Line_of_cols cols;
- svec<Real> config;
+ Array<Real> config;
Real energy;
/****************/
void OK()const;
- void setsol(svec<Real>);
+ void setsol(Array<Real>);
Col_configuration() ;
void add( PCol*c);
void print() const;
/// check if the spacing/breaking problem is well-stated
void problem_OK()const;
/// search all pcols which are breakable.
- svec<PCol *> find_breaks() const;
+ Array<PCol *> find_breaks() const;
/// helper: solve for the columns in #curline#.
- svec<Real> solve_line(Line_of_cols) const;
+ Array<Real> solve_line(Line_of_cols) const;
/// does curline fit on the paper?
bool feasible(Line_of_cols)const;
- virtual svec<Col_configuration> solve()=0;
+ virtual Array<Col_configuration> solve()=0;
};
/// wordwrap type algorithm: move to next line if current is optimal.
struct Word_wrap : Break_algorithm {
- virtual svec<Col_configuration> solve();
+ virtual Array<Col_configuration> solve();
Word_wrap(PScore&);
};
#endif // BREAK_HH
#ifndef CLEF_HH
#define CLEF_HH
#include "scalar.hh"
-#include "vray.hh"
+#include "varray.hh"
struct Clef {
int c0_pos;
String clef_type;
Clef();
- void read(svec<Scalar> args);
+ void read(Array<Scalar> args);
};
#endif // CLEF_HH
#define COMMAND_HH
#include "glob.hh"
-#include "vray.hh"
+#include "varray.hh"
#include "scalar.hh"
enum Commandcode {
Commandcode code;
/// analogous to argv[]
- svec<Scalar> args;
+ Array<Scalar> args;
///
int priority;
#include "moment.hh"
#include "interval.hh"
-#include "vray.hh"
+#include "varray.hh"
typedef Interval_t<Moment> MInterval;
/// data structure which represents rhythmic units
struct Rhythmic_grouping {
- svec<Rhythmic_grouping*> children;
+ Array<Rhythmic_grouping*> children;
MInterval *interval_;
/****************/
- svec<MInterval> intervals();
+ Array<MInterval> intervals();
MInterval interval()const;
Moment length() const;
void intersect(MInterval);
Rhythmic_grouping(Rhythmic_grouping const&);
Rhythmic_grouping(MInterval, int n=1);
Rhythmic_grouping();
- Rhythmic_grouping(svec<Rhythmic_grouping*>);
+ Rhythmic_grouping(Array<Rhythmic_grouping*>);
~Rhythmic_grouping();
void add_child(Moment start, Moment len);
void split(Rhythmic_grouping r);
- void split(svec<MInterval>);
+ void split(Array<MInterval>);
void split(int n);
void print() const;
void OK() const;
- svec<int> generate_beams(svec<int>, int&);
+ Array<int> generate_beams(Array<int>, int&);
private:
void init();
#ifndef ISCORE_HH
#define ISCORE_HH
-#include "vray.hh"
+#include "varray.hh"
#include "proto.hh"
#include "plist.hh"
/****************************************************************/
Input_score();
- Input_score(Input_score&);
- void add(svec<Input_command*> &s);
+ Input_score(Input_score const&);
+ void add(Array<Input_command*> &s);
void add(Input_staff*);
~Input_score();
/// construction
#include "string.hh"
#include "plist.hh"
-#include "vray.hh"
+#include "varray.hh"
#include "proto.hh"
struct Input_staff {
void add(Input_music*m);
Input_staff(Input_staff&);
Input_staff(String);
- void add(svec<Input_command*> &s);
- Staff* parse(PointerList<Input_command*>);
+ void add(Array<Input_command*> &s);
+ Staff* parse(PointerList<Input_command*>, Score*);
void print() const;
-
};
#ifndef KEY_HH
#define KEY_HH
-#include "vray.hh"
+#include "varray.hh"
#include "scalar.hh"
class Key {
- svec<int> accidentals;
+ Array<int> accidentals;
/****************/
public:
- svec<int> read(svec<Scalar> );
- svec<int> oldkey_undo(svec<Scalar>);
+ Array<int> read(Array<Scalar> );
+ Array<int> oldkey_undo(Array<Scalar>);
Key();
void set(int i, int acc);
Local_key();
private:
- svec<Key> octaves;
+ Array<Key> octaves;
};
#endif // KEY_HH
#define KEYITEM_HH
#include "item.hh"
-#include "vray.hh"
+#include "varray.hh"
///
struct Keyitem : Item {
- svec<int> pitch;
- svec<int> acc;
+ Array<int> pitch;
+ Array<int> acc;
int c_position;
Keyitem(int cposition);
void add(int pitch, int acc);
- void read(svec<int> k);
+ void read(Array<int> k);
void preprocess();
#ifndef LEASTSQUARE_HH
#define LEASTSQUARE_HH
-#include "vray.hh"
+#include "varray.hh"
#include "offset.hh"
struct Least_squares {
- svec<Offset> input;
+ Array<Offset> input;
void minimise(Real &coef, Real &offset);
};
#include "glob.hh"
#include "plist.hh"
-#include "vray.hh"
+#include "varray.hh"
#include "vector.hh"
#include "interval.hh"
/// spacing for one line.
class Spacing_problem {
- svec<const Idealspacing*> ideals;
- svec<Colinfo> cols;
+ Array<const Idealspacing*> ideals;
+ Array<Colinfo> cols;
/// the index of #c# in #cols#
int col_id(const PCol *c) const;
public:
/// solve the spacing problem
- svec<Real> solve() const;
+ Array<Real> solve() const;
/**
return the column positions, and the energy (last element)
*/
#ifndef LOCALKEYITEM_HH
#define LOCALKEYITEM_HH
#include "item.hh"
-#include "vray.hh"
+#include "varray.hh"
struct Local_acc {
int name , acc, octave;
};
struct Local_key_item : Item {
- svec<Local_acc> accs;
- svec<Notehead*> group;
+ Array<Local_acc> accs;
+ Array<Notehead*> group;
int c0_position; // move into walker
/****************/
#ifndef METER_HH
#define METER_HH
#include "item.hh"
-#include "vray.hh"
+#include "varray.hh"
struct Meter: Item {
- svec<Scalar> args;
+ Array<Scalar> args;
/****************/
- Meter(svec<Scalar> args) ;
+ Meter(Array<Scalar> args) ;
Molecule*brew_molecule() const;
};
#endif // METER_HH
#define PSCORE_HH
#include "break.hh"
-#include "vray.hh"
+#include "varray.hh"
#include "pcol.hh"
#include "pstaff.hh"
/// all stuff which goes onto paper
struct PScore {
- Paperdef *paper_; // indirection.
+ Paperdef *paper_l_;
/// the columns, ordered left to right
IPointerList<PCol *> cols;
IPointerList<Spanner*> broken_spans;
/****************/
-
- void add_broken(Spanner*);
-
- svec<Item*> select_items(PStaff*, PCol*);
-
- /// before calc_breaking
- void preprocess();
-
- void calc_breaking();
- /**
- calculate where the lines are to be broken.
-
- POST
-
- lines contain the broken lines.
- */
-
- /// after calc_breaking
- void postprocess();
+ /* CONSTRUCTION */
+ PScore(Paperdef*);
/// add a line to the broken stuff. Positions given in #config#
- void set_breaking(svec< Col_configuration> );
+ void set_breaking(Array<Col_configuration>);
void add(PStaff *);
/// add item
void typeset_item(Item *, PCol *,PStaff*,int=1);
- /// add an Spanner
+ /// add a Spanner
void typeset_spanner(Spanner*, PStaff*);
/// add to bottom of pcols
void add(PCol*);
- /**
+ void add_broken(Spanner*);
+
+ /* INSPECTION */
+ Array<Item*> select_items(PStaff*, PCol*);
+
+ /// return argument as a cursor.
+ PCursor<PCol *> find_col(const PCol *)const;
+
+ /* MAIN ROUTINES */
+ void process();
- */
+ /// last deed of this struct
void output(Tex_stream &ts);
- Idealspacing* get_spacing(PCol *, PCol *);
- /*
- get the spacing between c1 and c2, create one if necessary.
- */
+ /* UTILITY ROUTINES */
- /// return argument as a cursor.
- PCursor<PCol *> find_col(PCol *)const;
+ /// get the spacing between c1 and c2, create one if necessary.
+ Idealspacing* get_spacing(PCol *c1, PCol *c2);
- /// delete unused columns
- void clean_cols();
+ /// connect c1 and c2
+ void do_connect(PCol *c1, PCol *c2, Real distance_f, Real strength_f);
- /// invarinants
+ /// connect c1 and c2 and any children of c1 and c2
+ void connect(PCol* c1, PCol *c2, Real distance_f,Real strength_f= 1.0);
+
+ /* STANDARD ROUTINES */
void OK()const;
-
- PScore(Paperdef*);
void print() const;
+private:
+ /// before calc_breaking
+ void preprocess();
+
+ /// calculate where the lines are to be broken, and use results
+ void calc_breaking();
- /// which is first (left, higher)
- int compare_pcols( PCol*, PCol*)const;
+ /// after calc_breaking
+ void postprocess();
+
+ /// delete unused columns
+ void clean_cols();
};
/** notes, signs, symbols in a score can be grouped in two ways:
horizontally (staffwise), and vertically (columns). #PScore#
Matrix A,H;
- svec<int> active;
- svec<int> inactive; // actually this is a set, not an array.
+ Array<int> active;
+ Array<int> inactive; // actually this is a set, not an array.
const Ineq_constrained_qp *opt;
public:
int constraint_id() const { return ac->inactive[j]; }
Vector vec() const { return ac->vec(constraint_id()); }
Real rhs() const { return ac->rhs(constraint_id()); }
- bool ok() const { return j < ac->inactive.sz(); }
+ bool ok() const { return j < ac->inactive.size(); }
};
/**
loop through the inactive constraints.
#ifndef SCCOL_HH
#define SCCOL_HH
#include "proto.hh"
-#include "vray.hh"
+#include "varray.hh"
#include "moment.hh"
struct Score_column {
/// indirection to column
- PCol * pcol_;
+ PCol * pcol_l_;
/// length of notes/rests in this column
- svec<Moment> durations;
+ Array<Moment> durations;
- Moment when;
-
///
- bool musical;
+ bool musical_;
/****************/
-
+ Moment when() { return when_; }
Score_column(Moment when);
static int compare(Score_column & c1, Score_column &c2);
void add_duration(Moment );
void set_breakable();
bool used();
void print() const;
+
+private:
+ Moment when_;
};
/**
#ifndef SCORE_HH
#define SCORE_HH
-#include "vray.hh"
+#include "varray.hh"
#include "proto.hh"
#include "plist.hh"
#include "moment.hh"
/// the total music def of one movement
struct Score {
/// paper_, staffs_ and commands_ form the problem definition.
- Paperdef *paper_;
+ Paperdef *paper_p_;
IPointerList<Staff*> staffs_;
/// "runtime" fields for setting up spacing
IPointerList<Score_column*> cols_;
- PScore *pscore_;
+ PScore *pscore_p_;
/****************************************************************/
~Score();
void add(Staff*);
-
-
- void OK() const;
- PCursor<Score_column *> find_col(Moment,bool);
+ /// do everything except outputting to file
void process();
+
+ /// output to file
void output(String fn);
- PCursor<Score_column*> create_cols(Moment);
+
+ // standard
+ void OK() const;
void print() const;
+
+ // utils:
+ PCursor<Score_column*> create_cols(Moment);
+ PCursor<Score_column *> find_col(Moment,bool);
+ /// when does the last *musical* element finish?
Moment last() const;
private:
- void do_pcols();
+ Score(Score const&){}
+ void do_cols();
+ /**
+ make the pcol_l_ fields of each Score_column point to the correct PCol,
+ remove any unnecessary Score_column's
+ */
+
+ /// remove unused cols
void clean_cols();
- void distribute_commands();
- void do_connect(PCol *c1, PCol *c2, Real d,Real);
- void connect(PCol* c1, PCol *c2, Real d,Real = 1.0);
/// add #Idealspacings# to #pscore_#
void calc_idealspacing();
#define SCORELINE_HH
#include "plist.hh"
#include "proto.hh"
-#include "vray.hh"
+#include "varray.hh"
/// the columns of a score that form one line.
struct
// need to store height of each staff.
IPointerList<Line_of_staff*> staffs;
- PScore * pscore_; // needed to generate staffs
+ PScore * pscore_l_; // needed to generate staffs
/****************/
void process() ;
- Line_of_score(svec<PCol *> sv, PScore *);
+ Line_of_score(Array<PCol *> sv, PScore *);
String TeXstring() const;
#include "directionalspanner.hh"
#include "fproto.hh"
-#include "vray.hh"
+#include "varray.hh"
struct Slur : Directional_spanner {
- svec<Notehead*> encompass;
+ Array<Notehead*> encompass;
//int dir;
bool open_left,open_right;
#include "proto.hh"
#include "command.hh"
-#include "vray.hh"
+#include "varray.hh"
#include "plist.hh"
#include "timedescription.hh"
void add(Command c);
};
-/// the list of commands in Score
-struct Staff_commands : public IPointerList<Staff_commands_at*>
-{
- Staff_commands_at*find(Moment);
- void add(Staff_commands_at*);
- void clean(Moment last);
- void OK() const;
- void print() const;
- Moment last() const;
-};
-/** the list of commands in Score. Put in a separate class, since it
- otherwise clutters the methods of Score.
-
- */
-
#endif
#ifndef STAFFELEM_HH
#define STAFFELEM_HH
-#include "vray.hh"
+#include "varray.hh"
#include "proto.hh"
#include "offset.hh"
#include "molecule.hh"
OUTPUT, // molecule has been output
} status;
bool calc_children;
- svec<Staff_elem*> dependencies;
+ Array<Staff_elem*> dependencies;
- /// indirection to the pstaff it is in
- PStaff *pstaff_;
+ /// the pstaff it is in
+ PStaff *pstaff_l_;
/****************/
-
+ Staff_elem(Staff_elem const&);
String TeXstring () const ;
virtual void print() const;
virtual Interval width() const;
#include "real.hh"
#include "plist.hh"
-#include "vray.hh"
+#include "varray.hh"
#include "glob.hh"
#include "pstaff.hh"
/// one broken line of staff.
struct Line_of_staff {
- Line_of_score * line_of_score_;
- PStaff *pstaff_;
+ Line_of_score * line_of_score_l_;
+ PStaff *pstaff_l_;
/****************/
#ifndef STCOL_HH
#define STCOL_HH
#include "proto.hh"
-#include "vray.hh"
+#include "varray.hh"
#include "moment.hh"
/// store simultaneous requests
struct Staff_column {
- /// indirection
- Score_column *score_column;
+
+ Score_column *score_column_l_;
/// fields to collect data vertically.
- svec<Voice_element *> v_elts;
+ Array<Voice_element *> v_elts;
/// idem
- Staff_commands_at *s_commands;
+ Staff_commands_at *staff_commands_p_;
Time_description *tdescription_;
bool mus() const;
Moment when() const;
void add(Voice_element*ve);
-
+ void OK() const;
/****************************************************************
VIRTUAL
****************************************************************/
virtual void process_requests()=0;
virtual ~Staff_column();
+private:
+ Staff_column(Staff_column const&){}
};
#ifndef STEM_HH
#define STEM_HH
#include "item.hh"
-#include "vray.hh"
+#include "varray.hh"
#include "moment.hh"
/// the rule attached to the ball
Real stem_xoffset;
- svec<Notehead*> heads;
+ Array<Notehead*> heads;
/****************/
Stem(int center, Moment duration);
Beam::Beam()
{
- group = 0;
slope = 0;
left_pos = 0.0;
dir =0;
void
Beam::solve_slope()
{
- svec<Stem_info> sinfo;
+ Array<Stem_info> sinfo;
for (iter_top(stems,i); i.ok(); i++) {
i->set_default_extents();
Stem_info info(i);
}
Real leftx = sinfo[0].x;
Least_squares l;
- for (int i=0; i < sinfo.sz(); i++) {
+ for (int i=0; i < sinfo.size(); i++) {
sinfo[i].x -= leftx;
l.input.add(Offset(sinfo[i].x, sinfo[i].idealy));
}
l.minimise(slope, left_pos);
Real dy = 0.0;
- for (int i=0; i < sinfo.sz(); i++) {
+ for (int i=0; i < sinfo.size(); i++) {
Real y = sinfo[i].x * slope + left_pos;
Real my = sinfo[i].miny;
// URG
Real sl = slope*paper()->internote();
- paper()->lookup_->beam(sl, convert_dimen(20,"pt"));
+ paper()->lookup_p_->beam(sl, convert_dimen(20,"pt"));
slope = sl /paper()->internote();
}
{
def.OK();
cur.OK();
- assert(cur.children.sz() == stems.size());
+ assert(cur.children.size() == stems.size());
cur.split(def);
- group = new Rhythmic_grouping(cur);
- svec<int> b;
+
+ Array<int> b;
{
iter_top(stems,s);
- svec<int> flags;
+ Array<int> flags;
for (; s.ok(); s++) {
int f = intlog2(abs(s->flag))-2;
assert(f>0);
flags.add(f);
}
int fi =0;
- b= group->generate_beams(flags, fi);
+ b= cur.generate_beams(flags, fi);
b.insert(0,0);
b.add(0);
- assert(stems.size() == b.sz()/2);
+ assert(stems.size() == b.size()/2);
}
iter_top(stems,s);
- for (int i=0; i < b.sz() && s.ok(); i+=2, s++) {
+ for (int i=0; i < b.size() && s.ok(); i+=2, s++) {
s->beams_left = b[i];
s->beams_right = b[i+1];
}
void
Beam::do_pre_processing()
{
- left = (*stems.top()) ->pcol_;
- right = (*stems.bottom())->pcol_;
+ left = (*stems.top()) ->pcol_l_;
+ right = (*stems.bottom())->pcol_l_;
assert(stems.size()>1);
if (!dir)
set_default_dir();
Real dy=paper()->internote()*2;
Real stemdx = paper()->rule_thickness();
Real sl = slope*paper()->internote();
- paper()->lookup_->beam(sl, convert_dimen(20,"pt"));
+ paper()->lookup_p_->beam(sl, convert_dimen(20,"pt"));
Molecule leftbeams;
Molecule rightbeams;
int lhalfs= lhalfs = here->beams_left - prev->beams_right ;
int lwholebeams= here->beams_left <? prev->beams_right ;
Real w = (here->hpos() - prev->hpos())/4;
- Atom a = paper()->lookup_->beam(sl, w);
+ Atom a = paper()->lookup_p_->beam(sl, w);
a.translate(Offset (-w, -w * sl));
for (int j = 0; j < lhalfs; j++) {
Atom b(a);
int rwholebeams = here->beams_right <? next->beams_left;
Real w = next->hpos() - here->hpos();
- Atom a = paper()->lookup_->beam(sl, w + stemdx);
+ Atom a = paper()->lookup_p_->beam(sl, w + stemdx);
int j = 0;
for (; j < rwholebeams; j++) {
rightbeams.add( b );
}
w /= 4;
- a = paper()->lookup_->beam(sl, w);
+ a = paper()->lookup_p_->beam(sl, w);
for (; j < rwholebeams + rhalfs; j++) {
Atom b(a);
Molecule*
Beam::brew_molecule() const return out;
{
- assert(left->line == right->line);
Real inter=paper()->internote();
out = new Molecule;
Real x0 = stems.top()->hpos();
Beam::~Beam()
{
- delete group;
+
}
#include "boxes.hh"
#include "const.hh"
-#include "vray.hh"
+#include "varray.hh"
Box::Box()
/*
return all breakable columns
*/
-svec<PCol *>
+Array<PCol *>
Break_algorithm::find_breaks() const
{
- svec<PCol *> retval;
+ Array<PCol *> retval;
for (iter_top(pscore_.cols,c); c.ok(); c++)
if (c->breakable())
-
-
retval.add(c);
return retval;
}
// construct an appropriate Spacing_problem and solve it.
-svec<Real>
+Array<Real>
Break_algorithm::solve_line(Line_of_cols curline) const
{
Spacing_problem sp;
sp.add_column(curline[0], true, 0.0);
- for (int i=1; i< curline.sz()-1; i++)
+ for (int i=1; i< curline.size()-1; i++)
sp.add_column(curline[i]);
sp.add_column(curline.last(), true, linelength);
for (iter_top(pscore_.suz,i); i.ok(); i++) {
sp.add_ideal(i);
}
- svec<Real> the_sol=sp.solve();
+ Array<Real> the_sol=sp.solve();
return the_sol;
}
Break_algorithm::Break_algorithm(PScore&s)
:pscore_(s)
{
- linelength = s.paper_->linewidth;
+ linelength = s.paper_l_->linewidth;
}
bool
Break_algorithm::feasible(Line_of_cols curline) const
{
Real l =0;
- for (int i=0; i < curline.sz(); i++)
+ for (int i=0; i < curline.size(); i++)
l +=curline[i]->width().length();
return l < linelength;
}
}
void
-Col_configuration::setsol(svec<Real> sol)
+Col_configuration::setsol(Array<Real> sol)
{
config = sol;
energy = config.last();
{
#ifndef NPRINT
mtor << "energy : " << energy << '\n';
- mtor << "line of " << config.sz() << " cols\n";
+ mtor << "line of " << config.size() << " cols\n";
#endif
}
void
Col_configuration::OK()const
{
- assert(config.sz() == cols.sz());
+#ifndef NDEBUG
+ assert(config.size() == cols.size());
+#endif
}
#include "dimen.hh"
-void
-Score::do_connect(PCol *c1, PCol *c2, Real d, Real h)
-{
- if (!c1 || !c2 )
- return;
- Idealspacing*sp=pscore_->get_spacing(c1,c2);
-
- if (!sp->hooke){
- sp->hooke = h;
- sp->space =d;
- }
-}
-
-void
-Score::connect(PCol* c1, PCol *c2, Real d, Real h)
-{
- do_connect(c1,c2,d,h);
- do_connect(c1->postbreak, c2,d,h);
- do_connect(c1, c2->prebreak,d,h);
- do_connect(c1->postbreak, c2->prebreak,d,h);
-}
+/*
+ this needs A LOT of rethinking.
-/* this needs A LOT of rethinking.
+ generate springs between columns.
- generate springs between columns.
- */
+ */
void
Score::calc_idealspacing()
{
for (; i.ok(); i++) {
assert(i->used());
PCursor<Score_column*> j(i+1);
- if (i->musical) {
+ if (i->musical_) {
assert(j.ok());
- for (int n=0; n < i->durations.sz(); n++) {
+ for (int n=0; n < i->durations.size(); n++) {
Moment d = i->durations[n];
- Real dist = paper_->duration_to_dist(d);
- while (j->when < d + i->when)
+ Real dist = paper_p_->duration_to_dist(d);
+ while (j->when() < d + i->when())
j++;
-
- assert( j->when== d+i->when);
+ assert( j->when()== d+i->when());
- connect(i->pcol_, j->pcol_, dist);
- if (!j->musical && (j+1).ok()
- && (j+1)->when == j->when) {
+ pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist);
+ if (!j->musical_ && (j+1).ok()
+ && (j+1)->when() == j->when()) {
j++;
- connect(i->pcol_, j->pcol_, dist);
+ pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist);
}
}
} else if (j.ok()) {
the last col is breakable, and therefore in use
*/
- Moment d = j->when - i->when;
- Real dist = (d) ? paper_->duration_to_dist(d) :
+ Moment d = j->when() - i->when();
+ Real dist = (d) ? paper_p_->duration_to_dist(d) :
convert_dimen(2,"pt"); // todo
- connect(i->pcol_, j->pcol_, dist, (d) ? 1.0:1.0);
+ pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist, (d) ? 1.0:1.0);
}
- // !j.ok() might hold if we're at the last col.
-
+ // !j.ok() might hold if we're at the last col.
}
}
mtor << "Command " << "code " << code << " prio " << priority;
if ( isbreak())
mtor << "(break separator)";
- if (args.sz()) {
+ if (args.size()) {
mtor<< " args: ";
- for (int i = 0; i<args.sz(); i++)
+ for (int i = 0; i<args.size(); i++)
mtor << "`"<<args[i] <<"',";
}
mtor << "\n";
void
Rhythmic_grouping::OK()const
{
- assert(bool(children.sz()) != bool(interval_));
+#ifndef NDEBUG
+ assert(bool(children.size()) != bool(interval_));
- for (int i= 0; i < children.sz(); i++) {
+ for (int i= 0; i < children.size(); i++) {
children[i]->OK();
if (i>0)
assert(children[i-1]->interval().right ==
children[i]->interval().left);
}
+#endif
}
Moment
r.intersect(interval());
split(r.intervals());
- for (int i= 0; i < children.sz(); i++) {
+ for (int i= 0; i < children.size(); i++) {
if (!children[i]->interval_) {
Rhythmic_grouping here(r);
children[i]->split(here);
}
-svec<MInterval>
+Array<MInterval>
Rhythmic_grouping::intervals()
{
- svec<MInterval> r;
- if (interval_ || children.sz() == 1) {
+ Array<MInterval> r;
+ if (interval_ || children.size() == 1) {
MInterval i(interval());
MInterval r1(i), r2(i);
r1.right = r2.left = i.center();
r.add(r1); r.add(r2);
} else {
- for (int i=0; i < children.sz(); i++)
+ for (int i=0; i < children.size(); i++)
r.add(children[i]->interval());
}
return r;
return;
}
- for (int i=0; i < children.sz(); i++) {
+ for (int i=0; i < children.size(); i++) {
MInterval inter = intersection(t, children[i]->interval());
if (inter.empty() || inter.length() <= 0) {
delete children[i];
children[i]->intersect(t);
}
}
- for (int i=0; i < children.sz(); ) {
+ for (int i=0; i < children.size(); ) {
if (!children[i])
children.del(i);
else
}
void
-Rhythmic_grouping::split(svec<MInterval> splitpoints)
+Rhythmic_grouping::split(Array<MInterval> splitpoints)
{
//check on splitpoints..
int j = 0, i=0, starti = 0, startj = 0;
- svec<Rhythmic_grouping*> ch;
+ Array<Rhythmic_grouping*> ch;
while (1) {
- if ( i >= children.sz() || j >= splitpoints.sz())
+ if ( i >= children.size() || j >= splitpoints.size())
break;
assert(
}
-Rhythmic_grouping::Rhythmic_grouping(svec<Rhythmic_grouping*> r)
+Rhythmic_grouping::Rhythmic_grouping(Array<Rhythmic_grouping*> r)
:children(r)
{
interval_ =0;
Rhythmic_grouping::copy(Rhythmic_grouping const&s)
{
interval_ = (s.interval_)? new MInterval(*s.interval_) : 0;
- for (int i=0; i < s.children.sz(); i++)
+ for (int i=0; i < s.children.size(); i++)
children.add(new Rhythmic_grouping(*s.children[i]));
}
Rhythmic_grouping::junk()
{
delete interval_;
- for (int i=0; i < children.sz(); i++)
+ for (int i=0; i < children.size(); i++)
delete children[i];
init();
}
mtor << "{ \n";
if (interval_)
mtor<<" Interval "<< interval_->str();
- for (int i=0; i < children.sz(); i++) {
+ for (int i=0; i < children.size(); i++) {
children[i]->print();
}
mtor << "}\n";
Rhythmic_grouping::add_child(Moment start, Moment len)
{
Moment stop = start+len;
- for (int i=0; i < children.sz(); i ++) {
+ for (int i=0; i < children.size(); i ++) {
MInterval j=children[i]->interval();
if (j.left == start && j.right==stop) {
return;
}
}
- if (children.sz())
+ if (children.size())
assert ( children.last()->interval().right== start);
children.add(new Rhythmic_grouping(MInterval(start, stop)));
}
int
-min_elt(svec<int> v)
+min_elt(Array<int> v)
{
int i = 1000; // ugh
- for (int j = 0 ; j < v.sz(); j++)
+ for (int j = 0 ; j < v.size(); j++)
i = i <? v[j];
return i;
}
-svec<int>
-Rhythmic_grouping::generate_beams(svec<int> flags, int &flagidx)
+Array<int>
+Rhythmic_grouping::generate_beams(Array<int> flags, int &flagidx)
{
assert (!interval_) ;
- svec< svec<int> > children_beams;
- for (int i=0; i < children.sz(); i++) {
- svec<int> child_beams;
+ Array< Array<int> > children_beams;
+ for (int i=0; i < children.size(); i++) {
+ Array<int> child_beams;
if (children[i]->interval_) {
int f = flags[flagidx++];
child_beams.add(f);
}
children_beams.add(child_beams);
}
- svec<int> beams;
+ Array<int> beams;
int lastm, m, nextm;
- for (int i=0; i < children_beams.sz(); i++) {
+ for (int i=0; i < children_beams.size(); i++) {
bool add_left = (i >0);
- bool add_right = (i < children_beams.sz() -1);
+ bool add_right = (i < children_beams.size() -1);
if (!i)
m = min_elt(children_beams[i]);
if (add_right)
nextm = min_elt(children_beams[i+1]);
- if (children_beams[i].sz() == 1) {
+ if (children_beams[i].size() == 1) {
if (add_right)
beams.add(m);
if (add_left)
lastm = m;
m = nextm;
}
- assert(!(beams.sz()%2));
+ assert(!(beams.size()%2));
return beams;
}
#include "staffcommands.hh"
#include "getcommand.hh"
#include "command.hh"
+#include "stcol.hh"
+#include "staff.hh"
void
Commands_at::print() const
: tdescription_(dt, (prev)? &prev->tdescription_ : 0)
{
if (prev&& !tdescription_.whole_in_measure) {
- bottom().add(get_bar_command());
+ bottom().add(get_newmeasure_command());
}
}
{
s->tdescription_ = tdescription_;
for (iter_top(*this,cc); cc.ok(); cc++) {
- if (cc->args.sz() && cc->args[0] !="") {
+ if (cc->args.size() && cc->args[0] !="") {
Command c = **cc;
s->add(c);
}
-Staff_commands*
-Input_commands::parse() const
+void
+Input_commands::parse(Staff * staff_l) const
{
print();
- Staff_commands*nc = new Staff_commands;
-
for (iter_top(*this,i); i.ok(); i++) {
- Staff_commands_at* s= nc->find(i->when());
- if (!s){
- s = new Staff_commands_at(i->tdescription_);
- nc->add(s);
- }
+ Staff_column* col_l = staff_l->get_col(i->when(), false);
+ if (!col_l->staff_commands_p_)
+ col_l->staff_commands_p_ = new Staff_commands_at(i->tdescription_);
+
+ Staff_commands_at * com_l = col_l->staff_commands_p_;
+
if (!i->when()) { /* all pieces should start with a breakable. */
+ com_l->set_breakable();
+ #if 0
Command c;//(0.0);
c.code = INTERPRET;
c.args.add("BAR");
c.args.add("empty");
- s->add(c);
+ com_l->add(c);
+ #endif
}
- i->parse(s);
+ i->parse(com_l);
}
- return nc;
}
#include "paper.hh"
void
-Input_score::add(svec<Input_command*> &s)
+Input_score::add(Array<Input_command*> &s)
{
commands_.bottom().add(get_reset_command());
- for (int i=0; i < s.sz(); i++)
+ for (int i=0; i < s.size(); i++)
commands_.bottom().add(s[i]);
}
Score*
Input_score::parse()
{
- Paperdef* p=new Paperdef(*paper_);
- Score *s = new Score(p);
+ Paperdef* paper_p=new Paperdef(*paper_);
+ Score *s_p = new Score(paper_p);
for (iter_top(staffs_,i); i.ok(); i++) {
- Staff* staf=i->parse(commands_);
- s->add(staf);
+ Staff* staf_p=i->parse(commands_, s_p);
+ s_p->add(staf_p);
}
- return s;
+ return s_p;
}
Input_score::~Input_score()
{
- // should fix paper/symtabs to allow this deletion.
+ // TODO!
+//should fix paper/symtabs to allow this deletion.
// delete paper_;
}
#include "staff.hh"
void
-Input_staff::add(svec<Input_command*> &s)
+Input_staff::add(Array<Input_command*> &s)
{
commands_.bottom().add(get_reset_command());
- for (int i=0; i < s.sz(); i++)
+ for (int i=0; i < s.size(); i++)
commands_.bottom().add(s[i]);
s.set_size(0);
}
}
Staff*
-Input_staff::parse(PointerList<Input_command*> score_wide)
+Input_staff::parse(PointerList<Input_command*> score_wide, Score*score_l)
{
Staff *p=0;
p = new Melodic_staff;
else if (type == "rhythmic")
p = new Rhythmic_staff;
-
+ p->score_l_ = score_l;
for (iter_top(music_,i); i.ok(); i++) {
Voice_list vl = i->convert();
p->add(vl);
for (iter_top(commands_,i); i.ok(); i++)
commands.add(**i);
- p->staff_commands_ = commands.parse();
+ commands.parse(p);
return p;
}
for (iter_top(s.commands_,i); i.ok(); i++)
commands_.bottom().add(new Input_command(**i));
for (iter_top(s.music_,i); i.ok(); i++)
- add(i);
+ add(i->clone());
type = s.type;
}
octaves[i] = k;
}
-svec<int>
-Key::read(svec<Scalar> s)
+Array<int>
+Key::read(Array<Scalar> s)
{
- svec<int> newkey;
+ Array<int> newkey;
for (int j = 0; j < 7; j++)
accidentals[j] = 0;
- for (int i=0; i < s.sz(); ) {
+ for (int i=0; i < s.size(); ) {
int large = s[i++];
int small = s[i++];
accidentals[large]=small;
return newkey;
}
-svec<int>
-Key::oldkey_undo(svec<Scalar>s)
+Array<int>
+Key::oldkey_undo(Array<Scalar>s)
{
- svec<int> oldkey;
- svec<int> newkey;
+ Array<int> oldkey;
+ Array<int> newkey;
newkey.set_size(7);
- for (int i=0; i < newkey.sz(); i++)
+ for (int i=0; i < newkey.size(); i++)
newkey[i] = 0;
- for (int i=0; i < s.sz(); ) {
+ for (int i=0; i < s.size(); ) {
int large = s[i++];
int small = s[i++];
newkey[large] = small;
}
- for (int i=0; i < newkey.sz(); i++)
+ for (int i=0; i < newkey.size(); i++)
if (accidentals[i] && accidentals[i] != newkey[i]) {
oldkey.add(i);
oldkey.add(0);
}
void
-Keyitem::read(svec<int> s)
+Keyitem::read(Array<int> s)
{
- for (int i = 0 ; i< s.sz(); ) {
+ for (int i = 0 ; i< s.size(); ) {
int note = s[i++];
int acc = s[i++];
Molecule*output = new Molecule;
Real inter = paper()->interline()/2;
- for (int i =0; i < pitch.sz(); i++) {
- Symbol s= paper()->lookup_->accidental(acc[i]);
+ for (int i =0; i < pitch.size(); i++) {
+ Symbol s= paper()->lookup_p_->accidental(acc[i]);
Atom a(s);
a.translate(Offset(0,(c_position + pitch[i]) * inter));
Molecule m(a);
output->add_right(m);
}
- Molecule m(paper()->lookup_->fill(Box(
+ Molecule m(paper()->lookup_p_->fill(Box(
Interval(0, paper()->note_width()),
Interval(0,0))));
output->add_right(m);
Real sqx =0.0;
Real sxy = 0.0;
- for (int i=0; i < input.sz();i++) {
+ for (int i=0; i < input.size();i++) {
Real x=input[i].x;
Real y = input[i].y;
sx += x;
sqx += sqr(x);
sxy += x*y;
}
- int N = input.sz();
+ int N = input.size();
coef = (N * sxy - sx*sy )/(N*sqx - sqr(sx));
bool
Spacing_problem::contains(const PCol *w)
{
- for (int i=0; i< cols.sz(); i++)
+ for (int i=0; i< cols.size(); i++)
if (cols[i].pcol_ == w)
return true;
return false;
int
Spacing_problem::col_id(const PCol *w)const
{
- for (int i=0; i< cols.sz(); i++)
+ for (int i=0; i< cols.size(); i++)
if (cols[i].pcol_ == w)
return i;
assert(false);
Spacing_problem::OK() const
{
#ifndef NDEBUG
- Union_find connected(cols.sz());
- svec<int> fixed;
- for (int i=0; i < ideals.sz(); i++) {
+ Union_find connected(cols.size());
+ Array<int> fixed;
+ for (int i=0; i < ideals.size(); i++) {
assert(ideals[i]->hooke > 0);
int l = col_id(ideals[i]->left);
int r = col_id(ideals[i]->right);
connected.connect(l,r);
}
- for (int i = 0; i < cols.sz(); i++)
+ for (int i = 0; i < cols.size(); i++)
if (cols[i].fixed())
fixed.add(i);
- for (int i = 0; i < cols.sz(); i++) {
+ for (int i = 0; i < cols.size(); i++) {
bool c=false;
- for (int j =0; j<fixed.sz(); j++)
+ for (int j =0; j<fixed.size(); j++)
c |= connected.equiv(j,i);
assert(c);
}
Vector
Spacing_problem::try_initial_solution() const
{
- int dim=cols.sz();
+ int dim=cols.size();
Vector initsol(dim);
for (int i=0; i < dim; i++) {
if (cols[i].fixed()) {
quad.fill(0);
lin.fill(0);
c = 0;
- for (int j=0; j < ideals.sz(); j++){
+ for (int j=0; j < ideals.size(); j++){
Idealspacing const*i=ideals[j];
int l = col_id(i->left);
int r = col_id(i->right);
void
Spacing_problem::make_constraints(Mixed_qp& lp) const
{
- int dim=cols.sz();
+ int dim=cols.size();
for (int j=0; j < dim; j++) {
Colinfo *c=&(cols[j]);
if (c->fixed()) {
}
}
-svec<Real>
+Array<Real>
Spacing_problem::solve() const
{
print();
assert(check_feasible());
/* optimalisatiefunctie */
- Mixed_qp lp(cols.sz());
+ Mixed_qp lp(cols.size());
make_matrices(lp.quad,lp.lin, lp.const_term);
make_constraints(lp);
Vector start=find_initial_solution();
}
- svec<Real> posns(sol);
+ Array<Real> posns(sol);
posns.add(lp.eval(sol));
return posns;
}
Spacing_problem::print() const
{
#ifndef NPRINT
- for (int i=0; i < cols.sz(); i++) {
+ for (int i=0; i < cols.size(); i++) {
mtor << "col " << i<<' ';
cols[i].print();
}
- for (int i=0; i < ideals.sz(); i++) {
+ for (int i=0; i < ideals.size(); i++) {
print_ideal(ideals[i]);
}
#endif
Molecule* output = new Molecule;
Molecule*octmol = 0;
int lastoct = -100;
- for (int i = 0; i < accs.sz(); i++) {
+ for (int i = 0; i < accs.size(); i++) {
if (accs[i].octave != lastoct) {
if (octmol){
Real dy =lastoct*7*paper()->interline()/2;
octmol= new Molecule;
}
lastoct = accs[i].octave;
- Symbol s =paper()->lookup_->accidental(accs[i].acc);
+ Symbol s =paper()->lookup_p_->accidental(accs[i].acc);
Atom a(s);
Real dy = (accs[i].name + c0_position) * paper()->interline()/2;
a.translate(Offset(0,dy));
-#include "vray.hh"
+#include "varray.hh"
#include "interval.hh"
#include "dimen.hh"
#include "string.hh"
{
// whugh.. Hard coded...
String s("\\placebox{%}{%}{%}");
- svec<String> a;
+ Array<String> a;
a.add(print_dimen(off.y));
a.add(print_dimen(off.x));
a.add(sym.tex);
void
PScore::add(PStaff *s)
{
- assert(s->pscore_ == this);
+ assert(s->pscore_l_ == this);
staffs.bottom().add(s);
}
+
+void
+PScore::do_connect(PCol *c1, PCol *c2, Real d, Real h)
+{
+ if (!c1 || !c2 )
+ return;
+ Idealspacing*s_l=get_spacing(c1,c2);
+
+ if (!s_l->hooke){
+ s_l->hooke = h;
+ s_l->space =d;
+ }
+}
+
+void
+PScore::connect(PCol* c1, PCol *c2, Real d, Real h)
+{
+ do_connect(c1,c2,d,h);
+ do_connect(c1->postbreak_p_, c2,d,h);
+ do_connect(c1, c2->prebreak_p_,d,h);
+ do_connect(c1->postbreak_p_, c2->prebreak_p_,d,h);
+}
+
void
PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat)
{
assert(c && i && s);
// assert(!breakstat != 4 || c->breakable() );
if (breakstat == 0) {
- typeset_item(i, c->prebreak, s);
+ typeset_item(i, c->prebreak_p_, s);
return;
}
if (breakstat == 2) {
- typeset_item(i, c->postbreak, s);
+ typeset_item(i, c->postbreak_p_, s);
return;
}
void
PScore::typeset_spanner(Spanner*span_p, PStaff*ps)
{
- span_p->pstaff_ = ps;
+ span_p->pstaff_l_ = ps;
spanners.bottom().add(span_p);
ps->spans.bottom().add(span_p);
}
-int
-PScore::compare_pcols(PCol*a, PCol*b)const
-{
- PCursor<PCol*> ac(find_col(a));
- PCursor<PCol*> bc(find_col(b));
- assert(ac.ok() && bc.ok());
- return ac - bc;
-}
-
void
PScore::add(PCol *p)
{
- p->pscore_ = this;
+ p->pscore_l_ = this;
if (p->breakable()){
- p->prebreak->pscore_ = this;
- p->postbreak->pscore_ = this;
+ p->prebreak_p_->pscore_l_ = this;
+ p->postbreak_p_->pscore_l_ = this;
}
cols.bottom().add(p);
}
PScore::PScore( Paperdef*p)
{
- paper_ = p;
+ paper_l_ = p;
}
void
{
int l=1;
- ts << "\n "<< paper_->lookup_->texsetting << "%(Tex id)\n";
+ ts << "\n "<< paper_l_->lookup_p_->texsetting << "%(Tex id)\n";
for (iter_top(lines,lic); lic.ok(); lic++) {
ts << "% line of score no. " << l++ <<"\n";
ts << lic->TeXstring();
}
-svec<Item*>
-PScore::select_items(PStaff*ps , PCol*pc)
+Array<Item*>
+PScore::select_items(PStaff*ps, PCol*pc)
{
- svec<Item*> ret;
+ Array<Item*> ret;
assert(ps && pc);
for (iter_top(pc->its,i); i.ok(); i++){
- if (i->pstaff_ == ps)
+ if (i->pstaff_l_ == ps)
ret.add((Item*)(const Item*)i);
}
return ret;
{
#ifndef NPRINT
mtor << "PScore { ";
- paper_->print();
+ paper_l_->print();
mtor << "\ncolumns: ";
for (iter_top(cols,cc); cc.ok(); cc++)
cc->print();
}
PCursor<PCol *>
-PScore::find_col(PCol *c)const
+PScore::find_col(const PCol *c)const
{
- PCol*what = (PCol*)c;
- if (what->daddy )
- what = what -> daddy;
+ const PCol*what = c;
+ if (what->daddy_l_ )
+ what = what->daddy_l_;
- return cols.find(what);
+ return cols.find((PCol*)what);
}
void
PScore::add_broken(Spanner*s)
{
- assert(s->left->line == s->right->line);
+ assert(s->left->line_l_ == s->right->line_l_);
broken_spans.bottom().add(s);
s->left->starters.bottom().add (s);
s->right->stoppers.bottom().add (s);
}
void
-PScore::set_breaking(svec<Col_configuration> breaking)
+PScore::set_breaking(Array<Col_configuration> breaking)
{
- for (int j=0; j < breaking.sz(); j++) {
- svec<PCol*> &curline(breaking[j].cols);
- svec<Real> &config(breaking[j].config);
+ for (int j=0; j < breaking.size(); j++) {
+ Array<PCol*> &curline(breaking[j].cols);
+ Array<Real> &config(breaking[j].config);
- Line_of_score *p = new Line_of_score(curline,this);
- lines.bottom().add(p);
- for (int i=0; i < curline.sz(); i++){
+ Line_of_score *s_p = new Line_of_score(curline,this);
+ lines.bottom().add(s_p);
+ for (int i=0; i < curline.size(); i++){
curline[i]->hpos = config[i];
}
}
Word_wrap w(*this);
set_breaking(w.solve());
}
+
+void
+PScore::process()
+{
+ clean_cols();
+ *mlog << "Preprocessing ... ";
+ preprocess();
+ *mlog << "Calculating ... ";
+ calc_breaking();
+ *mlog << "Postprocessing ... ";
+ postprocess();
+}
Ineq_constrained_qp::OK() const
{
#ifndef NDEBUG
- assert(cons.sz() == consrhs.sz());
+ assert(cons.size() == consrhs.size());
Matrix Qdif= quad - quad.transposed();
assert(Qdif.norm()/quad.norm() < EPS);
#endif
print();
Ineq_constrained_qp pure(*this);
- for (int i= eq_cons.sz()-1; i>=0; i--) {
+ for (int i= eq_cons.size()-1; i>=0; i--) {
pure.eliminate_var(eq_cons[i], eq_consrhs[i]);
start.del(eq_cons[i]);
}
Vector sol = pure.solve(start);
- for (int i= 0; i < eq_cons.sz(); i++) {
+ for (int i= 0; i < eq_cons.size(); i++) {
sol.insert( eq_consrhs[i],eq_cons[i]);
}
return sol;
row.del(idx);
lin +=row ;
- for (int i=0; i < cons.sz(); i++) {
+ for (int i=0; i < cons.size(); i++) {
consrhs[i] -= cons[i](idx) *value;
cons[i].del(idx);
}
void
Ineq_constrained_qp::assert_solution(Vector sol) const
{
- svec<int> binding;
- for (int i=0; i < cons.sz(); i++) {
+ Array<int> binding;
+ for (int i=0; i < cons.size(); i++) {
Real R=cons[i] * sol- consrhs[i];
assert(R> -EPS);
if (R < EPS)
mtor << "Quad " << quad;
mtor << "lin " << lin <<"\n"
<< "const " << const_term<<"\n";
- for (int i=0; i < cons.sz(); i++) {
+ for (int i=0; i < cons.size(); i++) {
mtor << "constraint["<<i<<"]: " << cons[i] << " >= " << consrhs[i];
mtor << "\n";
}
{
#ifndef NDEBUG
Ineq_constrained_qp::OK();
- assert(eq_consrhs.sz() == eq_cons.sz());
+ assert(eq_consrhs.size() == eq_cons.size());
#endif
}
{
#ifndef NPRINT
Ineq_constrained_qp::print();
- for (int i=0; i < eq_cons.sz(); i++) {
+ for (int i=0; i < eq_cons.size(); i++) {
mtor << "eq cons "<<i<<": x["<<eq_cons[i]<<"] == " << eq_consrhs[i]<<"\n";
}
#endif
Active_constraints::status() const
{
String s("Active|Inactive [");
- for (int i=0; i< active.sz(); i++) {
+ for (int i=0; i< active.size(); i++) {
s += String(active[i]) + " ";
}
s+="| ";
- for (int i=0; i< inactive.sz(); i++) {
+ for (int i=0; i< inactive.size(); i++) {
s += String(inactive[i]) + " ";
}
s+="]";
}
void
-Active_constraints::OK() {
+Active_constraints::OK()
+{
+ #ifndef NDEBUG
H.OK();
A.OK();
- assert(active.sz() +inactive.sz() == opt->cons.sz());
+ assert(active.size() +inactive.size() == opt->cons.size());
assert(H.dim() == opt->dim());
- assert(active.sz() == A.rows());
- svec<int> allcons;
+ assert(active.size() == A.rows());
+ Array<int> allcons;
- for (int i=0; i < opt->cons.sz(); i++)
+ for (int i=0; i < opt->cons.size(); i++)
allcons.add(0);
- for (int i=0; i < active.sz(); i++) {
+ for (int i=0; i < active.size(); i++) {
int j = active[i];
allcons[j]++;
}
- for (int i=0; i < inactive.sz(); i++) {
+ for (int i=0; i < inactive.size(); i++) {
int j = inactive[i];
allcons[j]++;
}
- for (int i=0; i < allcons.sz(); i++)
+ for (int i=0; i < allcons.size(); i++)
assert(allcons[i] == 1);
+#endif
}
Vector
int cidx=inactive[k];
active.add(cidx);
- inactive.swap(k,inactive.sz()-1);
+ inactive.swap(k,inactive.size()-1);
inactive.pop();
Vector a( opt->cons[cidx] );
void
Active_constraints::drop(int k)
{
- int q=active.sz()-1;
+ int q=active.size()-1;
// drop indices
inactive.add(active[k]);
H(op->dim()),
opt(op)
{
- for (int i=0; i < op->cons.sz(); i++)
+ for (int i=0; i < op->cons.size(); i++)
inactive.add(i);
Choleski_decomposition chol(op->quad);
H=chol.inverse();
int
Score_column::compare(Score_column & c1, Score_column &c2)
{
- return sign(c1.when - c2.when);
+ return sign(c1.when_ - c2.when_);
}
void
-Score_column::set_breakable() {
- pcol_->set_breakable();
+Score_column::set_breakable()
+{
+ pcol_l_->set_breakable();
}
+
Score_column::Score_column(Moment w)
{
- when = w;
- pcol_ = new PCol(0);
- musical = false;
+ when_ = w;
+ pcol_l_ = new PCol(0);
+ musical_ = false;
}
bool
Score_column::used() {
- return pcol_->used();
+ return pcol_l_->used();
}
void
Score_column::print() const
{
#ifndef NPRINT
- mtor << "Score_column { mus "<< musical <<" at " << when<<'\n';
+ mtor << "Score_column { mus "<< musical_ <<" at " << when_<<'\n';
mtor << "durations: [";
- for (int i=0; i < durations.sz(); i++)
+ for (int i=0; i < durations.size(); i++)
mtor << durations[i] << " ";
mtor << "]\n";
- pcol_->print();
+ pcol_l_->print();
mtor << "}\n";
#endif
}
void
Score_column::add_duration(Moment d)
{
- for (int i = 0; i< durations.sz(); i++) {
+ for (int i = 0; i< durations.size(); i++) {
if (d == durations[i])
return ;
}
}
-Line_of_score::Line_of_score(svec<PCol *> sv,
+Line_of_score::Line_of_score(Array<PCol *> sv,
PScore *ps)
{
- pscore_ = ps;
- for (int i=0; i< sv.sz(); i++) {
+ pscore_l_ = ps;
+ for (int i=0; i< sv.size(); i++) {
PCol *p=(PCol *) sv[i];
cols.bottom().add(p);
- p->line=this;
+ p->line_l_=this;
}
- for (iter_top(pscore_->staffs,sc); sc.ok(); sc++)
+ for (iter_top(pscore_l_->staffs,sc); sc.ok(); sc++)
staffs.bottom().add(new Line_of_staff(this, sc));
}
/* construct a line with the named columns. Make the line field
#include "score.hh"
#include "string.hh"
-static svec<Input_score*> sv;
+static Array<Input_score*> score_array_global;
static String outfn="lelie.uit";
void
do_scores()
{
- for (int i=0; i < sv.sz(); i++) {
- Score * s = sv[i]->parse();
- delete sv[i];
-
- s->process();
- s->output(outfn);
- delete s;
+ for (int i=0; i < score_array_global.size(); i++) {
+ Score * s_p = score_array_global[i]->parse();
+ delete score_array_global[i];
+ s_p->print ();
+ s_p->process();
+ s_p->output(outfn);
+ delete s_p;
}
- sv.set_size(0);
+ score_array_global.set_size(0);
}
void
add_score(Input_score * s)
{
- sv.add(s);
+ score_array_global.add(s);
}
Simple_staff::get_TYPESET_item(Command *com)
{
Item *s=0;
- svec<Scalar> arg( com->args);
+ Array<Scalar> arg( com->args);
String type =arg[0];
arg.del(0);
if (type == "BAR" ) {
Interval
-itemlist_width(const svec<Item*> &its)
+itemlist_width(const Array<Item*> &its)
{
Interval iv ;
iv.set_empty();
- for (int j =0; j < its.sz(); j++){
+ for (int j =0; j < its.size(); j++){
iv.unite (its[j]->width());
}
{
assert(i);
- staff_->pscore_->typeset_item(i, score_column->pcol_,
+ staff_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_,
staff_->theline,breakst);
if (breakst == BREAK_PRE - BREAK_PRE) {
- svec<Item*> to_move(
- staff_->pscore_->select_items(staff_->theline,
- score_column->pcol_->prebreak));
+ Array<Item*> to_move(
+ staff_->pscore_l_->select_items(staff_->theline,
+ score_column_l_->pcol_l_->prebreak_p_));
Interval column_wid = itemlist_width(to_move);
assert(!column_wid.empty());
- for (int j=0; j < to_move.sz(); j++) {
+ for (int j=0; j < to_move.size(); j++) {
to_move[j]->translate(Offset(-column_wid.right, 0));
}
}
Simple_column::typeset_item_directional(Item *i, int dir, int breakst)
{
assert(i);
- PCol * c=score_column->pcol_;
+ PCol * c=score_column_l_->pcol_l_;
if (breakst == 0)
- c = c->prebreak;
+ c = c->prebreak_p_;
else if (breakst == 2)
- c = c->postbreak;
+ c = c->postbreak_p_;
- svec<Item*> to_move(staff_->pscore_->select_items(staff_->theline,
+ Array<Item*> to_move(staff_->pscore_l_->select_items(staff_->theline,
c));
typeset_item(i, breakst);
void
Simple_staff::set_output(PScore* ps )
{
- pscore_ = ps;
- pscore_->add(theline);
+ pscore_l_ = ps;
+ pscore_l_->add(theline);
}
Slur::set_default_dir()
{
int sumpos=0;
- for (int i=0; i < encompass.sz(); i ++) {
+ for (int i=0; i < encompass.size(); i ++) {
sumpos += encompass[i]->position;
}
/* should consult stems */
- Real meanpos = sumpos/Real(encompass.sz());
+ Real meanpos = sumpos/Real(encompass.size());
if (meanpos < 5) // todo
dir = -1;
else
void
Slur::do_pre_processing()
{
- right = encompass.last()->pcol_;
- left = encompass[0]->pcol_;
+ right = encompass.last()->pcol_l_;
+ left = encompass[0]->pcol_l_;
}
Spanner*
Slur::do_break_at(PCol*l, PCol*r) const
{
- assert(l->line == r->line);
+ assert(l->line_l_ == r->line_l_);
Slur*ret = new Slur(*this);
ret->encompass.set_size(0);
- for (int i =0; i < encompass.sz(); i++) {
- if (encompass[i]->pcol_->line==l->line)
+ for (int i =0; i < encompass.size(); i++) {
+ if (encompass[i]->pcol_l_->line_l_==l->line_l_)
ret->encompass.add(encompass[i]);
}
if (right != r)
Slur::brew_molecule() const
{
Molecule*output = new Molecule;
- assert(left->line == right->line);
+
int minp=1000, maxp=-1000; // todo
- for (int i=0; i<encompass.sz(); i++) {
+ for (int i=0; i<encompass.size(); i++) {
minp = encompass[i]->position <? minp;
maxp = encompass[i]->position >? maxp;
}
- assert(encompass.sz()>0); // todo
+ assert(encompass.size()>0); // todo
Notehead *lnote_p =encompass[0];
Notehead *rnote_p =encompass.last();
- int pos1 = lnote_p->position;
- int pos2 = rnote_p->position;
-
- int dy = pos2-pos1;
+ int lpos_i = lnote_p->position;
+ int rpos_i = rnote_p->position;
+ Offset left_off(lnote_p->x_dir, lpos_i + 2*dir);
+ Offset right_off(lnote_p->x_dir, rpos_i + 2*dir);
+ if (!lnote_p->extremal)
+ left_off += Offset(0.5, -dir);
+ if (!rnote_p->extremal)
+ right_off+= Offset(-0.5, -dir);
+
+ int dy = right_off.y - left_off.y;
+
Real nw_f = paper()->note_width();
+ Real nh_f = paper()->internote();
Real w = width().length();
- w+= (-lnote_p->x_dir + rnote_p->x_dir)* nw_f ;
+
+ w+= (right_off.x - left_off.x) * nw_f ;
Real round_w = w; // slur lookup rounds the slurwidth .
- Symbol sl = paper()->lookup_->slur(dy , round_w, dir);
+ Symbol sl = paper()->lookup_p_->slur(dy , round_w, dir);
Real error = w-round_w;
Atom a(sl);
- a.translate(Offset((lnote_p->x_dir + 0.5 )*nw_f + error/2,
- (pos2+2*dir) * paper()->internote()));
+ a.translate(Offset((left_off.x + 0.5 )*nw_f + error/2,
+ left_off.y * nh_f));
output->add(a);
return output;
}
String
Staff_elem::TeXstring() const
{
- assert(output && !calc_children);
+ assert(!calc_children);
Molecule m(*output);
m.translate(offset_); // ugh?
return m.TeXstring();
}
+Staff_elem::Staff_elem(Staff_elem const&s)
+ : dependencies(s.dependencies)
+{
+ status = s.status;
+ assert(!s.output);
+ output = 0;
+ pstaff_l_ = s.pstaff_l_;
+ calc_children = false;
+ offset_ = Offset(0,0);
+}
+
Staff_elem::~Staff_elem()
{
delete output;
Staff_elem::Staff_elem()
{
calc_children = false;
- pstaff_=0;
+ pstaff_l_=0;
offset_ = Offset(0,0);
output = 0;
status = ORPHAN;
Paperdef*
Staff_elem::paper() const
{
- assert(pstaff_);
- return pstaff_->pscore_->paper_;
+ assert(pstaff_l_);
+ return pstaff_l_->pscore_l_->paper_l_;
}
void
{
if (status >= PRECALCED )
return;
- for (int i=0; i < dependencies.sz(); i++)
+ for (int i=0; i < dependencies.size(); i++)
if (dependencies[i])
dependencies[i]->pre_processing();
if (!calc_children)
{
if (status > POSTCALCED)
return;
- for (int i=0; i < dependencies.sz(); i++)
+ for (int i=0; i < dependencies.size(); i++)
if (dependencies[i])
dependencies[i]->post_processing();
if (!calc_children)
{
if (status >= OUTPUT)
return;
- for (int i=0; i < dependencies.sz(); i++)
+ for (int i=0; i < dependencies.size(); i++)
if (dependencies[i])
dependencies[i]->molecule_processing();
if (!calc_children)
Stem::set_noteheads()
{
heads.sort(Notehead::compare);
+ heads[0]->extremal = -1;
+ heads.last()->extremal = 1;
int parity=1;
int lastpos = heads[0]->position;
- for (int i=1; i < heads.sz(); i ++) {
+ for (int i=1; i < heads.size(); i ++) {
int dy =abs(lastpos- heads[i]->position);
if (dy <= 1) {
if (!print_flag || abs(flag) <= 4)
return Interval(0,0); // TODO!
Paperdef*p= paper();
- Interval r(p->lookup_->flag(flag).dim.x);
+ Interval r(p->lookup_p_->flag(flag).dim.x);
r+= stem_xoffset;
return r;
}
Molecule*
Stem::brew_molecule()const return out;
{
- assert(pstaff_);
assert(bot!=top);
Paperdef *p =paper();
Real dy = p->internote();
- Symbol ss =p->lookup_->stem(bot*dy,top*dy);
+ Symbol ss =p->lookup_p_->stem(bot*dy,top*dy);
out = new Molecule(Atom(ss));
if (print_flag&&abs(flag) > 4){
- Symbol fl = p->lookup_->flag(flag);
+ Symbol fl = p->lookup_p_->flag(flag);
Molecule m(fl);
if (flag < -4){
out->add_bottom(m);
Real
Stem::hpos()const
{
- return pcol_->hpos + stem_xoffset;
+ return pcol_l_->hpos + stem_xoffset;
}
#include "symbol.hh"
-#include "vray.hh"
+#include "varray.hh"
Symbol::Symbol()
#include "tex.hh"
#include "symbol.hh"
#include "const.hh"
-#include "vray.hh"
+#include "varray.hh"
String
vstrut(Real h)
String
-substitute_args(String source, svec<String> args)
+substitute_args(String source, Array<String> args)
{
String retval (source);
- for (int i = 0 ; i < args.sz(); i++)
+ for (int i = 0 ; i < args.size(); i++)
substitute_arg(retval, args[i]);
while (retval.pos('%'))
substitute_arg(retval, "");
return retval;
}
String
-substitute_args(String source, svec<Scalar> args)
+substitute_args(String source, Array<Scalar> args)
{
- svec<String> sv;
- for (int i = 0 ; i < args.sz(); i++)
+ Array<String> sv;
+ for (int i = 0 ; i < args.size(); i++)
sv.add(args[i]);
return substitute_args(source, sv);
*/
-svec<Col_configuration>
+Array<Col_configuration>
Word_wrap::solve()
{
problem_OK();
iter_top(pscore_.cols,curcol);
- svec<Col_configuration> breaking;
- svec<PCol *> breakpoints(find_breaks());
- assert(breakpoints.sz()>=2);
- for (int i=0 ; i < breakpoints.sz() -1; ) {
+ Array<Col_configuration> breaking;
+ Array<PCol *> breakpoints(find_breaks());
+ assert(breakpoints.size()>=2);
+ for (int i=0 ; i < breakpoints.size() -1; ) {
Col_configuration minimum;
Col_configuration current;
// do another line
- PCol *post = breakpoints[i]->postbreak;
+ PCol *post = breakpoints[i]->postbreak_p_;
current.add( post);
curcol++; // skip the breakable.
i++;
- while (i < breakpoints.sz()) {
+ while (i < breakpoints.size()) {
// add another measure.
while (breakpoints[i] != curcol.ptr()){
current.add(curcol);
curcol++;
}
- current.add(breakpoints[i]->prebreak );
+ current.add(breakpoints[i]->prebreak_p_ );
if (!feasible(current.cols)) {
- if (!minimum.cols.sz())
+ if (!minimum.cols.size())
error("sorry, this measure is too long");
break;
}