summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHan-Wen Nienhuys <hanwen@xs4all.nl>1996-11-05 17:55:42 +0100
committerHan-Wen Nienhuys <hanwen@xs4all.nl>1996-11-05 17:55:42 +0100
commit748e6176ab755ccf841f408d13d5818260a05d32 (patch)
treeaed0afeddb2233cf6bf67d9f82ffde051c57f715
parent74e0f769a23454f038d20270463c734a9c22f5f9 (diff)
release: 0.0.5
-rw-r--r--.dstreamrc4
-rw-r--r--Makefile8
-rw-r--r--README2
-rw-r--r--Sources.make4
-rw-r--r--TODO7
-rw-r--r--boxes.cc14
-rw-r--r--boxes.hh2
-rw-r--r--break.cc27
-rw-r--r--calcideal.cc10
-rw-r--r--command.cc42
-rw-r--r--command.hh8
-rw-r--r--debug.cc3
-rw-r--r--debug.hh6
-rw-r--r--flower/Makefile2
-rw-r--r--flower/Sources.make3
-rw-r--r--flower/TODO1
-rw-r--r--flower/assoc.hh2
-rw-r--r--flower/associter.hh42
-rw-r--r--flower/dstream.cc26
-rw-r--r--flower/dstream.hh6
-rw-r--r--flower/plist.hh2
-rw-r--r--flower/plist.inl13
-rw-r--r--getcommands.cc58
-rw-r--r--item.cc5
-rw-r--r--item.hh1
-rw-r--r--lexer.l6
-rw-r--r--lilyponddefs.tex11
-rw-r--r--lookupsyms.cc4
-rw-r--r--maartje.ly17
-rwxr-xr-xmake_patch2
-rw-r--r--misc.cc4
-rw-r--r--misc.hh4
-rw-r--r--molecule.cc15
-rw-r--r--molecule.hh2
-rw-r--r--mtime.hh8
-rw-r--r--parseconstruct.hh6
-rw-r--r--parser.y33
-rw-r--r--pcol.cc31
-rw-r--r--pcol.hh2
-rw-r--r--proto.hh16
-rw-r--r--pscore.cc47
-rw-r--r--pscore.hh2
-rw-r--r--request.hh4
-rw-r--r--rhythmstaf.cc13
-rw-r--r--rhythmstaf.hh3
-rw-r--r--sccol.cc2
-rw-r--r--sccol.hh7
-rw-r--r--scommands.cc116
-rw-r--r--scommands.hh9
-rw-r--r--score.cc56
-rw-r--r--score.hh36
-rw-r--r--scores.cc3
-rw-r--r--staff.cc14
-rw-r--r--staff.hh36
-rw-r--r--stcol.cc4
-rw-r--r--stcol.hh2
-rw-r--r--suzan.ly3
-rw-r--r--symbol.ini6
-rw-r--r--table.cc3
-rw-r--r--voice.cc4
-rw-r--r--voice.hh10
61 files changed, 580 insertions, 259 deletions
diff --git a/.dstreamrc b/.dstreamrc
index b5fa669d14..fccd8d5c37 100644
--- a/.dstreamrc
+++ b/.dstreamrc
@@ -13,4 +13,6 @@ Parser 1
Lexer 1
parse_duration 1
parse_pitch 1
-
+Col_configuration 1
+Command 1
+Score_commands 1 \ No newline at end of file
diff --git a/Makefile b/Makefile
index 2f5b450761..c1636f4012 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
MAJVER=0
MINVER=0
-PATCHLEVEL=4
+PATCHLEVEL=5
#
#
@@ -28,8 +28,10 @@ DFILES=$(hdr) $(mycc) $(othersrc) $(OFILES) $(IFILES) $(SCRIPTS) $(DOC)
#compiling
LOADLIBES=-L$(FLOWERDIR) -lflower
FLOWERDIR=../flower
-#DEFINES=-DNDEBUG -DNPRINT -O2
-CXXFLAGS=$(DEFINES) -I$(FLOWERDIR) -pipe -Wall -W -pedantic -g
+#DEFINES=-DNDEBUG -DNPRINT -O2 # speedy
+DEFINES=-g # lots of debugging info
+
+CXXFLAGS=$(DEFINES) -I$(FLOWERDIR) -pipe -Wall -W -pedantic
FLEX=flex
BISON=bison
exe=$(PACKAGENAME)
diff --git a/README b/README
index 412248b144..0ad234c7ff 100644
--- a/README
+++ b/README
@@ -6,4 +6,6 @@ patches to me,
hanwen@stack.urc.tue.nl
+If you actually want to use this, you'd better use the "speed"
+compilation flags in the Makefile
diff --git a/Sources.make b/Sources.make
index 02eac2a6c0..6c420edad7 100644
--- a/Sources.make
+++ b/Sources.make
@@ -3,7 +3,7 @@ hdr= qlp.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 rhythmstaf.hh\
parseconstruct.hh debug.hh globvars.hh keyword.hh\
misc.hh score.hh notename.hh lexer.hh symtable.hh\
symbol.hh main.hh dimen.hh paper.hh lookupsyms.hh\
@@ -19,5 +19,5 @@ mycc= qlp.cc qlpsolve.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\
+ sccol.cc stcol.cc getcommands.cc\
template1.cc template2.cc template3.cc
diff --git a/TODO b/TODO
index 3f91b6bbd8..cce684e09c 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,4 @@
-bug in BAR.
-dot spacing
-typeset direction.
-beam
-stem
+melodie staff.
+beam + stem
diff --git a/boxes.cc b/boxes.cc
index 74475b4530..ebfc08abfe 100644
--- a/boxes.cc
+++ b/boxes.cc
@@ -2,11 +2,14 @@
#include "const.hh"
void
-Interval:: set_empty() {
- min = INFTY;
- max = -INFTY;
+Interval::set_empty() {
+ min = INFTY;
+ max = -INFTY;
+}
+Real
+Interval::length() const {
+ return max-min;
}
-
Box::Box(svec<Real> s)
{
assert(s.sz() == 4);
@@ -22,6 +25,7 @@ Box::Box()
Box::Box(Interval ix, Interval iy)
{
- x=ix;
+ x = ix;
y = iy;
}
+
diff --git a/boxes.hh b/boxes.hh
index c9ff3e62ef..5d0be85452 100644
--- a/boxes.hh
+++ b/boxes.hh
@@ -49,7 +49,7 @@ struct Interval {
if (h.max>max)
max = h.max;
}
-
+ Real length() const;
void set_empty() ;
bool empty() { return min > max; }
Interval() {
diff --git a/break.cc b/break.cc
index e705c546cf..b8dc1827bc 100644
--- a/break.cc
+++ b/break.cc
@@ -13,7 +13,7 @@ svec<Real>
PScore::solve_line(svec<const PCol *> curline) const
{
Spacing_problem sp;
- mtor << "line of " << curline.sz() << " cols\n";
+
sp.add_column(curline[0], true, 0.0);
for (int i=1; i< curline.sz()-1; i++)
sp.add_column(curline[i]);
@@ -36,8 +36,8 @@ PScore::problem_OK() const
PCursor<PCol *> start(cols);
PCursor<PCol *> end (((PScore*)this)->cols.bottom());
- assert(start->breakable);
- assert(end->breakable);
+ assert(start->breakable());
+ assert(end->breakable());
}
struct Col_configuration {
@@ -54,10 +54,16 @@ struct Col_configuration {
energy = config.last();
config.pop();
}
+ void print() const {
+#ifndef NPRINT
+ mtor << "energy : " << energy << '\n';
+ mtor << "line of " << config.sz() << " cols\n";
+#endif
+ }
};
/// wordwrap type algorithm
-/* el stupido. This should be optimised:
+/* el stupido. This should be done more accurately:
It would be nice to have a Dynamic Programming type of algorithm
similar to TeX's
@@ -77,8 +83,9 @@ PScore::calc_breaking()
Col_configuration minimum;
Col_configuration current;
- // do another line
- current.add(breakpoints[i]->postbreak );
+ // do another line
+ PCol *post = breakpoints[i]->postbreak;
+ current.add( post);
curcol++; // skip the breakable.
i++;
@@ -92,11 +99,15 @@ PScore::calc_breaking()
}
current.add(breakpoints[i]->prebreak );
current.setsol(solve_line(current.line));
- mtor << "energy : " << current.energy << '\n';
+ current.print();
if (current.energy < minimum.energy) {
minimum = current;
- } else {
+ } else { // we're one col too far.
+ i--;
+ while (curcol != breakpoints[i])
+ curcol --;
+
break;
}
diff --git a/calcideal.cc b/calcideal.cc
index bddd4f2897..1dc0e1d385 100644
--- a/calcideal.cc
+++ b/calcideal.cc
@@ -26,13 +26,13 @@ Score::connect_nonmus(PCol* c1, PCol *c2, Real d)
do_connect(c1,c2,d);
// alert! this is broken!
- if (c1->breakable) {
+ if (c1->breakable()) {
do_connect(c1->postbreak, c2,d);
}
- if (c2->breakable) {
+ if (c2->breakable()) {
do_connect(c1, c2->prebreak,d);
}
- if (c1->breakable &&c2->breakable) {
+ if (c1->breakable() &&c2->breakable()) {
do_connect(c1->postbreak, c2->prebreak,d);
}
}
@@ -49,8 +49,8 @@ Score::calc_idealspacing()
for (; sc.ok(); sc++) {
if (sc->musical)
for (int i=0; i < sc->durations.sz(); i++) {
- Mtime d = sc->durations[i];
- Real dist = duration_to_idealspace(d, paper->whole_width);
+ Real d = sc->durations[i];
+ 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 6375c7e6d3..23edf1ec36 100644
--- a/command.cc
+++ b/command.cc
@@ -5,39 +5,14 @@
bool
Command::isbreak()const
{
- return (code >= BREAK_PRE&&code <= BREAK_END);
+ return (code >= BREAK_PRE && code <= BREAK_END);
}
-Command*
-get_bar_command(Real w)
-{
- Command*c = new Command;
- c->when = w;
- c->code = TYPESET;
- c->args.add( "BAR");
- 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;
+ priority=0;
}
@@ -46,12 +21,19 @@ Command::Command(Real w)
{
code = NOP;
when = w;
+ priority=0;
}
+
void
Command::print() const
{
- mtor << "command code: " << code << " args: ";
- for (int i = 0; i<args.sz(); i++)
- mtor << args[i];
+#ifndef NPRINT
+ mtor << "command at " << when << ", code " << code << " prio " << priority;
+ if (args.sz()) {
+ mtor<< " args: ";
+ for (int i = 0; i<args.sz(); i++)
+ mtor << "`"<<args[i] <<"',";
+ }
mtor << "\n";
+#endif
}
diff --git a/command.hh b/command.hh
index 6b835e964b..3e90067075 100644
--- a/command.hh
+++ b/command.hh
@@ -1,7 +1,7 @@
#ifndef COMMAND_HH
#define COMMAND_HH
#include "glob.hh"
-#include "mtime.hh"
+
#include "vray.hh"
#include "string.hh"
@@ -15,9 +15,13 @@ enum Commandcode {
struct Command {
Commandcode code;
- Mtime when;
+ Real when;
/// analogous to argv[]
svec<String> args;
+ int priority;
+
+ /****************/
+
Command();
Command(Real w);
bool isbreak()const;
diff --git a/debug.cc b/debug.cc
index 874937573e..34859a3c9f 100644
--- a/debug.cc
+++ b/debug.cc
@@ -1,9 +1,10 @@
+#include <fstream.h>
#include "debug.hh"
#include "dstream.hh"
#include "vector.hh"
Dstream monitor(&cout,".dstreamrc");
-
+ostream * nulldev = new ofstream("/dev/null");
void
debug_init()
{
diff --git a/debug.hh b/debug.hh
index ca805df011..200585608b 100644
--- a/debug.hh
+++ b/debug.hh
@@ -9,10 +9,14 @@
#define WARN warnout << "warning: "<<__FUNCTION__ << "(): "
extern ostream &warnout ;
extern ostream *mlog;
+extern ostream *nulldev;
extern Dstream monitor; // monitor
+#ifdef NPRINT
+#define mtor *nulldev
+#else
#define mtor monitor.identify_as(__PRETTY_FUNCTION__)
-
+#endif
void error(String s);
void warning(String s);
diff --git a/flower/Makefile b/flower/Makefile
index 4533783563..5b40b40629 100644
--- a/flower/Makefile
+++ b/flower/Makefile
@@ -1,6 +1,6 @@
MAJVER=1
MINVER=0
-PATCHLEVEL=4
+PATCHLEVEL=5
PACKAGENAME=flower
VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
diff --git a/flower/Sources.make b/flower/Sources.make
index fd5dcf4146..e8b2250ad1 100644
--- a/flower/Sources.make
+++ b/flower/Sources.make
@@ -9,4 +9,5 @@ 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 plist.hh\
+ tsmat.hh tvsmat.hh plist.hh associter.hh\
+
diff --git a/flower/TODO b/flower/TODO
index 6f0f451cce..bcb4e27042 100644
--- a/flower/TODO
+++ b/flower/TODO
@@ -1,3 +1,4 @@
+ * PointerList<T>:List<T> -> PointerList<T>:List<T*>
* efficient copy cons for List
diff --git a/flower/assoc.hh b/flower/assoc.hh
index 84a54c9a72..2409985668 100644
--- a/flower/assoc.hh
+++ b/flower/assoc.hh
@@ -2,6 +2,7 @@
#define ASSOC_HH
#include "vray.hh"
+#include <assert.h>
template<class K,class V>
struct Assoc_ent_ {
@@ -72,4 +73,5 @@ public:
};
/** mindblowingly stupid Associative array implementation
*/
+
#endif
diff --git a/flower/associter.hh b/flower/associter.hh
new file mode 100644
index 0000000000..6103f2266c
--- /dev/null
+++ b/flower/associter.hh
@@ -0,0 +1,42 @@
+/*
+ associter.hh -- part of flowerlib
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef ASSOCITER_HH
+#define ASSOCITER_HH
+
+#include "assoc.hh"
+
+/// an iterator for the #Assoc# class
+template<class K, class V>
+struct Assoc_iter {
+ int i;
+ Assoc<K,V> &assoc_;
+
+ Assoc_iter(Assoc<K,V> &a) :
+ assoc_(a)
+ {
+ i= next(0);
+ }
+ int next(int j) {
+ while (j < assoc_.arr.sz() && assoc_.arr[j].free)
+ j++;
+ return j;
+ }
+ bool ok() const {
+ return i < assoc_.arr.sz();
+ }
+ void OK()const {
+ assert(!ok() || !assoc_.arr[i].free);
+ }
+ void operator++(int) { i++; i = next(i); }
+ K key() { return assoc_.arr[i].key; }
+ V &val() { return assoc_.arr[i].val; }
+};
+/*
+ Iterator
+ */
+
+#endif
diff --git a/flower/dstream.cc b/flower/dstream.cc
index d8cff69041..8540e734cf 100644
--- a/flower/dstream.cc
+++ b/flower/dstream.cc
@@ -1,5 +1,5 @@
#include <fstream.h>
-
+#include "assoc.hh"
#include "dstream.hh"
#include "string.hh"
#include "textdb.hh"
@@ -36,14 +36,14 @@ Dstream::identify_as(String name)
String cl(strip_member(mem));
String idx = cl;
- if (silent.elt_query(mem))
+ if (silent->elt_query(mem))
idx = mem;
- else if (silent.elt_query(cl))
+ else if (silent->elt_query(cl))
idx = cl;
else {
- silent[idx] = false;
+ (*silent)[idx] = false;
}
- local_silence = silent[idx];
+ local_silence = (*silent)[idx];
if (classname != idx && !local_silence) {
classname=idx;
*os << "[" << classname << ":]";
@@ -54,9 +54,9 @@ Dstream::identify_as(String name)
bool
Dstream::silence(String s)
{
- if (!silent.elt_query(s))
+ if (!silent->elt_query(s))
return false;
- return silent[s];
+ return (*silent)[s];
}
///
Dstream &
@@ -99,6 +99,7 @@ Dstream::operator<<(String s)
Dstream::Dstream(ostream *r, const char * cfg_nm )
{
os = r;
+ silent = new Assoc<String,bool>;
if (!os)
return;
indentlvl = 0;
@@ -109,15 +110,18 @@ Dstream::Dstream(ostream *r, const char * cfg_nm )
if (!ifs)
return;
}
- // cerr << "(" << fn;
+
Text_db cfg(fn);
while (! cfg.eof()){
Text_record r( cfg++);
assert(r.sz() == 2);
- silent[r[0]] = r[1].to_bool();
+ (*silent)[r[0]] = r[1].to_bool();
}
- // cerr <<")";
-}
+}
+Dstream::~Dstream()
+{
+ delete silent;
+}
diff --git a/flower/dstream.hh b/flower/dstream.hh
index 72d0897201..aae52a7838 100644
--- a/flower/dstream.hh
+++ b/flower/dstream.hh
@@ -4,10 +4,12 @@
#define DSTREAM_HH
#include "string.hh"
-#include "assoc.hh"
const char eol= '\n';
+template<class K,class V>
+struct Assoc;
+
/// debug stream
class Dstream
{
@@ -16,7 +18,7 @@ class Dstream
bool local_silence;
String classname;
- Assoc<String, bool> silent;
+ Assoc<String, bool> *silent;
public:
bool silence(String);
diff --git a/flower/plist.hh b/flower/plist.hh
index 3660968a47..8fa126b527 100644
--- a/flower/plist.hh
+++ b/flower/plist.hh
@@ -44,7 +44,7 @@ class PointerList : public List<T>
template<class T>
-void PL_copy(PointerList<T> &dst,PointerList<T> const&src);
+void PL_copy(PointerList<T*> &dst,PointerList<T*> const&src);
#define PL_instantiate(a) L_instantiate(a *); template class PointerList<a*>
diff --git a/flower/plist.inl b/flower/plist.inl
index fb18c87241..b8cd8d6020 100644
--- a/flower/plist.inl
+++ b/flower/plist.inl
@@ -25,18 +25,17 @@ 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();
+ for (PCursor<T> c(l ); c.ok(); c++ )
+ c->print();
}
template<class T>
inline void
-PL_copy(PointerList<T> &to,PointerList<T> const&src)
+PL_copy(PointerList<T*> &to,PointerList<T*> const&src)
{
- for (PCursor<T> pc(src); pc.ok(); pc++) {
- T q = pc;
- T p=new typeof(*q) (*q) ; // argh, how do i do this in ANSI-C++
+ for (PCursor<T*> pc(src); pc.ok(); pc++) {
+ T *q = pc;
+ T *p=new T(*q) ; // argh, how do i do this in ANSI-C++
to.bottom().add(p);
}
}
diff --git a/getcommands.cc b/getcommands.cc
new file mode 100644
index 0000000000..1f9362c59c
--- /dev/null
+++ b/getcommands.cc
@@ -0,0 +1,58 @@
+#include "string.hh"
+#include "parseconstruct.hh"
+#include "command.hh"
+
+Command*
+get_bar_command(Real w)
+{
+ Command*c = new Command;
+ c->when = w;
+ c->code = TYPESET;
+ c->args.add( "BAR");
+ c->args.add( "|");
+ c->priority = 100;
+ 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 );
+ c->priority = 50; // less than bar
+ return c;
+}
+
+Command *
+get_meterchange_command(int n, int m)
+{
+ Command*c = new Command;
+
+ c->code = INTERPRET;
+ c->args.add( "METER");
+ c->args.add( n );
+ c->args.add( m );
+ c->priority = 0; // more than bar
+ return c;
+}
+
+
+Command *
+get_skip_command(int n, Real m)
+{
+ Command*c = new Command;
+
+ c->code = INTERPRET;
+ c->args.add( "SKIP");
+ c->args.add( n );
+ c->args.add( m );
+ c->priority = 0; // more than bar
+ return c;
+}
+
+
diff --git a/item.cc b/item.cc
index 453200627b..96ec8a890a 100644
--- a/item.cc
+++ b/item.cc
@@ -54,3 +54,8 @@ Item::Item()
output = 0;
pstaff_ = 0;
}
+void
+Item::print() const
+{
+ output->print();
+}
diff --git a/item.hh b/item.hh
index 6a3a9880d7..484822533b 100644
--- a/item.hh
+++ b/item.hh
@@ -40,6 +40,7 @@ struct Item {
*/
String TeXstring () const ;
Item();
+ void print()const;
};
/** An item must be part of a Column
*/
diff --git a/lexer.l b/lexer.l
index 03853ca579..46a30cf752 100644
--- a/lexer.l
+++ b/lexer.l
@@ -113,9 +113,15 @@ REAL [0-9]+(\.[0-9]*)?
mtor << "parens\n";
return YYText()[0];
}
+[:] {
+ char c = YYText()[0];
+ mtor << "misc char" <<c<<"\n";
+ return c;
+}
[ \t\n]+ {
}
+
%.* {
//ignore
}
diff --git a/lilyponddefs.tex b/lilyponddefs.tex
index 242a17d5f4..9b18faf880 100644
--- a/lilyponddefs.tex
+++ b/lilyponddefs.tex
@@ -26,6 +26,9 @@
\mdef\singledot{'00}
\mdef\doubledot{'01}
\mdef\tripledot{'02}
+
+
+
\def\maatstreep{\vrule height8pt depth8pt }
\def\finishbar{\vrule height8pt width 1pt depth8pt}
\parindent0pt
@@ -42,7 +45,7 @@
\newcount\n
\def\linestafsym#1#2{\hbox to 0pt{\vbox to 0pt{\n=0%
- \loop\ifnum\n<#1\advance\n by1
+ \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}}
@@ -50,4 +53,8 @@
\def\cquartrest{\vcenter\quartrest}
\def\ceighthrest{\vcenter\eighthrest}
\def\csixteenthrest{\vcenter\sixteenthrest}
-\def\cthirtysecondrest{\vcenter\thirtysecondrest} \ No newline at end of file
+\def\cthirtysecondrest{\vcenter\thirtysecondrest}
+
+\def\lsingledot{\kern-6pt\singledot}
+\def\ldoubledot{\kern-6pt\doubledot}
+\def\ltripledot{\kern-6pt\tripledot} \ No newline at end of file
diff --git a/lookupsyms.cc b/lookupsyms.cc
index 66cbd6db08..14b3ab11e3 100644
--- a/lookupsyms.cc
+++ b/lookupsyms.cc
@@ -68,8 +68,8 @@ 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") );
+ s.dim.x = Interval( convert_dimen(-5,"pt"), convert_dimen(10,"pt"));
+ s.dim.y = Interval(0, convert_dimen(10,"pt") ); // todo
String src = the_sym_tables("param")->lookup("meter").tex;
s.tex = substitute_args(src,a);
return s;
diff --git a/maartje.ly b/maartje.ly
index 49665efd4d..508389a12e 100644
--- a/maartje.ly
+++ b/maartje.ly
@@ -2,7 +2,9 @@
score {
-% output "maartje.uit"
+ paper {
+ unitspace 3 cm
+ }
rhythmstaff {
voice { $ c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 $ }
}
@@ -11,12 +13,11 @@ score {
r2 r4 r1
$ }
}
-
- bar 2 bar 3
- bar 4.5 bar 5 bar 5.5
- bar 6 bar 7 bar 8
-
- meter 2 4 4 % after bars.
-
+ commands {
+ meter 4 4
+ skip 3:0
+ meter 2 4
+ skip 8:0
+ }
}
diff --git a/make_patch b/make_patch
index 08f4936b56..c2a1e50f8a 100755
--- a/make_patch
+++ b/make_patch
@@ -28,4 +28,4 @@ fi
#(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
+rm -rf $nm$old $nm$new
diff --git a/misc.cc b/misc.cc
index 2be0f81dd6..3a8658f4a0 100644
--- a/misc.cc
+++ b/misc.cc
@@ -1,6 +1,6 @@
#include "misc.hh"
#include "glob.hh"
-#include "mtime.hh"
+
#include <math.h>
int intlog2(int d) {
@@ -26,7 +26,7 @@ const double WHOLE_SPACE = 5.0; // should be settable from input
Real
-duration_to_idealspace(Mtime d, Real w)
+duration_to_idealspace(Real d, Real w)
{
// see Roelofs, p. 57
return w * pow(ENGRAVERS_SPACE, log2(d));
diff --git a/misc.hh b/misc.hh
index a22304267f..0321113242 100644
--- a/misc.hh
+++ b/misc.hh
@@ -1,7 +1,7 @@
#ifndef MISC_HH
#define MISC_HH
-#include "mtime.hh"
+#include "real.hh"
int intlog2(int d);
-Real duration_to_idealspace(Mtime d,Real w);
+Real duration_to_idealspace(Real d,Real w);
#endif
diff --git a/molecule.cc b/molecule.cc
index 7b8a752423..5ab384f87d 100644
--- a/molecule.cc
+++ b/molecule.cc
@@ -3,6 +3,13 @@
#include "string.hh"
#include "molecule.hh"
#include "symbol.hh"
+#include "debug.hh"
+
+void
+Atom::print() const
+{
+ mtor << "texstring: " <<sym.tex<<"\n";
+}
Box
Atom::extent() const
@@ -29,7 +36,6 @@ Atom::TeXstring() const
return s;
}
-/****************************************************************/
String
Molecule::TeXstring() const
@@ -111,3 +117,10 @@ Molecule::Molecule(const Molecule&s)
{
add(s);
}
+
+void
+Molecule::print() const
+{
+ for (PCursor<Atom*> c(ats); c.ok(); c++)
+ c->print();
+}
diff --git a/molecule.hh b/molecule.hh
index 60a7a05f44..05ec64e3e0 100644
--- a/molecule.hh
+++ b/molecule.hh
@@ -18,6 +18,7 @@ struct Atom {
Box extent() const;
Atom(Symbol s);
+ void print() const;
String TeXstring() const;
};
@@ -42,6 +43,7 @@ struct Molecule {
String TeXstring() const;
Molecule(const Molecule&s);
+ void print() const;
private:
void operator=(const Molecule&);
};
diff --git a/mtime.hh b/mtime.hh
deleted file mode 100644
index ef01d2314b..0000000000
--- a/mtime.hh
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef MTIME_HH
-#define MTIME_HH
-
-#include "real.hh"
-
-typedef Real Mtime;
-
-#endif
diff --git a/parseconstruct.hh b/parseconstruct.hh
index fa9f62757d..d2f2c1ac4a 100644
--- a/parseconstruct.hh
+++ b/parseconstruct.hh
@@ -5,4 +5,8 @@ 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);
+
+Command* get_meterchange_command( int,int);
+Command* get_meter_command( Real,int,int);
+Command* get_skip_command( int,Real);
+
diff --git a/parser.y b/parser.y
index d60face970..ebc4c54f8b 100644
--- a/parser.y
+++ b/parser.y
@@ -7,6 +7,7 @@
#include "score.hh"
#include "main.hh"
#include "keyword.hh"
+#include "scommands.hh"
#include "debug.hh"
#include "parseconstruct.hh"
#include "dimen.hh"
@@ -22,7 +23,7 @@
Real real;
Command *command;
Identifier *id;
-
+ Score_commands *scommands;
Voice *voice;
Voice_element *el;
Staff *staff;
@@ -34,7 +35,7 @@
}
%token VOICE STAFF SCORE TITLE RHYTHMSTAFF BAR NOTENAME OUTPUT
-%token CM IN PT MM PAPER WIDTH METER
+%token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS
%type <consstr> unit
%token <id> IDENTIFIER
@@ -50,7 +51,7 @@
%type <score> score_block score_body
%type <staff> staff_block rhythmstaff_block rhythmstaff_body
%type <i> int
-
+%type <scommands> score_commands_block score_commands_body
%%
@@ -66,9 +67,16 @@ score_block: SCORE '{' score_body '}' { $$ = $3; }
score_body: { $$ = new Score; }
| score_body staff_block { $$->add($2); }
- | score_body score_command { $$->add($2); }
- | score_body paper_block { delete $$->paper;
- $$->paper = $2;
+ | score_body score_commands_block { $$->set($2); }
+ | score_body paper_block { $$->set($2); }
+ ;
+score_commands_block:
+ COMMANDS '{' score_commands_body '}' { $$ =$3;}
+ ;
+
+score_commands_body: { $$ = new Score_commands; }
+ | score_commands_body score_command {
+ $$->parser_add($2);
}
;
@@ -82,6 +90,7 @@ paper_body:
| paper_body OUTPUT STRING { $$->outfile = *$3;
delete $3;
}
+ | paper_body UNITSPACE dim { $$->whole_width = $3; }
;
dim:
@@ -142,13 +151,17 @@ voice_elt:
;
score_command:
- BAR REAL {
- $$ = get_bar_command($2);
+ SKIP int ':' REAL {
+ $$ = get_skip_command($2, $4);
}
- | METER REAL int int {
- $$ = get_meter_command($2, $3, $4);
+ | METER int int {
+ $$ = get_meterchange_command($2, $3);
}
+/* | PARTIALMEASURE REAL {
+ $$ = get_partial_command($2);
+ }*/
;
+
int:
REAL {
diff --git a/pcol.cc b/pcol.cc
index 44c82a938d..1ae06519ac 100644
--- a/pcol.cc
+++ b/pcol.cc
@@ -5,10 +5,10 @@
void
Idealspacing::print() const
{
- #ifndef NPRINT
+#ifndef NPRINT
mtor << "idealspacing {" ;
mtor << "distance "<<space<< " strength " << hooke << "}\n";
- #endif
+#endif
}
Idealspacing::Idealspacing(const PCol * l,const PCol * r)
@@ -18,6 +18,7 @@ Idealspacing::Idealspacing(const PCol * l,const PCol * r)
left = l;
right = r;
}
+
void
Idealspacing::OK() const
{
@@ -46,7 +47,11 @@ PCol::print() const
#ifndef NPRINT
mtor << "PCol {";
mtor << "# symbols: " << its.size() ;
- mtor << "breakable: " << breakable<<"\n";
+ if (breakable()){
+ mtor << "pre,post: ";
+ prebreak->print();
+ postbreak->print();
+ }
mtor << "extent: " << width().min << ", " << width().max << "\n";
mtor << "}\n";
#endif
@@ -63,7 +68,9 @@ void
PCol::OK () const
{
if (prebreak || postbreak ) {
- assert(breakable);
+ assert(prebreak&&postbreak);
+ assert(prebreak->daddy == this);
+ assert(postbreak->daddy == this);
}
}
@@ -71,29 +78,33 @@ PCol::OK () const
void
PCol::set_breakable()
{
- if (breakable)
+ if (breakable())
return;
prebreak = new PCol(this);
postbreak = new PCol(this);
- breakable = true;
used = true;
}
+bool
+PCol::breakable() const
+{
+ return prebreak||postbreak;
+}
+
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 prebreak;
+
delete postbreak;
}
diff --git a/pcol.hh b/pcol.hh
index d11a23ca9c..203482b10e 100644
--- a/pcol.hh
+++ b/pcol.hh
@@ -12,7 +12,7 @@ struct PCol {
List<const Spanner*> stoppers, starters;
/// Can this be broken? true eg. for bars.
- bool breakable;
+ bool breakable()const;
/// does this column have items, does it have spacings attached?
bool used;
diff --git a/proto.hh b/proto.hh
index 394f3be14b..ba93e7a526 100644
--- a/proto.hh
+++ b/proto.hh
@@ -1,6 +1,13 @@
+/*
+ proto.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef PROTO_HH
+#define PROTO_HH
#include "real.hh"
-class Parametric_symbol;
class Line_of_score;
class Line_of_staff;
class PCol;
@@ -74,3 +81,10 @@ struct Identifier;
struct Keyword;
class Mixed_qp;
class Paperdef;
+class Score_commands;
+class Parametric_symbol;
+
+
+
+#endif // PROTO_HH
+
diff --git a/pscore.cc b/pscore.cc
index 44a87c0dd4..773554375c 100644
--- a/pscore.cc
+++ b/pscore.cc
@@ -1,5 +1,6 @@
// utility functions for PScore
#include "debug.hh"
+#include "molecule.hh"
#include "dimen.hh"
#include "line.hh"
#include "pscore.hh"
@@ -11,7 +12,6 @@ PScore::clean_cols()
for (PCursor<PCol *> c(cols); c.ok(); )
if (!c->used) {
c.del();
- mtor << "removing pcol\n";
} else
c++;
}
@@ -27,15 +27,28 @@ void
PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat)
{
assert(c && i && s);
- if (breakstat == 1 ) {
- typeset_item(i, c->prebreak, s, 0);
- } if (breakstat == 3)
- typeset_item(i, c->prebreak, s, 0 );
- else{
- its.bottom().add(i);
- s->add(i);
- c->add(i);
+// assert(!breakstat != 4 || c->breakable() );
+ if (breakstat == 0) {
+ typeset_item(i, c->prebreak, s);
+ return;
}
+
+ if (breakstat == 2) {
+ typeset_item(i, c->postbreak, s);
+ return;
+ }
+ if (c->daddy && c == c->daddy->prebreak) { // makeshift.
+ Interval iv (i->width());
+ if (!iv.empty()) {
+ svec<Item*> col_its (select_items(s, c));
+ for (int j =0; j < col_its.sz(); j++)
+ col_its[j]->output->translate(Offset(-iv.length(),0));
+ i->output->translate (Offset(-iv.max, 0));
+ }
+ }
+ its.bottom().add(i);
+ s->add(i);
+ c->add(i);
}
void
@@ -70,7 +83,7 @@ PScore::find_breaks() const
{
svec<const PCol *> retval;
for (PCursor<PCol *> c(cols); c.ok(); c++)
- if (c->breakable)
+ if (c->breakable())
retval.add(c);
return retval;
@@ -84,7 +97,7 @@ PScore::add(PCol *p)
PScore::PScore()
{
- linewidth = convert_dimen(15,"cm");
+ linewidth = convert_dimen(15,"cm"); // default
}
void
@@ -115,18 +128,18 @@ PScore::select_items(PStaff*ps , PCol*pc)
void
PScore::OK()const
{
+#ifdef NDEBUG
for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
cc->OK();
for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
ic->OK();
-
+#endif
}
void
PScore::print() const
-{
-
- #ifndef NPRINT
- mtor << "PScore { width "<<print_dimen(linewidth);
+{
+#ifndef NPRINT
+ mtor << "PScore { width "<<print_dimen(linewidth);
mtor << "\ncolumns: ";
for (PCursor<PCol*> cc(cols); cc.ok(); cc++)
cc->print();
@@ -135,6 +148,6 @@ PScore::print() const
for (PCursor<Idealspacing*> ic(suz); ic.ok(); ic++)
ic->print();
mtor << "}\n";
- #endif
+#endif
}
diff --git a/pscore.hh b/pscore.hh
index 5ae4c37951..b22582e3f6 100644
--- a/pscore.hh
+++ b/pscore.hh
@@ -55,7 +55,7 @@ struct PScore {
void add(PStaff *);
/// add item
- void typeset_item(Item *, PCol *,PStaff*,int);
+ void typeset_item(Item *, PCol *,PStaff*,int=1);
/// add to bottom of pcols
void add(PCol*);
/**
diff --git a/request.hh b/request.hh
index 79846e7e69..f2dc5f7144 100644
--- a/request.hh
+++ b/request.hh
@@ -4,7 +4,7 @@
#include "glob.hh"
#include "string.hh"
-#include "mtime.hh"
+
struct Request {
Voice_element*elt;
#if 0
@@ -172,7 +172,7 @@ struct Slur_req : Span_req {
/// helper in the hierarchy
struct Dynamic {
- Mtime subtime;
+ Real subtime;
};
/** Each dynamic is bound to one note ( a crescendo spanning multiple
notes is thought to be made of two "dynamics": a start and a stop).
diff --git a/rhythmstaf.cc b/rhythmstaf.cc
index d2a85d62ce..0b9e90e229 100644
--- a/rhythmstaf.cc
+++ b/rhythmstaf.cc
@@ -17,11 +17,13 @@ Rhythmic_column::Rhythmic_column(Score_column*s, Rhythmic_staff *rs)
staff_ = rs;
}
-
+Rhythmic_staff::Rhythmic_staff()
+{
+ theline = new Linestaff(1);
+}
void
Rhythmic_staff::set_output(PScore* ps )
{
- theline = new Linestaff(1);
pscore_ = ps;
pscore_->add(theline);
}
@@ -30,7 +32,7 @@ Rhythmic_staff::set_output(PScore* ps )
void
Rhythmic_column::process_commands( )
{
- int breakstat = BREAK_END;
+ int breakstat = BREAK_END - BREAK_PRE;
for (int i = 0 ; i < s_commands.sz(); i++) {
Command *com = s_commands[i];
switch (com->code){
@@ -41,7 +43,7 @@ Rhythmic_column::process_commands( )
case BREAK_POST:
case BREAK_END:
score_column->set_breakable();
- breakstat = com->code;
+ breakstat = com->code- BREAK_PRE;
break;
case TYPESET:
@@ -77,7 +79,6 @@ Rhythmic_column::process_requests()
the_note = rq;
}
break;
-
}
}
@@ -136,7 +137,7 @@ Rhythmic_column::typeset_req(Request *rq)
m->add_right(dm);
}
i->output=m;
- staff_->pscore_->typeset_item(i, score_column->pcol, staff_->theline,0 );
+ staff_->pscore_->typeset_item(i, score_column->pcol, staff_->theline );
}
void
diff --git a/rhythmstaf.hh b/rhythmstaf.hh
index 8e362146e3..69b61ec487 100644
--- a/rhythmstaf.hh
+++ b/rhythmstaf.hh
@@ -32,11 +32,14 @@ struct Rhythmic_column : Staff_column {
struct Rhythmic_staff : Staff {
/// indirection to the PStaff.
PStaff *theline;
+
+ /****************/
void set_output(PScore *);
void process_commands( PCursor<Command*> &where);
void grant_requests();
Staff_column * create_col(Score_column*);
+ Rhythmic_staff();
};
diff --git a/sccol.cc b/sccol.cc
index 28955332d5..1dfc8f2176 100644
--- a/sccol.cc
+++ b/sccol.cc
@@ -1,7 +1,7 @@
#include "sccol.hh"
#include "debug.hh"
-Score_column::Score_column(Mtime w)
+Score_column::Score_column(Real w)
{
when = w;
pcol = new PCol(0);
diff --git a/sccol.hh b/sccol.hh
index 9c22c277a1..21a341d17f 100644
--- a/sccol.hh
+++ b/sccol.hh
@@ -7,19 +7,18 @@
#ifndef SCCOL_HH
#define SCCOL_HH
#include "pcol.hh"
-#include "mtime.hh"
struct Score_column {
PCol * pcol;
- svec<Mtime> durations;
- Mtime when;
+ svec<Real> durations;
+ Real when;
///
bool musical;
- Score_column(Mtime when);
+ Score_column(Real when);
static int compare(Score_column & c1, Score_column &c2) {
return sgn(c1.when - c2.when);
diff --git a/scommands.cc b/scommands.cc
index 82fe9a1691..8f86ff6fad 100644
--- a/scommands.cc
+++ b/scommands.cc
@@ -1,5 +1,6 @@
#include "scommands.hh"
#include "debug.hh"
+#include "parseconstruct.hh"
/*
maybe it's time for a "narrowing" cursor?
@@ -78,45 +79,74 @@ Score_commands::is_breakable(Real w)
}
return false;
}
+
+void
+Score_commands::insert_between(Command victim, PCursor<Command*> firstc,
+ PCursor<Command*> last)
+{
+ assert(last->when==firstc->when);
+ PCursor<Command*> c(firstc+1);
+ while (c != last) { // hmm what if !last.ok()?
+ if (victim.priority > c->priority) {
+ c.insert(new Command(victim));
+ return;
+ }
+ c++;
+ }
+ last.insert(new Command(victim));
+
+}
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));
+ PCursor<Command*> c ( first(w)), f(c), l(c);
+
while (!c->isbreak())
c++;
- c.add(new Command(pre));
-
+ f = c++;
while (!c->isbreak())
c++;
- c.add(new Command(mid));
-
+ l = c++;
+
+ insert_between(pre, f, l);
+ f = l;
while (!c->isbreak())
c++;
- c.add(new Command(post));
+ l = c++;
+ insert_between(mid, f, l);
+ f = l;
+ while (!c->isbreak())
+ c++;
+ l = c++;
+ insert_between(post, f, l);
+ assert(l.ok() && l->when ==w && l->code == BREAK_END);
}
void
-Score_commands::add(Command c)
+Score_commands::parser_add(Command *c)
{
- bool encapsulate =false;
+ bottom().add(c);
+}
- Command pre(c.when);
- Command mid(c.when);
- Command post(c.when);
+void
+Score_commands::process_add(Command c)
+{
+ bool encapsulate =false;
+ Real w = c.when;
+ Command pre(w);
+ Command mid(w);
+ Command post(w);
if (c.code == TYPESET) {
if (c.args[0] == "BAR") {
- set_breakable(c.when);
+ set_breakable(w);
encapsulate = true;
mid = c;
pre = c;
}
- if (c.args[0] == "METER" && is_breakable(c.when)) {
+ if (c.args[0] == "METER" && is_breakable(w)) {
encapsulate = true;
mid = c;
pre = c;
@@ -146,14 +176,14 @@ Score_commands::clean(Real l)
c.code = TYPESET;
c.args.add("BAR");
c.args.add("empty");
- add(c);
+ process_add(c);
}
PCursor<Command*> bot(bottom());
while (bot.ok() && bot->when > l) {
-
- mtor <<"removing "<< bot->code <<" at " << bot->when<<'\n';
+ mtor <<"removing ";
+ bot->print();
bot.del();
bot = bottom();
}
@@ -163,7 +193,7 @@ Score_commands::clean(Real l)
c.code = TYPESET;
c.args.add("BAR");
c.args.add("||");
- add(c);
+ process_add(c);
}
OK();
}
@@ -173,6 +203,8 @@ Score_commands::OK() const
{
for (PCursor<Command*> cc(*this); cc.ok() && (cc+1).ok(); cc++) {
assert(cc->when <= (cc+1)->when);
+ if (cc->when == (cc+1)->when && !cc->isbreak() && !(cc+1)->isbreak())
+ assert(cc->priority >= (cc+1)->priority);
}
}
@@ -183,3 +215,47 @@ Score_commands::print() const
cc->print();
}
}
+
+Score_commands*
+Score_commands::parse(Real l) const
+{
+ Score_commands*nc = new Score_commands;
+ int beats_per_meas=4;
+ Real measlen = 1.0; // 4/4 by default
+
+ Real inbar=0.0;
+ int barcount=0;
+ Real wholes=0.0;
+ Real stoppos=0.0;
+
+ {
+ Command c(0.0);
+ c.code = TYPESET;
+ c.args.add("BAR");
+ c.args.add("empty");
+ nc->process_add(c);
+ }
+ for (PCursor<Command*> cc(*this); cc.ok() && cc->when <= l; cc++) {
+ assert (cc->code==INTERPRET);
+ if (cc->args[0] == "METER") {
+ beats_per_meas=cc->args[1].value();
+ int one_beat =cc->args[2].value ();
+ measlen = beats_per_meas/Real(one_beat);
+ nc->process_add(*get_meter_command(wholes,beats_per_meas, one_beat));
+ }
+ if (cc->args[0] == "SKIP") {
+ stoppos = wholes + cc->args[1].value() * measlen + cc->args[2].fvalue();
+ wholes += (measlen-inbar); // skip at least 1 measure
+ barcount++;
+ while (wholes <= stoppos) {
+ nc->process_add(*get_bar_command(wholes)); // liek
+ wholes += measlen;
+ barcount ++;
+ }
+ wholes = stoppos;
+ //something
+ }
+ }
+
+ return nc;
+}
diff --git a/scommands.hh b/scommands.hh
index 15c844ca65..ee3b4591ab 100644
--- a/scommands.hh
+++ b/scommands.hh
@@ -9,8 +9,10 @@
#include "vray.hh"
#include "list.hh"
-struct Score_commands : public PointerList<Command*> {
- void add(Command);
+struct Score_commands : public PointerList<Command*> {
+ void process_add(Command);
+ Score_commands*parse(Real last)const;
+ void parser_add(Command*);
void add_seq(svec<Command>);
void clean(Real last);
void set_breakable(Real when);
@@ -20,6 +22,9 @@ struct Score_commands : public PointerList<Command*> {
void add_command_to_break(Command pre, Command mid,Command post);
void OK() const;
void print() const;
+ Real last() const;
+ void insert_between(Command victim, PCursor<Command*> firstc,
+ PCursor<Command*> last);
};
/** the list of commands in Score. Put in a separate class, since it
otherwise clutters the methods of Score. */
diff --git a/score.cc b/score.cc
index 0f8bbf70de..3c95fd1790 100644
--- a/score.cc
+++ b/score.cc
@@ -1,3 +1,4 @@
+#include "scommands.hh"
#include "tstream.hh"
#include "score.hh"
#include "sccol.hh"
@@ -7,14 +8,20 @@
#include "paper.hh"
void
+Score::set(Paperdef*p)
+{
+ delete paper_;
+ paper_ = p;
+}
+void
Score::output(String s)
{
OK();
- if (paper->outfile=="")
- paper->outfile = s;
+ if (paper_->outfile=="")
+ paper_->outfile = s;
- *mlog << "output to " << paper->outfile << "...\n";
- Tex_stream the_output(paper->outfile);
+ *mlog << "output to " << paper_->outfile << "...\n";
+ Tex_stream the_output(paper_->outfile);
pscore_->output(the_output);
}
@@ -22,10 +29,13 @@ Score::output(String s)
void
Score::process()
{
- if (!paper)
- paper = new Paperdef;
-
- commands_.clean(last());
+ set(commands_->parse(last()));
+ commands_->print();
+
+ if (!paper_)
+ paper_ = new Paperdef;
+
+ commands_->clean(last());
/// distribute commands to disciples
distribute_commands();
@@ -72,7 +82,7 @@ Score::clean_cols()
*/
// todo
PCursor<Score_column*>
-Score::create_cols(Mtime w)
+Score::create_cols(Real w)
{
Score_column* c1 = new Score_column(w);
Score_column* c2 = new Score_column(w);
@@ -102,7 +112,7 @@ Score::create_cols(Mtime w)
}
Score_column*
-Score::find_col(Mtime w,bool mus)
+Score::find_col(Real w,bool mus)
{
PCursor<Score_column*> scc(cols_);
for (; scc.ok(); scc++) {
@@ -121,7 +131,7 @@ void
Score::distribute_commands(void)
{
for (PCursor<Staff*> sc(staffs_); sc.ok(); sc++) {
- sc->add_commands(commands_);
+ sc->add_commands(*commands_);
}
}
void
@@ -140,10 +150,10 @@ Score::do_pcols()
pscore_->add(sc->pcol);
}
}
-Mtime
+Real
Score::last() const
{
- Mtime l = 0;
+ Real l = 0;
for (PCursor<Staff*> stc(staffs_); stc.ok(); stc++) {
l = MAX(l, stc->last());
}
@@ -163,7 +173,7 @@ Score::OK() const
for (PCursor<Score_column*> cc(cols_); cc.ok() && (cc+1).ok(); cc++) {
assert(cc->when <= (cc+1)->when);
}
- commands_.OK();
+ commands_->OK();
#endif
}
@@ -179,7 +189,7 @@ Score::print() const
for (PCursor<Score_column*> sc(cols_); sc.ok(); sc++) {
sc->print();
}
- commands_.print();
+ commands_->print();
mtor << "}\n";
#endif
}
@@ -187,10 +197,20 @@ Score::print() const
Score::Score()
{
pscore_=0;
- paper = 0;
+ paper_ = 0;
+ commands_ = new Score_commands;
}
+
+Score::~Score()
+{
+ delete pscore_;
+ delete commands_;
+ delete paper_;
+}
+
void
-Score::add(Command*c)
+Score::set(Score_commands*c)
{
- commands_.add(*c);
+ delete commands_;
+ commands_ = c;
}
diff --git a/score.hh b/score.hh
index c6af97c7a1..e58f87f058 100644
--- a/score.hh
+++ b/score.hh
@@ -1,16 +1,16 @@
#ifndef SCORE_HH
#define SCORE_HH
-
#include "vray.hh"
-#include "mtime.hh"
-#include "scommands.hh"
+#include "proto.hh"
+#include "list.hh"
+
/// the total music def of one movement
struct Score {
- Paperdef *paper;
- /// staffs_ and commands_ form the problem definition.
+ /// paper_, staffs_ and commands_ form the problem definition.
+ Paperdef *paper_;
PointerList<Staff *> staffs_;
- Score_commands commands_;
+ Score_commands *commands_;
/// "runtime" fields for setting up spacing
PointerList<Score_column*> cols_;
@@ -18,27 +18,25 @@ struct Score {
/****************************************************************/
- Score();
- void process();
-
/// construction
void add_staff(Staff *st);
+ void set(Paperdef*);
+ Score();
+ ~Score();
+ void add(Staff*);
+ void set(Score_commands*);
- void OK() const;
- Score_column *find_col(Mtime,bool);
- void do_pcols();
- void add(Staff*);
+ void OK() const;
+ Score_column *find_col(Real,bool);
+ void process();
void output(String fn);
- PCursor<Score_column*> create_cols(Mtime);
+ PCursor<Score_column*> create_cols(Real);
void print() const;
-
- Mtime last() const;
-
- void add(Command*);
+ Real last() const;
private:
-
+ void do_pcols();
void clean_cols();
void distribute_commands();
void do_connect(PCol *c1, PCol *c2, Real d);
diff --git a/scores.cc b/scores.cc
index cb06b0074f..46685d6050 100644
--- a/scores.cc
+++ b/scores.cc
@@ -1,5 +1,6 @@
#include "main.hh"
#include "score.hh"
+#include "string.hh"
static svec<Score*> sv;
@@ -11,6 +12,8 @@ do_scores()
for (int i=0; i < sv.sz(); i++) {
sv[i]->process();
sv[i]->output(outfn);
+ delete sv[i];
+ sv[i] =0;
}
}
diff --git a/staff.cc b/staff.cc
index 0827c953f0..7dd2666dc9 100644
--- a/staff.cc
+++ b/staff.cc
@@ -17,7 +17,7 @@ Staff::clean_cols()
}
Staff_column *
-Staff::get_col(Mtime w, bool mus)
+Staff::get_col(Real w, bool mus)
{
Score_column* sc = score_->find_col(w,mus);
assert(sc->when == w);
@@ -65,7 +65,7 @@ Staff::setup_staffcols()
for (PCursor<Voice*> vc(voices); vc.ok(); vc++) {
- Mtime now = vc->start;
+ Real now = vc->start;
for (PCursor<Voice_element *> ve(vc->elts); ve.ok(); ve++) {
Staff_column *sc=get_col(now,true);
@@ -130,9 +130,9 @@ Staff::OK() const
}
-Mtime
+Real
Staff::last() const {
- Mtime l = 0.0;
+ Real l = 0.0;
for (PCursor<Voice*> vc(voices); vc.ok(); vc++) {
l = MAX(l, vc->last());
}
@@ -154,3 +154,9 @@ Staff::print() const
#endif
}
+Staff::Staff()
+{
+ score_ =0;
+ pscore_=0;
+
+}
diff --git a/staff.hh b/staff.hh
index cca8c35266..3d39c6e78b 100644
--- a/staff.hh
+++ b/staff.hh
@@ -19,6 +19,8 @@ struct Staff {
Score *score_;
PScore *pscore_;
+ /****************************************************************/
+
void add_voice(Voice *v);
void add_staff_column(Staff_column *sp);
@@ -28,18 +30,13 @@ struct Staff {
/**
This routines calls virtual functions from Staff, to delegate the
interpretation of requests to a derived class of Staff */
-
-
- /****************************************************************
- VIRTUALS
- ****************************************************************/
-
void setup_staffcols();
- virtual void set_output(PScore * destination)=0;
- virtual void grant_requests()=0;
-
- Staff_column * get_col(Mtime,bool);
+ void OK() const;
+ void print() const;
+ Real last() const;
+ void clean_cols() ;
+ Staff_column * get_col(Real,bool);
void add_commands(PointerList<Command* >const & sv);
/**
@@ -48,12 +45,21 @@ struct Staff {
PRE
sv is time-ordered.
*/
+
+ Staff();
+ /**
+ Should construct with Score as arg, but this isn't known during parsing.
+ */
+ /****************************************************************
+ VIRTUALS
+ ****************************************************************/
+
+ virtual void set_output(PScore * destination)=0;
+ virtual void grant_requests()=0;
virtual Staff_column * create_col(Score_column * )=0;
+ virtual ~Staff() { }
- void OK() const;
- void print() const;
- Mtime last() const;
- void clean_cols() ;
- virtual ~Staff() { }
};
#endif
+
+
diff --git a/stcol.cc b/stcol.cc
index e9a80c8e36..799daed316 100644
--- a/stcol.cc
+++ b/stcol.cc
@@ -8,7 +8,7 @@ Staff_column::mus() const
return score_column->musical;
}
-Mtime
+Real
Staff_column::when() const
{
return score_column->when;
@@ -17,7 +17,7 @@ Staff_column::when() const
void
Staff_column::add(Voice_element*ve)
{
- Mtime d= ve->duration;
+ Real d= ve->duration;
if (d){
score_column->durations.add(d);
}
diff --git a/stcol.hh b/stcol.hh
index 2b23934c53..060d585fde 100644
--- a/stcol.hh
+++ b/stcol.hh
@@ -17,7 +17,7 @@ struct Staff_column {
svec<Command *> s_commands;
Staff_column(Score_column*s);
- bool mus() const ;
+ bool mus() const;
Real when() const;
void add(Voice_element*ve);
/****************************************************************
diff --git a/suzan.ly b/suzan.ly
index 08c4ddf643..59eb0c7489 100644
--- a/suzan.ly
+++ b/suzan.ly
@@ -2,6 +2,7 @@
score{
rhythmstaff {
- voice { $c2 c2 c2 c2$ }
+ voice { $ c2 c2 c4. c8 c4 c4 c4 c4 c4 c4 c2 c2$ }
}
+ commands { meter 2 4 skip 2:0 meter 4 4 skip 2:0}
}
diff --git a/symbol.ini b/symbol.ini
index 459deb1f67..26c0a31bff 100644
--- a/symbol.ini
+++ b/symbol.ini
@@ -36,7 +36,7 @@ table param
end
table dots
- 1 \singledot 0pt 4pt -1pt 1pt
- 2 \doubledot 0pt 8pt -1pt 1pt
- 3 \tripledot 0pt 12pt -1pt 1pt
+ 1 \lsingledot 0pt 8pt -1pt 1pt
+ 2 \ldoubledot 0pt 12pt -1pt 1pt
+ 3 \ltripledot 0pt 16pt -1pt 1pt
end
diff --git a/table.cc b/table.cc
index 72b5ccfd55..da2af9575e 100644
--- a/table.cc
+++ b/table.cc
@@ -17,6 +17,9 @@ static Keyword_ent the_key_tab[]={
"paper", PAPER,
"width", WIDTH,
"meter", METER,
+ "unitspace", UNITSPACE,
+ "skip", SKIP,
+ "commands", COMMANDS,
0,0
} ;
diff --git a/voice.cc b/voice.cc
index 907f229481..ae9342b487 100644
--- a/voice.cc
+++ b/voice.cc
@@ -51,10 +51,10 @@ Voice_element::print() const
#endif
}
-Mtime
+Real
Voice::last() const
{
- Mtime l =start;
+ Real l =start;
for (PCursor<Voice_element*> vec(elts); vec.ok(); vec++)
l += vec->duration;
return l;
diff --git a/voice.hh b/voice.hh
index 35537525ec..b580972b23 100644
--- a/voice.hh
+++ b/voice.hh
@@ -1,18 +1,18 @@
#ifndef VOICE_HH
#define VOICE_HH
-#include "mtime.hh"
+
#include "list.hh"
#include "request.hh"
/// class for horizontal stuff.
struct Voice {
PointerList<Voice_element *> elts;
- Mtime start;
+ Real start;
/****************/
- Mtime when(const Voice_element*)const;
- Mtime last() const;
+ Real when(const Voice_element*)const;
+ Real last() const;
Voice();
void add(Voice_element*);
void print() const;
@@ -30,7 +30,7 @@ struct Voicegroup {
///
struct Voice_element {
- Mtime duration;
+ Real duration;
const Voicegroup *group;
const Voice *voice;
PointerList<Request*> reqs;