From e2e28b839d88bcee34dcd04505a928a1bd14bd92 Mon Sep 17 00:00:00 2001 From: fred Date: Fri, 11 Oct 1996 22:52:36 +0000 Subject: [PATCH] lilypond-0.0.3 --- cols.cc | 9 +++- linespace.cc | 14 +++++- qlp.cc | 21 ++++++--- score.cc | 144 ++++++++++++++++++++++++++++++++++++----------------------- staff.cc | 13 ++++-- 5 files changed, 134 insertions(+), 67 deletions(-) diff --git a/cols.cc b/cols.cc index e2a13f35f3..0de683cc55 100644 --- a/cols.cc +++ b/cols.cc @@ -11,7 +11,9 @@ Idealspacing::Idealspacing(const PCol * l,const PCol * r) void Idealspacing::OK() const { +#ifndef NDEBUG assert(hooke >= 0 && left && right); +#endif } Interval @@ -31,6 +33,7 @@ int PCol::compare(const PCol &c1, const PCol &c2) { assert(false); + return 0 ; } void @@ -64,8 +67,10 @@ PCol::PCol(PCol *parent) { PCol::~PCol() { - delete prebreak; - delete postbreak; + if (prebreak) + delete prebreak; // no recursion! + if (postbreak) + delete postbreak; } void diff --git a/linespace.cc b/linespace.cc index 91b0e3009c..402bd4074e 100644 --- a/linespace.cc +++ b/linespace.cc @@ -27,6 +27,7 @@ Spacing_problem::col_id(const PCol *w)const void Spacing_problem::OK() const { +#ifndef NDEBUG Union_find connected(cols.sz()); for (int i=0; i < ideals.sz(); i++) { @@ -39,6 +40,7 @@ Spacing_problem::OK() const for (int i = 0; i < cols.sz(); i++) { assert( connected.equiv(0,i)); } +#endif } bool @@ -164,9 +166,10 @@ Spacing_problem::make_constraints(Optimisation_problem& lp) const svec Spacing_problem::solve() const { + print(); OK(); assert(check_feasible()); - print(); + /* optimalisatiefunctie */ Optimisation_problem lp(cols.sz()); @@ -212,16 +215,19 @@ Spacing_problem::add_ideal(const Idealspacing *i) void Spacing_problem::print_ideal(const Idealspacing*id)const { +#ifndef NPRINT int l = col_id(id->left); int r = col_id(id->right); mtor << "idealspacing { between " << l <<","<space<< " strength " << id->hooke << "}\n"; +#endif } void Spacing_problem::print() const { + #ifndef NPRINT for (int i=0; i < cols.sz(); i++) { mtor << "col " << i<<' '; cols[i].print(); @@ -229,14 +235,20 @@ Spacing_problem::print() const for (int i=0; i < ideals.sz(); i++) { print_ideal(ideals[i]); } + #endif + } void Colinfo::print() const { +#ifndef NPRINT mtor << "column { "; if (fixed) mtor << "fixed at " << fixpos<<", "; mtor << "[" << minleft() << ", " << minright() << "]"; mtor <<"}\n"; +#endif } + + diff --git a/qlp.cc b/qlp.cc index 9ad72de4a0..c76946e866 100644 --- a/qlp.cc +++ b/qlp.cc @@ -1,18 +1,22 @@ #include "debug.hh" +#include "const.hh" #include "qlp.hh" #include "choleski.hh" + void Mixed_qp::add_equality_cons(Vector v, double r) { assert(false); } + void Mixed_qp::add_fixed_var(int i, Real r) { eq_cons.add(i); eq_consrhs.add(r); } - void + +void Ineq_constrained_qp::add_inequality_cons(Vector c, double r) { cons.add(c); @@ -26,11 +30,13 @@ Ineq_constrained_qp::Ineq_constrained_qp(int novars): } void -Ineq_constrained_qp::OK()const +Ineq_constrained_qp::OK() const { +#ifndef NDEBUG assert(cons.sz() == consrhs.sz()); Matrix Qdif= quad - quad.transposed(); - assert(Qdif.norm() < EPS); + assert(Qdif.norm()/quad.norm() < EPS); +#endif } @@ -95,29 +101,34 @@ Mixed_qp::Mixed_qp(int n) } void -Mixed_qp::OK()const +Mixed_qp::OK() const { +#ifndef NDEBUG Ineq_constrained_qp::OK(); assert(eq_consrhs.sz() == eq_cons.sz()); +#endif } void Ineq_constrained_qp::print() const { - +#ifndef NPRINT mtor << "Quad " << quad; mtor << "lin " << lin <<"\n"; for (int i=0; i < cons.sz(); i++) { mtor << "constraint["<= " << consrhs[i]; mtor << "\n"; } +#endif } void Mixed_qp::print() const { +#ifndef NPRINT Ineq_constrained_qp::print(); for (int i=0; i < eq_cons.sz(); i++) { mtor << "eq cons "< + #include "tstream.hh" #include "score.hh" #include "pscore.hh" @@ -7,32 +7,56 @@ #include "debug.hh" void +Score::add_command_seq(svec com) +{ + if (!com.sz()) + return; + Real when = com[0]->when; + + PCursor pc(commands_); + while (pc.ok()&&pc->when <= when) + pc++; + + for (int i = 0; i < com.sz(); i++) { + assert(com[i]->when == when); + if (!pc.ok()) + pc.add(com[i]); + else + pc.insert(com[i]); + } + +} + +void Score::add(Command *c) { + svec seq; if (c->code == TYPESET && c->args[0] == "BAR") { /* should be encapsulated in BREAKs THIS SUX. */ + Command k; k.when = c->when; k.code = BREAK_PRE; - commands_.bottom().add(new Command(k)); - commands_.bottom().add(new Command(*c)); + + seq.add(new Command(k)); + seq.add(new Command(*c)); k.code = BREAK_MIDDLE; - commands_.bottom().add(new Command(k)); - commands_.bottom().add(new Command(*c)); + seq.add(new Command(k)); + seq.add(new Command(*c)); k.code = BREAK_POST; - commands_.bottom().add(new Command(k)); + seq.add(new Command(k)); k.code = BREAK_END; - commands_.bottom().add(new Command(k)); + seq.add(new Command(k)); } else - commands_.bottom().add(new Command(*c)); - + seq.add(new Command(*c)); + add_command_seq(seq); } void @@ -53,43 +77,41 @@ Score::do_pcols() } /* this sux. Really makeshift. + + first and last column should be breakable. + Remove any command past the last musical column. */ void Score::do_miscs() { Command c; - c.when = 0.0; + { + Command c; + c.when = 0.0; + c.code = TYPESET; + c.args.add("BAR"); + c.args.add("empty"); + add(&c); + } - c.code = BREAK_END; - commands_.top().insert(new Command(c)); - c.code = BREAK_POST; - commands_.top().insert(new Command(c)); - c.code = BREAK_MIDDLE; - commands_.top().insert(new Command(c)); - c.code = BREAK_PRE; - commands_.top().insert(new Command(c)); - PCursor bot(commands_.bottom()); - c.when = last(); - while (bot.ok() && bot->when > c.when) { -// mtor <<"removing "<< bot->code <<" at " << bot->when<<'\n'; - bot.remove(); - bot = commands_.bottom(); + Real l = last(); + while (bot.ok() && bot->when > l) { + + mtor <<"removing "<< bot->code <<" at " << bot->when<<'\n'; + bot.del(); + bot = commands_.bottom(); + } + + if (bot->when != l || bot->code != BREAK_END) { + Command c; + c.code = TYPESET; + c.when = l; + c.args.add("BAR"); + c.args.add("||"); + add(&c); } - - c.code = BREAK_PRE; - bot.add(new Command(c)); - bot++; - c.code = BREAK_MIDDLE; - bot.add(new Command(c)); - bot++; - c.code = BREAK_POST; - bot.add(new Command(c)); - bot++; - c.code = BREAK_END; - bot.add(new Command(c)); - commands_.OK(); } @@ -106,11 +128,12 @@ void Score::clean_commands() { Mtime l= last(); - for (PCursor cc(commands_); cc.ok(); cc++) { + for (PCursor cc(commands_); cc.ok(); ) { if (cc->when > l){ - mtor << "remming \n"; - cc.remove(); - } + mtor << "remming \n"; + cc.del(); + } else + cc++; } } void @@ -143,14 +166,17 @@ Score::process() */ void Score::clean_cols() -{ +{ for (PCursor sc(staffs_); sc.ok(); sc++) sc->clean_cols(); - for (PCursor c(cols_); c.ok(); c++) { + + for (PCursor c(cols_); c.ok(); ) { if (!c->pcol->used) { -// mtor << "removing : "; c->print(); - c.remove(); - } + mtor << "removing : "; + c->print(); + c.del(); + } else + c++; } pscore_->clean_cols(); @@ -218,19 +244,18 @@ void Score::output(String s) { OK(); - mtor << "output to " << s << "...\n"; - - Tex_stream the_output(s); - the_output << "% Automatically generated by LilyPond 0.0 at"; - time_t t(time(0)); - the_output << ctime(&t)<<"\n"; - the_output << "% from input file ..\n"; + if (outfile=="") + outfile = s; + + *mlog << "output to " << outfile << "...\n"; + Tex_stream the_output(outfile); pscore_->output(the_output); } void Score::OK() const { +#ifndef NDEBUG for (PCursor sc(staffs_); sc.ok(); sc++) { sc->OK(); assert(sc->score_ == this); @@ -243,12 +268,13 @@ Score::OK() const for (PCursor cc(commands_); cc.ok() && (cc+1).ok(); cc++) { assert(cc->when <= (cc+1)->when); } - +#endif } void Score::print() const { +#ifndef NPRINT mtor << "score {\n"; for (PCursor sc(staffs_); sc.ok(); sc++) { sc->print(); @@ -257,8 +283,12 @@ Score::print() const sc->print(); } mtor << "}\n"; +#endif +} +Score::Score() +{ + pscore_=0; } - /****************************************************************/ Score_column::Score_column(Mtime w) @@ -276,10 +306,14 @@ Score_column::used() { void Score_column::print() const { + #ifndef NPRINT mtor << "Score_column { mus "<< musical <<" at " << when<<'\n'; mtor << " # symbols: " << pcol->its.size() << "\n"; mtor << "durations: [" ; for (int i=0; i < durations.sz(); i++) mtor << durations[i] << " "; mtor << "]\n}\n"; + #endif } + + diff --git a/staff.cc b/staff.cc index 61699dccb2..12bf074d04 100644 --- a/staff.cc +++ b/staff.cc @@ -6,9 +6,11 @@ void Staff::clean_cols() { PCursor stc(cols); - for(; stc.ok(); stc++){ + for(; stc.ok(); ){ if (!stc->score_column->used()) - stc.remove(); + stc.del(); + else + stc++; } } @@ -122,11 +124,12 @@ Staff::process() void Staff::OK() const { +#ifndef NDEBUG cols.OK(); commands.OK(); voices.OK(); - assert(score_); - + assert(score_); +#endif } @@ -164,6 +167,7 @@ Staff_column::when() const { return score_column->when; } + void Staff_column::add(Voice_element*ve) { @@ -174,6 +178,7 @@ Staff_column::add(Voice_element*ve) v_elts.add(ve); } + Staff_column::Staff_column(Score_column*s) { score_column = s; } -- 2.11.4.GIT