From 182ae3001dd7eaa7d40b487978e671edcac5b0dc Mon Sep 17 00:00:00 2001 From: fred Date: Sun, 6 Oct 1996 17:40:04 +0000 Subject: [PATCH] lilypond-0.0.1 --- lilyponddefs.tex | 29 +++++++++++++ pscore.cc | 99 ++++++++++++++++++++++++++++++++++++++++++ symtable.cc | 109 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+) create mode 100644 lilyponddefs.tex create mode 100644 pscore.cc create mode 100644 symtable.cc diff --git a/lilyponddefs.tex b/lilyponddefs.tex new file mode 100644 index 0000000000..48d1e32059 --- /dev/null +++ b/lilyponddefs.tex @@ -0,0 +1,29 @@ + + +\def\musixtwentydefs{ + \font\musicfnt=musix20 +% \hulplijnbreedte5pt + %\hlijnhoogte1pt + %\balkskip4pt +} +\musixtwentydefs +\def\mdef#1#2{\def#1{{\musicfnt\char#2}}} +\mdef\quartball{'007} +\mdef\halfball{'010} +\mdef\wholeball{'011} +\mdef\wholerest{'074} +\mdef\halfrest{'072} +\mdef\quartrest{'076} +\mdef\eighthrest{'077} +\mdef\sixteenthrest{'078} +\mdef\thirtysecondrest{'079} +\mdef\sharp{'065} +\mdef\flat{'063} +\mdef\natural{'067} +\mdef\singledot{'00} +\mdef\doubledot{'01} +\mdef\tripledot{'02} +\def\maatstreep{\vrule height10pt width 1pt} +\parindent0pt + + diff --git a/pscore.cc b/pscore.cc new file mode 100644 index 0000000000..dd8ae697bc --- /dev/null +++ b/pscore.cc @@ -0,0 +1,99 @@ +// utility functions for PScore +#include "debug.hh" +#include "line.hh" +#include "pscore.hh" +#include "tstream.hh" + +void +PScore::clean_cols() +{ + for (PCursor c(cols); c.ok(); c++) + if (!c->used) { + c.remove(); + //mtor << "removing pcol\n"; + } +} + + +void +PScore::add(PStaff *s) +{ + staffs.bottom().add(s); +} + +void +PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat) +{ + assert(c && i && s); + if (breakstat == 1 ) { + typeset_item(i, c->prebreak, s, 0); + } if (breakstat == 3) + typeset_item(i, c->prebreak, s, 0 ); + else{ + its.bottom().add(i); + s->add(i); + c->add(i); + } +} + +void +PScore::add_line(svec curline, svec config) +{ + Line_of_score *p = new Line_of_score(curline,this); + lines.bottom().add(p); + for (int i=0; i < curline.sz(); i++){ + PCol *c=(PCol *)curline[i]; // so, this isn't really const. + c->hpos= config[i]; + } +} + +Idealspacing* +PScore::get_spacing(PCol*l, PCol*r) +{ + assert(l!=r); + for (PCursor ic (suz); ic.ok(); ic++) { + if (ic->left == l && ic->right == r){ + return ic; + } + } + + Idealspacing*ip =new Idealspacing(l,r); + suz.bottom().add(ip); + // l->used = r->used = true; + return ip; +} + +svec +PScore::find_breaks() const +{ + svec retval; + for (PCursor c(cols); c.ok(); c++) + if (c->breakable) + retval.add(c); + + return retval; +} + +void +PScore::add(PCol *p) +{ + cols.bottom().add(p); +} +/* + todo: config of width + */ +PScore::PScore() +{ + linewidth = 15; // in cm for now +} + +void +PScore::output(Tex_stream &ts) +{ + int l=1; + ts << "% linewidth " << linewidth * HOR_TO_PT << " pt\n"; + for (PCursor lic(lines); lic.ok(); lic++) { + ts << "% line of score no. " << l++ <<"\n"; + ts << lic->TeXstring(); + } +} diff --git a/symtable.cc b/symtable.cc new file mode 100644 index 0000000000..a63bc195c8 --- /dev/null +++ b/symtable.cc @@ -0,0 +1,109 @@ +#include "misc.hh" +#include "debug.hh" +#include "real.hh" +#include "tex.hh" +#include "assoc.hh" +#include "symtable.hh" +#include "const.hh" + +Symtable* +Symtables::operator()(String s) +{ + if (!done_reading){ // read on demand + *mlog << '(' << fname ; + read(); + done_reading = true; + *mlog << ")\n"; + } + return Assoc::operator[](s); +} + +void +Symtables::read() +{ + Text_db symini(fname); + while (1) { + if (symini.eof()) + break; + Text_record r( symini++); + if (!r.sz()) + continue; + + assert (r[0] == "table"); + + String tabnam = r[1]; + Symtable * sp = new Symtable; + while (1) { + r = symini++; + if (!r.sz()) + continue; + if (r[0] == "end") + break; + + assert(r.sz() == 6); + int i=0; + String id=r[i++]; + String tex=r[i++]; + svec dims; + for (int j=0; j < 4; j++) + dims.add( r[i++].fvalue() *1.0/CM_TO_PT); + + Symbol s(tex, Box(dims)); + (*sp)[id] = s; + } + (*this)[tabnam] = sp; + } +} + +Symtables the_sym_tables("symbol.ini"); + + +const Symbol* +Symbol::find_ball(int i) +{ + int j = intlog2(i); + if (j > 4) j = 4; + Symtable * st = the_sym_tables("balls"); + return &(*st)[String(j)]; + +} + +const Symbol* +Symbol::find_rest(int i) +{ + int j = intlog2(i); + return &(*the_sym_tables("rests"))[String(j)]; +} +const Symbol* +Symbol::find_bar(String s) +{ + return &(*the_sym_tables("bars"))[s]; +} +/****************************************************************/ +// bare bones. + +struct Linestaf_symbol : Stretchable_symbol { + int lines; + String operator ()(Real w); + Linestaf_symbol(int n) { lines = n;} +}; +// should be done in TeX +String +Linestaf_symbol::operator()(Real w) +{ + String s; + s += "\\hbox to 0pt{"; + s+= "\\vbox to 0pt{"; + for (int i=0; i