From 04e49b6495d247e24f752aacb9f8289aefd4d598 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Thu, 19 Dec 1996 11:20:48 +0100 Subject: [PATCH] release: 0.0.18 --- .dstreamrc | 10 +- Makefile | 5 + NEWS | 3 + README | 47 +++-- Variables.make | 2 +- flower/Sources.make | 6 +- flower/Variables.make | 4 +- flower/cursor.hh | 1 + flower/{cursor.cc => cursor.tcc} | 0 flower/interval.hh | 14 +- flower/{interval.cc => interval.tcc} | 0 flower/iterate.hh | 6 + flower/list.hh | 10 +- flower/list.inl | 4 +- flower/{list.cc => list.tcc} | 0 flower/plist.hh | 8 +- flower/{plist.cc => plist.tcc} | 0 flower/smat.cc | 2 +- flower/{tsmat.cc => tsmat.tcc} | 0 hdr/Makefile | 3 + hdr/beam.hh | 2 +- hdr/command.hh | 4 +- hdr/getcommand.hh | 2 +- hdr/grouping.hh | 33 +-- hdr/pscore.hh | 12 +- hdr/scoreline.hh | 4 +- hdr/simplewalker.hh | 7 + hdr/slur.hh | 2 +- hdr/spanner.hh | 2 +- hdr/staffcommands.hh | 36 ++-- make_patch | 8 +- src/Makefile | 3 + src/beam.cc | 9 +- src/break.cc | 10 +- src/calcideal.cc | 24 +-- src/command.cc | 10 +- src/getcommands.cc | 4 +- src/grouping.cc | 204 +++++++++--------- src/inputcommands.cc | 13 +- src/item.cc | 4 +- src/keyitem.cc | 4 +- src/linespace.cc | 2 +- src/parser.y | 4 +- src/pcol.cc | 4 +- src/pscore.cc | 10 +- src/qlp.cc | 75 ++++--- src/score.cc | 5 +- src/scoreline.cc | 2 +- src/simplewalker.cc | 41 +++- src/slur.cc | 2 +- src/staff.cc | 5 +- src/staffcommands.cc | 302 +++++++++++---------------- src/staffline.cc | 8 +- src/template3.cc | 1 + symbol.ini | 2 +- 55 files changed, 518 insertions(+), 467 deletions(-) rename flower/{cursor.cc => cursor.tcc} (100%) rename flower/{interval.cc => interval.tcc} (100%) create mode 100644 flower/iterate.hh rename flower/{list.cc => list.tcc} (100%) rename flower/{plist.cc => plist.tcc} (100%) rename flower/{tsmat.cc => tsmat.tcc} (100%) diff --git a/.dstreamrc b/.dstreamrc index b14fb6c79a..be1953b0de 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -1,7 +1,7 @@ # class name silence? -My_flex_lexer 0 -yyFlexLexer 0 +My_flex_lexer 1 +yyFlexLexer 1 PCol 1 Score_column 1 Ineq_constrained_qp 1 @@ -12,7 +12,7 @@ PScore 1 Idealspacing 1 # yydebug -Parser 0 +Parser 1 # FlexLexer debug Lexer 1 @@ -25,8 +25,8 @@ Note_req 1 Rhythmic_req 1 Rest_req 1 delete_identifiers 1 -Command 1 -Staff_commands 1 +Command 0 +Staff_commands 0 Stem 0 Staff 0 Score 0 diff --git a/Makefile b/Makefile index ac9d7254ea..d0bdffd022 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,16 @@ include Variables.make +.SUFFIXES: +.SUFFIXES: .cc .o .hh .y .l + $(exe): $(obs) $(CXX) -o $@ $^ $(LOADLIBES) clean: # $(MAKE) -C objects clean rm -f $(exe) objects/*.o $(DOCDIR)/* core + $(MAKE) -C $(CCDIR) clean + $(MAKE) -C $(HEADERDIR) clean distclean: clean rm -f depend version.hh $(gencc) .GENERATE *~ diff --git a/NEWS b/NEWS index 455012a74f..34a2deafd2 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,6 @@ +pl 18: + - robust Staff_commands + pl 17: - robust Input_commands - merged Vertical_/Horizontal music diff --git a/README b/README index b849b7f2ee..c936c13e29 100644 --- a/README +++ b/README @@ -1,6 +1,10 @@ -*-text-*- -last update: 96/12/12, 0.0.16 +last update: 96/17/12, 0.0.17 + +LICENSE + +See file COPYING INTRODUCTION @@ -50,6 +54,7 @@ why G++ >= 2.7? LilyPond & flower lib uses: builtin bool typeof operator ? + new for-scope USING @@ -63,30 +68,40 @@ what I type in my xterm: This is what the output looks like over here: -hw:~/musix/spacer$ lilypond maartje.ly -LilyPond version 0.0.16 compiled on Dec 11 1996 at 13:54:27 -Parsing ... [symbol.ini][maartje.ly] -Processing ... Calculating ... Postprocessing ... -output to lelie.uit... + hw:~/musix/spacer$ lilypond maartje.ly + LilyPond 0.0.17/FlowerLib 1.0.14. Compile: Dec 17 1996, 11:33:54 (g++ 2.7.2) + Parsing ... [symbol.ini][maartje.ly] + Processing ... Calculating ... Postprocessing ... + output to lelie.uit... -hw:~/musix/spacer$ tex test -This is TeX, Version 3.14159 (C version 6.1) -(test.tex -Hyphenation patterns for english, dutch, loaded. -(lilyponddefs.tex) (lelie.uit) [1] [2] ) -Output written on test.dvi (2 pages, 8072 bytes). -Transcript written on test.log. + hw:~/musix/spacer$ tex test + This is TeX, Version 3.14159 (C version 6.1) + (test.tex + Hyphenation patterns for english, dutch, loaded. + (lilyponddefs.tex) (lelie.uit) [1] [2] ) + Output written on test.dvi (2 pages, 8072 bytes). + Transcript written on test.log. -hw:~/musix/spacer$ xdvi test& -[1] 1468 + hw:~/musix/spacer$ xdvi test& + [1] 1468 Check out kortjakje.ly, it has some comments + PROBLEMS If LilyPond bombs out, then please recompile using -g, and send a gdb -stacktrace of the crash. +stacktrace of the crash. It also helps if you can print the values of the objects. So if you trace is + +(gdb) backtrace 12 +#0 Interval::operator+= (this=0x11fffec60, r=-1.7976931348623157e+308) + at ../flower/interval.hh:50 +#1 0x12005195c in Item::width (this=0x14008a680) at src/item.cc:39 +#2 0x12008fdbc in itemlist_width (its=0x11fffed58) at src/simpleprint.cc:40 + : + : +Than it would help if you send a dump of the Interval and the Item (use: 'print *this' or use LilyPond print() methods) HOW DOES IT WORK diff --git a/Variables.make b/Variables.make index f386e5546d..6e67b107d3 100644 --- a/Variables.make +++ b/Variables.make @@ -37,7 +37,7 @@ endif # version info MAJVER=0 MINVER=0 -PATCHLEVEL=17 +PATCHLEVEL=18 VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) CXXVER=`$(CXX) --version` diff --git a/flower/Sources.make b/flower/Sources.make index 84e27c4681..2a618814c3 100644 --- a/flower/Sources.make +++ b/flower/Sources.make @@ -3,12 +3,14 @@ cc=lgetopt.cc string.cc dataf.cc textdb.cc unionfind.cc \ smat.cc matrix.cc choleski.cc vector.cc dstream.cc\ matdebug.cc scalar.cc -templatecc=cursor.cc list.cc tsmat.cc plist.cc interval.cc +templatecc=cursor.tcc list.tcc tsmat.tcc plist.tcc interval.tcc + inl=findcurs.inl link.inl list.inl cursor.inl plist.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 plist.hh associter.hh fproto.hh\ - interval.hh scalar.hh sstack.hh rational.hh + interval.hh scalar.hh sstack.hh rational.hh iterate.hh\ + diff --git a/flower/Variables.make b/flower/Variables.make index 9d58ba9063..7d6f0479a5 100644 --- a/flower/Variables.make +++ b/flower/Variables.make @@ -1,10 +1,10 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=17 +PATCHLEVEL=18 PACKAGENAME=flower #PROFILEFLAG=-pg -DEBUGFLAG=-g -O2 +DEBUGFLAG=-g -O2 -DNDEBUG OPTIFLAG=-DNDEBUG -DNPRINT -O2 ######################################### diff --git a/flower/cursor.hh b/flower/cursor.hh index 428a52748f..c6a8584335 100644 --- a/flower/cursor.hh +++ b/flower/cursor.hh @@ -110,5 +110,6 @@ template_instantiate_compare(Cursor, Cursor::compare, template); #include "pcursor.hh" #include "list.hh" #include "cursor.inl" +#include "iterate.hh" #endif // CURSOR_HH diff --git a/flower/cursor.cc b/flower/cursor.tcc similarity index 100% rename from flower/cursor.cc rename to flower/cursor.tcc diff --git a/flower/interval.hh b/flower/interval.hh index 4184451701..294457db0f 100644 --- a/flower/interval.hh +++ b/flower/interval.hh @@ -24,15 +24,25 @@ struct Interval_t { left += t; right += t; } - T operator[](int j) { + T& idx(int j) { if (j==-1) return left; else if (j==1) return right; else assert(false); - return 0; + return left; } + T& operator[](int j) { + return idx(j); + } + T operator[](int j) const { + return ((Interval_t *)this)->idx(j); + } + T &max() { return right;} + T max()const { return right;} + T min()const{ return left; } + T &min(){ return left; } void unite(Interval_t h); /** PRE diff --git a/flower/interval.cc b/flower/interval.tcc similarity index 100% rename from flower/interval.cc rename to flower/interval.tcc diff --git a/flower/iterate.hh b/flower/iterate.hh new file mode 100644 index 0000000000..adff7792bb --- /dev/null +++ b/flower/iterate.hh @@ -0,0 +1,6 @@ + +#define iterator(set) typeof((set).top()) + +// should use top() +#define iter_top(set,var) iterator(set) var(set) + diff --git a/flower/list.hh b/flower/list.hh index 117e1862e4..f49b5d7850 100644 --- a/flower/list.hh +++ b/flower/list.hh @@ -16,11 +16,13 @@ class List List(); virtual ~List(); - Cursor bottom(); - int size() const; - Cursor top(); - void OK() const; + + Cursor bottom() const; // const sucks.. + Cursor top() const; + + void OK() const; // check list + protected: friend class Cursor; friend class Link; diff --git a/flower/list.inl b/flower/list.inl index c3ee7e2948..df0687b7c8 100644 --- a/flower/list.inl +++ b/flower/list.inl @@ -39,7 +39,7 @@ List::size() const template inline Cursor -List::top() +List::top()const { return Cursor( *this, top_ ); } @@ -47,7 +47,7 @@ List::top() template inline Cursor -List::bottom() +List::bottom()const { return Cursor( *this, bottom_ ); } diff --git a/flower/list.cc b/flower/list.tcc similarity index 100% rename from flower/list.cc rename to flower/list.tcc diff --git a/flower/plist.hh b/flower/plist.hh index 99be3ff811..bac9f7bf02 100644 --- a/flower/plist.hh +++ b/flower/plist.hh @@ -14,8 +14,12 @@ template class PointerList : public List { public: - PCursor top() { return PCursor (List::top()); } - PCursor bottom() { return PCursor (List::bottom()); } + PCursor top() const{ + return PCursor (List::top()); + } + PCursor bottom() const { + return PCursor (List::bottom()); + } PCursor find(T) const; void concatenate(PointerList const &s) { List::concatenate(s); } PointerList() {} diff --git a/flower/plist.cc b/flower/plist.tcc similarity index 100% rename from flower/plist.cc rename to flower/plist.tcc diff --git a/flower/smat.cc b/flower/smat.cc index 3830fd6825..93726ec08a 100644 --- a/flower/smat.cc +++ b/flower/smat.cc @@ -22,7 +22,7 @@ Full_storage::OK() const Real *r = els[maxh -1]; if (maxw>0) { assert(r); - Real s = r[maxw -1]; + Real s = r[maxw -1]; // accessing unitialised memory. s = sin(s); } } diff --git a/flower/tsmat.cc b/flower/tsmat.tcc similarity index 100% rename from flower/tsmat.cc rename to flower/tsmat.tcc diff --git a/hdr/Makefile b/hdr/Makefile index 81a8f4595c..29358a5d9d 100644 --- a/hdr/Makefile +++ b/hdr/Makefile @@ -6,3 +6,6 @@ dist: TAGS: $(hdr) etags -CT $(hdr) + +clean: + rm -f parser.hh \ No newline at end of file diff --git a/hdr/beam.hh b/hdr/beam.hh index be2cb8f94c..60b5dedd71 100644 --- a/hdr/beam.hh +++ b/hdr/beam.hh @@ -22,7 +22,7 @@ struct Beam: public Spanner { virtual Interval width()const; - Spanner *broken_at(const PCol *, const PCol *) const; + Spanner *broken_at(PCol *, PCol *) const; Beam(); void add(Stem*); void process(); diff --git a/hdr/command.hh b/hdr/command.hh index e2ece4a6fa..26e47ffa1f 100644 --- a/hdr/command.hh +++ b/hdr/command.hh @@ -16,7 +16,7 @@ enum Commandcode { struct Command { Commandcode code; - Real when; +// Real when; /// analogous to argv[] svec args; @@ -28,7 +28,7 @@ struct Command { /****************/ Command(); - Command(Real w); +// Command(Real w); bool isbreak()const; void print() const; }; diff --git a/hdr/getcommand.hh b/hdr/getcommand.hh index eb6f624966..79e6bd407a 100644 --- a/hdr/getcommand.hh +++ b/hdr/getcommand.hh @@ -9,7 +9,7 @@ #include "proto.hh" -Command* get_meter_command( Real,int,int); +Command* get_meter_command(int,int); diff --git a/hdr/grouping.hh b/hdr/grouping.hh index a6e93bf840..21a4b4b70f 100644 --- a/hdr/grouping.hh +++ b/hdr/grouping.hh @@ -10,24 +10,29 @@ #include "interval.hh" #include "vray.hh" -struct Rhythmic_grouping { - Interval t; + +struct Rhythmic_grouping { + svec divisions; svec children; + /****************/ - - void split_half(); - Real last(); - Rhythmic_grouping* sub_grouping(Interval v); - void split_grouping(Rhythmic_grouping &initial_grouping); - void split_grouping(svec initial_grouping); - svec get_bounds(); - Rhythmic_grouping(Interval); - Rhythmic_grouping(svec notes, - svec initial_grouping); + svec interior(); + Rhythmic_grouping partial_grouping(Interval t); + Real length() const; + Interval time() const; + Rhythmic_grouping(Interval); + Rhythmic_grouping(); + Rhythmic_grouping(svec); + Rhythmic_grouping(Rhythmic_grouping const&); + + void split(Rhythmic_grouping r); + void split(svec); + void intersect(Interval); + void split(int n); void print() const; + void OK() const; ~Rhythmic_grouping(); }; - -#endif // GROUPING_HH +#endif diff --git a/hdr/pscore.hh b/hdr/pscore.hh index 00fb79bccc..33741e9263 100644 --- a/hdr/pscore.hh +++ b/hdr/pscore.hh @@ -55,13 +55,13 @@ struct PScore { void postprocess(); /// search all pcols which are breakable. - svec find_breaks() const; + svec< PCol *> find_breaks() const; /// add a line to the broken stuff. Positions given in #config# - void add_line(svec curline, svec config); + void add_line(svec< PCol *> curline, svec config); /// helper: solve for the columns in #curline#. - svec solve_line(svec curline) const; + svec solve_line(svec curline) const; void add(PStaff *); /// add item @@ -83,7 +83,7 @@ struct PScore { */ /// return argument as a cursor. - PCursor find_col(const PCol *)const; + PCursor find_col(PCol *)const; /// delete unused columns void clean_cols(); @@ -98,10 +98,10 @@ struct PScore { void print() const; /// does curline fit on the paper? - bool feasible(svec curline) const; + bool feasible(svec curline) const; /// which is first (left, higher) - int compare_pcols(const PCol*, const PCol*)const; + int compare_pcols( PCol*, PCol*)const; }; /** notes, signs, symbols in a score can be grouped in two ways: horizontally (staffwise), and vertically (columns). #PScore# diff --git a/hdr/scoreline.hh b/hdr/scoreline.hh index e3997b5a36..5734a7b4b4 100644 --- a/hdr/scoreline.hh +++ b/hdr/scoreline.hh @@ -13,7 +13,7 @@ /// the columns of a score that form one line. struct Line_of_score { - PointerList cols; + PointerList cols; // need to store height of each staff. IPointerList staffs; @@ -21,7 +21,7 @@ Line_of_score { /****************/ void process() ; - Line_of_score(svec sv, PScore *); + Line_of_score(svec sv, PScore *); String TeXstring() const; diff --git a/hdr/simplewalker.hh b/hdr/simplewalker.hh index a8db0337aa..2631f8b983 100644 --- a/hdr/simplewalker.hh +++ b/hdr/simplewalker.hh @@ -8,6 +8,7 @@ #define SIMPLEWALKER_HH #include "proto.hh" +#include "grouping.hh" struct Simple_walker: Staff_walker { Stem *stem_; @@ -22,8 +23,14 @@ struct Simple_walker: Staff_walker { bool processed_key; bool processed_clef; Clef clef_; + Rhythmic_grouping default_grouping; + Rhythmic_grouping current_grouping; + svec pending_slur_reqs; svec pending_slurs; + + + /****************/ virtual void do_TYPESET_command(Command*); diff --git a/hdr/slur.hh b/hdr/slur.hh index 43359399e8..10b5884571 100644 --- a/hdr/slur.hh +++ b/hdr/slur.hh @@ -25,7 +25,7 @@ struct Slur : Spanner { void add(Notehead*); void set_default_dir(); Interval height() const; - Spanner* broken_at(const PCol*, const PCol*) const; + Spanner* broken_at( PCol*, PCol*) const; void process(); private: void brew_molecule(); diff --git a/hdr/spanner.hh b/hdr/spanner.hh index 3940cebf60..8a22985819 100644 --- a/hdr/spanner.hh +++ b/hdr/spanner.hh @@ -31,7 +31,7 @@ struct Spanner { /// clone a piece of this spanner. - virtual Spanner *broken_at(const PCol *c1, const PCol *c2) const=0; + virtual Spanner *broken_at( PCol *c1, PCol *c2) const=0; /** PRE diff --git a/hdr/staffcommands.hh b/hdr/staffcommands.hh index b7cdef0f9b..7573595a37 100644 --- a/hdr/staffcommands.hh +++ b/hdr/staffcommands.hh @@ -9,28 +9,38 @@ #include "vray.hh" #include "plist.hh" + +struct Staff_commands_at : public IPointerList { + Real when; + + /****************/ + + bool is_breakable(); + + Staff_commands_at(Real); + void set_breakable(); + void add_command_to_break(Command pre, Command mid,Command post); + void print() const; + void OK() const; + void insert_between(Command victim, PCursor firstc, + PCursor last); + void add(Command c); + +}; + /// the list of commands in Score -struct Staff_commands : public IPointerList { - void process_add(Command); - void add_seq(svec,bool); +struct Staff_commands : public IPointerList +{ + Staff_commands_at*find(Real); + void add(Command,Real); void clean(Real last); - void set_breakable(Real when); - bool is_breakable(Real w); - PCursor last_insertion(Real w); - PCursor first(Real w); - 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 firstc, - PCursor last); }; /** the list of commands in Score. Put in a separate class, since it otherwise clutters the methods of Score. - This class serves two purposes: it stores the commands (via - parser_add()) in the yacc parser. at a later stage, some 'high - level' commands are converted (method: parse()) */ #endif diff --git a/make_patch b/make_patch index 8f8a688cd7..290e2e33da 100755 --- a/make_patch +++ b/make_patch @@ -1,4 +1,10 @@ #!/bin/sh + +case $# in +0) echo make_patch old new name + exit 1;; +esac + old=$1 new=$2 nm=$3- @@ -31,5 +37,5 @@ fi #(cd $nm$old; touch depend; make clean) #(cd $nm$new; touch depend; make clean) -(cd $nm$new; diff -rP -c ../$nm$old . > ../patch-$new) +(cd $nm$new; diff -urP ../$nm$old . > ../patch-$new) rm -rf $nm$old $nm$new diff --git a/src/Makefile b/src/Makefile index 65374e807e..a3cc55c1e4 100644 --- a/src/Makefile +++ b/src/Makefile @@ -6,3 +6,6 @@ dist: TAGS: $(mycc) etags -CT $(mycc) + +clean: + rm -f $(gencc) \ No newline at end of file diff --git a/src/beam.cc b/src/beam.cc index 3d43b4ed1d..a2d58254af 100644 --- a/src/beam.cc +++ b/src/beam.cc @@ -1,3 +1,4 @@ +#include "dimen.hh" #include "beam.hh" #include "misc.hh" #include "debug.hh" @@ -141,7 +142,7 @@ Beam::process() // todo. Spanner * -Beam::broken_at(const PCol *, const PCol *) const +Beam::broken_at( PCol *, PCol *) const { return new Beam(*this); } @@ -166,6 +167,7 @@ Beam::width() const return Interval( (*me->stems.top()) ->hpos(), (*me->stems.bottom()) ->hpos() ); } + /* beams to go with one stem. */ @@ -177,6 +179,8 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev) Real dy=paper()->internote()*2; Real stemdx = paper()->rule_thickness(); Real sl = slope*paper()->internote(); + paper()->lookup_->beam(sl, convert_dimen(20,"pt")); + slope = sl /paper()->internote(); Molecule leftbeams; Molecule rightbeams; @@ -227,10 +231,7 @@ Beam::brew_molecule() { assert(left->line == right->line); Real inter=paper()->internote(); - Real sl = slope*inter; - output = new Molecule; - slope = sl / inter; Real x0 = stems.top()->hpos(); for (PCursor i(stems); i.ok(); i++) { diff --git a/src/break.cc b/src/break.cc index 6cb1d3303b..ff86e848af 100644 --- a/src/break.cc +++ b/src/break.cc @@ -10,7 +10,7 @@ // construct an appropriate Spacing_problem and solve it. svec -PScore::solve_line(svec curline) const +PScore::solve_line(svec< PCol *> curline) const { Spacing_problem sp; @@ -28,7 +28,7 @@ PScore::solve_line(svec curline) const } bool -PScore::feasible(svec curline) const +PScore::feasible(svec< PCol *> curline) const { Real l =0; for (int i=0; i < curline.sz(); i++) @@ -49,14 +49,14 @@ PScore::problem_OK() const } struct Col_configuration { - svec line; + svec< PCol*> line; svec config; Real energy; Col_configuration() { energy = INFTY; } - void add(const PCol*c) { line.add(c);} + void add( PCol*c) { line.add(c);} void setsol(svec sol) { config = sol; energy = config.last(); @@ -85,7 +85,7 @@ PScore::calc_breaking() problem_OK(); PCursor curcol(cols); - svec breakpoints(find_breaks()); + svec breakpoints(find_breaks()); assert(breakpoints.sz()>=2); for (int i=0 ; i < breakpoints.sz() -1; ) { Col_configuration minimum; diff --git a/src/calcideal.cc b/src/calcideal.cc index 47ca885ade..9db9472113 100644 --- a/src/calcideal.cc +++ b/src/calcideal.cc @@ -37,20 +37,20 @@ Score::connect(PCol* c1, PCol *c2, Real d, Real h) void Score::calc_idealspacing() { -#if 1 PCursor i(cols_); for (; i.ok(); i++) { assert(i->used()); PCursor j (i+1); if (i->musical) { + assert(j.ok()); for (int n=0; n < i->durations.sz(); n++) { Real d = i->durations[n]; Real dist = paper_->duration_to_dist(d); while (j->when < d + i->when) j++; - assert(j->when == d+i->when); + assert( distance(j->when, d+i->when) < 1e-8); connect(i->pcol_, j->pcol_, dist); if (!j->musical && (j+1).ok() @@ -67,31 +67,13 @@ Score::calc_idealspacing() Real d = j->when - i->when; Real dist = (d) ? paper_->duration_to_dist(d) : - convert_dimen(2,"pt"); + convert_dimen(2,"pt"); // todo connect(i->pcol_, j->pcol_, dist, (d) ? 1.0:1.0); } // !j.ok() might hold if we're at the last col. } -#else - PCursor sc(cols_); - - for (; sc.ok(); sc++) { - if (sc->musical) - for (int i=0; i < sc->durations.sz(); i++) { - Real d = sc->durations[i]; - Real dist = paper_->duration_to_dist(d); - PCol * c2 = find_col(sc->when + d,true)->pcol_; - connect(sc->pcol_, c2, dist); - c2 = find_col(sc->when + d,false)->pcol_; - connect(sc->pcol_, c2, dist); - } - else if (sc->used()) { // ignore empty columns - PCol * c2 = find_col(sc->when,true)->pcol_; - connect(sc->pcol_, c2, 0.0); - } -#endif } diff --git a/src/command.cc b/src/command.cc index 94d3bb94d2..98be691cd3 100644 --- a/src/command.cc +++ b/src/command.cc @@ -11,14 +11,6 @@ Command::isbreak()const Command::Command() { code = NOP; - when = -1; - priority=0; -} - -Command::Command(Real w) -{ - code = NOP; - when = w; priority=0; } @@ -26,7 +18,7 @@ void Command::print() const { #ifndef NPRINT - mtor << "command at " << when << ", code " << code << " prio " << priority; + mtor << "Command " << "code " << code << " prio " << priority; if ( isbreak()) mtor << "(break separator)"; if (args.sz()) { diff --git a/src/getcommands.cc b/src/getcommands.cc index 1ac2cc0bcb..b415e0b1cf 100644 --- a/src/getcommands.cc +++ b/src/getcommands.cc @@ -16,11 +16,11 @@ get_key_typeset_command(svecwhich) } Command * -get_meter_command(Real w, int n, int m) +get_meter_command(int n, int m) { Command*c = new Command; - c->when = w; +// c->when = w; c->code = TYPESET; c->args.add( "METER"); c->args.add( n ); diff --git a/src/grouping.cc b/src/grouping.cc index e07de1254a..1d70808fc7 100644 --- a/src/grouping.cc +++ b/src/grouping.cc @@ -1,148 +1,164 @@ -#include "grouping.hh" #include "debug.hh" +#include "grouping.hh" +#include "interval.hh" -Interval -vec_union(svec notes) +void +Rhythmic_grouping::OK()const { - Interval u; - u.set_empty(); - for (int i =0 ; i < notes.sz() ; i++) { - u.unite(notes[i]); - } - return u; + for (int i= 1; i < divisions.sz(); i++) { + Real dt = divisions[i] - divisions[i-1]; + assert(dt>0); + } + Interval u; + for (int i= 1; i < children.sz(); i++) { + children[i]->OK(); + u.unite(children[i]->time()); + } + } -svec -default_bounds(Interval t) +Real +Rhythmic_grouping::length() const { - svec bounds; - Real dt = t.length(); - bounds.add(t.min); - bounds.add(t.min + dt/2); - return bounds; + return divisions.last() - divisions[0]; } -svec -Rhythmic_grouping::get_bounds() +void +Rhythmic_grouping::split(Rhythmic_grouping r) { - svec bounds; - if (children.sz()) { - for (int i=0; i < children.sz(); i++) { - bounds.add(children[i]->t.min); - } - } else { - default_bounds(t); + svec ir = r.interior(); + split(ir); + + for (int i= 0; i < children.sz(); i++) { + Rhythmic_grouping here(r.partial_grouping(children[i]->time())); + if (here.divisions.sz() == 2) + here.split(2); + children[i]->split(here); } -// bounds.add(t.max ); - return bounds; } -Real -Rhythmic_grouping::last() +svec +Rhythmic_grouping::interior() { - return t.max; + svec r(divisions); + r.del(0); + r.pop(); + return r; } void -Rhythmic_grouping::split_grouping(svec bounds) +Rhythmic_grouping::split(int n) { - int lasti =0; - svec newgrp; - for (int i=0, j = 1; i < children.sz() && j < bounds.sz(); ) { - if ( children[i]->t.max < bounds[j]) { - i ++; - continue; - } else if (children[i]->t.max > bounds[j]) { - j ++; - continue; - } - - assert( children[lasti]->t.min == bounds[j-1] ); - assert( children[i]->t.max == bounds[j] ); - - Rhythmic_grouping * n = new Rhythmic_grouping(Interval( - bounds[j-1], bounds[j])); - for (int k = lasti ; k < i; k++) - n->children.add(children[k]); - newgrp.add(n); - - i = lasti = i+1; - } - if (newgrp.sz() <= 1) { - newgrp[0]->children.set_size(0); - delete newgrp[0]; - return; - } - children = newgrp; + assert(divisions.sz() == 2 && children.sz() == 0); + Real dt =(divisions.last()-divisions[0] )/n; + svec r; + for (int i= 0; i <= n; i++) + r.add(divisions[0] +dt *i); + divisions = r; } void -Rhythmic_grouping::split_half() +Rhythmic_grouping::intersect(Interval t) { - svec bounds = default_bounds(t); - bounds.add(t.max); - split_grouping(bounds); + svec r; + for (int i=0; i < divisions.sz(); i++) + if (t.elt_q(divisions[i])) + r.add(divisions[i]); + if (r[0] > t.min ) // todo + r.insert( t.min,0); + if (r.last() < t.max) + r.add(t.max); + divisions = r; + svec nc; for (int i=0; i < children.sz(); i++) { - if (children[i]->children.sz()) - children[i]->split_half(); + Interval inter = intersection(t, children[i]->time()); + if (!inter.empty()) { + Rhythmic_grouping*p =new Rhythmic_grouping(*children[i]); + nc.add(p); + p->intersect(inter); + } + delete children[i]; } + children = nc; } -Rhythmic_grouping* -Rhythmic_grouping::sub_grouping(Interval v) +Rhythmic_grouping +Rhythmic_grouping::partial_grouping(Interval t) { - return 0; // todo! + Rhythmic_grouping r(*this); + r.intersect(t); + return r; } + void -Rhythmic_grouping::split_grouping(Rhythmic_grouping &initial_grouping) +Rhythmic_grouping::split(svec splitpoints) { - svec newgrp; - svec bounds = initial_grouping.get_bounds(); - bounds.add(initial_grouping.last()); - split_grouping(bounds); - for (int i=0; i < children.sz(); i++) { - Interval h = children[i]->t; - Rhythmic_grouping*r = initial_grouping.sub_grouping(h); - if (children[i]->children.sz()) { - if (r) - children[i]->split_grouping(*r); - else - children[i]->split_half(); + assert(!children.sz()); + svec child; + int j = 0, i=0; + while (1) { + if ( i >= divisions.sz() || j >= splitpoints.sz()) + break; + + child.add(divisions[i]); + if (divisions[i] < splitpoints[j]) { + i++; + } else if (divisions[i] > splitpoints[j]) { + j ++; + } else { + children.add(new Rhythmic_grouping(child)); + child.set_size(1); + child[0] = divisions[i]; } } } -Rhythmic_grouping::Rhythmic_grouping(Interval i) +Rhythmic_grouping::Rhythmic_grouping(svec d) + :divisions(d) { - t=i; } - -Rhythmic_grouping::Rhythmic_grouping(svec notes, - svec initial_grouping) +Rhythmic_grouping::Rhythmic_grouping() { - t = vec_union(notes); - for (int i=0; i < notes.sz(); i++) { - children.add(new Rhythmic_grouping(notes[i])); - } - split_grouping(initial_grouping); +} +Interval +Rhythmic_grouping::time()const +{ + return Interval(divisions[0], divisions.last()); +} +Rhythmic_grouping::Rhythmic_grouping(Interval h) +{ + divisions.add(h.min); + divisions.add(h.max); } Rhythmic_grouping::~Rhythmic_grouping() { - for (int i=0; i < children.sz(); i++) { + for (int i=0; i < children.sz(); i++) delete children[i]; - } } + +Rhythmic_grouping::Rhythmic_grouping(Rhythmic_grouping const&s) +{ + divisions = s.divisions; + for (int i=0; i < s.children.sz(); i++) + children.add(new Rhythmic_grouping(*s.children[i])); +} + void Rhythmic_grouping::print()const { - mtor << "{ " << t << "\n"; +#ifndef NPRINT + mtor << "{ "; + for (int i=0; i < divisions.sz(); i++) { + mtor << divisions[i] << ','; + } for (int i=0; i < children.sz(); i++) { children[i]->print(); } mtor << "}"; +#endif } diff --git a/src/inputcommands.cc b/src/inputcommands.cc index c7f7aaff56..3a27b3801f 100644 --- a/src/inputcommands.cc +++ b/src/inputcommands.cc @@ -13,7 +13,7 @@ void Commands_at::print() const { #ifndef NPRINT - mtor << "{ at "< cc(*this); cc.ok(); cc++) @@ -47,7 +47,7 @@ Commands_at::Commands_at(Real dt, Commands_at* prev) } void -Commands_at::add(Input_command *i ) +Commands_at::add(Input_command *i) { bottom().add(i); if (i->args[0] == "METER") { // should check for other meterchanges here. @@ -81,7 +81,6 @@ Commands_at::setpartial(Real p) } Real Commands_at::barleft() - { return whole_per_measure-whole_in_measure; } @@ -180,19 +179,19 @@ Input_commands::parse() const Staff_commands*nc = new Staff_commands; { /* all pieces should start with a breakable. */ - Command c(0.0); + Command c;//(0.0); c.code = INTERPRET; c.args.add("BAR"); c.args.add("empty"); - nc->process_add(c); + nc->add(c,0.0); } for (PCursor i(*this); i.ok(); i++) for (PCursor cc(**i); cc.ok(); cc++) { if (cc->args.sz() && cc->args[0] !="") { Command c = **cc; - c.when = i->when; - nc->process_add(c); +// c.when = i->when; + nc->add(c, i->when); } } diff --git a/src/item.cc b/src/item.cc index 4a8ea949d6..ba71539d30 100644 --- a/src/item.cc +++ b/src/item.cc @@ -36,7 +36,9 @@ Interval Item::width() const { Interval i =output->extent().x ; - return i+=offset_.x; + if (!i.empty()) // float exception on DEC Alpha + i+=offset_.x; + return i; } Interval diff --git a/src/keyitem.cc b/src/keyitem.cc index 71f1654f19..26ad1745e3 100644 --- a/src/keyitem.cc +++ b/src/keyitem.cc @@ -11,7 +11,6 @@ Keyitem::Keyitem(int c) c_position = c; } - void Keyitem::read(svec s) { @@ -30,7 +29,8 @@ Keyitem::add(int p, int a) } void -Keyitem::preprocess() { +Keyitem::preprocess() +{ brew_molecole(); } diff --git a/src/linespace.cc b/src/linespace.cc index fbab62449b..e403c2dcc0 100644 --- a/src/linespace.cc +++ b/src/linespace.cc @@ -130,6 +130,7 @@ Spacing_problem::make_matrices(Matrix &quad, Vector &lin, Real &c) const { quad.fill(0); lin.fill(0); + c = 0; for (int j=0; j < ideals.sz(); j++){ Idealspacing const*i=ideals[j]; int l = col_id(i->left); @@ -176,7 +177,6 @@ Spacing_problem::solve() const OK(); assert(check_feasible()); - /* optimalisatiefunctie */ Mixed_qp lp(cols.sz()); make_matrices(lp.quad,lp.lin, lp.const_term); diff --git a/src/parser.y b/src/parser.y index a0b9ed9b2f..bc38c27e14 100644 --- a/src/parser.y +++ b/src/parser.y @@ -447,8 +447,8 @@ int_list: /* */ { $$ = new svec; } - | int { - $$->add($1); + | int_list int { + $$->add($2); } ; diff --git a/src/pcol.cc b/src/pcol.cc index 2fab154829..951be6fa5f 100644 --- a/src/pcol.cc +++ b/src/pcol.cc @@ -19,7 +19,7 @@ PCol::rank() const { if(!pscore_) return -1; - PCursor me=pscore_->find_col(this); + PCursor me=pscore_->find_col( (PCol*)this); if (!me.ok()) return -1; PCursor bot(pscore_->cols.top()); @@ -51,7 +51,7 @@ PCol::print() const int PCol::compare(const PCol &c1, const PCol &c2) { - return c1.pscore_->compare_pcols(&c1,&c2); + return c1.pscore_->compare_pcols((PCol*)&c1,(PCol*)&c2); } void diff --git a/src/pscore.cc b/src/pscore.cc index fcd03ca55a..a34d86b0ba 100644 --- a/src/pscore.cc +++ b/src/pscore.cc @@ -77,7 +77,7 @@ PScore::typeset_spanner(Spanner*sp, PStaff*ps) void -PScore::add_line(svec curline, svec config) +PScore::add_line(svec< PCol *> curline, svec config) { Line_of_score *p = new Line_of_score(curline,this); lines.bottom().add(p); @@ -105,7 +105,7 @@ PScore::get_spacing(PCol*l, PCol*r) int -PScore::compare_pcols(const PCol*a, const PCol*b)const +PScore::compare_pcols(PCol*a, PCol*b)const { PCursor ac(find_col(a)); PCursor bc(find_col(b)); @@ -116,10 +116,10 @@ PScore::compare_pcols(const PCol*a, const PCol*b)const /* return all breakable columns */ -svec +svec< PCol *> PScore::find_breaks() const { - svec retval; + svec< PCol *> retval; for (PCursor c(cols); c.ok(); c++) if (c->breakable()) retval.add(c); @@ -217,7 +217,7 @@ PScore::postprocess() } PCursor -PScore::find_col(const PCol *c)const +PScore::find_col(PCol *c)const { PCol*what = (PCol*)c; if (what->daddy ) diff --git a/src/qlp.cc b/src/qlp.cc index 3dd8e4227e..460bd86423 100644 --- a/src/qlp.cc +++ b/src/qlp.cc @@ -25,7 +25,8 @@ Ineq_constrained_qp::add_inequality_cons(Vector c, double r) Ineq_constrained_qp::Ineq_constrained_qp(int novars): quad(novars), - lin(novars) + lin(novars), + const_term (0.0) { } @@ -45,13 +46,6 @@ Ineq_constrained_qp::eval (Vector v) { return v * quad * v + lin * v + const_term; } -/* - eliminate appropriate variables, until we have a Ineq_constrained_qp - then solve that. - - PRE - cons should be ascending - */ Vector Mixed_qp::solve(Vector start) const { @@ -94,32 +88,59 @@ Ineq_constrained_qp::eliminate_var(int idx, Real value) - -Mixed_qp::Mixed_qp(int n) - : Ineq_constrained_qp(n) -{ -} - void -Mixed_qp::OK() const +Ineq_constrained_qp::assert_solution(Vector sol) const { -#ifndef NDEBUG - Ineq_constrained_qp::OK(); - assert(eq_consrhs.sz() == eq_cons.sz()); -#endif + svec binding; + for (int i=0; i < cons.sz(); i++) { + Real R=cons[i] * sol- consrhs[i]; + assert(R> -EPS); + if (R < EPS) + binding.add(i); + } + // KKT check... + // todo } + void Ineq_constrained_qp::print() const { #ifndef NPRINT mtor << "Quad " << quad; - mtor << "lin " << lin <<"\n"; + mtor << "lin " << lin <<"\n" + << "const " << const_term<<"\n"; for (int i=0; i < cons.sz(); i++) { mtor << "constraint["<= " << consrhs[i]; mtor << "\n"; } #endif } + +/****************/ + +/* + eliminate appropriate variables, until we have a Ineq_constrained_qp + then solve that. + + PRE + cons should be ascending + */ + + +Mixed_qp::Mixed_qp(int n) + : Ineq_constrained_qp(n) +{ +} + +void +Mixed_qp::OK() const +{ +#ifndef NDEBUG + Ineq_constrained_qp::OK(); + assert(eq_consrhs.sz() == eq_cons.sz()); +#endif +} + void Mixed_qp::print() const { @@ -131,17 +152,3 @@ Mixed_qp::print() const #endif } - -void -Ineq_constrained_qp::assert_solution(Vector sol) const -{ - svec binding; - for (int i=0; i < cons.sz(); i++) { - Real R=cons[i] * sol- consrhs[i]; - assert(R> -EPS); - if (R < EPS) - binding.add(i); - } - // KKT check... - // todo -} diff --git a/src/score.cc b/src/score.cc index 4c584c4ea7..5a65809c5a 100644 --- a/src/score.cc +++ b/src/score.cc @@ -24,8 +24,9 @@ Score::process() // do this after processing, staffs first have to generate PCols. do_pcols(); - // ugh. Would want to clean the columns before anything else. - clean_cols(); + + clean_cols(); // can't move this farther up. + calc_idealspacing(); // debugging diff --git a/src/scoreline.cc b/src/scoreline.cc index bd21c32bba..788efd5dab 100644 --- a/src/scoreline.cc +++ b/src/scoreline.cc @@ -22,7 +22,7 @@ Line_of_score::TeXstring() const } -Line_of_score::Line_of_score(svec sv, +Line_of_score::Line_of_score(svec sv, PScore *ps) { pscore_ = ps; diff --git a/src/simplewalker.cc b/src/simplewalker.cc index f275cd272e..fcf2558aac 100644 --- a/src/simplewalker.cc +++ b/src/simplewalker.cc @@ -16,25 +16,48 @@ #include "slur.hh" #include "localkeyitem.hh" +Rhythmic_grouping +parse_grouping(svec a) +{ + Rhythmic_grouping ret; + Real one_beat =a[0]; + a.del(0); + svec r; + for (int i= 0 ; i < a.sz(); i++) + r.add(a[i]); + Real here =0.0; + for (int i=0; i < r.sz(); i++) { + ret.divisions.add(here); + Real last = here; + here += one_beat * r[i]; + Rhythmic_grouping *child =new Rhythmic_grouping(Interval(last, here)); + child->split(r[i]); + ret.children.add(child); + } + ret.divisions.add(here); +} + void Simple_walker::do_INTERPRET_command(Command*com) { - if (com->args[0] == "BAR") { + svec args(com->args); + args.del(0); + if (com->args[0] == "GROUPING") { + default_grouping = parse_grouping(args); + }else if (com->args[0] == "BAR") { local_key_.reset(key_); + current_grouping = default_grouping; } else if (com->args[0] == "KEY") { - svecs(com->args); - s.del(0); - if (com->when) { + + if (col()->when()) { assert(!oldkey_undo); - oldkey_undo = new svec( key_.oldkey_undo(s)); + oldkey_undo = new svec( key_.oldkey_undo(args)); } - typesetkey = key_.read(s); + typesetkey = key_.read(args); local_key_.reset(key_); } else if (com->args[0] == "CLEF") { - svecs(com->args); - s.del(0); - clef_.read(s); + clef_.read(args); } else { WARN << " ignoring INTERPRET command: " << com->args[0]<< '\n'; } diff --git a/src/slur.cc b/src/slur.cc index 5d9eb0de44..f795dc8284 100644 --- a/src/slur.cc +++ b/src/slur.cc @@ -52,7 +52,7 @@ Slur::preprocess() } Spanner* -Slur::broken_at(const PCol*l, const PCol*r) const +Slur::broken_at(PCol*l, PCol*r) const { assert(l->line == r->line); Slur*ret = new Slur(*this); diff --git a/src/staff.cc b/src/staff.cc index cbe0e59bbb..f3d6a063be 100644 --- a/src/staff.cc +++ b/src/staff.cc @@ -98,9 +98,10 @@ Staff::setup_staffcols() } } - for (PCursor cc(*staff_commands_); cc.ok(); cc++) { + for (PCursor cc(*staff_commands_); cc.ok(); cc++) { Staff_column *sc=get_col(cc->when,false); - sc->s_commands.add(cc); + for (PCursor i(**cc); i.ok(); i++) + sc->s_commands.add(i); } } diff --git a/src/staffcommands.cc b/src/staffcommands.cc index 96647b1de6..2837de161c 100644 --- a/src/staffcommands.cc +++ b/src/staffcommands.cc @@ -2,126 +2,64 @@ #include "debug.hh" #include "parseconstruct.hh" -/* - ARG! - */ - -/* - maybe it's time for a "narrowing" cursor? - */ -PCursor -Staff_commands::first(Real w) +void +Staff_commands_at::print() const { - PCursor pc(*this); - while (pc.ok() && pc->when < w) - pc++; - if (!pc.ok() || pc->when != w) { - Command *c = new Command(w); - c->priority = 10000; - if (!pc.ok()) - pc.add(c); - else - pc.insert(c); - } - - return pc; +#ifndef NPRINT + PCursor i (*this); + mtor << "Commands at: " << when<<"\n"; + + for (; i.ok(); i++) + i->print(); +#endif } -/* - RETURN: pc->when == w && pc.ok - */ - -PCursor -Staff_commands::last_insertion(Real w) -{ - PCursor pc(first(w)), next(pc); - while (next.ok() && next->when == w) { - pc=next; - next++; - } - if (pc->priority != -10000) { - Command*c = new Command(w); - c->priority = -10000; - pc.add(c); - pc++; - } - - return pc; +void +Staff_commands_at::OK()const +{ + PCursor i (*this); + for (; i.ok() && (i+1).ok(); i++) + if (!i->isbreak() && !(i+1)->isbreak()) + assert(i->priority >= (i+1)->priority); } -/* - */ -void -Staff_commands::add_seq(svec com, bool checkbreak) +Staff_commands_at::Staff_commands_at(Real r) { - if (!com.sz()) - return; - - Real when = com[0].when; + when = r; +} - PCursor begin(first(when)); - PCursor end(last_insertion(when)); - if (checkbreak && is_breakable(when)) { - if (com[0].priority < 0) - while (begin->code != BREAK_END) - begin++; - else - while (end->code != BREAK_PRE) - end--; - } - for (int i = 0; i < com.sz(); i++) { - insert_between(com[i], begin, end); +bool +Staff_commands_at::is_breakable() +{ + PCursor i(*this); + for (; i.ok(); i++) { + if (i->isbreak()) + return true; } + return false; } void -Staff_commands::set_breakable(Real when) +Staff_commands_at::set_breakable() { - bool found_typeset(false); - PCursor cc = first(when); - for (; cc.ok() && cc->when == when; cc++) { - if (cc->isbreak()) - return; - if (cc->code == TYPESET) - found_typeset=true; - } - - assert(!found_typeset); + assert(!is_breakable()); - svec seq; - Command k(when); - k.priority = 5; + Command k; k.code = BREAK_PRE; - seq.add(k); - k.priority = 4; + bottom().add(new Command(k)); k.code = BREAK_MIDDLE; - seq.add(k); - k.priority = 3; + bottom().add(new Command(k)); k.code = BREAK_POST; - seq.add(k); - k.priority = 2; + bottom().add(new Command(k)); k.code = BREAK_END; - seq.add(k); - - add_seq(seq,false); -} - -bool -Staff_commands::is_breakable(Real w) -{ - PCursor cc = first(w); - for (; cc.ok() && cc->when == w; cc++) { - if (cc->isbreak()) - return true; - } - return false; + bottom().add(new Command(k)); } void -Staff_commands::insert_between(Command victim, PCursor firstc, - PCursor last) +Staff_commands_at::insert_between(Command victim, PCursor firstc, + PCursor last) { PCursor c(firstc+1); - assert(last->when==firstc->when&&firstc < last&&last.ok()); + assert(firstc < last&&last.ok()); while (c < last) { if (c->priority <= victim.priority) { @@ -134,11 +72,10 @@ Staff_commands::insert_between(Command victim, PCursor firstc, } void -Staff_commands::add_command_to_break(Command pre, Command mid, Command post) +Staff_commands_at::add_command_to_break(Command pre, Command mid,Command post) { - Real w = pre.when; - assert(w >= 0); - PCursor c ( first(w)), f(c), l(c); + assert(is_breakable()); + PCursor c ( *this), f(c), l(c); while (!c->isbreak()) c++; @@ -157,96 +94,91 @@ Staff_commands::add_command_to_break(Command pre, Command mid, Command post) while (!c->isbreak()) c++; l = c++; - assert(l.ok() && l->when ==w && l->code == BREAK_END); + assert(l.ok() && l->code == BREAK_END); insert_between(post, f, l); } - + void -Staff_commands::process_add(Command c) +Staff_commands_at::add(Command c) { bool encapsulate =false; - Real w = c.when; - assert(w >= 0); - - Command pre(w); - Command mid(w); - Command post(w); + Command pre; + Command mid; + Command post; if (c.code == INTERPRET) { // UGH if (c.args[0] == "BAR") { - Command typeset(w); // kut met peren + Command typeset; // kut met peren typeset.code = TYPESET; typeset.args = c.args; typeset.priority = 100; - process_add(typeset); + add(typeset); } else if (c.args[0] == "KEY") { - Command typeset(w); + Command typeset; typeset.code = TYPESET; typeset.args.add("KEY"); typeset.priority = 70; - process_add(typeset); + add(typeset); } else if (c.args[0] == "CLEF") { - Command typeset(w); + Command typeset; typeset.code = TYPESET; typeset.args=c.args; typeset.priority = 90; - process_add(typeset); + add(typeset); } else if (c.args[0] == "METER") { - Command typeset(w); + Command typeset; typeset.code = TYPESET; typeset.args=c.args; typeset.priority = 40; - process_add(typeset); + add(typeset); return; } } // kut en peer if (c.code == TYPESET) { + encapsulate = is_breakable(); if (c.args[0] == "BAR") { - set_breakable(w); - encapsulate = true; + set_breakable(); + encapsulate = true; mid = c; pre = c; { /* every line a currentkey. */ - Command kc(w); + Command kc; kc.code =TYPESET; kc.args.add( "CURRENTKEY"); kc.priority = 60; - process_add(kc); + add(kc); } { /* every line a currentclef. */ - Command kc(w); + Command kc; kc.code =TYPESET; kc.args.add( "CURRENTCLEF"); kc.priority = 80; - process_add(kc); + add(kc); } - }else - if (c.args[0] == "METER" && is_breakable(w)) { - encapsulate = true; + }else if (c.args[0] == "METER" && is_breakable()) { mid = c; pre = c; post =c; }else - if( c.args[0] == "KEY" && is_breakable(c.when)) { - encapsulate = true; + if( c.args[0] == "KEY" && is_breakable()) { + mid = c; pre = c; post = c; - }else - if (c.args[0] == "CURRENTKEY" && is_breakable(w)) { + }else if (c.args[0] == "CURRENTKEY" && is_breakable() ){ post = c; - encapsulate = true; + }else - if (c.args[0] == "CURRENTCLEF" && is_breakable(w)) { + if (c.args[0] == "CURRENTCLEF" && is_breakable() ){ post = c; - encapsulate = true; + }else - if (c.args[0] == "CLEF" && is_breakable(w)) { - encapsulate = true; + if (c.args[0] == "CLEF" && is_breakable()) { + post = c; pre = c; mid = c; @@ -254,65 +186,77 @@ Staff_commands::process_add(Command c) } if (encapsulate) - add_command_to_break(pre, mid, post); + add_command_to_break(pre, mid, post); else { - svec seq; - seq.add(c); - add_seq(seq,true); + bottom().add(new Command(c)); } } -/* - first and last column should be breakable. - Remove any command past the last musical column. - */ + +/****************************************************************/ + void -Staff_commands::clean(Real l) +Staff_commands::OK() const { - assert(l>0); - if (!is_breakable(0.0)) { - Command c(0.0); - c.code = TYPESET; - c.args.add("BAR"); - c.args.add("empty"); - process_add(c); +#ifndef NDEBUG + for (PCursor i(*this); i.ok() && (i+1).ok(); i++) { + assert(i->when <= (i+1)->when); + i->OK(); + } - - PCursor bot(bottom()); +#endif +} - while (bot.ok() && bot->when > l) { - mtor <<"removing "; - bot->print(); - bot.del(); - bot = bottom(); +void +Staff_commands::print() const +{ +#ifndef NPRINT + for (PCursor i(*this); i.ok() ; i++) { + i->print(); } +#endif +} - if (!is_breakable(l)) { - Command c(l); - c.code = TYPESET; - c.args.add("BAR"); - c.args.add("||"); - process_add(c); +Staff_commands_at* +Staff_commands::find(Real w) +{ + PCursor i(bottom()); + for (; i.ok() ; i--) { + if (i->when == w) + return i; + if (i->when < w) + break; + } + Staff_commands_at*p =new Staff_commands_at(w); + if (!i.ok()) + i.insert(p); + else { + i.add(p); + i++; } - OK(); + return i; } void -Staff_commands::OK() const +Staff_commands::add(Command c, Real when) { - for (PCursor 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); - } + Staff_commands_at* p = find(when); + p->add(c); } void -Staff_commands::print() const +Staff_commands::clean(Real l) { -#ifndef NPRINT - for (PCursor cc(*this); cc.ok() ; cc++) { - cc->print(); + PCursor i(bottom()); + for (; i->when > l ; i=bottom()) { + remove(i); + } + Staff_commands_at*p = find(l); + + if (!p->is_breakable()) { + p->set_breakable(); +/* Command b; + b.code = INTERPRET; + b.args.add("BAR");*/ } -#endif } diff --git a/src/staffline.cc b/src/staffline.cc index a51c669e1f..9fd5b1d5bf 100644 --- a/src/staffline.cc +++ b/src/staffline.cc @@ -64,13 +64,13 @@ Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st) pstaff_=st; - const PCol *linestart = sc->cols.top(); - const PCol *linestop = sc->cols.bottom(); + PCol *linestart = sc->cols.top(); + PCol *linestop = sc->cols.bottom(); for (PCursor sp(pstaff_->spans); sp.ok(); sp++) { - const PCol *brokenstart = &MAX(*linestart, *sp->left); - const PCol *brokenstop = &MIN(*linestop, *sp->right); + PCol *brokenstart = &MAX(*linestart, *sp->left); + PCol *brokenstop = &MIN(*linestop, *sp->right); if ( *brokenstart < *brokenstop) { line_of_score_->pscore_-> // higghl add_broken(sp->broken_at(brokenstart,brokenstop)); diff --git a/src/template3.cc b/src/template3.cc index be32eeceff..3e06cfdb23 100644 --- a/src/template3.cc +++ b/src/template3.cc @@ -16,3 +16,4 @@ IPL_instantiate(Command); IPL_instantiate(Input_command); IPL_instantiate(Commands_at); IPL_instantiate(Input_staff); +IPL_instantiate(Input_music); diff --git a/symbol.ini b/symbol.ini index 21226c079d..d0dd12453d 100644 --- a/symbol.ini +++ b/symbol.ini @@ -213,4 +213,4 @@ english_names = notenames { } default_table = symboltables { table_sixteen } -notenames { dutch_names } \ No newline at end of file +notenames { dutch_names } -- 2.39.2