summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.dstreamrc3
-rw-r--r--Makefile20
-rw-r--r--README9
-rw-r--r--Sources.make17
-rw-r--r--TODO7
-rw-r--r--boxes.cc1
-rw-r--r--break.cc5
-rw-r--r--calcideal.cc4
-rw-r--r--command.cc44
-rw-r--r--command.hh8
-rw-r--r--const.hh4
-rw-r--r--debug.hh8
-rw-r--r--depend192
-rw-r--r--dimen.cc40
-rw-r--r--dimen.hh12
-rw-r--r--dimen.tex7
-rw-r--r--flower/Makefile2
-rw-r--r--flower/Sources.make10
-rw-r--r--flower/TODO2
-rw-r--r--flower/cursor.hh16
-rw-r--r--flower/cursor.inl5
-rw-r--r--flower/dataf.cc12
-rw-r--r--flower/list.cc31
-rw-r--r--flower/list.hh34
-rw-r--r--flower/list.inl44
-rw-r--r--flower/matdebug.cc3
-rw-r--r--flower/pcursor.hh14
-rw-r--r--flower/plist.cc16
-rw-r--r--flower/stringutil.hh4
-rwxr-xr-xgenheader16
-rw-r--r--item.cc5
-rw-r--r--item.hh4
-rw-r--r--lexer.l2
-rw-r--r--lilyponddefs.tex33
-rw-r--r--line.cc17
-rw-r--r--linespace.cc19
-rw-r--r--linespace.hh9
-rw-r--r--linestaff.cc12
-rw-r--r--linestaff.hh4
-rw-r--r--lookupsyms.cc91
-rw-r--r--lookupsyms.hh18
-rw-r--r--maartje.ly7
-rw-r--r--main.cc37
-rw-r--r--main.hh3
-rwxr-xr-xmake_patch4
-rw-r--r--misc.cc4
-rw-r--r--misc.hh7
-rw-r--r--molecule.cc43
-rw-r--r--molecule.hh22
-rw-r--r--mtime.hh2
-rw-r--r--note.cc2
-rw-r--r--paper.cc8
-rw-r--r--paper.hh13
-rw-r--r--parseconstruct.hh1
-rw-r--r--parser.y61
-rw-r--r--pcol.cc (renamed from cols.cc)30
-rw-r--r--pcol.hh (renamed from cols.hh)11
-rw-r--r--proto.hh6
-rw-r--r--pscore.cc50
-rw-r--r--pscore.hh9
-rw-r--r--pstaff.hh6
-rw-r--r--qlp.hh4
-rw-r--r--request.cc42
-rw-r--r--request.hh53
-rw-r--r--rhythmstaf.cc74
-rw-r--r--rhythmstaf.hh14
-rw-r--r--sccol.cc28
-rw-r--r--sccol.hh46
-rw-r--r--scommands.cc185
-rw-r--r--scommands.hh28
-rw-r--r--score.cc203
-rw-r--r--score.hh65
-rw-r--r--staff.cc42
-rw-r--r--staff.hh19
-rw-r--r--stcol.cc30
-rw-r--r--stcol.hh33
-rw-r--r--suzan.ly9
-rw-r--r--symbol.cc28
-rw-r--r--symbol.hh22
-rw-r--r--symbol.ini43
-rw-r--r--symtable.cc66
-rw-r--r--symtable.hh14
-rw-r--r--table.cc7
-rw-r--r--template1.cc18
-rw-r--r--template2.cc2
-rw-r--r--template3.cc2
-rw-r--r--tex.cc38
-rw-r--r--tex.hh26
-rw-r--r--tstream.cc11
-rw-r--r--voice.cc9
90 files changed, 1328 insertions, 963 deletions
diff --git a/.dstreamrc b/.dstreamrc
index ec6e96fabc..b5fa669d14 100644
--- a/.dstreamrc
+++ b/.dstreamrc
@@ -12,4 +12,5 @@ PScore 1
Parser 1
Lexer 1
parse_duration 1
-parse_pitch 1 \ No newline at end of file
+parse_pitch 1
+
diff --git a/Makefile b/Makefile
index 38b71b9bbb..2f5b450761 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
MAJVER=0
MINVER=0
-PATCHLEVEL=3
+PATCHLEVEL=4
#
#
@@ -19,17 +19,19 @@ VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
PACKAGENAME=lilypond
DNAME=$(PACKAGENAME)-$(VERSION)
othersrc=lexer.l parser.y
-SCRIPTS=make_version make_patch
+SCRIPTS=make_version make_patch genheader
IFILES=dimen.tex symbol.ini suzan.ly maartje.ly lilyponddefs.tex test.tex .dstreamrc
-OFILES=Makefile Sources.make depend
-DFILES=$(hdr) $(mycc) $(othersrc) $(OFILES) $(IFILES) $(SCRIPTS) COPYING
+OFILES=Makefile Sources.make
+DOC=COPYING README TODO
+DFILES=$(hdr) $(mycc) $(othersrc) $(OFILES) $(IFILES) $(SCRIPTS) $(DOC)
#compiling
LOADLIBES=-L$(FLOWERDIR) -lflower
FLOWERDIR=../flower
-#DEFINES=-DNDEBUG
-CXXFLAGS=$(DEFINES) -I$(FLOWERDIR) -pipe -Wall -g
-
+#DEFINES=-DNDEBUG -DNPRINT -O2
+CXXFLAGS=$(DEFINES) -I$(FLOWERDIR) -pipe -Wall -W -pedantic -g
+FLEX=flex
+BISON=bison
exe=$(PACKAGENAME)
##################################################################
@@ -62,7 +64,7 @@ depend: Sources.make .GENERATE
include depend
parser.cc: parser.y
- bison -d $<
+ $(BISON) -d $<
mv parser.tab.h parser.hh
mv parser.tab.c parser.cc
@@ -74,7 +76,7 @@ version.hh: Makefile make_version
make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) > $@
lexer.cc: lexer.l
- flex -+ -t $< > $@
+ $(FLEX) -+ -t $< > $@
DDIR=$(DNAME)
dist:
diff --git a/README b/README
new file mode 100644
index 0000000000..412248b144
--- /dev/null
+++ b/README
@@ -0,0 +1,9 @@
+
+
+This is a beta version of LilyPond (a music typesetter). This release is
+preliminary, please do not distribute. Please send your helpful comments and
+patches to me,
+
+ hanwen@stack.urc.tue.nl
+
+
diff --git a/Sources.make b/Sources.make
index 54ff23ac29..02eac2a6c0 100644
--- a/Sources.make
+++ b/Sources.make
@@ -1,22 +1,23 @@
hdr= qlp.hh \
linespace.hh qlpsolve.hh\
- cols.hh proto.hh pstaff.hh line.hh\
+ pcol.hh proto.hh pstaff.hh line.hh\
const.hh glob.hh molecule.hh boxes.hh pscore.hh item.hh tex.hh\
request.hh voice.hh command.hh staff.hh linestaff.hh \
- tstream.hh mtime.hh rhythmstaf.hh\
+ tstream.hh mtime.hh rhythmstaf.hh\
parseconstruct.hh debug.hh globvars.hh keyword.hh\
misc.hh score.hh notename.hh lexer.hh symtable.hh\
- symbol.hh main.hh
+ symbol.hh main.hh dimen.hh paper.hh lookupsyms.hh\
+ sccol.hh stcol.hh scommands.hh
-mycc= qlp.cc qlpsolve.cc \
- break.cc linespace.cc molecule.cc line.cc\
- pscore.cc tex.cc item.cc cols.cc staff.cc rhythmstaf.cc\
+mycc= qlp.cc qlpsolve.cc \
+ break.cc linespace.cc molecule.cc line.cc\
+ pscore.cc tex.cc item.cc pcol.cc staff.cc rhythmstaf.cc\
score.cc note.cc main.cc misc.cc \
symbol.cc request.cc notename.cc voice.cc\
keyword.cc linestaff.cc table.cc command.cc\
warn.cc debug.cc symtable.cc boxes.cc\
pstaff.cc tstream.cc version.cc\
calcideal.cc scores.cc identifier.cc \
+ dimen.cc paper.cc lookupsyms.cc scommands.cc\
+ sccol.cc stcol.cc\
template1.cc template2.cc template3.cc
-
-
diff --git a/TODO b/TODO
new file mode 100644
index 0000000000..3f91b6bbd8
--- /dev/null
+++ b/TODO
@@ -0,0 +1,7 @@
+bug in BAR.
+dot spacing
+typeset direction.
+beam
+stem
+
+
diff --git a/boxes.cc b/boxes.cc
index e55af6c6f5..74475b4530 100644
--- a/boxes.cc
+++ b/boxes.cc
@@ -19,6 +19,7 @@ Box::Box(svec<Real> s)
Box::Box()
{
}
+
Box::Box(Interval ix, Interval iy)
{
x=ix;
diff --git a/break.cc b/break.cc
index 9eb55cc9f7..e705c546cf 100644
--- a/break.cc
+++ b/break.cc
@@ -29,12 +29,12 @@ PScore::solve_line(svec<const PCol *> curline) const
void
-PScore::problem_OK()
+PScore::problem_OK() const
{
if (!cols.size())
error("PScore::problem_OK(): Score does not have any columns");
PCursor<PCol *> start(cols);
- PCursor<PCol *> end (cols.bottom());
+ PCursor<PCol *> end (((PScore*)this)->cols.bottom());
assert(start->breakable);
assert(end->breakable);
@@ -67,6 +67,7 @@ struct Col_configuration {
void
PScore::calc_breaking()
{
+ OK();
problem_OK();
PCursor<PCol *> curcol(cols);
diff --git a/calcideal.cc b/calcideal.cc
index b1410aefc0..bddd4f2897 100644
--- a/calcideal.cc
+++ b/calcideal.cc
@@ -2,7 +2,9 @@
#include "score.hh"
#include "pscore.hh"
#include "staff.hh"
+#include "paper.hh"
#include "misc.hh"
+#include "sccol.hh"
#include "debug.hh"
@@ -48,7 +50,7 @@ Score::calc_idealspacing()
if (sc->musical)
for (int i=0; i < sc->durations.sz(); i++) {
Mtime d = sc->durations[i];
- Real dist = duration_to_idealspace(d);
+ Real dist = duration_to_idealspace(d, paper->whole_width);
PCol * c2 = find_col(sc->when + d,true)->pcol;
connect_nonmus(sc->pcol, c2, dist);
c2 = find_col(sc->when + d,false)->pcol;
diff --git a/command.cc b/command.cc
index ebf993d239..6375c7e6d3 100644
--- a/command.cc
+++ b/command.cc
@@ -1,7 +1,12 @@
-
#include "string.hh"
+#include "debug.hh"
#include "command.hh"
+bool
+Command::isbreak()const
+{
+ return (code >= BREAK_PRE&&code <= BREAK_END);
+}
Command*
get_bar_command(Real w)
@@ -13,3 +18,40 @@ get_bar_command(Real w)
c->args.add( "|");
return c;
}
+
+Command *
+get_meter_command(Real w, int n, int m)
+{
+ Command*c = new Command;
+
+ c->when = w;
+ c->code = TYPESET;
+ c->args.add( "METER");
+ c->args.add( n );
+ c->args.add( m );
+ return c;
+}
+
+
+
+Command::Command()
+{
+ code = NOP;
+ when = -1;
+}
+
+
+
+Command::Command(Real w)
+{
+ code = NOP;
+ when = w;
+}
+void
+Command::print() const
+{
+ mtor << "command code: " << code << " args: ";
+ for (int i = 0; i<args.sz(); i++)
+ mtor << args[i];
+ mtor << "\n";
+}
diff --git a/command.hh b/command.hh
index 353bf5d4bb..6b835e964b 100644
--- a/command.hh
+++ b/command.hh
@@ -3,11 +3,13 @@
#include "glob.hh"
#include "mtime.hh"
#include "vray.hh"
+#include "string.hh"
+
enum Commandcode {
NOP,
INTERPRET,
TYPESET,
- BREAK_PRE,BREAK_MIDDLE, BREAK_POST, BREAK_END,
+ BREAK_PRE,BREAK_MIDDLE, BREAK_POST, BREAK_END
};
/// set a nonrythmical symbol
struct Command {
@@ -16,6 +18,10 @@ struct Command {
Mtime when;
/// analogous to argv[]
svec<String> args;
+ Command();
+ Command(Real w);
+ bool isbreak()const;
+ void print() const;
};
/**
diff --git a/const.hh b/const.hh
index 38e464c382..dce593b4a0 100644
--- a/const.hh
+++ b/const.hh
@@ -6,10 +6,6 @@
#include <math.h>
#include "real.hh"
-const Real CM_TO_PT=72/2.54;
-const Real VERT_TO_PT=CM_TO_PT; // tex output
-const Real HOR_TO_PT=CM_TO_PT; // tex output
-
const Real EPS=1e-7; // qlpsolve.hh
const int MAXITER=100; // qlpsolve.hh
const Real INFTY=HUGE;
diff --git a/debug.hh b/debug.hh
index ae75b77fa1..ca805df011 100644
--- a/debug.hh
+++ b/debug.hh
@@ -16,12 +16,4 @@ extern Dstream monitor; // monitor
void error(String s);
void warning(String s);
-extern int debug_flags;
-
-void
-set_debug(String s);
-const int DEBUGPARSER = 0x01;
-const int DEBUGTOKEN = 0x02;
-const int DEBUGITEMS = 0x04;
-
#endif
diff --git a/depend b/depend
deleted file mode 100644
index 3c3bccbdb5..0000000000
--- a/depend
+++ /dev/null
@@ -1,192 +0,0 @@
-qlp.o: qlp.cc debug.hh ../flower/dstream.hh ../flower/string.hh \
- ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh const.hh \
- ../flower/real.hh qlp.hh ../flower/matrix.hh ../flower/vsmat.hh \
- ../flower/vector.hh ../flower/choleski.hh
-qlpsolve.o: qlpsolve.cc qlpsolve.hh qlp.hh ../flower/matrix.hh \
- ../flower/vsmat.hh ../flower/vray.hh ../flower/real.hh \
- ../flower/vector.hh const.hh debug.hh ../flower/dstream.hh \
- ../flower/string.hh ../flower/stringutil.hh ../flower/assoc.hh \
- ../flower/choleski.hh
-break.o: break.cc linespace.hh glob.hh ../flower/real.hh proto.hh \
- const.hh ../flower/list.hh ../flower/list.inl ../flower/cursor.hh \
- ../flower/link.hh ../flower/link.inl ../flower/cursor.inl \
- ../flower/vray.hh cols.hh boxes.hh ../flower/textdb.hh \
- ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \
- item.hh tex.hh ../flower/compare.hh ../flower/matrix.hh \
- ../flower/vsmat.hh ../flower/vector.hh debug.hh ../flower/dstream.hh \
- ../flower/assoc.hh line.hh pstaff.hh pscore.hh
-linespace.o: linespace.cc linespace.hh glob.hh ../flower/real.hh \
- proto.hh const.hh ../flower/list.hh ../flower/list.inl \
- ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \
- ../flower/cursor.inl ../flower/vray.hh cols.hh boxes.hh \
- ../flower/textdb.hh ../flower/textstr.hh ../flower/string.hh \
- ../flower/stringutil.hh item.hh tex.hh ../flower/compare.hh \
- ../flower/matrix.hh ../flower/vsmat.hh ../flower/vector.hh debug.hh \
- ../flower/dstream.hh ../flower/assoc.hh qlp.hh ../flower/unionfind.hh
-molecule.o: molecule.cc glob.hh ../flower/real.hh proto.hh const.hh \
- ../flower/string.hh ../flower/stringutil.hh molecule.hh \
- ../flower/list.hh ../flower/list.inl ../flower/cursor.hh \
- ../flower/link.hh ../flower/link.inl ../flower/cursor.inl boxes.hh \
- ../flower/textdb.hh ../flower/textstr.hh ../flower/vray.hh item.hh \
- tex.hh symbol.hh
-line.o: line.cc line.hh ../flower/real.hh ../flower/list.hh \
- ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \
- ../flower/link.inl ../flower/cursor.inl ../flower/vray.hh glob.hh \
- proto.hh const.hh pstaff.hh item.hh boxes.hh ../flower/textdb.hh \
- ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \
- tex.hh symbol.hh cols.hh ../flower/compare.hh pscore.hh
-pscore.o: pscore.cc debug.hh ../flower/dstream.hh ../flower/string.hh \
- ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh line.hh \
- ../flower/real.hh ../flower/list.hh ../flower/list.inl \
- ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \
- ../flower/cursor.inl glob.hh proto.hh const.hh pstaff.hh item.hh \
- boxes.hh ../flower/textdb.hh ../flower/textstr.hh tex.hh pscore.hh \
- cols.hh ../flower/compare.hh tstream.hh
-tex.o: tex.cc tex.hh ../flower/string.hh ../flower/stringutil.hh \
- boxes.hh ../flower/textdb.hh ../flower/textstr.hh ../flower/vray.hh \
- ../flower/real.hh symbol.hh const.hh
-item.o: item.cc line.hh ../flower/real.hh ../flower/list.hh \
- ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \
- ../flower/link.inl ../flower/cursor.inl ../flower/vray.hh glob.hh \
- proto.hh const.hh pstaff.hh item.hh boxes.hh ../flower/textdb.hh \
- ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \
- tex.hh symbol.hh cols.hh ../flower/compare.hh
-cols.o: cols.cc cols.hh glob.hh ../flower/real.hh proto.hh const.hh \
- boxes.hh ../flower/textdb.hh ../flower/textstr.hh ../flower/string.hh \
- ../flower/stringutil.hh ../flower/vray.hh ../flower/list.hh \
- ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \
- ../flower/link.inl ../flower/cursor.inl item.hh tex.hh \
- ../flower/compare.hh pstaff.hh
-staff.o: staff.cc staff.hh score.hh ../flower/vray.hh cols.hh glob.hh \
- ../flower/real.hh proto.hh const.hh boxes.hh ../flower/textdb.hh \
- ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \
- ../flower/list.hh ../flower/list.inl ../flower/cursor.hh \
- ../flower/link.hh ../flower/link.inl ../flower/cursor.inl item.hh \
- tex.hh ../flower/compare.hh mtime.hh command.hh voice.hh request.hh \
- debug.hh ../flower/dstream.hh ../flower/assoc.hh pscore.hh pstaff.hh
-rhythmstaf.o: rhythmstaf.cc request.hh glob.hh ../flower/real.hh \
- proto.hh const.hh ../flower/string.hh ../flower/stringutil.hh \
- mtime.hh debug.hh ../flower/dstream.hh ../flower/assoc.hh \
- ../flower/vray.hh linestaff.hh pstaff.hh ../flower/list.hh \
- ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \
- ../flower/link.inl ../flower/cursor.inl item.hh boxes.hh \
- ../flower/textdb.hh ../flower/textstr.hh tex.hh staff.hh score.hh \
- cols.hh ../flower/compare.hh command.hh voice.hh pscore.hh \
- molecule.hh rhythmstaf.hh symbol.hh
-score.o: score.cc tstream.hh ../flower/string.hh \
- ../flower/stringutil.hh score.hh ../flower/vray.hh cols.hh glob.hh \
- ../flower/real.hh proto.hh const.hh boxes.hh ../flower/textdb.hh \
- ../flower/textstr.hh ../flower/list.hh ../flower/list.inl \
- ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \
- ../flower/cursor.inl item.hh tex.hh ../flower/compare.hh mtime.hh \
- command.hh pscore.hh pstaff.hh staff.hh voice.hh request.hh misc.hh \
- debug.hh ../flower/dstream.hh ../flower/assoc.hh
-note.o: note.cc ../flower/string.hh ../flower/stringutil.hh \
- ../flower/real.hh debug.hh ../flower/dstream.hh ../flower/assoc.hh \
- ../flower/vray.hh request.hh glob.hh proto.hh const.hh mtime.hh \
- voice.hh ../flower/list.hh ../flower/list.inl ../flower/cursor.hh \
- ../flower/link.hh ../flower/link.inl ../flower/cursor.inl notename.hh
-main.o: main.cc ../flower/lgetopt.hh misc.hh mtime.hh \
- ../flower/real.hh ../flower/string.hh ../flower/stringutil.hh main.hh \
- proto.hh
-misc.o: misc.cc misc.hh mtime.hh ../flower/real.hh glob.hh proto.hh \
- const.hh
-symbol.o: symbol.cc symbol.hh ../flower/string.hh \
- ../flower/stringutil.hh boxes.hh ../flower/textdb.hh \
- ../flower/textstr.hh ../flower/vray.hh ../flower/real.hh
-request.o: request.cc request.hh glob.hh ../flower/real.hh proto.hh \
- const.hh ../flower/string.hh ../flower/stringutil.hh mtime.hh
-notename.o: notename.cc glob.hh ../flower/real.hh proto.hh const.hh \
- ../flower/string.hh ../flower/stringutil.hh
-voice.o: voice.cc debug.hh ../flower/dstream.hh ../flower/string.hh \
- ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh voice.hh \
- mtime.hh ../flower/real.hh ../flower/list.hh ../flower/list.inl \
- ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \
- ../flower/cursor.inl request.hh glob.hh proto.hh const.hh
-keyword.o: keyword.cc glob.hh ../flower/real.hh proto.hh const.hh \
- lexer.hh
-linestaff.o: linestaff.cc linestaff.hh pstaff.hh ../flower/list.hh \
- ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \
- ../flower/link.inl ../flower/cursor.inl item.hh glob.hh \
- ../flower/real.hh proto.hh const.hh boxes.hh ../flower/textdb.hh \
- ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \
- ../flower/vray.hh tex.hh symbol.hh
-table.o: table.cc glob.hh ../flower/real.hh proto.hh const.hh debug.hh \
- ../flower/dstream.hh ../flower/string.hh ../flower/stringutil.hh \
- ../flower/assoc.hh ../flower/vray.hh keyword.hh parser.hh
-command.o: command.cc ../flower/string.hh ../flower/stringutil.hh \
- command.hh glob.hh ../flower/real.hh proto.hh const.hh mtime.hh \
- ../flower/vray.hh
-warn.o: warn.cc debug.hh ../flower/dstream.hh ../flower/string.hh \
- ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh
-debug.o: debug.cc debug.hh ../flower/dstream.hh ../flower/string.hh \
- ../flower/stringutil.hh ../flower/assoc.hh ../flower/vray.hh \
- ../flower/vector.hh ../flower/real.hh
-symtable.o: symtable.cc misc.hh mtime.hh ../flower/real.hh debug.hh \
- ../flower/dstream.hh ../flower/string.hh ../flower/stringutil.hh \
- ../flower/assoc.hh ../flower/vray.hh symbol.hh boxes.hh \
- ../flower/textdb.hh ../flower/textstr.hh symtable.hh const.hh
-boxes.o: boxes.cc boxes.hh ../flower/textdb.hh ../flower/textstr.hh \
- ../flower/string.hh ../flower/stringutil.hh ../flower/vray.hh \
- ../flower/real.hh const.hh
-pstaff.o: pstaff.cc pstaff.hh ../flower/list.hh ../flower/list.inl \
- ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \
- ../flower/cursor.inl item.hh glob.hh ../flower/real.hh proto.hh \
- const.hh boxes.hh ../flower/textdb.hh ../flower/textstr.hh \
- ../flower/string.hh ../flower/stringutil.hh ../flower/vray.hh tex.hh
-tstream.o: tstream.cc tex.hh ../flower/string.hh \
- ../flower/stringutil.hh boxes.hh ../flower/textdb.hh \
- ../flower/textstr.hh ../flower/vray.hh ../flower/real.hh misc.hh \
- mtime.hh tstream.hh debug.hh ../flower/dstream.hh ../flower/assoc.hh
-version.o: version.cc version.hh
-calcideal.o: calcideal.cc tstream.hh ../flower/string.hh \
- ../flower/stringutil.hh score.hh ../flower/vray.hh cols.hh glob.hh \
- ../flower/real.hh proto.hh const.hh boxes.hh ../flower/textdb.hh \
- ../flower/textstr.hh ../flower/list.hh ../flower/list.inl \
- ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \
- ../flower/cursor.inl item.hh tex.hh ../flower/compare.hh mtime.hh \
- command.hh pscore.hh pstaff.hh staff.hh voice.hh request.hh misc.hh \
- debug.hh ../flower/dstream.hh ../flower/assoc.hh
-scores.o: scores.cc main.hh proto.hh ../flower/real.hh score.hh \
- ../flower/vray.hh cols.hh glob.hh const.hh boxes.hh \
- ../flower/textdb.hh ../flower/textstr.hh ../flower/string.hh \
- ../flower/stringutil.hh ../flower/list.hh ../flower/list.inl \
- ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \
- ../flower/cursor.inl item.hh tex.hh ../flower/compare.hh mtime.hh \
- command.hh
-identifier.o: identifier.cc keyword.hh lexer.hh proto.hh \
- ../flower/real.hh parser.hh
-template1.o: template1.cc line.hh ../flower/real.hh ../flower/list.hh \
- ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \
- ../flower/link.inl ../flower/cursor.inl ../flower/vray.hh glob.hh \
- proto.hh const.hh pstaff.hh item.hh boxes.hh ../flower/textdb.hh \
- ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \
- tex.hh cols.hh ../flower/compare.hh request.hh mtime.hh command.hh \
- ../flower/list.cc ../flower/cursor.cc
-template2.o: template2.cc line.hh ../flower/real.hh ../flower/list.hh \
- ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \
- ../flower/link.inl ../flower/cursor.inl ../flower/vray.hh glob.hh \
- proto.hh const.hh pstaff.hh item.hh boxes.hh ../flower/textdb.hh \
- ../flower/textstr.hh ../flower/string.hh ../flower/stringutil.hh \
- tex.hh symbol.hh voice.hh mtime.hh request.hh staff.hh score.hh \
- cols.hh ../flower/compare.hh command.hh ../flower/list.cc \
- ../flower/cursor.cc
-template3.o: template3.cc request.hh glob.hh ../flower/real.hh \
- proto.hh const.hh ../flower/string.hh ../flower/stringutil.hh \
- mtime.hh command.hh ../flower/vray.hh molecule.hh ../flower/list.hh \
- ../flower/list.inl ../flower/cursor.hh ../flower/link.hh \
- ../flower/link.inl ../flower/cursor.inl boxes.hh ../flower/textdb.hh \
- ../flower/textstr.hh item.hh tex.hh ../flower/list.cc \
- ../flower/cursor.cc
-parser.o: parser.cc lexer.hh proto.hh ../flower/real.hh staff.hh \
- score.hh ../flower/vray.hh cols.hh glob.hh const.hh boxes.hh \
- ../flower/textdb.hh ../flower/textstr.hh ../flower/string.hh \
- ../flower/stringutil.hh ../flower/list.hh ../flower/list.inl \
- ../flower/cursor.hh ../flower/link.hh ../flower/link.inl \
- ../flower/cursor.inl item.hh tex.hh ../flower/compare.hh mtime.hh \
- command.hh voice.hh request.hh main.hh keyword.hh debug.hh \
- ../flower/dstream.hh ../flower/assoc.hh parseconstruct.hh
-lexer.o: lexer.cc glob.hh ../flower/real.hh proto.hh const.hh \
- ../flower/string.hh ../flower/stringutil.hh lexer.hh keyword.hh \
- ../flower/vray.hh parser.hh debug.hh ../flower/dstream.hh \
- ../flower/assoc.hh
diff --git a/dimen.cc b/dimen.cc
new file mode 100644
index 0000000000..eb53756b45
--- /dev/null
+++ b/dimen.cc
@@ -0,0 +1,40 @@
+#include <ctype.h>
+#include "dimen.hh"
+#include "debug.hh"
+#include "string.hh"
+
+Real
+parse_dimen(String dim)
+{
+ int i=dim.len()-1;
+ const char *s = dim;
+ while (i > 0 && (isspace(s[i]) || isalpha(s[i])) ){
+ i--;
+ }
+ String unit(s + i+1);
+ return convert_dimen(dim.fvalue(), unit);
+}
+
+const Real CM_TO_PT=72/2.54;
+
+Real
+convert_dimen(Real quant, String unit)
+{
+ if (unit == "cm")
+ return quant * CM_TO_PT;
+ if (unit == "pt")
+ return quant;
+ if (unit == "mm")
+ return quant*CM_TO_PT/10;
+ if (unit == "in")
+ return quant * 72;
+ error ("unknown length unit: `" + unit+"'");
+}
+
+String
+print_dimen(Real r)
+{
+ String s(r);
+ s += "pt ";
+ return s;
+}
diff --git a/dimen.hh b/dimen.hh
new file mode 100644
index 0000000000..4ee17ea140
--- /dev/null
+++ b/dimen.hh
@@ -0,0 +1,12 @@
+#ifndef DIMEN_HH
+#define DIMEN_HH
+
+#include "real.hh"
+#include "string.hh"
+
+Real parse_dimen(String);
+Real convert_dimen(Real, String);
+String print_dimen(Real);
+
+#endif
+
diff --git a/dimen.tex b/dimen.tex
index 0be3eca9a8..7665eb3379 100644
--- a/dimen.tex
+++ b/dimen.tex
@@ -34,16 +34,11 @@
\hbox to 50pt{\qquad\twhrul\mb{#1}\hss}\setbox0=\hbox{\mb{#1}} width \the\wd0\ depth \the\dp0 \ height \the\ht0}
\newcount\n
-\def\charn{\n=0
+\def\charn{\n=-1
\loop\ifnum\n<255\advance\n by1
\doitem{\number\n}\endgraf\repeat}
\charn
-
-
-
-
-
\bye \ No newline at end of file
diff --git a/flower/Makefile b/flower/Makefile
index aff8ac8f14..4533783563 100644
--- a/flower/Makefile
+++ b/flower/Makefile
@@ -1,6 +1,6 @@
MAJVER=1
MINVER=0
-PATCHLEVEL=3
+PATCHLEVEL=4
PACKAGENAME=flower
VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
diff --git a/flower/Sources.make b/flower/Sources.make
index 6521100b3b..fd5dcf4146 100644
--- a/flower/Sources.make
+++ b/flower/Sources.make
@@ -1,12 +1,12 @@
cc=lgetopt.cc string.cc dataf.cc textdb.cc unionfind.cc \
smat.cc matrix.cc choleski.cc vector.cc dstream.cc\
- matdebug.cc
+ matdebug.cc
-templatecc=cursor.cc list.cc tsmat.cc
-inl=findcurs.inl link.inl list.inl
-hh=cursor.hh pcursor.hh cursor.inl lgetopt.hh link.hh list.hh dstream.hh \
+templatecc=cursor.cc list.cc tsmat.cc plist.cc
+inl=findcurs.inl link.inl list.inl plist.inl cursor.inl
+hh=cursor.hh pcursor.hh lgetopt.hh link.hh list.hh dstream.hh \
string.hh stringutil.hh vray.hh textdb.hh textstr.hh assoc.hh\
findcurs.hh unionfind.hh compare.hh handle.hh matrix.hh\
smat.hh vsmat.hh vector.hh real.hh choleski.hh\
- tsmat.hh tvsmat.hh
+ tsmat.hh tvsmat.hh plist.hh\
diff --git a/flower/TODO b/flower/TODO
index 8d6e50591d..6f0f451cce 100644
--- a/flower/TODO
+++ b/flower/TODO
@@ -1,4 +1,6 @@
+ * efficient copy cons for List
+
* change String::pos
s[s.pos('%')] == '%'
diff --git a/flower/cursor.hh b/flower/cursor.hh
index cff93c68ce..1c61b1a76c 100644
--- a/flower/cursor.hh
+++ b/flower/cursor.hh
@@ -11,7 +11,10 @@ template<class T>
class Cursor
{
public:
- Cursor( List<T>& list, Link<T>* pointer = 0 );
+ Cursor( const List<T>& list, Link<T>* pointer = 0 );
+ /** this isn't true, actually, #list# surely isn't const, but I get
+ tired of the warning messages. */
+
Cursor( const Cursor<T>& cursor );
/// return current T
@@ -100,17 +103,8 @@ private:
/*
- comparations.
+ comparisons.
*/
-
-
-
-
-
-
-
-
-
#include "compare.hh"
template<class T>
diff --git a/flower/cursor.inl b/flower/cursor.inl
index a4e03492b5..bdc242590f 100644
--- a/flower/cursor.inl
+++ b/flower/cursor.inl
@@ -6,12 +6,11 @@
template<class T>
inline
-Cursor<T>::Cursor( List<T>& list, Link<T>* pointer ) :
- list_( list )
+Cursor<T>::Cursor( const List<T>& list, Link<T>* pointer ) :
+ list_((List<T>&) list )
{
if ( list.size() )
pointer_ = pointer ? pointer : list.top_;
- //list.top().pointer_; // ARGH! recursion.
else
pointer_ = pointer;
}
diff --git a/flower/dataf.cc b/flower/dataf.cc
index e53c716d8b..d050e278c5 100644
--- a/flower/dataf.cc
+++ b/flower/dataf.cc
@@ -110,16 +110,14 @@ String Data_file::get_line()
void
Data_file::gobble_leading_white()
{
- char c;
-
// eat blank lines.
- while (!eof())
- {
- c = data_get();
- if (!isspace(c))
+ while (!eof()) {
+ char c = data_get();
+ if (!isspace(c)) {
+ data_unget(c);
break;
}
- data_unget(c);
+ }
}
diff --git a/flower/list.cc b/flower/list.cc
index 782b3da86e..741e4ee97c 100644
--- a/flower/list.cc
+++ b/flower/list.cc
@@ -4,6 +4,15 @@
#include "list.hh"
template<class T>
+List<T>::List(List const&src)
+{
+ set_empty();
+ // probably el stupido
+ for (Cursor<T> c(src); c.ok(); c++)
+ bottom().add(c);
+}
+
+template<class T>
void
List<T>::OK() const
{
@@ -29,7 +38,7 @@ template<class T>
Cursor<T>
List<T>::top()
{
-
+#if 0
// ?? waarvoor is deze if ?
if ( top_ ) // equivalent: if ( size_ )
{
@@ -42,7 +51,9 @@ List<T>::top()
t = top_->previous();
}
}
- // list empty: Cursor not ok()
+#endif
+
+// list empty: Cursor not ok()
return Cursor<T>( *this, top_ );
}
@@ -70,20 +81,4 @@ List<T>::bottom()
}
-// not inlined since it assumes knowledge of destructor.
-template<class T>
-inline void
-PointerList<T>::remove( Cursor<T> me )
-{
- if ( me.ok() )
- {
-
- delete *me;
- List<T>::remove( me );
- }
-}
-
-
-
-
#endif
diff --git a/flower/list.hh b/flower/list.hh
index a45252b8c3..6edf4aebc4 100644
--- a/flower/list.hh
+++ b/flower/list.hh
@@ -11,10 +11,12 @@ template<class T> class Link;
template<class T>
class List
{
- public:
- /// construct empty list
- List();
+ List(List const&src);
+ public:
+ /// construct empty list
+ List();
+
/// construct list from first item.
List( const T& thing );
@@ -28,6 +30,11 @@ class List
protected:
friend class Cursor<T>;
friend class Link<T>;
+ /// make *this empty
+ void set_empty();
+ /**
+ WARNING: contents lost, and not deleted.
+ */
/// add after after_me
void add( const T& thing, Cursor<T> after_me );
@@ -67,32 +74,13 @@ class List
*/
-/// Use for list of pointers, e.g. PointerList<AbstractType*>.
-template<class T>
-class PointerList : public List<T>
-{
- public:
- PointerList();
- PointerList( const T& thing );
-
- ///
- virtual ~PointerList();
- /**
- This function deletes deletes the allocated pointers of all links.
- #\Ref{~List}# is used to delete the links themselves.
- */
-
- protected:
- virtual void remove( Cursor<T> me );
-};
-
#include "list.inl"
#include "cursor.hh"
// instantiate a template: explicit instantiation.
#define L_instantiate(a) template class List<a>; template class Cursor<a>; \
template class Link<a>
-#define PL_instantiate(a) L_instantiate(a *); template class PointerList<a*>
+
#endif // __LIST_HH //
diff --git a/flower/list.inl b/flower/list.inl
index 8396156b6a..8bdcf15877 100644
--- a/flower/list.inl
+++ b/flower/list.inl
@@ -5,6 +5,13 @@ template<class T>
inline
List<T>::List()
{
+ set_empty();
+}
+
+template<class T>
+inline void
+List<T>::set_empty()
+{
top_ = bottom_ = 0;
size_ = 0;
}
@@ -13,8 +20,7 @@ template<class T>
inline
List<T>::List( const T& thing )
{
- top_ = bottom_ = 0;
- size_ = 0;
+ set_empty();
add( thing, Cursor<T>( *this, bottom_ ) );
}
@@ -113,40 +119,6 @@ List<T>::size() const
return size_;
}
-template<class T>
-inline
-PointerList<T>::PointerList() :
- List<T>()
-{
-}
-
-template<class T>
-inline
-PointerList<T>::PointerList( const T& thing ) :
- List<T>( thing )
-{
-}
-
-template<class T>
-inline
-PointerList<T>::~PointerList()
-{
- Cursor<T> next(*this);
- for ( Cursor<T> c( *this ); c.ok(); c = next ) {
- next = c;
- next++;
- remove( c ); // PointerList::remove deletes the real data
- }
-}
-
-template<class T>
-inline void
-PointerList_print( PointerList<T> const & l )
-{
- List<T>& promises_to_be_const = (List<T>&) l;
- for ( Cursor<T> c( promises_to_be_const ); c.ok(); c++ )
- (*c)->print();
-}
#endif
diff --git a/flower/matdebug.cc b/flower/matdebug.cc
index 5a31312386..1c3df9dda1 100644
--- a/flower/matdebug.cc
+++ b/flower/matdebug.cc
@@ -34,10 +34,9 @@ Matrix::print() const
Vector::operator String() const
{
- int i=0;
String s("vector [");
#ifndef NDEBUG
- for (; i < dim(); i++) {
+ for (int i=0; i < dim(); i++) {
s += String(dat[i], "%6f") + ' ';
}
#endif
diff --git a/flower/pcursor.hh b/flower/pcursor.hh
index 8b0b179b4f..eb0e8f15f9 100644
--- a/flower/pcursor.hh
+++ b/flower/pcursor.hh
@@ -1,4 +1,13 @@
+/*
+ pcursor.hh -- part of flowerlib
+
+ (c) 1996 Han-Wen Nienhuys&Jan Nieuwenhuizen
+*/
+
+#ifndef PCURSOR_HH
+#define PCURSOR_HH
+
/// cursor which feels like a pointer
template<class T>
@@ -13,14 +22,15 @@ struct PCursor : public Cursor<T> {
PCursor<T> operator +( int no) const {
return PCursor<T> (Cursor<T>::operator+(no));
}
- PCursor(List<T> & l) : Cursor<T> (l) {}
+ PCursor(const List<T> & l) : Cursor<T> (l) {}
PCursor( const Cursor<T>& cursor ) : Cursor<T>(cursor) { }
T operator ->() { return *(*this); }
};
/**
- HWN: I'd like an operator->(), so here it is.
+ I like operator->(), so here it is.
Cursor to go with pointer list.
*/
+#endif
diff --git a/flower/plist.cc b/flower/plist.cc
new file mode 100644
index 0000000000..bbb0e7428f
--- /dev/null
+++ b/flower/plist.cc
@@ -0,0 +1,16 @@
+#include "plist.hh"
+
+// not inlined since it assumes knowledge of destructor.
+template<class T>
+void
+PointerList<T>::remove( Cursor<T> me )
+{
+ if ( me.ok() ) {
+ delete *me;
+ List<T>::remove( me );
+ }
+}
+
+
+
+
diff --git a/flower/stringutil.hh b/flower/stringutil.hh
index fe0b8e307b..d7f7081617 100644
--- a/flower/stringutil.hh
+++ b/flower/stringutil.hh
@@ -6,11 +6,12 @@
#define NDEBUG BLONDE
#endif
+const INITIALMAX=8;
class String_handle;
/// Internal String struct
class StringData {
// GNU malloc: storage overhead is 8 bytes anyway.
- const int INITIALMAX =8; // how to do this in ANSI C++ ?
+
friend class String_handle;
int maxlen; // maxlen is arraysize-1
@@ -156,6 +157,7 @@ friend class String_handle;
the data itself. Handles simple tasks (resizing, resetting)
*/
+
/****************************************************************/
/// ref. counting for strings
class String_handle {
diff --git a/genheader b/genheader
new file mode 100755
index 0000000000..739df26c47
--- /dev/null
+++ b/genheader
@@ -0,0 +1,16 @@
+#!/bin/sh
+def=`echo $1 | sed s/\\\./_/ | tr a-z A-Z`
+cat << HERE
+/*
+ $1 -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef $def
+#define $def
+
+
+#endif // $def
+
+HERE
diff --git a/item.cc b/item.cc
index 72f447be94..453200627b 100644
--- a/item.cc
+++ b/item.cc
@@ -1,13 +1,14 @@
#include "line.hh"
#include "symbol.hh"
-#include "cols.hh"
+#include "molecule.hh"
+#include "pcol.hh"
String
Spanner::TeXstring() const
{
assert(right->line);
Real w = left->hpos - right->hpos;
- return (*strets)(w);
+ return strets->eval(w).tex;
}
Spanner *
diff --git a/item.hh b/item.hh
index 28b6b5604c..6a3a9880d7 100644
--- a/item.hh
+++ b/item.hh
@@ -9,7 +9,7 @@
/// a symbol which is attached between two columns.
struct Spanner {
const PCol *left, *right;
- Stretchable_symbol *strets;
+ Parametric_symbol *strets;
PStaff * pstaff_;
/// clone a piece of this spanner.
Spanner *broken_at(const PCol *c1, const PCol *c2) const;
@@ -33,7 +33,7 @@ struct Item {
virtual Interval width() const;
virtual Interval height() const;
const PCol * col;
- Output *output;
+ Molecule *output;
PStaff *pstaff_;
/** needed for knowing at which staff to output this item
diff --git a/lexer.l b/lexer.l
index a0da226a99..03853ca579 100644
--- a/lexer.l
+++ b/lexer.l
@@ -193,4 +193,4 @@ yyerror(char *s)
return NOTENAME;
}
-#endif \ No newline at end of file
+#endif
diff --git a/lilyponddefs.tex b/lilyponddefs.tex
index 46da68d7fb..242a17d5f4 100644
--- a/lilyponddefs.tex
+++ b/lilyponddefs.tex
@@ -1,5 +1,3 @@
-
-
\def\musixtwentydefs{
\font\musicfnt=musix20
@@ -8,13 +6,9 @@
%\balkskip4pt
}
\def\interstaffline{
-% \vskip 20pt%
-}
-\def\interscoreline{
- \par\vskip 10pt\par
- \hrule height 2pt width2cm
- \vskip 10pt
+ \vskip 20pt%
}
+
\musixtwentydefs
\def\mdef#1#2{\def#1{{\musicfnt\char#2}}}
\mdef\quartball{'007}
@@ -32,11 +26,28 @@
\mdef\singledot{'00}
\mdef\doubledot{'01}
\mdef\tripledot{'02}
-\def\maatstreep{\vrule height10pt }
-\def\finishbar{\vrule height10pt width 1pt}
+\def\maatstreep{\vrule height8pt depth8pt }
+\def\finishbar{\vrule height8pt width 1pt depth8pt}
\parindent0pt
+\def\generalmeter#1#2{\vbox to 0pt{\vss\rm\hbox{#1}\hbox{#2}\vss}}
+
+\mdef\mussepline{155}
+\def\lineseparator{\vbox{\mussepline\vskip -5pt\mussepline}}
+\def\interscoreline{
+ \par\vskip 10pt\par
+ \hskip -5pt\lineseparator% \hbox to 1cm{\kern -5mm\hrulefill}
+ \vskip 10pt
+}
+
+\newcount\n
+\def\linestafsym#1#2{\hbox to 0pt{\vbox to 0pt{\n=0%
+ \loop\ifnum\n<#1\advance\n by1
+ \ifnum\n>1\vskip2pt\fi \hrule width#2\repeat\vss}\hss}}
+
\def\vcenter#1{\vbox to 0pt{\vss #1\vss}}
\def\cquartrest{\vcenter\quartrest}
-
+\def\ceighthrest{\vcenter\eighthrest}
+\def\csixteenthrest{\vcenter\sixteenthrest}
+\def\cthirtysecondrest{\vcenter\thirtysecondrest} \ No newline at end of file
diff --git a/line.cc b/line.cc
index d0a5d794bb..ebe9595d3b 100644
--- a/line.cc
+++ b/line.cc
@@ -1,21 +1,23 @@
#include "line.hh"
+#include "dimen.hh"
#include "symbol.hh"
-#include "cols.hh"
+#include "pcol.hh"
#include "pscore.hh"
String
Line_of_staff::TeXstring() const
{
String s("%line_of_staff\n\\vbox to ");
- s += String(maxheight() * VERT_TO_PT) +"pt{";
+ s += print_dimen(maxheight() ) +"{";
//make some room
- s += vstrut(base* VERT_TO_PT);
+ s += vstrut(base);
// the staff itself: eg lines, accolades
s += "\\hbox{";
{
- s+=(*pstaff_->stafsym)(scor->score->linewidth);
+ Symbol sym = pstaff_->get_stafsym(scor->score->linewidth);
+ s+=sym.tex;
PCursor<const PCol *> cc(scor->cols);
Real lastpos=cc->hpos;
@@ -25,7 +27,7 @@ Line_of_staff::TeXstring() const
lastpos = cc->hpos;
// moveover
- s +=String( "\\kern ") + HOR_TO_PT*delta + "pt ";
+ s +=String( "\\kern ") + print_dimen(delta);
// now output the items.
@@ -102,7 +104,10 @@ Real
Line_of_staff::maxheight() const
{
Interval y;
- y = pstaff_->stafsym->height(scor->score->linewidth);
+ {
+ Symbol s = pstaff_->stafsym->eval(scor->score->linewidth);
+ y = s.dim.y;
+ }
PCursor<const PCol *> cc(scor->cols);
// all items in the current line & staff.
diff --git a/linespace.cc b/linespace.cc
index 402bd4074e..17c16ef4ef 100644
--- a/linespace.cc
+++ b/linespace.cc
@@ -143,7 +143,7 @@ Spacing_problem::make_matrices(Matrix &quad, Vector &lin, Real &c) const
// put the constraints into the LP problem
void
-Spacing_problem::make_constraints(Optimisation_problem& lp) const
+Spacing_problem::make_constraints(Mixed_qp& lp) const
{
int dim=cols.sz();
for (int j=0; j < dim; j++) {
@@ -172,7 +172,7 @@ Spacing_problem::solve() const
/* optimalisatiefunctie */
- Optimisation_problem lp(cols.sz());
+ Mixed_qp lp(cols.sz());
make_matrices(lp.quad,lp.lin, lp.const_term);
make_constraints(lp);
Vector start=find_initial_solution();
@@ -196,6 +196,7 @@ Spacing_problem::add_column(const PCol *col, bool fixed, Real fixpos)
Colinfo c;
c.fixed=fixed;
c.fixpos=fixpos;
+ assert(col);
c.col=col;
cols.add(c);
}
@@ -219,15 +220,14 @@ Spacing_problem::print_ideal(const Idealspacing*id)const
int l = col_id(id->left);
int r = col_id(id->right);
- mtor << "idealspacing { between " << l <<","<<r<<'\n';
- mtor << "distance "<<id->space<< " strength " << id->hooke << "}\n";
+ mtor << "between " << l <<","<<r<<":" ;
#endif
}
void
Spacing_problem::print() const
{
- #ifndef NPRINT
+#ifndef NPRINT
for (int i=0; i < cols.sz(); i++) {
mtor << "col " << i<<' ';
cols[i].print();
@@ -235,7 +235,7 @@ Spacing_problem::print() const
for (int i=0; i < ideals.sz(); i++) {
print_ideal(ideals[i]);
}
- #endif
+#endif
}
@@ -246,9 +246,14 @@ Colinfo::print() const
mtor << "column { ";
if (fixed)
mtor << "fixed at " << fixpos<<", ";
+ assert(col);
mtor << "[" << minleft() << ", " << minright() << "]";
mtor <<"}\n";
#endif
}
-
+Colinfo::Colinfo()
+{
+ fixed=false;
+ col=0;
+}
diff --git a/linespace.hh b/linespace.hh
index 5a3c4edeb8..e5b23ca7f0 100644
--- a/linespace.hh
+++ b/linespace.hh
@@ -4,7 +4,7 @@
#include "glob.hh"
#include "list.hh"
#include "vray.hh"
-#include "cols.hh"
+#include "pcol.hh"
#include "matrix.hh"
/// helper struct for #Spacing_problem#
@@ -12,10 +12,7 @@ struct Colinfo {
const PCol *col;
bool fixed;
Real fixpos;
- Colinfo() {
- fixed=false;
- col=0;
- }
+ Colinfo();
void print() const;
Real minright()const { return col->width().max; }
Real minleft()const { return -col->width().min; }
@@ -42,7 +39,7 @@ class Spacing_problem {
void make_matrices(Matrix &quad, Vector &lin,Real&) const;
/// generate the LP constraints
- void make_constraints(Optimisation_problem& lp) const;
+ void make_constraints(Mixed_qp& lp) const;
public:
/// solve the spacing problem
diff --git a/linestaff.cc b/linestaff.cc
index f2dd43b2b5..dd9227b155 100644
--- a/linestaff.cc
+++ b/linestaff.cc
@@ -1,11 +1,17 @@
#include "linestaff.hh"
#include "symbol.hh"
-
-
+#include "lookupsyms.hh"
+#include "dimen.hh"
Linestaff::Linestaff(int l)
{
nolines = l;
- stafsym = Stretchable_symbol::get_linestaff(l);
+ stafsym = Lookup::linestaff(l);
}
+Symbol
+Linestaff::get_stafsym(Real width)const
+{
+ String w(print_dimen(width));
+ return stafsym->eval(w);
+}
diff --git a/linestaff.hh b/linestaff.hh
index 7ca34f5739..33e9d39f4e 100644
--- a/linestaff.hh
+++ b/linestaff.hh
@@ -1,8 +1,10 @@
#include "pstaff.hh"
struct Linestaff : PStaff {
- int nolines;
+ int nolines;
+
+ Symbol get_stafsym(Real width)const;
Linestaff(int);
};
diff --git a/lookupsyms.cc b/lookupsyms.cc
new file mode 100644
index 0000000000..66cbd6db08
--- /dev/null
+++ b/lookupsyms.cc
@@ -0,0 +1,91 @@
+#include "lookupsyms.hh"
+#include "debug.hh"
+#include "symtable.hh"
+#include "dimen.hh"
+#include "tex.hh"
+
+Symtables the_sym_tables("symbol.ini");
+
+Symbol
+Lookup::ball(int j)
+{
+ if (j > 4) j = 4;
+ Symtable * st = the_sym_tables("balls");
+ return st->lookup(String(j));
+}
+
+Symbol
+Lookup::rest(int j)
+{
+ return the_sym_tables("rests")->lookup(String(j));
+}
+
+
+ Symbol
+Lookup::bar(String s)
+{
+ return the_sym_tables("bars")->lookup(s);
+}
+ Symbol
+Lookup::dots(int j)
+{
+ if (j>3)
+ error("max 3 dots");
+ return the_sym_tables("dots")->lookup(j);
+}
+
+/****************************************************************/
+// bare bones.
+
+struct Linestaf_symbol : Parametric_symbol {
+ int lines;
+ Linestaf_symbol(int n) { lines = n;}
+ Symbol eval(svec<String>)const;
+};
+
+
+Symbol
+Linestaf_symbol::eval(svec<String> w)const
+{
+ Real wid = w[0].fvalue();
+
+ Symbol s;
+ s.dim.x = Interval(0,wid);
+ s.dim.y = Interval(0, lines*convert_dimen(5,"pt"));
+ svec<String> a;
+ a.add(lines);
+ a.add(w[0]);
+ s.tex = the_sym_tables("param")->lookup("linestaf").tex;
+ s.tex = substitute_args(s.tex, a);
+ return s;
+}
+
+/****************************************************************
+ */
+
+
+struct Meter_sym:Parametric_symbol {
+
+ Symbol eval(svec<String> a) const{
+ Symbol s;
+ s.dim.x = Interval(0, convert_dimen(10,"pt"));
+ s.dim.y = Interval(0, convert_dimen(10,"pt") );
+ String src = the_sym_tables("param")->lookup("meter").tex;
+ s.tex = substitute_args(src,a);
+ return s;
+ }
+};
+/****************************************************************/
+
+Parametric_symbol *
+Lookup::meter(String )
+{
+ return new Meter_sym;
+}
+
+Parametric_symbol *
+Lookup::linestaff(int n)
+{
+ return new Linestaf_symbol(n);
+}
+
diff --git a/lookupsyms.hh b/lookupsyms.hh
new file mode 100644
index 0000000000..d4e08667db
--- /dev/null
+++ b/lookupsyms.hh
@@ -0,0 +1,18 @@
+/*
+ lilypond, (c) 1996 Han-Wen Nienhuys
+*/
+#ifndef LOOKUPSYMS_HH
+#define LOOKUPSYMS_HH
+
+#include "symbol.hh"
+
+struct Lookup {
+ static Parametric_symbol *linestaff(int n);
+ static Parametric_symbol *meter(String);
+ static Symbol ball(int);
+ static Symbol rest(int);
+ static Symbol bar(String);
+ static Symbol dots(int);
+};
+
+#endif
diff --git a/maartje.ly b/maartje.ly
index a0711079af..49665efd4d 100644
--- a/maartje.ly
+++ b/maartje.ly
@@ -7,13 +7,16 @@ score {
voice { $ c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 $ }
}
rhythmstaff {
- voice { $ c4 r4 c4 r4 c4 r4 c4 r4 c4 r4 c4 r4 c4 r4 c4 r4
+ voice { $ c2.. r8 c4 r4 c4 r4 c4 r4 c4 r4 c4 r4 c4 r4 c4 r4
r2 r4 r1
$ }
}
-bar 0.5
+
bar 2 bar 3
bar 4.5 bar 5 bar 5.5
bar 6 bar 7 bar 8
+
+ meter 2 4 4 % after bars.
+
}
diff --git a/main.cc b/main.cc
index 2145331565..5e518752cf 100644
--- a/main.cc
+++ b/main.cc
@@ -17,25 +17,24 @@ long_option_init theopts[] = {
void notice()
{
cout <<
- "LilyPond, a music typesetter.
-Copyright (C) 1996 by
- Han-Wen Nienhuys <hanwen@stack.urc.tue.nl>
-
-
- This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License version 2
-as published by the Free Software Foundation.
-
- This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-General Public License for more details.
-
- You should have received a copy (refer to the file COPYING) of the
-GNU General Public License along with this program; if not, write to
-the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
-USA.
-"
+ "LilyPond, a music typesetter.\n"
+ "Copyright (C) 1996 by\n"
+ " Han-Wen Nienhuys <hanwen@stack.urc.tue.nl>\n"
+ "\n"
+ "\n"
+ " This program is free software; you can redistribute it and/or\n"
+ "modify it under the terms of the GNU General Public License version 2\n"
+ "as published by the Free Software Foundation.\n"
+ "\n"
+ " This program is distributed in the hope that it will be useful,\n"
+ "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
+ "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n"
+ "General Public License for more details.\n"
+ "\n"
+ " You should have received a copy (refer to the file COPYING) of the\n"
+ "GNU General Public License along with this program; if not, write to\n"
+ "the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,\n"
+ "USA.\n";
}
int
diff --git a/main.hh b/main.hh
index 264ac3aa78..58928f5142 100644
--- a/main.hh
+++ b/main.hh
@@ -1,8 +1,11 @@
#ifndef MAIN_HH
#define MAIN_HH
#include "proto.hh"
+
void debug_init();
void do_scores();
void add_score(Score * s);
void set_default_output(String s);
+const char *get_version();
+
#endif
diff --git a/make_patch b/make_patch
index 80548815df..08f4936b56 100755
--- a/make_patch
+++ b/make_patch
@@ -25,7 +25,7 @@ then
tar zfxv $nm$old.tar.gz
fi
-(cd $nm$old; make clean)
-(cd $nm$new; make clean)
+#(cd $nm$old; touch depend; make clean)
+#(cd $nm$new; touch depend; make clean)
(cd $nm$new; diff -P -c ../$nm$old . > ../patch-$new)
rm -rf $nm$old
diff --git a/misc.cc b/misc.cc
index effab35896..2be0f81dd6 100644
--- a/misc.cc
+++ b/misc.cc
@@ -26,10 +26,10 @@ const double WHOLE_SPACE = 5.0; // should be settable from input
Real
-duration_to_idealspace(Mtime d)
+duration_to_idealspace(Mtime d, Real w)
{
// see Roelofs, p. 57
- return WHOLE_SPACE * pow(ENGRAVERS_SPACE, log2(d));
+ return w * pow(ENGRAVERS_SPACE, log2(d));
}
diff --git a/misc.hh b/misc.hh
index fb8889f551..a22304267f 100644
--- a/misc.hh
+++ b/misc.hh
@@ -1,8 +1,7 @@
#ifndef MISC_HH
#define MISC_HH
#include "mtime.hh"
-int intlog2(int d);
-Real duration_to_idealspace(Mtime d);
-class String;
-const char *get_version();
+int intlog2(int d);
+Real duration_to_idealspace(Mtime d,Real w);
+
#endif
diff --git a/molecule.cc b/molecule.cc
index e1c4ac5f8d..7b8a752423 100644
--- a/molecule.cc
+++ b/molecule.cc
@@ -1,4 +1,5 @@
#include "glob.hh"
+#include "dimen.hh"
#include "string.hh"
#include "molecule.hh"
#include "symbol.hh"
@@ -6,24 +7,25 @@
Box
Atom::extent() const
{
- Box b( sym->dim);
+ Box b( sym.dim);
b.translate(off);
return b;
}
-Atom::Atom(const Symbol * s)
+Atom::Atom(Symbol s)
{
sym=s;
}
+
String
Atom::TeXstring() const
{
// whugh.. Hard coded...
String s("\\raise");
- s+= String(off.y * VERT_TO_PT)+"pt\\hbox to 0pt{\\kern ";
- s+= String(off.x * HOR_TO_PT) + "pt";
- s+= sym->tex + "\\hss}";
+ s+= print_dimen(off.y) +"\\hbox to 0pt{\\kern ";
+ s+= print_dimen(off.x);
+ s+= sym.tex + "\\hss}";
return s;
}
@@ -33,8 +35,8 @@ String
Molecule::TeXstring() const
{
String s;
- for(Cursor<Atom> c(ats); c.ok(); c++)
- s+=(*c).TeXstring();
+ for(PCursor<Atom*> c(ats); c.ok(); c++)
+ s+=c->TeXstring();
return s;
}
@@ -42,24 +44,23 @@ Box
Molecule::extent() const
{
Box b;
- for(Cursor<Atom> c(ats); c.ok(); c++)
- b.unite((*c).extent());
+ for(PCursor<Atom*> c(ats); c.ok(); c++)
+ b.unite(c->extent());
return b;
}
void
Molecule::translate(Offset o)
{
- for(Cursor<Atom> c(ats); c.ok(); c++)
- (*c).translate(o);
+ for (PCursor<Atom*> c(ats); c.ok(); c++)
+ c->translate(o);
}
void
Molecule::add(const Molecule &m)
{
- for (Cursor<Atom> c(m.ats); c.ok(); c++) {
- Atom a(c);
- ats.bottom().add(a);
+ for (PCursor<Atom*> c(m.ats); c.ok(); c++) {
+ add(**c);
}
}
@@ -78,7 +79,7 @@ Molecule::add_left(const Molecule &m)
Real xof=extent().x.min - m.extent().x.max;
Molecule toadd(m);
toadd.translate(Offset(xof, 0.0));
- add(toadd);
+ add(toadd);
}
@@ -88,7 +89,7 @@ Molecule::add_top(const Molecule &m)
Real yof=extent().y.max - m.extent().y.min;
Molecule toadd(m);
toadd.translate(Offset(0,yof));
- add(toadd);
+ add(toadd);
}
void
@@ -100,3 +101,13 @@ Molecule::add_bot(const Molecule &m)
add(toadd);
}
+void
+Molecule::operator = (const Molecule&)
+{
+ assert(false);
+}
+
+Molecule::Molecule(const Molecule&s)
+{
+ add(s);
+}
diff --git a/molecule.hh b/molecule.hh
index 6709b73750..60a7a05f44 100644
--- a/molecule.hh
+++ b/molecule.hh
@@ -4,11 +4,11 @@
#include "list.hh"
#include "boxes.hh"
#include "item.hh"
-
+#include "symbol.hh"
/// a symbol which can be translated, and freely copied
struct Atom {
Offset off;
- const Symbol * sym;
+ Symbol sym;
void translate(Offset o) {
off += o;
@@ -16,28 +16,34 @@ struct Atom {
/// how big is #this#?
Box extent() const;
- Atom(const Symbol*s);
+ Atom(Symbol s);
+
+
String TeXstring() const;
};
/// a group of #Atom#s
-struct Molecule : Output {
- List<Atom> ats;
+struct Molecule {
+ PointerList<Atom*> ats;
Molecule() { }
- Molecule(Atom a) { ats.bottom().add(a); }
- // Molecule(Molecule const&src);
+ Molecule(Atom a) { add(a) ; }
+
void add_right(const Molecule &m);
void add_left(const Molecule &m);
void add_top(const Molecule &m);
void add_bot(const Molecule &m);
void add(Molecule const &m);
void translate(Offset);
-
+ void add(Atom a) { ats.bottom().add(new Atom(a)); }
/// how big is #this#?
Box extent() const;
String TeXstring() const;
+
+ Molecule(const Molecule&s);
+private:
+ void operator=(const Molecule&);
};
/** a group of individually translated symbols. You can add molecules
to the top, to the right, etc. */
diff --git a/mtime.hh b/mtime.hh
index f42c87b82d..ef01d2314b 100644
--- a/mtime.hh
+++ b/mtime.hh
@@ -5,4 +5,4 @@
typedef Real Mtime;
-#endif MTIME_HH
+#endif
diff --git a/note.cc b/note.cc
index c51e3c33af..2307729a3c 100644
--- a/note.cc
+++ b/note.cc
@@ -111,7 +111,7 @@ get_note_element(String pitch, String durstr)
}
Voice_element *
-get_rest_element(String type, String durstr)
+get_rest_element(String, String durstr)
{
Voice_element*v = new Voice_element;
int i=0;
diff --git a/paper.cc b/paper.cc
new file mode 100644
index 0000000000..5afee7d56f
--- /dev/null
+++ b/paper.cc
@@ -0,0 +1,8 @@
+#include "paper.hh"
+#include "dimen.hh"
+
+Paperdef::Paperdef()
+{
+ width = convert_dimen(15,"cm"); // in cm for now
+ whole_width= convert_dimen(5,"cm");
+}
diff --git a/paper.hh b/paper.hh
new file mode 100644
index 0000000000..b48391a4b9
--- /dev/null
+++ b/paper.hh
@@ -0,0 +1,13 @@
+
+
+#include "real.hh"
+#include "string.hh"
+struct Paperdef {
+ Paperdef();
+ String outfile;
+ Real width;
+ /// how much space does a whole note take (ideally?)
+ Real whole_width;
+ // maybe add pointsize?
+ // symbol init?
+};
diff --git a/parseconstruct.hh b/parseconstruct.hh
index 820499cb36..fa9f62757d 100644
--- a/parseconstruct.hh
+++ b/parseconstruct.hh
@@ -5,3 +5,4 @@ Staff * get_new_rhythmstaff();
Voice_element * get_note_element(String,String);
Voice_element* get_rest_element(String,String);
Command * get_bar_command(Real);
+Command* get_meter_command(Real, int,int);
diff --git a/parser.y b/parser.y
index cb0853b340..d60face970 100644
--- a/parser.y
+++ b/parser.y
@@ -2,20 +2,23 @@
#include <iostream.h>
#include "lexer.hh"
+#include "paper.hh"
#include "staff.hh"
#include "score.hh"
#include "main.hh"
#include "keyword.hh"
#include "debug.hh"
#include "parseconstruct.hh"
-#define YYDEBUG 1
+#include "dimen.hh"
+#ifndef NDEBUG
+#define YYDEBUG 1
+#endif
%}
-%union {
- int i;
+%union {
Real real;
Command *command;
Identifier *id;
@@ -24,22 +27,30 @@
Voice_element *el;
Staff *staff;
String *string;
- Score *score;
+ Score *score;
+ const char *consstr;
+ Paperdef *paper;
+ int i;
}
%token VOICE STAFF SCORE TITLE RHYTHMSTAFF BAR NOTENAME OUTPUT
+%token CM IN PT MM PAPER WIDTH METER
-
+%type <consstr> unit
%token <id> IDENTIFIER
%token <string> PITCH DURATION RESTNAME
%token <real> REAL
%token <string> STRING
+%type <paper> paper_block paper_body
+%type <real> dim
%type <voice> voice_block voice_body voice_elts voice_elts_dollar
%type <el> voice_elt
%type <command> score_command
%type <score> score_block score_body
%type <staff> staff_block rhythmstaff_block rhythmstaff_body
+%type <i> int
+
%%
@@ -56,11 +67,35 @@ score_block: SCORE '{' score_body '}' { $$ = $3; }
score_body: { $$ = new Score; }
| score_body staff_block { $$->add($2); }
| score_body score_command { $$->add($2); }
- | score_body OUTPUT STRING { $$->outfile = *$3;
+ | score_body paper_block { delete $$->paper;
+ $$->paper = $2;
+ }
+ ;
+
+paper_block:
+ PAPER '{' paper_body '}' { $$ = $3; }
+ ;
+
+paper_body:
+ /* empty */ { $$ = new Paperdef; }
+ | paper_body WIDTH dim { $$->width = $3;}
+ | paper_body OUTPUT STRING { $$->outfile = *$3;
delete $3;
}
;
+dim:
+ REAL unit { $$ = convert_dimen($1,$2); }
+ ;
+
+
+unit: CM { $$ = "cm"; }
+ |IN { $$ = "in"; }
+ |MM { $$ = "mm"; }
+ |PT { $$ = "pt"; }
+ ;
+
+
staff_block:
rhythmstaff_block
;
@@ -110,6 +145,18 @@ score_command:
BAR REAL {
$$ = get_bar_command($2);
}
+ | METER REAL int int {
+ $$ = get_meter_command($2, $3, $4);
+ }
+ ;
+
+int:
+ REAL {
+ $$ = int($1);
+ if (ABS($1-Real(int($$))) > 1e-8)
+ yyerror("expecting integer number");
+
+ }
;
%%
@@ -118,7 +165,9 @@ void
parse_file(String s)
{
*mlog << "Parsing ... ";
+#ifdef YYDEBUG
yydebug = !monitor.silence("Parser");
+#endif
new_input(s);
yyparse();
}
diff --git a/cols.cc b/pcol.cc
index 0de683cc55..44c82a938d 100644
--- a/cols.cc
+++ b/pcol.cc
@@ -1,5 +1,15 @@
-#include "cols.hh"
+#include "pcol.hh"
#include "pstaff.hh"
+#include "debug.hh"
+
+void
+Idealspacing::print() const
+{
+ #ifndef NPRINT
+ mtor << "idealspacing {" ;
+ mtor << "distance "<<space<< " strength " << hooke << "}\n";
+ #endif
+}
Idealspacing::Idealspacing(const PCol * l,const PCol * r)
{
@@ -16,6 +26,8 @@ Idealspacing::OK() const
#endif
}
+/****************************************************************/
+
Interval
PCol::width() const
{
@@ -27,10 +39,21 @@ PCol::width() const
w.unite(Interval(0,0));
return w;
}
-/****************************************************************/
+
+void
+PCol::print() const
+{
+ #ifndef NPRINT
+ mtor << "PCol {";
+ mtor << "# symbols: " << its.size() ;
+ mtor << "breakable: " << breakable<<"\n";
+ mtor << "extent: " << width().min << ", " << width().max << "\n";
+ mtor << "}\n";
+ #endif
+}
int
-PCol::compare(const PCol &c1, const PCol &c2)
+PCol::compare(const PCol &, const PCol &)
{
assert(false);
return 0 ;
@@ -42,6 +65,7 @@ PCol::OK () const
if (prebreak || postbreak ) {
assert(breakable);
}
+
}
void
diff --git a/cols.hh b/pcol.hh
index e51e2d56c0..d11a23ca9c 100644
--- a/cols.hh
+++ b/pcol.hh
@@ -46,9 +46,7 @@ struct PCol {
Interval width() const;
~PCol();
PCol(PCol * parent);
- /// initialize the prebreak and postbreak fields
- setup_breaks();
-
+
/// which col comes first?
static int compare(const PCol &c1, const PCol &c2);
/**
@@ -59,7 +57,7 @@ struct PCol {
void OK() const;
void set_breakable();
-
+ void print()const;
};
/**
This is a class to address items vertically. It contains the data for:
@@ -88,9 +86,10 @@ struct Idealspacing {
/// the two columns
const PCol *left, *right;
-
+
+ void print()const;
void OK() const ;
- Idealspacing(const PCol *left,const PCol *right);
+ Idealspacing(const PCol *left,const PCol *right);
};
#endif
diff --git a/proto.hh b/proto.hh
index 0721e19fd4..394f3be14b 100644
--- a/proto.hh
+++ b/proto.hh
@@ -1,7 +1,6 @@
#include "real.hh"
-class Vector;
-class Matrix;
+class Parametric_symbol;
class Line_of_score;
class Line_of_staff;
class PCol;
@@ -46,6 +45,7 @@ struct Note_req;
struct Lyric_req;
struct Script_req;
struct Rest_req;
+struct Rhythmic_req;
struct Chord;
struct Stem_req;
struct Span_req;
@@ -73,4 +73,4 @@ struct Tex_stream;
struct Identifier;
struct Keyword;
class Mixed_qp;
-typedef Mixed_qp Optimisation_problem;
+class Paperdef;
diff --git a/pscore.cc b/pscore.cc
index 16156d1321..44a87c0dd4 100644
--- a/pscore.cc
+++ b/pscore.cc
@@ -1,5 +1,6 @@
// utility functions for PScore
#include "debug.hh"
+#include "dimen.hh"
#include "line.hh"
#include "pscore.hh"
#include "tstream.hh"
@@ -60,7 +61,7 @@ PScore::get_spacing(PCol*l, PCol*r)
Idealspacing*ip =new Idealspacing(l,r);
suz.bottom().add(ip);
- // l->used = r->used = true;
+
return ip;
}
@@ -80,19 +81,17 @@ PScore::add(PCol *p)
{
cols.bottom().add(p);
}
-/*
- todo: config of width
- */
+
PScore::PScore()
{
- linewidth = 15; // in cm for now
+ linewidth = convert_dimen(15,"cm");
}
void
PScore::output(Tex_stream &ts)
{
int l=1;
- ts << "% linewidth " << linewidth * HOR_TO_PT << " pt\n";
+ ts << "% linewidth " << print_dimen(linewidth )+"\n";
for (PCursor<Line_of_score*> lic(lines); lic.ok(); lic++) {
ts << "% line of score no. " << l++ <<"\n";
ts << lic->TeXstring();
@@ -100,3 +99,42 @@ PScore::output(Tex_stream &ts)
ts << "\\interscoreline\n";
}
}
+
+svec<Item*>
+PScore::select_items(PStaff*ps , PCol*pc)
+{
+ svec<Item*> ret;
+ assert(ps && pc);
+ for (PCursor<const Item*> ic(pc->its); ic.ok(); ic++){
+ if (ic->pstaff_ == ps)
+ ret.add((Item*)(const Item*)ic);
+ }
+ return ret;
+}
+
+void
+PScore::OK()const
+{
+ for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
+ cc->OK();
+ for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
+ ic->OK();
+
+}
+void
+PScore::print() const
+{
+
+ #ifndef NPRINT
+ mtor << "PScore { width "<<print_dimen(linewidth);
+ mtor << "\ncolumns: ";
+ for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
+ cc->print();
+
+ mtor << "\nideals: ";
+ for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
+ ic->print();
+ mtor << "}\n";
+ #endif
+}
+
diff --git a/pscore.hh b/pscore.hh
index 75da46a4a5..5ae4c37951 100644
--- a/pscore.hh
+++ b/pscore.hh
@@ -5,7 +5,7 @@
#include "vray.hh"
-#include "cols.hh"
+#include "pcol.hh"
#include "pstaff.hh"
/// all stuff which goes onto paper
@@ -32,6 +32,8 @@ struct PScore {
PointerList<Spanner *> spanners;
/****************************************************************/
+
+ svec<Item*> select_items(PStaff*, PCol*);
void calc_breaking();
/**
@@ -69,9 +71,10 @@ struct PScore {
PCursor<PCol *> find_col(PCol *);
void clean_cols();
- void problem_OK() ;
-
+ void problem_OK()const ;
+ void OK()const ;
PScore();
+ void print() const;
};
/** notes, signs, symbols in a score can be grouped in two ways:
horizontally (staffwise), and vertically (columns). #PScore#
diff --git a/pstaff.hh b/pstaff.hh
index de535a6518..8d17b9dd19 100644
--- a/pstaff.hh
+++ b/pstaff.hh
@@ -3,11 +3,15 @@
#include "list.hh"
#include "item.hh"
+#include "symbol.hh"
/// items grouped vertically.
class PStaff {
+
public:
- Stretchable_symbol *stafsym;
+ Parametric_symbol *stafsym;
+ virtual Symbol get_stafsym(Real width)const=0; // mayybe overkill
+
List<const Spanner*> spans;
List<Item*> its;
diff --git a/qlp.hh b/qlp.hh
index 54d31910ba..b539fe6b86 100644
--- a/qlp.hh
+++ b/qlp.hh
@@ -19,7 +19,7 @@ public:
/**
use a KKT method to assert optimality of sol
*/
- /// solve the problem using a variable metric method
+ /// solve the problem using a projected gradient method
Vector solve(Vector start) const;
int dim() const{
@@ -85,5 +85,5 @@ public:
x^T QUAD x /2 + b^T x
*/
-typedef Mixed_qp Optimisation_problem;
+
#endif
diff --git a/request.cc b/request.cc
index 27029ba8d7..27816e5b43 100644
--- a/request.cc
+++ b/request.cc
@@ -1,48 +1,38 @@
#include "request.hh"
+#include "debug.hh"
+
+void
+Request::print() const
+{
+#ifndef NPRINT
+ mtor << "Req{ unknown }\n";
+#endif
+}
+
Request::Request(Voice_element*v)
{
elt = v;
- tag = UNKNOWN;
}
-Note_req::Note_req(Voice_element*v):
- Request(v)
+Note_req::Note_req(Voice_element*v)
+ : Rhythmic_req(v)
{
name = 'c';
octave = 0;
accidental = 0;
forceacc = false;
- balltype = 1;
- dots = 0;
- tag = NOTE;
}
-Rest_req::Rest_req(Voice_element*v)
+Rhythmic_req::Rhythmic_req(Voice_element*v)
:Request(v)
{
balltype = 1;
dots = 0;
- tag =REST;
}
Request::Request()
{
elt = 0;
- tag = UNKNOWN;
-}
-
-Note_req*
-Request::note()
-{
- assert(tag == NOTE);
- return (Note_req*)this;
-}
-
-Rest_req*
-Request::rest()
-{
- assert(tag == REST);
- return (Rest_req*)this;
}
@@ -60,11 +50,7 @@ wholes(int dur, int dots)
}
Real
-Note_req::duration() const {
- return wholes( balltype,dots);
-}
-Real
-Rest_req::duration() const{
+Rhythmic_req::duration() const {
return wholes( balltype,dots);
}
diff --git a/request.hh b/request.hh
index 0cd0fe0903..79846e7e69 100644
--- a/request.hh
+++ b/request.hh
@@ -7,13 +7,16 @@
#include "mtime.hh"
struct Request {
Voice_element*elt;
+#if 0
enum {
UNKNOWN, NOTE, REST, LYRIC, SCRIPT, CHORD, BEAM,
BRACKET, STEM, SLUR, CRESC, DECRESC, ABSDYNAMIC
} tag;
-
- Note_req *note();
- Rest_req *rest();
+#endif
+ virtual void print()const ;
+ virtual Note_req *note() {return 0;}
+ virtual Rest_req *rest() {return 0;}
+ virtual Rhythmic_req*rhythmic() { return 0;}
Request(Voice_element*);
Request();
virtual Real duration() const { return 0.0; }
@@ -50,18 +53,22 @@ struct Request {
beams/stems to look up the balls it has to connect to. */
-
+struct Rhythmic_req : Request {
+ int balltype;
+ int dots;
+ Real duration() const;
+ Rhythmic_req(Voice_element*);
+ Rhythmic_req*rhythmic() { return this;}
+};
+
/// Put a note of specified type, height, and with accidental on the staff.
-struct Note_req : Request {
+struct Note_req : Rhythmic_req {
char name;
int octave;
int accidental;
bool forceacc;
- int balltype;
- int dots;
-
- Real duration() const;
Note_req(Voice_element*v);
+ Note_req*note() { return this;}
};
/**
Staff has to decide if the ball should be hanging left or right. This
@@ -73,6 +80,19 @@ is also for the Staff to decide. The Staff can decide on positioning
based on ottava commands and the appropriate clef.
*/
+
+///Put a rest on the staff.
+struct Rest_req : Rhythmic_req {
+
+ Rest_req(Voice_element*v) : Rhythmic_req(v) { }
+ Rest_req * rest() { return this;}
+};
+/**
+Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded.
+*/
+
+#if 0
+
///Put a lyric above or below (?) this staff.
struct Lyric_req : Request {
String text;
@@ -82,7 +102,7 @@ struct Lyric_req : Request {
///Put a script above or below this ``note''
struct Script_req : Request {
int orientation;
- Symbol *sym;
+ Symbol sym;
};
/**
eg upbow, downbow. Why a request? These symbols may conflict with slurs and brackets, so this
@@ -90,17 +110,6 @@ also a request
*/
-///Put a rest on the staff.
-struct Rest_req : Request {
- int balltype;
- int dots;
- Rest_req(Voice_element*);
- Real duration() const;
-};
-/**
-Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded.
-*/
-
///Draw a (Guitar) chord above or below this ``note''
@@ -191,5 +200,5 @@ struct Decresc_req : Span_req, Dynamic {
struct Absdynamic_req : Request, Dynamic {
Loudness loudness;
};
-
+#endif
#endif
diff --git a/rhythmstaf.cc b/rhythmstaf.cc
index a7fade6fc5..d2a85d62ce 100644
--- a/rhythmstaf.cc
+++ b/rhythmstaf.cc
@@ -7,8 +7,8 @@
#include "command.hh"
#include "molecule.hh"
#include "rhythmstaf.hh"
-#include "symbol.hh"
-
+#include "lookupsyms.hh"
+#include "sccol.hh"
Rhythmic_column::Rhythmic_column(Score_column*s, Rhythmic_staff *rs)
: Staff_column(s)
@@ -69,21 +69,16 @@ Rhythmic_column::process_requests()
for (int i = 0 ; i < v_elts.sz(); i ++)
for (PCursor<Request *> rqc(v_elts[i]->reqs); rqc.ok(); rqc++) {
Request *rq= rqc;
- switch(rq->tag){
- case Request::NOTE:
- case Request::REST:
+ if (rq->rhythmic()){
if (the_note){
WARN << "too many notes.\n";
return;
}
the_note = rq;
- break;
-
- default:
- return;
}
+ break;
+
}
-
}
@@ -91,14 +86,30 @@ void
Rhythmic_column::typeset_command(Command *com, int breakst)
{
Item *i = new Item;
- const Symbol*s=0;
+ Symbol s;
if (com -> args[0] == "BAR" ) {
- s = Symbol::find_bar(com->args[1]);
+ s = Lookup::bar(com->args[1]);
+ } else if (com->args[0] == "METER") {
+ Parametric_symbol *p = Lookup::meter("general");
+ svec<String> arg( com->args);
+ arg.del(0);
+ s = p->eval(arg);
} else
assert(false);
-
- i->output=new Molecule(Atom(s));
+
+ Molecule * m =new Molecule(Atom(s));
+ {
+ Interval wid;
+ svec<Item*> sv(staff_->pscore_->
+ select_items(staff_->theline, score_column->pcol));
+ for (int j=0; j<sv.sz(); j++) {
+ wid.unite(sv[j]->output->extent().x);
+ }
+ if (!wid.empty())
+ m->translate(Offset(wid.max,0));
+ }
+ i->output=m;
staff_->pscore_->typeset_item(i, score_column->pcol,
staff_->theline,breakst);
}
@@ -107,22 +118,25 @@ void
Rhythmic_column::typeset_req(Request *rq)
{
Item *i = new Item;
- const Symbol*s=0;
-
- switch(rq->tag){
- case Request::NOTE:
- s = Symbol::find_ball(rq->note()->balltype);
- break;
- case Request::REST:
- s = Symbol::find_rest(rq->rest()->balltype);
- break;
- default:
- assert(false);
- break;
- }
- i->output = new Molecule(Atom(s));
-
- staff_->pscore_->typeset_item(i, score_column->pcol, staff_->theline,0 );
+ Symbol s;
+ int dots=0;
+
+ if (rq->note())
+ s = Lookup::ball(rq->note()->balltype);
+ if (rq->rhythmic())
+ dots=rq->rhythmic()->dots;
+ if (rq->rest())
+ s = Lookup::rest(rq->rest()->balltype);
+
+ Molecule *m = new Molecule(Atom(s));
+ if (dots) {
+ Symbol d = Lookup::dots(dots);
+ Molecule dm;
+ dm.add(Atom(d));
+ m->add_right(dm);
+ }
+ i->output=m;
+ staff_->pscore_->typeset_item(i, score_column->pcol, staff_->theline,0 );
}
void
diff --git a/rhythmstaf.hh b/rhythmstaf.hh
index 1e56355cd7..8e362146e3 100644
--- a/rhythmstaf.hh
+++ b/rhythmstaf.hh
@@ -1,3 +1,13 @@
+/*
+ rhythmstaf.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef RHYTHMSTAF_HH
+#define RHYTHMSTAF_HH
+#include "stcol.hh"
+
struct Rhythmic_staff;
/// column of Rhythmic_staff
@@ -29,3 +39,7 @@ struct Rhythmic_staff : Staff {
Staff_column * create_col(Score_column*);
};
+
+#endif // RHYTHMSTAF_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<Mtime> 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/scommands.cc b/scommands.cc
new file mode 100644
index 0000000000..82fe9a1691
--- /dev/null
+++ b/scommands.cc
@@ -0,0 +1,185 @@
+#include "scommands.hh"
+#include "debug.hh"
+
+/*
+ maybe it's time for a "narrowing" cursor?
+ */
+PCursor<Command*>
+Score_commands::first(Real w)
+{
+ PCursor<Command*> pc(*this);
+ while (pc.ok() && pc->when < w)
+ pc++;
+
+ return pc;
+}
+
+PCursor<Command*>
+Score_commands::last_insertion(Real w)
+{
+ PCursor<Command*> pc(*this);
+ while (pc.ok() && pc->when <= w)
+ pc++;
+ return pc;
+}
+
+void
+Score_commands::add_seq(svec<Command> com)
+{
+ if (!com.sz())
+ return;
+ Real when = com[0].when;
+
+ PCursor<Command*> pc(last_insertion(when));
+ for (int i = 0; i < com.sz(); i++) {
+ Command *c = new Command(com[i]);
+ assert(com[i].when == when);
+ if (!pc.ok())
+ pc.add(c);
+ else
+ pc.insert(c);
+ }
+}
+
+void
+Score_commands::set_breakable(Real when)
+{
+ bool found_typeset(false);
+ PCursor<Command*> cc = first(when);
+ for (; cc.ok() && cc->when == when; cc++) {
+ if (cc->isbreak())
+ return;
+ if (cc->code == TYPESET)
+ found_typeset=true;
+ }
+
+ assert(!found_typeset);
+
+ svec<Command> seq;
+ Command k(when);
+ k.code = BREAK_PRE;
+ seq.add(k);
+ k.code = BREAK_MIDDLE;
+ seq.add(k);
+ k.code = BREAK_POST;
+ seq.add(k);
+ k.code = BREAK_END;
+ seq.add(k);
+
+ add_seq(seq);
+}
+bool
+Score_commands::is_breakable(Real w)
+{
+ PCursor<Command*> cc = first(w);
+ for (; cc.ok() && cc->when == w; cc++) {
+ if (cc->isbreak())
+ return true;
+ }
+ return false;
+}
+void
+Score_commands::add_command_to_break(Command pre, Command mid,Command post)
+{
+ Real w = pre.when;
+
+ Command k(w);
+
+ PCursor<Command*> c ( first(w));
+ while (!c->isbreak())
+ c++;
+ c.add(new Command(pre));
+
+ while (!c->isbreak())
+ c++;
+ c.add(new Command(mid));
+
+ while (!c->isbreak())
+ c++;
+ c.add(new Command(post));
+}
+
+void
+Score_commands::add(Command c)
+{
+ bool encapsulate =false;
+
+ Command pre(c.when);
+ Command mid(c.when);
+ Command post(c.when);
+
+
+ if (c.code == TYPESET) {
+ if (c.args[0] == "BAR") {
+ set_breakable(c.when);
+ encapsulate = true;
+ mid = c;
+ pre = c;
+ }
+ if (c.args[0] == "METER" && is_breakable(c.when)) {
+ encapsulate = true;
+ mid = c;
+ pre = c;
+ post =c;
+ }
+ }
+
+ if (encapsulate)
+ add_command_to_break(pre, mid, post);
+ else {
+ svec<Command> seq;
+ seq.add(c);
+ add_seq(seq);
+ }
+}
+
+/*
+ first and last column should be breakable.
+ Remove any command past the last musical column.
+ */
+void
+Score_commands::clean(Real l)
+{
+ assert(l>0);
+ if (!is_breakable(0.0)) {
+ Command c(0.0);
+ c.code = TYPESET;
+ c.args.add("BAR");
+ c.args.add("empty");
+ add(c);
+ }
+
+ PCursor<Command*> bot(bottom());
+
+ while (bot.ok() && bot->when > l) {
+
+ mtor <<"removing "<< bot->code <<" at " << bot->when<<'\n';
+ bot.del();
+ bot = bottom();
+ }
+
+ if (!is_breakable(l)) {
+ Command c(l);
+ c.code = TYPESET;
+ c.args.add("BAR");
+ c.args.add("||");
+ add(c);
+ }
+ OK();
+}
+
+void
+Score_commands::OK() const
+{
+ for (PCursor<Command*> cc(*this); cc.ok() && (cc+1).ok(); cc++) {
+ assert(cc->when <= (cc+1)->when);
+ }
+}
+
+void
+Score_commands::print() const
+{
+ for (PCursor<Command*> cc(*this); cc.ok() ; cc++) {
+ cc->print();
+ }
+}
diff --git a/scommands.hh b/scommands.hh
new file mode 100644
index 0000000000..15c844ca65
--- /dev/null
+++ b/scommands.hh
@@ -0,0 +1,28 @@
+/*
+ lilypond, (c) 1996 Han-Wen Nienhuys
+*/
+#ifndef SCOMMANDS_HH
+#define SCOMMANDS_HH
+
+#include "proto.hh"
+#include "command.hh"
+#include "vray.hh"
+#include "list.hh"
+
+struct Score_commands : public PointerList<Command*> {
+ void add(Command);
+ void add_seq(svec<Command>);
+ void clean(Real last);
+ void set_breakable(Real when);
+ bool is_breakable(Real w);
+ PCursor<Command*> last_insertion(Real w);
+ PCursor<Command*> first(Real w);
+ void add_command_to_break(Command pre, Command mid,Command post);
+ void OK() const;
+ void print() const;
+};
+/** the list of commands in Score. Put in a separate class, since it
+ otherwise clutters the methods of Score. */
+
+#endif
+
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<Command *> com)
-{
- if (!com.sz())
- return;
- Real when = com[0]->when;
-
- PCursor<Command*> 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<Command*> 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<Score_column*> 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<Command*> 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<Staff*> stc(staffs_); stc.ok(); stc++) {
- l = MAX(l, stc->last());
- }
- return l;
-}
-void
-Score::clean_commands()
-{
- Mtime l= last();
- for (PCursor<Command*> 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<Score_column*> sc(cols_);
+ for (; sc.ok(); sc++) {
+ pscore_->add(sc->pcol);
+ }
+}
+Mtime
+Score::last() const
+{
+ Mtime l = 0;
+ for (PCursor<Staff*> stc(staffs_); stc.ok(); stc++) {
+ l = MAX(l, stc->last());
+ }
+ return l;
}
void
@@ -265,12 +163,11 @@ Score::OK() const
for (PCursor<Score_column*> cc(cols_); cc.ok() && (cc+1).ok(); cc++) {
assert(cc->when <= (cc+1)->when);
}
- for (PCursor<Command*> 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<Score_column*> 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<Mtime> 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<Staff *> staffs_;
- PointerList<Command*> commands_;
+ Score_commands commands_;
/// "runtime" fields for setting up spacing
PointerList<Score_column*> 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<Command*> );
void output(String fn);
PCursor<Score_column*> 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 */
};
/**
diff --git a/staff.cc b/staff.cc
index 12bf074d04..0827c953f0 100644
--- a/staff.cc
+++ b/staff.cc
@@ -1,6 +1,8 @@
#include "staff.hh"
+#include "stcol.hh"
+#include "sccol.hh"
#include "debug.hh"
-#include "pscore.hh"
+
void
Staff::clean_cols()
@@ -14,11 +16,6 @@ Staff::clean_cols()
}
}
-/*
- maak een staff column, met specs in args.
-
- (sorry wat is het vroeg vandaag..)
- */
Staff_column *
Staff::get_col(Mtime w, bool mus)
{
@@ -106,7 +103,7 @@ Staff::add_commands(PointerList<Command*> const &cl)
}
// now integrate break commands with other commands.
- // may be do this in derived functions.
+ // maybe do this in derived functions.
}
void
@@ -146,39 +143,14 @@ Staff::last() const {
void
Staff::print() const
{
+ #ifndef NPRINT
+
mtor << "Staff {\n";
for (PCursor<Voice*> vc(voices); vc.ok(); vc++) {
vc->print();
}
mtor <<"}\n";
+ #endif
}
-/****************************************************************/
-
-bool
-Staff_column::mus() const
-{
- return score_column->musical;
-}
-
-Mtime
-Staff_column::when() const
-{
- return score_column->when;
-}
-
-void
-Staff_column::add(Voice_element*ve)
-{
- Mtime d= ve->duration;
- if (d){
- score_column->durations.add(d);
- }
-
- v_elts.add(ve);
-}
-
-Staff_column::Staff_column(Score_column*s) {
- score_column = s;
-}
diff --git a/staff.hh b/staff.hh
index 49439f373b..cca8c35266 100644
--- a/staff.hh
+++ b/staff.hh
@@ -5,25 +5,6 @@
#include "voice.hh"
#include "command.hh"
-struct Staff_column {
- Score_column *score_column;
-
- /// fields to collect data vertically.
- svec<Voice_element *> v_elts;
- svec<Command *> s_commands;
-
- Staff_column(Score_column*s);
- bool mus() const ;
- Mtime when() const;
- void add(Voice_element*ve);
- /****************************************************************
- VIRTUAL
- ****************************************************************/
- virtual void process_requests()=0;
- virtual void process_commands()=0;
- virtual ~Staff_column() { }
-};
-
/// base class for a collection of voices.
struct Staff {
diff --git a/stcol.cc b/stcol.cc
new file mode 100644
index 0000000000..e9a80c8e36
--- /dev/null
+++ b/stcol.cc
@@ -0,0 +1,30 @@
+#include "stcol.hh"
+#include "sccol.hh"
+#include "voice.hh"
+
+bool
+Staff_column::mus() const
+{
+ return score_column->musical;
+}
+
+Mtime
+Staff_column::when() const
+{
+ return score_column->when;
+}
+
+void
+Staff_column::add(Voice_element*ve)
+{
+ Mtime d= ve->duration;
+ if (d){
+ score_column->durations.add(d);
+ }
+
+ v_elts.add(ve);
+}
+
+Staff_column::Staff_column(Score_column*s) {
+ score_column = s;
+}
diff --git a/stcol.hh b/stcol.hh
new file mode 100644
index 0000000000..2b23934c53
--- /dev/null
+++ b/stcol.hh
@@ -0,0 +1,33 @@
+/*
+ stcol.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef STCOL_HH
+#define STCOL_HH
+#include "proto.hh"
+#include "vray.hh"
+
+struct Staff_column {
+ Score_column *score_column;
+
+ /// fields to collect data vertically.
+ svec<Voice_element *> v_elts;
+ svec<Command *> s_commands;
+
+ Staff_column(Score_column*s);
+ bool mus() const ;
+ Real when() const;
+ void add(Voice_element*ve);
+ /****************************************************************
+ VIRTUAL
+ ****************************************************************/
+ virtual void process_requests()=0;
+ virtual void process_commands()=0;
+ virtual ~Staff_column() { }
+};
+
+
+#endif // STCOL_HH
+
diff --git a/suzan.ly b/suzan.ly
index 35a949ecd5..08c4ddf643 100644
--- a/suzan.ly
+++ b/suzan.ly
@@ -2,13 +2,6 @@
score{
rhythmstaff {
- voice { $ c4 c2 c4 $ }
+ voice { $c2 c2 c2 c2$ }
}
- rhythmstaff {
- voice { $ c2 c2 $ }
- }
- rhythmstaff {
- voice { $ c4 c4 c4 c4 $ }
- }
-% bar 2
}
diff --git a/symbol.cc b/symbol.cc
index 66771dc90a..d67049cefa 100644
--- a/symbol.cc
+++ b/symbol.cc
@@ -1,11 +1,35 @@
#include "symbol.hh"
+
Symbol::Symbol()
: dim(Interval(0,0),Interval(0,0))
{
- tex = "\\unknown";
+ tex = "\\unknown";
}
Symbol::Symbol(String s, Box b)
- : tex(s), dim(b)
+ : dim(b)
+{
+ tex = s;
+}
+
+/****************************************************************/
+
+Symbol
+Parametric_symbol::eval(String args1)const
{
+ svec<String> a;
+ a.add(args1);
+ return eval(a);
}
+Symbol
+Parametric_symbol::eval(String args1,String arg2)const
+{
+ svec<String> a;
+ a.add(args1);
+ a.add(arg2);
+ return eval(a);
+}
+
+Parametric_symbol::~Parametric_symbol()
+{
+}
diff --git a/symbol.hh b/symbol.hh
index 464a423742..6d6ed1acbe 100644
--- a/symbol.hh
+++ b/symbol.hh
@@ -2,25 +2,21 @@
#define SYMBOL_HH
#include "string.hh"
#include "boxes.hh"
+
struct Symbol {
String tex;
Box dim;
- Symbol (String, Box );
- static const Symbol*find_ball(int);
- static const Symbol*find_rest(int);
- static const Symbol*find_bar(String);
- Symbol() ;
+ Symbol (String, Box);
+ Symbol();
};
-/// a symbol with a variable width
-struct Stretchable_symbol {
-public:
-
- /// return a string for a symbol in this width.
- virtual String operator ()(Real width)=0;
- virtual Interval height(Real width) const =0;
- static const Stretchable_symbol* get_linestaff(int n);
+struct Parametric_symbol {
+
+ Symbol eval(String args1) const; // convenience
+ Symbol eval(String args1,String arg2) const; // convenience
+ virtual Symbol eval(svec<String> args)const =0;
+ virtual ~Parametric_symbol();
};
#endif
diff --git a/symbol.ini b/symbol.ini
index d00e751dc5..459deb1f67 100644
--- a/symbol.ini
+++ b/symbol.ini
@@ -1,27 +1,42 @@
# index TeXstring, xmin xmax ymin ymax
+# be careful with editing this:
+# the "index" entry is hardwired into lilypond.
+
table balls
- 1 \wholeball -5 5 -1 1
- 2 \halfball -5 5 -1 1
- 4 \quartball -5 5 -1 1
+ 1 \wholeball -5pt 5pt -1pt 1pt
+ 2 \halfball -5pt 5pt -1pt 1pt
+ 4 \quartball -5pt 5pt -1pt 1pt
end
table bars
- empty \emptybar 0 0 0 0
- | \maatstreep 0 1 0 10
- || \finishbar 0 2 0 10
+ empty \emptybar 0pt 0pt 0pt 0pt
+ | \maatstreep 0pt 1pt -8pt 8pt
+ || \finishbar 0pt 2pt -8pt 8pt
end
table rests
- 1 \wholerest -5 1 -1 1
- 2 \halfrest -5 1 -1 1
- 4 \cquartrest -5 2 -5 5
- 8 \eighthrest -5 1 -1 1
- 16 \sixteenthrest -5 1 -1 1
- 32 \thirtysecondrest -1 1 -1 1
+ 1 \wholerest -5pt 1pt -1pt 1pt
+ 2 \halfrest -5pt 1pt -1pt 1pt
+ 4 \cquartrest -5pt 2pt -5pt 5pt
+ 8 \ceighthrest -5pt 1pt -1pt 1pt
+ 16 \csixteenthrest -5pt 1pt -1pt 1pt
+ 32 \cthirtysecondrest -1pt 1pt -1pt 1pt
end
+table meters
+ C \fourfourmeter 0pt 10pt -5pt 5pt
+ C2 \allabreve 0pt 10pt -5pt 5pt
+end
+# dims ignored for this table
+table param
+ meter \generalmeter{%}{%} -3pt 10pt -5pt 5pt
+ linestaf \linestafsym{%}{%} 0pt 0pt 0pt 0pt
+end
-
-
+table dots
+ 1 \singledot 0pt 4pt -1pt 1pt
+ 2 \doubledot 0pt 8pt -1pt 1pt
+ 3 \tripledot 0pt 12pt -1pt 1pt
+end
diff --git a/symtable.cc b/symtable.cc
index 5d295d0be5..b4de607b8d 100644
--- a/symtable.cc
+++ b/symtable.cc
@@ -1,23 +1,24 @@
#include "misc.hh"
+#include "dimen.hh"
#include "debug.hh"
#include "real.hh"
#include "symbol.hh"
#include "assoc.hh"
#include "symtable.hh"
-#include "const.hh"
-static Symbol unknown;
-// scary! What if Symtable resizes on the fly...?
-const Symbol *
+
+
+Symbol
Symtable::lookup(String s) const
{
if (elt_query(s))
- return &(*this)[s];
+ return (*this)[s];
else {
+ Symbol unknown;
WARN<<"Unknown symbol " << s <<'\n';
- return &unknown;
+ return unknown;
}
}
@@ -54,7 +55,7 @@ Symtables::read()
String tex=r[i++];
svec<Real> dims;
for (int j=0; j < 4; j++)
- dims.add( r[i++].fvalue() *1.0/CM_TO_PT);
+ dims.add( parse_dimen(r[i++]));
Symbol s(tex, Box(dims));
(*sp)[id] = s;
@@ -63,56 +64,5 @@ Symtables::read()
}
}
-Symtables the_sym_tables("symbol.ini");
-
-
-const Symbol*
-Symbol::find_ball(int j)
-{
- if (j > 4) j = 4;
- Symtable * st = the_sym_tables("balls");
- return st->lookup(String(j));
-}
-const Symbol*
-Symbol::find_rest(int j)
-{
- return the_sym_tables("rests")->lookup(String(j));
-}
-const Symbol*
-Symbol::find_bar(String s)
-{
- return the_sym_tables("bars")->lookup(s);
-}
-/****************************************************************/
-// bare bones.
-struct Linestaf_symbol : Stretchable_symbol {
- int lines;
- String operator ()(Real w);
- Linestaf_symbol(int n) { lines = n;}
- Interval height(Real) const { return Interval(0,lines*1/CM_TO_PT); }
-};
-
-
-
-// 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);
-}
diff --git a/symtable.hh b/symtable.hh
index f390e285e0..73c4079e70 100644
--- a/symtable.hh
+++ b/symtable.hh
@@ -1,5 +1,14 @@
+/*
+ lilypond, (c) 1996 Han-Wen Nienhuys
+*/
+#ifndef SYMTABLE_HH
+#define SYMTABLE_HH
+#include "assoc.hh"
+#include "string.hh"
+#include "symbol.hh"
+
struct Symtable : public Assoc<String, Symbol> {
- const Symbol * lookup(String)const;
+ Symbol lookup(String)const;
};
@@ -14,3 +23,6 @@ struct Symtables : private Assoc<String, Symtable*> {
};
+
+#endif
+
diff --git a/table.cc b/table.cc
index b06e2ee92f..72b5ccfd55 100644
--- a/table.cc
+++ b/table.cc
@@ -10,6 +10,13 @@ static Keyword_ent the_key_tab[]={
"score", SCORE,
"bar", BAR,
"output", OUTPUT,
+ "cm", CM,
+ "pt", PT,
+ "in", IN,
+ "mm", MM,
+ "paper", PAPER,
+ "width", WIDTH,
+ "meter", METER,
0,0
} ;
diff --git a/template1.cc b/template1.cc
index 908de8d4e1..b7c453b6e0 100644
--- a/template1.cc
+++ b/template1.cc
@@ -1,20 +1,20 @@
#include "line.hh"
#include "list.hh"
-#include "cols.hh"
+#include "pcol.hh"
#include "item.hh"
#include "request.hh"
#include "command.hh"
#include "list.cc"
#include "cursor.cc"
+#define PLC_instantiate(a) PL_instantiate(a); PL_instantiate(const a)
-
-PL_instantiate(Line_of_score);
-PL_instantiate(Line_of_staff);
-PL_instantiate(Item);
-PL_instantiate(Spanner);
-PL_instantiate(PStaff);
-PL_instantiate(Idealspacing);
-PL_instantiate(PCol);
+PLC_instantiate(Line_of_score);
+PLC_instantiate(Line_of_staff);
+PLC_instantiate(Item);
+PLC_instantiate(Spanner);
+PLC_instantiate(PStaff);
+PLC_instantiate(Idealspacing);
+PLC_instantiate(PCol);
diff --git a/template2.cc b/template2.cc
index 40cd5b9fbe..08f2eea880 100644
--- a/template2.cc
+++ b/template2.cc
@@ -3,6 +3,8 @@
#include "voice.hh"
#include "staff.hh"
+#include "sccol.hh"
+#include "stcol.hh"
#include "list.cc"
#include "cursor.cc"
diff --git a/template3.cc b/template3.cc
index b647f18598..6f2e92104c 100644
--- a/template3.cc
+++ b/template3.cc
@@ -3,7 +3,7 @@
#include "molecule.hh"
#include "list.cc"
#include "cursor.cc"
-L_instantiate(Atom);
+PL_instantiate(Atom);
PL_instantiate(Command);
PL_instantiate(Request);
diff --git a/tex.cc b/tex.cc
index e11ebb90b8..ae9dc1b5f3 100644
--- a/tex.cc
+++ b/tex.cc
@@ -1,28 +1,32 @@
-
+#include "dimen.hh"
#include "tex.hh"
#include "symbol.hh"
#include "const.hh"
-/*
- #TeXstring# should generate a TeX string to typeset the object in
- a hbox or vbox of exactly the objects' dimension.
-*/
-
-/// #h# is in points
String
vstrut(Real h)
{
- return String("\\vrule height ") + h + "pt depth 0pt width 0pt";
+ return String("\\vrule height ") + print_dimen(h) + "depth 0pt width 0pt";
}
-/// the staff with five lines.
- struct Fiveline_staff: Stretchable_symbol {
- String operator()(Real width) {
- String s("\\normalebalk{ ");
- s+=width * HOR_TO_PT;
- s+= "pt}";
- return s;
- }
-};
+static void
+substitute_arg(String& r, String arg)
+{
+ int p = r.pos('%');
+ if (!p ) return ;
+ else p--;
+ r = r.left(p) + arg + r.right(r.len() - p -1);
+}
+
+String
+substitute_args(String source, svec<String> args)
+{
+ String retval (source);
+ for (int i = 0 ; i < args.sz(); i++)
+ substitute_arg(retval, args[i]);
+ while (retval.pos('%'))
+ substitute_arg(retval, "");
+ return retval;
+}
diff --git a/tex.hh b/tex.hh
index fd4a0b6ddf..2f60630fd5 100644
--- a/tex.hh
+++ b/tex.hh
@@ -4,28 +4,14 @@
#include "string.hh"
#include "boxes.hh"
-/// anything which can be output
-struct Output {
- virtual String TeXstring() const=0;
- /** generate a TeX string, which typesets the symbol. Vertical
- base position is the "origin" of the staff
- */
- virtual Box extent() const=0;
-};
+String
+substitute_args(String source, svec<String> args);
/**
- any output should (at least) be outputtable for TeX, and have a
- dimension
-*/
-
-
-/// an idea
-struct Text_gob : Output {
- String text;
- // fonts, sizes, etc?
- virtual String TeXstring() const;
- virtual Box extent() const;
-};
+ this structure provides a simple macro mechanism:
+ if source == "tex%bla%", then
+ eval({"X","Y"}) == "texXblaY"
+ */
/// #h# is in points
String vstrut(Real h);
diff --git a/tstream.cc b/tstream.cc
index c47fca6da6..b7c88f1b0b 100644
--- a/tstream.cc
+++ b/tstream.cc
@@ -1,16 +1,15 @@
#include <fstream.h>
#include <time.h>
#include "tex.hh"
-#include "misc.hh"
+#include "main.hh"
#include "tstream.hh"
#include "debug.hh"
Tex_stream::Tex_stream(String filename)
{
-
os = new ofstream(filename);
if (!*os)
- error("can't open " + filename);
+ error("can't open `" + filename+"\'");
nest_level = 0;
outputting_comment=false;
header();
@@ -18,16 +17,16 @@ Tex_stream::Tex_stream(String filename)
void
Tex_stream::header()
{
- *os << "% Creator: " << get_version() << "\n";
+ *os << "% Creator: " << get_version();
*os << "% Automatically generated, at ";
time_t t(time(0));
- *os << ctime(&t)<<"\n";
+ *os << ctime(&t);
//*os << "% from input file ..\n";
}
Tex_stream::~Tex_stream()
{
- assert(nest_level == 0);
delete os;
+ assert(nest_level == 0);
}
// print string. don't forget indent.
diff --git a/voice.cc b/voice.cc
index ac6d33166d..907f229481 100644
--- a/voice.cc
+++ b/voice.cc
@@ -4,7 +4,7 @@
void
Voice_element::add(Request*r)
{
- if (r->tag == Request::NOTE ||r->tag == Request::REST) {
+ if (r->rhythmic()) {
assert (!duration);
duration = r->duration();
}
@@ -32,18 +32,23 @@ Voice_element::Voice_element()
void
Voice::print() const
{
+ #ifndef NPRINT
+
mtor << "start: "<< start<<eol;
for (PCursor<Voice_element*> vec(elts); vec.ok(); vec++)
vec->print();
+#endif
}
void
Voice_element::print() const
{
+#ifndef NPRINT
mtor << "voice_element { dur :"<< duration <<"\n";
for (PCursor<Request*> rc(reqs); rc.ok(); rc++) {
- mtor << "reqtag: " << rc->tag<<eol;
+ rc->print();
}
mtor << "}\n";
+#endif
}
Mtime