#include "linespace.hh"
#include "debug.hh"
#include "scoreline.hh"
-#include "pscore.hh"
+#include "p-score.hh"
/*
#include "idealspacing.hh"
#include "score.hh"
-#include "pscore.hh"
+#include "p-score.hh"
#include "paper-def.hh"
#include "score-column.hh"
#include "dimen.hh"
#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"
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
-#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
#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
#include <math.h>
#include "linespace.hh"
-#include "pcol.hh"
+#include "p-col.hh"
#include "debug.hh"
#include "qlp.hh"
#include "unionfind.hh"
-#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)
(c) 1997 Jan Nieuwenhuizen <jan@digicash.com>
*/
-#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"
#include <limits.h>
#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"
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;
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
#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 )
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();
// 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 <hanwen@stack.nl>, "
- " Jan Nieuwenhuizen <jan@digicash.com>\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 <hanwen@stack.nl>,"
+ " Jan Nieuwenhuizen <jan@digicash.com>\n";
+
+ Midi_text authors( Midi_text::COPYRIGHT, str );
+ midi_track.add( Moment( 0.0 ), &authors );
*midi_stream_l_ << midi_track;
}
(c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>, Jan Nieuwenhuizen <jan@digicash.com>
*/
-#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"
--- /dev/null
+#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<PCol*> me=pscore_l_->find_col( (PCol*)this);
+ if (!me.ok())
+ return -1;
+ PCursor<PCol*> 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<PCol*> ac(ps_l->find_col(&c1));
+ PCursor<PCol*> 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();
+}
--- /dev/null
+#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<Item*>
+PScore::select_items(PStaff*ps, PCol*pc)
+{
+ Array<Item*> 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<PCol *>
+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<Col_hpositions> breaking)
+{
+ for (int j=0; j < breaking.size(); j++) {
+ Array<PCol*> &curline(breaking[j].cols);
+ Array<Real> &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 ... " <<flush;
+ preprocess();
+ *mlog << "\nCalculating column positions ... " <<flush;
+ calc_breaking();
+ *mlog << "\nPostprocessing ..." << endl;
+ postprocess();
+}
--- /dev/null
+#include "p-staff.hh"
+#include "molecule.hh"
+
+PStaff::PStaff(PScore*ps)
+{
+ pscore_l_=ps;
+}
+
+void
+PStaff::add(Item *i)
+{
+ its.bottom().add(i);
+ i->pstaff_l_ = this;
+}
*/
#include "debug.hh"
-#include "pcol.hh"
+#include "p-col.hh"
#include "score-column.hh"
int
#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"
#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
#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"
#include "debug.hh"
#include "spanner.hh"
-#include "pcol.hh"
+#include "p-col.hh"
#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"
-#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"
#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)
#include "notehead.hh"
#include "lookup.hh"
#include "molecule.hh"
-#include "pcol.hh"
+#include "p-col.hh"
#include "misc.hh"
const int STEMLEN=7;
#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"
#include "break.hh"
-#include "pscore.hh"
+#include "p-score.hh"
#include "debug.hh"
/** el stupido. This should be done more accurately: