From 98f8e669c890aab93b1422f51f0da085be783acd Mon Sep 17 00:00:00 2001 From: fred Date: Tue, 22 Oct 1996 20:17:15 +0000 Subject: [PATCH] lilypond-0.0.4 --- sccol.cc | 28 ++++++++ sccol.hh | 46 +++++++++++++ score.cc | 203 +++++++++++-------------------------------------------- score.hh | 65 +++++------------- 4 files changed, 130 insertions(+), 212 deletions(-) create mode 100644 sccol.cc create mode 100644 sccol.hh diff --git a/sccol.cc b/sccol.cc new file mode 100644 index 0000000000..28955332d5 --- /dev/null +++ b/sccol.cc @@ -0,0 +1,28 @@ +#include "sccol.hh" +#include "debug.hh" + +Score_column::Score_column(Mtime w) +{ + when = w; + pcol = new PCol(0); + musical = false; +} + +bool +Score_column::used() { + return pcol->used; +} + +void +Score_column::print() const +{ +#ifndef NPRINT + mtor << "Score_column { mus "<< musical <<" at " << when<<'\n'; + mtor << "durations: ["; + for (int i=0; i < durations.sz(); i++) + mtor << durations[i] << " "; + mtor << "]\n"; + pcol->print(); + mtor << "}\n"; +#endif +} diff --git a/sccol.hh b/sccol.hh new file mode 100644 index 0000000000..9c22c277a1 --- /dev/null +++ b/sccol.hh @@ -0,0 +1,46 @@ +/* + sccol.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef SCCOL_HH +#define SCCOL_HH +#include "pcol.hh" +#include "mtime.hh" + + +struct Score_column { + PCol * pcol; + svec durations; + Mtime when; + + /// + bool musical; + + + Score_column(Mtime when); + + static int compare(Score_column & c1, Score_column &c2) { + return sgn(c1.when - c2.when); + } + void set_breakable() { + pcol->set_breakable(); + } + bool used(); + void print() const; +}; +/** + + When typesetting hasn't started on PScore yet, the columns which + contain data have a rhythmical position. Score_column is the type + with a rhythmical time attached to it. The calculation of + idealspacing is done with data in these columns. (notably: the + #durations# field) + + */ + +instantiate_compare(Score_column&, Score_column::compare); + +#endif // SCCOL_HH + diff --git a/score.cc b/score.cc index f5e357ecdb..0f8bbf70de 100644 --- a/score.cc +++ b/score.cc @@ -1,145 +1,31 @@ - #include "tstream.hh" #include "score.hh" +#include "sccol.hh" #include "pscore.hh" #include "staff.hh" -#include "misc.hh" #include "debug.hh" +#include "paper.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) +Score::output(String s) { - 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; - - seq.add(new Command(k)); - seq.add(new Command(*c)); - k.code = BREAK_MIDDLE; - seq.add(new Command(k)); - seq.add(new Command(*c)); - k.code = BREAK_POST; - seq.add(new Command(k)); - k.code = BREAK_END; - seq.add(new Command(k)); - } - else - seq.add(new Command(*c)); + OK(); + if (paper->outfile=="") + paper->outfile = s; - add_command_seq(seq); -} - -void -Score::add(Staff*s) -{ - s->score_ = this; - staffs_.bottom().add(s); + *mlog << "output to " << paper->outfile << "...\n"; + Tex_stream the_output(paper->outfile); + pscore_->output(the_output); } -void -Score::do_pcols() -{ - PCursor sc(cols_); - for (;sc.ok(); sc++) { - pscore_->add(sc->pcol); - } -} -/* - 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; - - { - Command c; - c.when = 0.0; - c.code = TYPESET; - c.args.add("BAR"); - c.args.add("empty"); - add(&c); - } - - PCursor 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); - } - commands_.OK(); -} - -Mtime -Score::last() const -{ - Mtime l = 0; - for (PCursor stc(staffs_); stc.ok(); stc++) { - l = MAX(l, stc->last()); - } - return l; -} -void -Score::clean_commands() -{ - Mtime l= last(); - for (PCursor cc(commands_); cc.ok(); ) { - if (cc->when > l){ - mtor << "remming \n"; - cc.del(); - } else - cc++; - } -} void Score::process() { - do_miscs(); + if (!paper) + paper = new Paperdef; + + commands_.clean(last()); /// distribute commands to disciples distribute_commands(); @@ -238,18 +124,30 @@ Score::distribute_commands(void) sc->add_commands(commands_); } } +void +Score::add(Staff*s) +{ + s->score_ = this; + staffs_.bottom().add(s); +} void -Score::output(String s) +Score::do_pcols() { - OK(); - if (outfile=="") - outfile = s; - - *mlog << "output to " << outfile << "...\n"; - Tex_stream the_output(outfile); - pscore_->output(the_output); + PCursor sc(cols_); + for (; sc.ok(); sc++) { + pscore_->add(sc->pcol); + } +} +Mtime +Score::last() const +{ + Mtime l = 0; + for (PCursor stc(staffs_); stc.ok(); stc++) { + l = MAX(l, stc->last()); + } + return l; } void @@ -265,12 +163,11 @@ Score::OK() const for (PCursor cc(cols_); cc.ok() && (cc+1).ok(); cc++) { assert(cc->when <= (cc+1)->when); } - for (PCursor cc(commands_); cc.ok() && (cc+1).ok(); cc++) { - assert(cc->when <= (cc+1)->when); - } + commands_.OK(); #endif } + void Score::print() const { @@ -282,38 +179,18 @@ Score::print() const for (PCursor sc(cols_); sc.ok(); sc++) { sc->print(); } + commands_.print(); mtor << "}\n"; #endif } + Score::Score() { pscore_=0; + paper = 0; } -/****************************************************************/ - -Score_column::Score_column(Mtime w) -{ - when = w; - pcol = new PCol(0); - musical = false; -} - -bool -Score_column::used() { - return pcol->used; -} - void -Score_column::print() const +Score::add(Command*c) { - #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 + commands_.add(*c); } - - diff --git a/score.hh b/score.hh index 5ec7f33b5a..c6af97c7a1 100644 --- a/score.hh +++ b/score.hh @@ -2,49 +2,15 @@ #define SCORE_HH #include "vray.hh" -#include "cols.hh" #include "mtime.hh" -#include "command.hh" - -struct Score_column { - PCol * pcol; - svec durations; - Mtime when; - - /// - bool musical; - - - Score_column(Mtime when); - - static int compare(Score_column & c1, Score_column &c2) { - return sgn(c1.when - c2.when); - } - void set_breakable() { - pcol->set_breakable(); - } - bool used(); - void print() const; -}; -/** - - When typesetting hasn't started on PScore yet, the columns which - contain data have a rhythmical position. Score_column is the type - with a rhythmical time attached to it. The calculation of - idealspacing is done with data in these columns. (notably: the - #durations# field) - - */ - -instantiate_compare(Score_column&, Score_column::compare); - +#include "scommands.hh" /// the total music def of one movement struct Score { - String outfile; + Paperdef *paper; /// staffs_ and commands_ form the problem definition. PointerList staffs_; - PointerList commands_; + Score_commands commands_; /// "runtime" fields for setting up spacing PointerList cols_; @@ -52,34 +18,35 @@ struct Score { /****************************************************************/ - Score(); - - /// add #Idealspacings# to #pscore_# - void calc_idealspacing(); + Score(); void process(); /// construction void add_staff(Staff *st); - void distribute_commands(); - /** add the score wide commands (bars, breaks) to each staff so - they can process (typeset) them if needed */ void OK() const; Score_column *find_col(Mtime,bool); void do_pcols(); - void add(Command *); + void add(Staff*); - void add_command_seq(svec ); void output(String fn); PCursor create_cols(Mtime); void print() const; - void do_miscs() ; + Mtime last() const; + + void add(Command*); + +private: + void clean_cols(); - void clean_commands(); - + void distribute_commands(); void do_connect(PCol *c1, PCol *c2, Real d); void connect_nonmus(PCol* c1, PCol *c2, Real d); + /// add #Idealspacings# to #pscore_# + void calc_idealspacing(); + /** add the score wide commands (bars, breaks) to each staff so + they can process (typeset) them if needed */ }; /** -- 2.39.5