From: fred Date: Sun, 24 Mar 2002 19:34:50 +0000 (+0000) Subject: lilypond-0.0.41 X-Git-Tag: release/1.5.59~5215 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=df21354467287db17d74c94e0afd8418d177c025;p=lilypond.git lilypond-0.0.41 --- diff --git a/lily/break.cc b/lily/break.cc index 7d21918637..cc588e6b0f 100644 --- a/lily/break.cc +++ b/lily/break.cc @@ -6,7 +6,7 @@ #include "linespace.hh" #include "debug.hh" #include "scoreline.hh" -#include "pscore.hh" +#include "p-score.hh" /* diff --git a/lily/calcideal.cc b/lily/calcideal.cc index 5ead08dd39..474015e3cc 100644 --- a/lily/calcideal.cc +++ b/lily/calcideal.cc @@ -1,6 +1,6 @@ #include "idealspacing.hh" #include "score.hh" -#include "pscore.hh" +#include "p-score.hh" #include "paper-def.hh" #include "score-column.hh" #include "dimen.hh" diff --git a/lily/complex-staff.cc b/lily/complex-staff.cc index bb13274449..661d8332ed 100644 --- a/lily/complex-staff.cc +++ b/lily/complex-staff.cc @@ -1,7 +1,7 @@ #include "complex-staff.hh" #include "complex-walker.hh" #include "score.hh" -#include "pscore.hh" +#include "p-score.hh" #include "staffsym.hh" #include "score-column.hh" diff --git a/lily/complex-walker.cc b/lily/complex-walker.cc index 0a76c81d0e..09773b1503 100644 --- a/lily/complex-walker.cc +++ b/lily/complex-walker.cc @@ -6,17 +6,17 @@ (c) 1997 Han-Wen Nienhuys */ -#include "musicalrequest.hh" +#include "musical-request.hh" #include "staff-column.hh" #include "voice.hh" -#include "pscore.hh" +#include "p-score.hh" #include "complex-staff.hh" #include "debug.hh" #include "voice-group-regs.hh" #include "voice-regs.hh" #include "complex-walker.hh" //#include "misc.hh" -#include "commandrequest.hh" +#include "command-request.hh" #include "walk-regs.hh" void diff --git a/lily/idealspacing.cc b/lily/idealspacing.cc index 3ceaff1e6d..805cb3bebb 100644 --- a/lily/idealspacing.cc +++ b/lily/idealspacing.cc @@ -1,7 +1,7 @@ #include "idealspacing.hh" -#include "pcol.hh" -#include "pscore.hh" -#include "pstaff.hh" +#include "p-col.hh" +#include "p-score.hh" +#include "p-staff.hh" #include "debug.hh" void diff --git a/lily/linespace.cc b/lily/linespace.cc index a7bfa1df9b..750487cff7 100644 --- a/lily/linespace.cc +++ b/lily/linespace.cc @@ -1,6 +1,6 @@ #include #include "linespace.hh" -#include "pcol.hh" +#include "p-col.hh" #include "debug.hh" #include "qlp.hh" #include "unionfind.hh" diff --git a/lily/lyric-staff.cc b/lily/lyric-staff.cc index 8414f4ecaf..77d276187c 100644 --- a/lily/lyric-staff.cc +++ b/lily/lyric-staff.cc @@ -1,11 +1,11 @@ -#include "musicalrequest.hh" +#include "musical-request.hh" #include "voice.hh" #include "staff-walker.hh" #include "debug.hh" #include "staff.hh" #include "lyric-staff.hh" #include "lyric-walker.hh" -#include "pscore.hh" +#include "p-score.hh" void Lyric_staff::set_output(PScore*pscore_l) diff --git a/lily/lyric-walker.cc b/lily/lyric-walker.cc index 614e258be7..6643215ea3 100644 --- a/lily/lyric-walker.cc +++ b/lily/lyric-walker.cc @@ -6,9 +6,9 @@ (c) 1997 Jan Nieuwenhuizen */ -#include "musicalrequest.hh" +#include "musical-request.hh" #include "voice.hh" -#include "pscore.hh" +#include "p-score.hh" #include "lyric-staff.hh" #include "lyric-walker.hh" #include "debug.hh" diff --git a/lily/midi-item.cc b/lily/midi-item.cc index 9a63d93e5a..2bc00a3a0f 100644 --- a/lily/midi-item.cc +++ b/lily/midi-item.cc @@ -8,13 +8,13 @@ #include #include "proto.hh" #include "plist.hh" -#include "pcol.hh" +#include "p-col.hh" #include "debug.hh" #include "misc.hh" #include "string.hh" #include "string-convert.hh" #include "request.hh" -#include "musicalrequest.hh" +#include "musical-request.hh" #include "voice.hh" #include "midi-item.hh" #include "midi-stream.hh" @@ -161,6 +161,24 @@ Midi_tempo::str() const return String_convert::hex2bin_str( str ); } +Midi_time::Midi_time( int num_i, int den_i, int clocks_per_1_i ) +{ + num_i_ = num_i; + den_i_ = den_i; + clocks_per_1_i_ = clocks_per_1_i; +} + +String +Midi_time::str() const +{ + String str = "ff5804"; + str += String_convert::i2hex_str( num_i_, 2, '0' ); + str += String_convert::i2hex_str( intlog2( den_i_ ) , 2, '0' ); + str += String_convert::i2hex_str( clocks_per_1_i_, 2, '0' ); + str += String_convert::i2hex_str( 8, 2, '0' ); + return String_convert::hex2bin_str( str ); +} + Midi_text::Midi_text( Midi_text::Type type, String text_str ) { type_ = type; @@ -195,7 +213,8 @@ Midi_track::Midi_track( int number_i ) number_i_ = number_i; - char const* data_ch_c_l = "00" "ff58" "0404" "0218" "08" + char const* data_ch_c_l = "" +// "00" "ff58" "0404" "0218" "08" // "00" "ff51" "0307" "a120" // why a key at all, in midi? // key: C diff --git a/lily/midi-output.cc b/lily/midi-output.cc index ec3b727400..9d2407244c 100644 --- a/lily/midi-output.cc +++ b/lily/midi-output.cc @@ -23,7 +23,7 @@ #include "midi-walker.hh" #include "midi-item.hh" #include "staff-column.hh" -#include "musicalrequest.hh" +#include "musical-request.hh" Midi_output::Midi_output(Score* score_l, Midi_def* midi_l ) @@ -74,6 +74,9 @@ Midi_output::do_staff(Staff*st_l,int track_i) Midi_tempo midi_tempo( midi_l_->get_tempo_i( Moment( 1, 4 ) ) ); midi_track.add( Moment( 0.0 ), &midi_tempo ); + Midi_time midi_time( Midi_def::num_i_s, Midi_def::den_i_s, 18 ); + midi_track.add( Moment( 0.0 ), &midi_time ); + for (Midi_walker w (st_l, &midi_track); w.ok(); w++) w.process_requests(); @@ -89,24 +92,38 @@ Midi_output::header() // perhaps multiple text events? String str = String( "Creator: " ) + get_version() + "\n"; - str += "Generated, at "; - str += ctime( &t ); - str += ", from musical definition: " + infile_str_g; - str += "\n"; Midi_text creator( Midi_text::TEXT, str ); midi_track.add( Moment( 0.0 ), &creator ); + str = "Generated, at "; + str += ctime( &t ); + str = str.left_str( str.length_i() - 1 ); + str += ",\n"; + Midi_text generate( Midi_text::TEXT, str ); + midi_track.add( Moment( 0.0 ), &generate ); + + str = "from musical definition: " + infile_str_g + "\n"; + Midi_text from( Midi_text::TEXT, str ); + midi_track.add( Moment( 0.0 ), &from ); + + // set track name + Midi_text track_name( Midi_text::TRACK_NAME, "Track " + String_convert::i2dec_str( 0, 0, '0' ) ); + midi_track.add( Moment( 0.0 ), &track_name ); + struct tm* tm_l = gmtime( &t ); String year_str = String_convert::i2dec_str( 1900 + tm_l->tm_year, 4, '0' ); // your copyleft here - str = " Copyleft (o) " + year_str; - str += " Han-Wen Nienhuys , " - " Jan Nieuwenhuizen \n"; - + str = " Copyleft (o) " + year_str + "by\n"; Midi_text copyleft( Midi_text::COPYRIGHT, str ); midi_track.add( Moment( 0.0 ), ©left ); + + str = " Han-Wen Nienhuys ," + " Jan Nieuwenhuizen \n"; + + Midi_text authors( Midi_text::COPYRIGHT, str ); + midi_track.add( Moment( 0.0 ), &authors ); *midi_stream_l_ << midi_track; } diff --git a/lily/midi-walker.cc b/lily/midi-walker.cc index 4a1674c7f7..88cd6b724d 100644 --- a/lily/midi-walker.cc +++ b/lily/midi-walker.cc @@ -6,8 +6,8 @@ (c) 1997 Han-Wen Nienhuys , Jan Nieuwenhuizen */ -#include "musicalrequest.hh" -#include "pscore.hh" +#include "musical-request.hh" +#include "p-score.hh" #include "staff.hh" #include "midi-walker.hh" #include "midi-item.hh" diff --git a/lily/p-col.cc b/lily/p-col.cc new file mode 100644 index 0000000000..2bfa097431 --- /dev/null +++ b/lily/p-col.cc @@ -0,0 +1,121 @@ +#include "p-col.hh" +#include "p-score.hh" +#include "p-staff.hh" +#include "debug.hh" + +Interval +PCol::width() const +{ + Interval w; + + for (iter_top(its,i); i.ok(); i++) + w.unite(i->width()); + if (w.empty()) + w.unite(Interval(0,0)); + return w; +} + +int +PCol::rank() const +{ + if(!pscore_l_) + return -1; + PCursor me=pscore_l_->find_col( (PCol*)this); + if (!me.ok()) + return -1; + PCursor bot(pscore_l_->cols.top()); + return me - bot; +} + +void +PCol::print() const +{ +#ifndef NPRINT + mtor << "PCol {"; + + if (rank() >= 0) + mtor << "rank: " << rank() << '\n'; + + mtor << "# symbols: " << its.size() ; + if (breakable_b()){ + mtor << "\npre,post: "; + prebreak_p_->print(); + postbreak_p_->print(); + } else if (daddy_l_) { + mtor<<'\n' << ((this == daddy_l_->prebreak_p_) ? + "prebreak" : "postbreak"); + mtor << '\n'; + } + mtor << "extent: " << width().str() << "\n"; + mtor << "}\n"; +#endif +} + +int +PCol::compare(const PCol &c1, const PCol &c2) +{ + PScore*ps_l = c1.pscore_l_; + PCursor ac(ps_l->find_col(&c1)); + PCursor bc(ps_l->find_col(&c2)); + assert(ac.ok() && bc.ok()); + return ac - bc; +} + +void +PCol::OK() const +{ +#ifndef NDEBUG + if (prebreak_p_ || postbreak_p_ ) { + assert(prebreak_p_&&postbreak_p_); + assert(prebreak_p_->daddy_l_ == this); + assert(postbreak_p_->daddy_l_ == this); + } +#endif +} + +void +PCol::set_breakable() +{ + if (breakable_b()) + return; + + prebreak_p_ = new PCol(this); + postbreak_p_ = new PCol(this); + prebreak_p_->pscore_l_ = pscore_l_; + postbreak_p_->pscore_l_ = pscore_l_; +} + +bool +PCol::breakable_b() const +{ + return prebreak_p_||postbreak_p_; +} + +PCol::PCol(PCol *parent) +{ + daddy_l_ = parent; + prebreak_p_=0; + postbreak_p_=0; + line_l_=0; + hpos = -1.0; + pscore_l_ = 0; +} + +PCol::~PCol() +{ + delete prebreak_p_; + delete postbreak_p_; +} + +void +PCol::add( Item *i) +{ + its.bottom().add(i); + i->pcol_l_ = this; +} + +bool +PCol::used_b()const +{ + return breakable_b() || its.size(); +} diff --git a/lily/p-score.cc b/lily/p-score.cc new file mode 100644 index 0000000000..582a3148ef --- /dev/null +++ b/lily/p-score.cc @@ -0,0 +1,257 @@ +#include "idealspacing.hh" +#include "debug.hh" +#include "lookup.hh" +#include "spanner.hh" +#include "paper-def.hh" +#include "molecule.hh" +#include "dimen.hh" +#include "scoreline.hh" +#include "p-score.hh" +#include "tex-stream.hh" +#include "item.hh" +#include "break.hh" + +Idealspacing* +PScore::get_spacing(PCol*l, PCol*r) +{ + assert(l!=r); + + Idealspacing*i_p =new Idealspacing(l,r); + suz.bottom().add(i_p); + + return i_p; +} + + +void +PScore::clean_cols() +{ + for (iter_top(cols,c); c.ok(); ) + if (!c->used_b()) { + delete c.remove_p(); + } else + c++; +} + + +void +PScore::add(PStaff *s) +{ + 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); + + + 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); + + if (breakstat == 0) { + typeset_item(i, c->prebreak_p_, s); + return; + } + + if (breakstat == 2) { + typeset_item(i, c->postbreak_p_, s); + return; + } + + + its.bottom().add(i); + s->add(i); + c->add(i); + + /* first do this, because i->width() may follow the 0-pointer */ + i->add_processing(); +} + +void +PScore::typeset_spanner(Spanner*span_p, PStaff*ps) +{ + span_p->pstaff_l_ = ps; + spanners.bottom().add(span_p); + ps->spans.bottom().add(span_p); + + // do not init start/stop fields. These are for broken spans only. + span_p->add_processing(); +} + + +void +PScore::add(PCol *p) +{ + p->pscore_l_ = this; + if (p->breakable_b()){ + p->prebreak_p_->pscore_l_ = this; + p->postbreak_p_->pscore_l_ = this; + } + cols.bottom().add(p); +} + +PScore::PScore( Paper_def*p) +{ + paper_l_ = p; +} + +void +PScore::output(Tex_stream &ts) +{ + int l=1; + + ts << "\n "<< paper_l_->lookup_l()->texsetting << "%(Tex id)\n"; + for (iter_top(lines,lic); lic.ok(); lic++) { + ts << "% line of score no. " << l++ <<"\n"; + ts << lic->TeXstring(); + if ((lic+1).ok()) + ts << "\\interscoreline\n"; + } +} + + +Array +PScore::select_items(PStaff*ps, PCol*pc) +{ + Array ret; + assert(ps && pc); + for (iter_top(pc->its,i); i.ok(); i++){ + if (i->pstaff_l_ == ps) + ret.push((Item*)(const Item*)i); + } + return ret; +} + +void +PScore::OK()const +{ +#ifdef NDEBUG + for (iter_top(cols,cc); cc.ok(); cc++) + cc->OK(); + for (iter_top(suz,i); i.ok(); i++) + i->OK(); +#endif +} + +void +PScore::print() const +{ +#ifndef NPRINT + mtor << "PScore { "; + paper_l_->print(); + mtor << "\ncolumns: "; + for (iter_top(cols,cc); cc.ok(); cc++) + cc->print(); + + mtor << "\nideals: "; + for (iter_top(suz,i); i.ok(); i++) + i->print(); + mtor << "}\n"; +#endif +} + +void +PScore::preprocess() +{ + for (iter_top(spanners,i); i.ok(); i++) { + i->pre_processing(); + } + for (iter_top(its,i); i.ok(); i++){ + i->pre_processing(); + } +} + +void +PScore::postprocess() +{ + for (iter_top(broken_spans,i); i.ok(); i++) { // could chase spans as well. + i->post_processing(); + } + for (iter_top(its,i); i.ok(); i++){ + i->post_processing(); + } + + for (iter_top(broken_spans,i); i.ok(); i++) { + i->molecule_processing(); + } + for (iter_top(its,i); i.ok(); i++){ + i->molecule_processing(); + } + + for (iter_top(lines,i); i.ok(); i++) + i->process(); + +} + +PCursor +PScore::find_col(const PCol *c)const +{ + const PCol*what = c; + if (what->daddy_l_ ) + what = what->daddy_l_; + + return cols.find((PCol*)what); +} + +void +PScore::add_broken(Spanner*s) +{ + 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(Array breaking) +{ + for (int j=0; j < breaking.size(); j++) { + Array &curline(breaking[j].cols); + Array &config(breaking[j].config); + + 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]; + } + } +} + +void +PScore::calc_breaking() +{ + Word_wrap w(*this); + set_breaking(w.solve()); +} + +void +PScore::process() +{ + clean_cols(); + *mlog << "Preprocessing ... " <pstaff_l_ = this; +} diff --git a/lily/score-column.cc b/lily/score-column.cc index 4387630e8d..3a699e5dc5 100644 --- a/lily/score-column.cc +++ b/lily/score-column.cc @@ -7,7 +7,7 @@ */ #include "debug.hh" -#include "pcol.hh" +#include "p-col.hh" #include "score-column.hh" int diff --git a/lily/score.cc b/lily/score.cc index 88e2e2f07b..cb764b2f7a 100644 --- a/lily/score.cc +++ b/lily/score.cc @@ -8,7 +8,7 @@ #include "tex-stream.hh" #include "score.hh" #include "score-column.hh" -#include "pscore.hh" +#include "p-score.hh" #include "staff.hh" #include "debug.hh" #include "paper-def.hh" diff --git a/lily/scoreline.cc b/lily/scoreline.cc index 2f8f0f3a4b..65c6546b5a 100644 --- a/lily/scoreline.cc +++ b/lily/scoreline.cc @@ -4,8 +4,8 @@ #include "spanner.hh" #include "symbol.hh" #include "paper-def.hh" -#include "pcol.hh" -#include "pscore.hh" +#include "p-col.hh" +#include "p-score.hh" String diff --git a/lily/slur.cc b/lily/slur.cc index 29623c0d0c..1d9bceade8 100644 --- a/lily/slur.cc +++ b/lily/slur.cc @@ -8,7 +8,7 @@ #include "lookup.hh" #include "paper-def.hh" #include "notehead.hh" -#include "pcol.hh" +#include "p-col.hh" #include "molecule.hh" #include "debug.hh" #include "boxes.hh" diff --git a/lily/spanner.cc b/lily/spanner.cc index cc57686393..d89301bc10 100644 --- a/lily/spanner.cc +++ b/lily/spanner.cc @@ -1,6 +1,6 @@ #include "debug.hh" #include "spanner.hh" -#include "pcol.hh" +#include "p-col.hh" diff --git a/lily/staff-column.cc b/lily/staff-column.cc index 87ceab5ebf..baca3a0a98 100644 --- a/lily/staff-column.cc +++ b/lily/staff-column.cc @@ -12,12 +12,12 @@ #include "time-description.hh" #include "score-column.hh" #include "staff-column.hh" -#include "commandrequest.hh" -#include "musicalrequest.hh" +#include "command-request.hh" +#include "musical-request.hh" #include "interval.hh" -#include "pscore.hh" +#include "p-score.hh" #include "item.hh" -#include "pcol.hh" +#include "p-col.hh" #include "voice-element.hh" #include "pqueue.hh" diff --git a/lily/staff-elem.cc b/lily/staff-elem.cc index b24172fa63..0524f08b32 100644 --- a/lily/staff-elem.cc +++ b/lily/staff-elem.cc @@ -1,6 +1,6 @@ -#include "pscore.hh" +#include "p-score.hh" #include "symbol.hh" -#include "pstaff.hh" +#include "p-staff.hh" #include "molecule.hh" #include "staff-elem.hh" #include "debug.hh" diff --git a/lily/staffline.cc b/lily/staffline.cc index 5d18b219e6..a0ac8a6f99 100644 --- a/lily/staffline.cc +++ b/lily/staffline.cc @@ -5,8 +5,8 @@ #include "symbol.hh" #include "paper-def.hh" #include "molecule.hh" -#include "pcol.hh" -#include "pscore.hh" +#include "p-col.hh" +#include "p-score.hh" static String make_vbox(Interval i) diff --git a/lily/stem.cc b/lily/stem.cc index 0950ada371..4b141cb2e8 100644 --- a/lily/stem.cc +++ b/lily/stem.cc @@ -5,7 +5,7 @@ #include "notehead.hh" #include "lookup.hh" #include "molecule.hh" -#include "pcol.hh" +#include "p-col.hh" #include "misc.hh" const int STEMLEN=7; diff --git a/lily/template1.cc b/lily/template1.cc index 5aa1906af6..23c68dd011 100644 --- a/lily/template1.cc +++ b/lily/template1.cc @@ -1,9 +1,9 @@ #include "proto.hh" #include "idealspacing.hh" #include "plist.hh" -#include "pcol.hh" +#include "p-col.hh" #include "item.hh" -#include "musicalrequest.hh" +#include "musical-request.hh" #include "spanner.hh" #include "scoreline.hh" #include "staffline.hh" diff --git a/lily/wordwrap.cc b/lily/wordwrap.cc index f217a63b08..3738235df9 100644 --- a/lily/wordwrap.cc +++ b/lily/wordwrap.cc @@ -1,5 +1,5 @@ #include "break.hh" -#include "pscore.hh" +#include "p-score.hh" #include "debug.hh" /** el stupido. This should be done more accurately: