Parser 1
Lexer 1
parse_duration 1
-parse_pitch 1
\ No newline at end of file
+parse_pitch 1
+
MAJVER=0
MINVER=0
-PATCHLEVEL=3
+PATCHLEVEL=4
#
#
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)
##################################################################
include depend
parser.cc: parser.y
- bison -d $<
+ $(BISON) -d $<
mv parser.tab.h parser.hh
mv parser.tab.c parser.cc
make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) > $@
lexer.cc: lexer.l
- flex -+ -t $< > $@
+ $(FLEX) -+ -t $< > $@
DDIR=$(DNAME)
dist:
--- /dev/null
+
+
+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
+
+
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
-
-
--- /dev/null
+bug in BAR.
+dot spacing
+typeset direction.
+beam
+stem
+
+
Box::Box()
{
}
+
Box::Box(Interval ix, Interval iy)
{
x=ix;
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);
void
PScore::calc_breaking()
{
+ OK();
problem_OK();
PCursor<PCol *> curcol(cols);
#include "score.hh"
#include "pscore.hh"
#include "staff.hh"
+#include "paper.hh"
#include "misc.hh"
+#include "sccol.hh"
#include "debug.hh"
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;
+++ /dev/null
-#include "cols.hh"
-#include "pstaff.hh"
-
-Idealspacing::Idealspacing(const PCol * l,const PCol * r)
-{
- space = 0.0;
- hooke = 0.0;
- left = l;
- right = r;
-}
-void
-Idealspacing::OK() const
-{
-#ifndef NDEBUG
- assert(hooke >= 0 && left && right);
-#endif
-}
-
-Interval
-PCol::width() const
-{
- Interval w;
-
- for (PCursor<const Item *> ic(its); ic.ok(); ic++)
- w.unite(ic->width());
- if (w.empty())
- w.unite(Interval(0,0));
- return w;
-}
-/****************************************************************/
-
-int
-PCol::compare(const PCol &c1, const PCol &c2)
-{
- assert(false);
- return 0 ;
-}
-
-void
-PCol::OK () const
-{
- if (prebreak || postbreak ) {
- assert(breakable);
- }
-}
-
-void
-PCol::set_breakable()
-{
- if (breakable)
- return;
-
- prebreak = new PCol(this);
- postbreak = new PCol(this);
- breakable = true;
- used = true;
-}
-
-PCol::PCol(PCol *parent) {
- daddy = parent;
- prebreak=0;
- postbreak=0;
- breakable=false;
- line=0;
- used = false;
-}
-
-PCol::~PCol()
-{
- if (prebreak)
- delete prebreak; // no recursion!
- if (postbreak)
- delete postbreak;
-}
-
-void
-PCol::add(const Item *i)
-{
- its.bottom().add(i);
- used = true;
-}
-
+++ /dev/null
-#ifndef COLS_HH
-#define COLS_HH
-
-#include "glob.hh"
-#include "boxes.hh"
-#include "list.hh"
-#include "item.hh"
-
-/// stuff grouped vertically.
-struct PCol {
- List<const Item*> its;
- List<const Spanner*> stoppers, starters;
-
- /// Can this be broken? true eg. for bars.
- bool breakable;
-
- /// does this column have items, does it have spacings attached?
- bool used;
-
- /// prebreak is put before end of line.
- PCol *prebreak;
- /**
- if broken here, then (*this) column is discarded, and prebreak
- is put at end of line, owned by Col
- */
-
- /// postbreak at beginning of the new line
- PCol *postbreak;
- /** \See{prebreak}
- */
- PCol *daddy;
- /*
- if this column is pre or postbreak, then this field points to the parent.
- */
- /// if lines are broken then this column is in #line#
- const Line_of_score *line;
-
- /// if lines are broken then this column x-coord #hpos#
- Real hpos;
-
-
- /****************************************************************/
-
- void add(const Item*i);
-
- 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);
- /**
- signed compare on columns.
-
- return < 0 if c1 < c2.
- */
-
- void OK() const;
- void set_breakable();
-
-};
-/**
- This is a class to address items vertically. It contains the data for:
- \begin{itemize}
- \item
- unbroken score
- \item
- broken score
- \item
- the linespacing problem
- \end{itemize}
- */
-
-#include "compare.hh"
-instantiate_compare(const PCol &, PCol::compare);
-
-
-/// ideal spacing between two columns
-struct Idealspacing {
-
- /// the ideal distance
- Real space;
-
- /// Hooke's constant: how strong are the "springs" attached to columns
- Real hooke;
-
- /// the two columns
- const PCol *left, *right;
-
- void OK() const ;
- Idealspacing(const PCol *left,const PCol *right);
-};
-
-#endif
-
#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)
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";
+}
#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 {
Mtime when;
/// analogous to argv[]
svec<String> args;
+ Command();
+ Command(Real w);
+ bool isbreak()const;
+ void print() const;
};
/**
#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;
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
+++ /dev/null
-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
--- /dev/null
+#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;
+}
--- /dev/null
+#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
+
\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
MAJVER=1
MINVER=0
-PATCHLEVEL=3
+PATCHLEVEL=4
PACKAGENAME=flower
VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
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\
+ * efficient copy cons for List
+
* change String::pos
s[s.pos('%')] == '%'
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
/*
- comparations.
+ comparisons.
*/
-
-
-
-
-
-
-
-
-
#include "compare.hh"
template<class T>
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;
}
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);
+ }
}
#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
Cursor<T>
List<T>::top()
{
-
+#if 0
// ?? waarvoor is deze if ?
if ( top_ ) // equivalent: if ( size_ )
{
t = top_->previous();
}
}
- // list empty: Cursor not ok()
+#endif
+
+// list empty: Cursor not ok()
return Cursor<T>( *this, top_ );
}
}
-// 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
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 );
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 );
*/
-/// 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 //
template<class T>
inline
List<T>::List()
+{
+ set_empty();
+}
+
+template<class T>
+inline void
+List<T>::set_empty()
{
top_ = bottom_ = 0;
size_ = 0;
inline
List<T>::List( const T& thing )
{
- top_ = bottom_ = 0;
- size_ = 0;
+ set_empty();
add( thing, Cursor<T>( *this, bottom_ ) );
}
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
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
+/*
+ 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>
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
--- /dev/null
+#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 );
+ }
+}
+
+
+
+
#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
the data itself. Handles simple tasks (resizing, resetting)
*/
+
/****************************************************************/
/// ref. counting for strings
class String_handle {
--- /dev/null
+#!/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
#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 *
/// 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;
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
return NOTENAME;
}
-#endif
\ No newline at end of file
+#endif
-
-
\def\musixtwentydefs{
\font\musicfnt=musix20
%\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}
\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
#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;
lastpos = cc->hpos;
// moveover
- s +=String( "\\kern ") + HOR_TO_PT*delta + "pt ";
+ s +=String( "\\kern ") + print_dimen(delta);
// now output the items.
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.
// 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++) {
/* 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();
Colinfo c;
c.fixed=fixed;
c.fixpos=fixpos;
+ assert(col);
c.col=col;
cols.add(c);
}
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();
for (int i=0; i < ideals.sz(); i++) {
print_ideal(ideals[i]);
}
- #endif
+#endif
}
mtor << "column { ";
if (fixed)
mtor << "fixed at " << fixpos<<", ";
+ assert(col);
mtor << "[" << minleft() << ", " << minright() << "]";
mtor <<"}\n";
#endif
}
-
+Colinfo::Colinfo()
+{
+ fixed=false;
+ col=0;
+}
#include "glob.hh"
#include "list.hh"
#include "vray.hh"
-#include "cols.hh"
+#include "pcol.hh"
#include "matrix.hh"
/// helper struct for #Spacing_problem#
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; }
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
#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);
+}
#include "pstaff.hh"
struct Linestaff : PStaff {
- int nolines;
+ int nolines;
+
+ Symbol get_stafsym(Real width)const;
Linestaff(int);
};
--- /dev/null
+#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);
+}
+
--- /dev/null
+/*
+ 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
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.
+
}
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
#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
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
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));
}
#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
#include "glob.hh"
+#include "dimen.hh"
#include "string.hh"
#include "molecule.hh"
#include "symbol.hh"
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;
}
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;
}
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);
}
}
Real xof=extent().x.min - m.extent().x.max;
Molecule toadd(m);
toadd.translate(Offset(xof, 0.0));
- add(toadd);
+ add(toadd);
}
Real yof=extent().y.max - m.extent().y.min;
Molecule toadd(m);
toadd.translate(Offset(0,yof));
- add(toadd);
+ add(toadd);
}
void
add(toadd);
}
+void
+Molecule::operator = (const Molecule&)
+{
+ assert(false);
+}
+
+Molecule::Molecule(const Molecule&s)
+{
+ add(s);
+}
#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;
/// 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. */
typedef Real Mtime;
-#endif MTIME_HH
+#endif
}
Voice_element *
-get_rest_element(String type, String durstr)
+get_rest_element(String, String durstr)
{
Voice_element*v = new Voice_element;
int i=0;
--- /dev/null
+#include "paper.hh"
+#include "dimen.hh"
+
+Paperdef::Paperdef()
+{
+ width = convert_dimen(15,"cm"); // in cm for now
+ whole_width= convert_dimen(5,"cm");
+}
--- /dev/null
+
+
+#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?
+};
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);
#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;
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
+
%%
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
;
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");
+
+ }
;
%%
parse_file(String s)
{
*mlog << "Parsing ... ";
+#ifdef YYDEBUG
yydebug = !monitor.silence("Parser");
+#endif
new_input(s);
yyparse();
}
--- /dev/null
+#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)
+{
+ space = 0.0;
+ hooke = 0.0;
+ left = l;
+ right = r;
+}
+void
+Idealspacing::OK() const
+{
+#ifndef NDEBUG
+ assert(hooke >= 0 && left && right);
+#endif
+}
+
+/****************************************************************/
+
+Interval
+PCol::width() const
+{
+ Interval w;
+
+ for (PCursor<const Item *> ic(its); ic.ok(); ic++)
+ w.unite(ic->width());
+ if (w.empty())
+ 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 &, const PCol &)
+{
+ assert(false);
+ return 0 ;
+}
+
+void
+PCol::OK () const
+{
+ if (prebreak || postbreak ) {
+ assert(breakable);
+ }
+
+}
+
+void
+PCol::set_breakable()
+{
+ if (breakable)
+ return;
+
+ prebreak = new PCol(this);
+ postbreak = new PCol(this);
+ breakable = true;
+ used = true;
+}
+
+PCol::PCol(PCol *parent) {
+ daddy = parent;
+ prebreak=0;
+ postbreak=0;
+ breakable=false;
+ line=0;
+ used = false;
+}
+
+PCol::~PCol()
+{
+ if (prebreak)
+ delete prebreak; // no recursion!
+ if (postbreak)
+ delete postbreak;
+}
+
+void
+PCol::add(const Item *i)
+{
+ its.bottom().add(i);
+ used = true;
+}
+
--- /dev/null
+#ifndef COLS_HH
+#define COLS_HH
+
+#include "glob.hh"
+#include "boxes.hh"
+#include "list.hh"
+#include "item.hh"
+
+/// stuff grouped vertically.
+struct PCol {
+ List<const Item*> its;
+ List<const Spanner*> stoppers, starters;
+
+ /// Can this be broken? true eg. for bars.
+ bool breakable;
+
+ /// does this column have items, does it have spacings attached?
+ bool used;
+
+ /// prebreak is put before end of line.
+ PCol *prebreak;
+ /**
+ if broken here, then (*this) column is discarded, and prebreak
+ is put at end of line, owned by Col
+ */
+
+ /// postbreak at beginning of the new line
+ PCol *postbreak;
+ /** \See{prebreak}
+ */
+ PCol *daddy;
+ /*
+ if this column is pre or postbreak, then this field points to the parent.
+ */
+ /// if lines are broken then this column is in #line#
+ const Line_of_score *line;
+
+ /// if lines are broken then this column x-coord #hpos#
+ Real hpos;
+
+
+ /****************************************************************/
+
+ void add(const Item*i);
+
+ Interval width() const;
+ ~PCol();
+ PCol(PCol * parent);
+
+ /// which col comes first?
+ static int compare(const PCol &c1, const PCol &c2);
+ /**
+ signed compare on columns.
+
+ return < 0 if c1 < c2.
+ */
+
+ void OK() const;
+ void set_breakable();
+ void print()const;
+};
+/**
+ This is a class to address items vertically. It contains the data for:
+ \begin{itemize}
+ \item
+ unbroken score
+ \item
+ broken score
+ \item
+ the linespacing problem
+ \end{itemize}
+ */
+
+#include "compare.hh"
+instantiate_compare(const PCol &, PCol::compare);
+
+
+/// ideal spacing between two columns
+struct Idealspacing {
+
+ /// the ideal distance
+ Real space;
+
+ /// Hooke's constant: how strong are the "springs" attached to columns
+ Real hooke;
+
+ /// the two columns
+ const PCol *left, *right;
+
+ void print()const;
+ void OK() const ;
+ Idealspacing(const PCol *left,const PCol *right);
+};
+
+#endif
#include "real.hh"
-class Vector;
-class Matrix;
+class Parametric_symbol;
class Line_of_score;
class Line_of_staff;
class PCol;
struct Lyric_req;
struct Script_req;
struct Rest_req;
+struct Rhythmic_req;
struct Chord;
struct Stem_req;
struct Span_req;
struct Identifier;
struct Keyword;
class Mixed_qp;
-typedef Mixed_qp Optimisation_problem;
+class Paperdef;
// utility functions for PScore
#include "debug.hh"
+#include "dimen.hh"
#include "line.hh"
#include "pscore.hh"
#include "tstream.hh"
Idealspacing*ip =new Idealspacing(l,r);
suz.bottom().add(ip);
- // l->used = r->used = true;
+
return ip;
}
{
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();
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
+}
+
#include "vray.hh"
-#include "cols.hh"
+#include "pcol.hh"
#include "pstaff.hh"
/// all stuff which goes onto paper
PointerList<Spanner *> spanners;
/****************************************************************/
+
+ svec<Item*> select_items(PStaff*, PCol*);
void calc_breaking();
/**
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#
#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;
/**
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{
x^T QUAD x /2 + b^T x
*/
-typedef Mixed_qp Optimisation_problem;
+
#endif
#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;
}
}
Real
-Note_req::duration() const {
- return wholes( balltype,dots);
-}
-Real
-Rest_req::duration() const{
+Rhythmic_req::duration() const {
return wholes( balltype,dots);
}
#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; }
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
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;
///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
*/
-///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''
struct Absdynamic_req : Request, Dynamic {
Loudness loudness;
};
-
+#endif
#endif
#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)
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;
+
}
-
}
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);
}
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
+/*
+ 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
Staff_column * create_col(Score_column*);
};
+
+#endif // RHYTHMSTAF_HH
+
+
--- /dev/null
+#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
+}
--- /dev/null
+/*
+ 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
+
--- /dev/null
+#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();
+ }
+}
--- /dev/null
+/*
+ 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
+
-
#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();
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
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
{
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);
}
-
-
#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_;
/****************************************************************/
- 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 */
};
/**
#include "staff.hh"
+#include "stcol.hh"
+#include "sccol.hh"
#include "debug.hh"
-#include "pscore.hh"
+
void
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)
{
}
// now integrate break commands with other commands.
- // may be do this in derived functions.
+ // maybe do this in derived functions.
}
void
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;
-}
#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 {
--- /dev/null
+#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;
+}
--- /dev/null
+/*
+ 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
+
score{
rhythmstaff {
- voice { $ c4 c2 c4 $ }
+ voice { $c2 c2 c2 c2$ }
}
- rhythmstaff {
- voice { $ c2 c2 $ }
- }
- rhythmstaff {
- voice { $ c4 c4 c4 c4 $ }
- }
-% bar 2
}
#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()
+{
+}
#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
# 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
#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;
}
}
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;
}
}
-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);
-}
+/*
+ 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;
};
};
+
+#endif
+
"score", SCORE,
"bar", BAR,
"output", OUTPUT,
+ "cm", CM,
+ "pt", PT,
+ "in", IN,
+ "mm", MM,
+ "paper", PAPER,
+ "width", WIDTH,
+ "meter", METER,
0,0
} ;
#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);
#include "voice.hh"
#include "staff.hh"
+#include "sccol.hh"
+#include "stcol.hh"
#include "list.cc"
#include "cursor.cc"
#include "molecule.hh"
#include "list.cc"
#include "cursor.cc"
-L_instantiate(Atom);
+PL_instantiate(Atom);
PL_instantiate(Command);
PL_instantiate(Request);
-
+#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;
+}
#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);
#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();
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.
void
Voice_element::add(Request*r)
{
- if (r->tag == Request::NOTE ||r->tag == Request::REST) {
+ if (r->rhythmic()) {
assert (!duration);
duration = r->duration();
}
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