]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-0.0.1
authorfred <fred>
Sun, 6 Oct 1996 17:40:04 +0000 (17:40 +0000)
committerfred <fred>
Sun, 6 Oct 1996 17:40:04 +0000 (17:40 +0000)
lilyponddefs.tex [new file with mode: 0644]
pscore.cc [new file with mode: 0644]
symtable.cc [new file with mode: 0644]

diff --git a/lilyponddefs.tex b/lilyponddefs.tex
new file mode 100644 (file)
index 0000000..48d1e32
--- /dev/null
@@ -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 (file)
index 0000000..dd8ae69
--- /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<PCol *> 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<const PCol *> curline, svec<Real> 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<Idealspacing*> 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<const PCol *>
+PScore::find_breaks() const
+{
+    svec<const PCol *> retval;
+    for (PCursor<PCol *> 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<Line_of_score*> 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 (file)
index 0000000..a63bc19
--- /dev/null
@@ -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<String, Symtable*>::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<Real> 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<lines; i++) {
+       if (i) s+= "\\vskip1pt";
+       s+= "\\hrule width " + String(w* HOR_TO_PT) +"pt";
+    }
+    s+="\\vss}\\hss}";
+    return s;
+}
+
+const Stretchable_symbol *
+Stretchable_symbol::get_linestaff(int n)
+{
+    return new Linestaf_symbol(n);
+}