From b669f94707fdf46934e3d1df471158f2e650d0e3 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Fri, 6 Dec 1996 23:41:30 +0100 Subject: [PATCH] release: 0.0.11 --- Documentation/Makefile | 3 +- Documentation/pointers | 31 +++++++ Documentation/slurfont | 43 ++++++++++ Makefile | 1 + README | 2 +- Sources.make | 6 +- Variables.make | 2 +- dimen.tex | 5 +- flower/Makefile | 2 +- flower/choleski.cc | 10 +-- flower/cursor.cc | 33 ++++---- flower/cursor.inl | 40 ++++----- flower/fproto.hh | 1 + flower/interval.cc | 34 +++++++- flower/interval.hh | 16 ++-- flower/matrix.cc | 18 ---- flower/matrix.hh | 6 +- hdr/boxes.hh | 47 +---------- hdr/keyitem.hh | 2 +- hdr/localkeyitem.hh | 1 + hdr/lookup.hh | 15 +++- hdr/meter.hh | 1 + hdr/paper.hh | 1 + hdr/pcol.hh | 23 ++--- hdr/proto.hh | 2 +- hdr/pscore.hh | 12 ++- hdr/request.hh | 2 + hdr/sccol.hh | 5 ++ hdr/scoreline.hh | 5 +- hdr/simplestaff.hh | 4 +- hdr/simplewalker.hh | 6 +- hdr/slur.hh | 36 ++++++++ hdr/staffline.hh | 5 +- hdr/voice.hh | 2 +- lilyponddefs.tex | 13 +++ maartje.ly | 28 +++--- objects/Makefile | 5 +- src/beam.cc | 5 +- src/boxes.cc | 12 +-- src/calcideal.cc | 2 +- src/key.cc | 4 +- src/keyitem.cc | 2 +- src/lookup.cc | 80 +++++++++--------- src/main.cc | 2 +- src/melodicstaff.cc | 2 +- src/meter.cc | 7 +- src/molecule.cc | 3 + src/notehead.cc | 2 +- src/paper.cc | 6 ++ src/pcol.cc | 40 ++++++--- src/pscore.cc | 41 +++++++-- src/sccol.cc | 2 +- src/scommands.cc | 6 +- src/score.cc | 2 +- src/scoreline.cc | 6 +- src/simplestaff.cc | 3 + src/simplewalker.cc | 80 ++++++++++++++---- src/slur.cc | 105 +++++++++++++++++++++++ src/spanner.cc | 6 +- src/staffline.cc | 27 +++--- src/stem.cc | 12 ++- src/symbol.cc | 2 + src/symtable.cc | 10 +-- src/template1.cc | 4 +- src/template2.cc | 3 +- src/template3.cc | 5 +- src/template4.cc | 4 + src/tex.cc | 1 + src/texslur.cc | 187 +++++++++++++++++++++++++++++++++++++++++ src/voice.cc | 8 +- src/warn.cc | 8 +- symbol.ini | 4 + 72 files changed, 854 insertions(+), 307 deletions(-) create mode 100644 Documentation/pointers create mode 100644 Documentation/slurfont create mode 100644 hdr/slur.hh create mode 100644 src/slur.cc create mode 100644 src/template4.cc create mode 100644 src/texslur.cc diff --git a/Documentation/Makefile b/Documentation/Makefile index daf587679e..383026e355 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -1,5 +1,6 @@ -DOCFILES=commands CodingStyle algorithms Makefile breaking +DOCFILES=commands CodingStyle algorithms Makefile breaking\ + slurfont pointers dist: ln $(DOCFILES) $(DDIR)/Documentation/ \ No newline at end of file diff --git a/Documentation/pointers b/Documentation/pointers new file mode 100644 index 0000000000..45e2479d3f --- /dev/null +++ b/Documentation/pointers @@ -0,0 +1,31 @@ +This describes the ownership of certain classes in LilyPond. + +signifies a "list of". (This is not complete) + +Score: + Paperdef + Staff+ + Score_commands + Score_columns+ + PScore + +Staff: + Voice + Staff_column+ + Command+ + + +Voice: + Voice_element + +Voice_element: + Request+ + + +PScore: + PStaff+ + PCol+ + Idealspacing+ + Item+ + Spanner+ + Spanner+ (broken) + diff --git a/Documentation/slurfont b/Documentation/slurfont new file mode 100644 index 0000000000..fda65e193a --- /dev/null +++ b/Documentation/slurfont @@ -0,0 +1,43 @@ +How are slur fonts organised? + +xhslu20: see xslhu20 + +xslhu20: half slurs, pointing up + right + width in steps of 12pt (12pt-96pt) + height in 16 steps + left + idem + +xslhd20: half slurs, pointing down, idem + +xslu20: whole slurs, ascending + pointing up + height (dy) in 8 steps + width in 16 steps of 4pt (8 pt - 64pt) + pointing down + height (dy) in 8 steps + width in steps of 4pt (8 pt - 64pt) + +xsld20: whole slurs, descending + pointing up + height (dy) in 8 steps + width in steps of 4pt (8 pt - 60pt) + pointing down + height (dy) in 8 steps + width in steps of 4pt (8 pt - 60pt) + + +xslhz: middlepieces for half-slurs + pointing up + width in 100 steps of 4 pt (4 pt to 400pt) + pointing down + idem + +xslz: horizontal slurs + pointing up + width in 54 steps of 4pt + pointing down + idem + +xtie: same as xslhz. diff --git a/Makefile b/Makefile index 4dcc395210..9b1b762a3a 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ $(exe): $(obs) $(CXX) -o $@ $^ $(LOADLIBES) clean: + $(MAKE) -C objects clean rm -f $(exe) *.o $(DOCDIR)/* core distclean: clean diff --git a/README b/README index c3c4cbd23e..d60b5b8ca4 100644 --- a/README +++ b/README @@ -5,7 +5,7 @@ INTRODUCTION This is a beta version of LilyPond (a music typesetter). Please send your helpful comments and patches to me, - hanwen@stack.urc.tue.nl + hanwen@stack.nl LilyPond is updated very frequently, the latest version is always available at: diff --git a/Sources.make b/Sources.make index 61c32fa41c..c4d585bc6a 100644 --- a/Sources.make +++ b/Sources.make @@ -14,7 +14,7 @@ hdr= qlp.hh linespace.hh qlpsolve.hh\ notehead.hh leastsquares.hh beam.hh rest.hh\ swalker.hh bar.hh meter.hh accidental.hh\ key.hh keyitem.hh localkeyitem.hh simplewalker.hh\ - clef.hh clefitem.hh + clef.hh clefitem.hh slur.hh mycc= qlp.cc qlpsolve.cc \ break.cc linespace.cc molecule.cc staffline.cc\ @@ -32,6 +32,6 @@ mycc= qlp.cc qlpsolve.cc \ texbeam.cc rest.cc swalker.cc scoreline.cc\ simplewalker.cc bar.cc meter.cc accidental.cc\ key.cc keyitem.cc localkeyitem.cc\ - clef.cc clefitem.cc\ - template1.cc template2.cc template3.cc\ + clef.cc clefitem.cc texslur.cc slur.cc\ + template1.cc template2.cc template3.cc template4.cc\ version.cc diff --git a/Variables.make b/Variables.make index 2d27e3be3f..f8cd146ba4 100644 --- a/Variables.make +++ b/Variables.make @@ -18,7 +18,7 @@ EXTRACXXFLAGS=-pipe -Wall -W -pedantic # version info MAJVER=0 MINVER=0 -PATCHLEVEL=10 +PATCHLEVEL=11 VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) # directories diff --git a/dimen.tex b/dimen.tex index 7665eb3379..f0198c6c75 100644 --- a/dimen.tex +++ b/dimen.tex @@ -1,5 +1,7 @@ \font\musicfnt=musix20 -\def\mb#1{{\musicfnt\musicfnt\char#1}} +%\def\mb#1{{\musicfnt\musicfnt\char#1}} +\font\slurfont=xslhz20 +\def\mb#1{{\musicfnt\slurfont\char#1}} \newdimen\wid \newdimen\inc \newdimen\here @@ -13,6 +15,7 @@ \hbox to0pt{\kern\here\vrule width0.05pt height 2pt\hss}% \repeat% } + \def\vruler#1{% \wid=#1pt \inc=\wid diff --git a/flower/Makefile b/flower/Makefile index 46fb7b5ab4..25e9384d56 100644 --- a/flower/Makefile +++ b/flower/Makefile @@ -1,6 +1,6 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=11 +PATCHLEVEL=12 PACKAGENAME=flower VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) diff --git a/flower/choleski.cc b/flower/choleski.cc index 82740a27c1..4202a9b1e5 100644 --- a/flower/choleski.cc +++ b/flower/choleski.cc @@ -15,13 +15,11 @@ Choleski_decomposition::solve(Vector rhs)const sum += y(j) * L(i,j); y(i) = (rhs(i) - sum)/L(i,i); } - for (int i=0; i < n; i++) { - assert(D(i)); + for (int i=0; i < n; i++) y(i) /= D(i); - } // backward subst - Vector x(n); + Vector &x(rhs); // using input as return val. for (int i=n-1; i >= 0; i--) { Real sum(0.0); for (int j=i+1; j < n; j++) @@ -91,7 +89,3 @@ Choleski_decomposition::inverse() const return invm; } - - - - diff --git a/flower/cursor.cc b/flower/cursor.cc index 75f607dcaa..3d2116c46f 100644 --- a/flower/cursor.cc +++ b/flower/cursor.cc @@ -5,14 +5,25 @@ #include template -Cursor -Cursor::operator ++( int ) + void +Cursor::backspace() { - Cursor r = *this; - assert( pointer_ ); - pointer_ = pointer_->next(); - return r; + Cursor c(*this); + c--; + list_.remove( *this ); +} + +template + void +Cursor::del() +{ + Cursor c(*this); + c++; + list_.remove( *this ); + *this = c; } + + template Cursor Cursor::operator -=( int j ) @@ -30,16 +41,6 @@ Cursor::operator +=( int j ) return *this; } -template -Cursor -Cursor::operator --( int ) -{ - Cursor r = *this; - assert( pointer_ ); - pointer_ = pointer_->previous(); - return r; -} - template Cursor Cursor::operator +( int i ) const diff --git a/flower/cursor.inl b/flower/cursor.inl index 0b077bd811..4337ef446a 100644 --- a/flower/cursor.inl +++ b/flower/cursor.inl @@ -54,25 +54,6 @@ Cursor::insert( const T& th ) list_.insert( th, *this ); } -template -inline void -Cursor::backspace() -{ - Cursor c(*this); - c--; - list_.remove( *this ); -} - -template -inline void -Cursor::del() -{ - Cursor c(*this); - c++; - list_.remove( *this ); - *this = c; -} - template inline const List& Cursor::list() const @@ -108,4 +89,25 @@ Cursor::ok() return ( pointer_ != 0 ); } + +template +inline Cursor +Cursor::operator ++( int ) +{ + Cursor r (*this); + assert( pointer_ ); + pointer_ = pointer_->next(); + return r; +} + +template +inline Cursor +Cursor::operator --( int ) +{ + Cursor r (*this); + assert( pointer_ ); + pointer_ = pointer_->previous(); + return r; +} + #endif diff --git a/flower/fproto.hh b/flower/fproto.hh index 672a992dc9..43452af7b8 100644 --- a/flower/fproto.hh +++ b/flower/fproto.hh @@ -29,6 +29,7 @@ struct Getopt_long ; struct Matrix ; struct StringData ; struct String_handle ; +struct String; struct virtual_smat ; struct Vector ; class Text_stream; diff --git a/flower/interval.cc b/flower/interval.cc index b307f4c634..6cc2a7916e 100644 --- a/flower/interval.cc +++ b/flower/interval.cc @@ -1,6 +1,8 @@ #include -#include "interval.hh" #include +#include "interval.hh" +#include "string.hh" + const Real INFTY = HUGE; @@ -15,4 +17,34 @@ Interval::length() const { assert(max >= min); return max-min; } +void +Interval::unite(Interval h) +{ + if (h.minmax) + max = h.max; +} +void +Interval::intersect(Interval h) +{ + min = MAX(h.min, min); + max = MIN(h.max, max); +} +Interval +intersect(Interval x, Interval const &y) +{ + x.intersect(y); + return x; +} + + +Interval::operator String() const +{ + if (empty()) + return "[empty]"; + String s("["); + + return s + min + "," + max +"]"; +} diff --git a/flower/interval.hh b/flower/interval.hh index 950945ca87..6f9fa63f67 100644 --- a/flower/interval.hh +++ b/flower/interval.hh @@ -8,6 +8,7 @@ #define INTERVAL_HH #include +#include "fproto.hh" #include "real.hh" @@ -29,15 +30,12 @@ struct Interval { return 0.0; } - void unite(Interval h) { - if (h.minmax) - max = h.max; - } + void unite(Interval h) ; + void intersect(Interval h); + Real length() const; void set_empty() ; - bool empty() { return min > max; } + bool empty() const { return min > max; } Interval() { set_empty(); } @@ -50,9 +48,13 @@ struct Interval { max +=r; return *this; } + + operator String() const; }; +Interval intersection(Interval, Interval const&); + #endif // INTERVAL_HH diff --git a/flower/matrix.cc b/flower/matrix.cc index b95a4ab1f9..63bd85a33c 100644 --- a/flower/matrix.cc +++ b/flower/matrix.cc @@ -9,24 +9,6 @@ Matrix::norm() const return sqrt(r); } -//inline -Real -Matrix::operator()(int i,int j) const -{ - assert(i >= 0 && j >= 0); - assert(i < rows() && j < cols()); - return dat->elem(i,j); -} - -//inline -Real & -Matrix::operator()(int i, int j) -{ - assert(i >= 0 && j >= 0); - assert(i < rows() && j < cols()); - return dat->elem(i,j); -} - void Matrix::fill(Real r) { diff --git a/flower/matrix.hh b/flower/matrix.hh index e092a5fbe6..5283dc71ef 100644 --- a/flower/matrix.hh +++ b/flower/matrix.hh @@ -35,7 +35,7 @@ public: void unit() { set_diag(1.0); } void operator+=(const Matrix&m); - void operator-=(const Matrix&m); + void operator-=(const Matrix&m); void operator*=(Real a); void operator/=(Real a) { (*this) *= 1/a; } @@ -74,10 +74,10 @@ public: void operator=(const Matrix&m); /// access an element - Real operator()(int i,int j) const; + Real operator()(int i,int j) const { return dat->elem(i,j); } /// access an element - Real &operator()(int i, int j); + Real &operator()(int i, int j) { return dat->elem(i,j); } /// Matrix multiply with vec (from right) Vector operator *(const Vector &v) const; diff --git a/hdr/boxes.hh b/hdr/boxes.hh index e3ea69a3bf..5bc2cb2e73 100644 --- a/hdr/boxes.hh +++ b/hdr/boxes.hh @@ -5,9 +5,10 @@ #ifndef BOXES_HH #define BOXES_HH -#include "textdb.hh" +#include "fproto.hh" #include "real.hh" -#include "vray.hh" +#include "interval.hh" + /// 2d vector struct Offset { @@ -34,46 +35,6 @@ struct Offset { } }; -/// a Real interval -struct Interval { - Real min, max; - - void translate(Real t) { - min += t; - max += t; - } - Real operator[](int j) { - if (j==-1) - return min; - else if (j==1) - return max; - else - assert(false); - - } - void unite(Interval h) { - if (h.minmax) - max = h.max; - } - Real length() const; - void set_empty() ; - bool empty() { return min > max; } - Interval() { - set_empty(); - } - Interval(Real m, Real M) { - min =m; - max = M; - } - Interval &operator += (Real r) { - min += r; - max +=r; - return *this; - } -}; - /// a 4-tuple of #Real#s struct Box { @@ -87,7 +48,7 @@ struct Box { x.unite(b.x); y.unite(b.y); } - Box(svec ); + Box(svec &); Box(); Box(Interval ix, Interval iy); }; diff --git a/hdr/keyitem.hh b/hdr/keyitem.hh index d5b159368b..ba49475ce4 100644 --- a/hdr/keyitem.hh +++ b/hdr/keyitem.hh @@ -8,7 +8,7 @@ #define KEYITEM_HH #include "item.hh" - +#include "vray.hh" struct Keyitem : Item { svec pitch; svec acc; diff --git a/hdr/localkeyitem.hh b/hdr/localkeyitem.hh index 5b045c93ae..cc786e8e7f 100644 --- a/hdr/localkeyitem.hh +++ b/hdr/localkeyitem.hh @@ -7,6 +7,7 @@ #ifndef LOCALKEYITEM_HH #define LOCALKEYITEM_HH #include "item.hh" +#include "vray.hh" struct Local_acc { int name , acc, octave; diff --git a/hdr/lookup.hh b/hdr/lookup.hh index 5be2b25464..14ed92f6b8 100644 --- a/hdr/lookup.hh +++ b/hdr/lookup.hh @@ -5,16 +5,14 @@ #define LOOKUPSYMS_HH #include "symbol.hh" - +#include "fproto.hh" struct Lookup { Symtables *symtables_; /****************/ - + Real internote(); void parse (Text_db&t); Parametric_symbol *linestaff(int n); - Parametric_symbol *meter(String); - Parametric_symbol *stem(); Symbol beam_element(int,int,Real=0); /// round slope to closest TeXslope @@ -26,6 +24,8 @@ struct Lookup { pos == -3: below staff */ + Symbol meter(svec); + Symbol stem(Real y1_pos, Real y2_pos); Symbol rule_symbol(Real height, Real width); Symbol accidental(int); Symbol ball(int); @@ -34,6 +34,13 @@ struct Lookup { Symbol clef(String); Symbol bar(String); Symbol dots(int); + Symbol slur(int dy, Real &dx, int dir); + Symbol half_slur(int dy, Real &dx, int dir, int xpart); + Symbol half_slur_middlepart(Real &dx, int dir); + Symbol big_slur(int dy, Real &dx, int dir); + + + Lookup(); ~Lookup(); }; diff --git a/hdr/meter.hh b/hdr/meter.hh index 6af8817265..5498112d37 100644 --- a/hdr/meter.hh +++ b/hdr/meter.hh @@ -7,6 +7,7 @@ #ifndef METER_HH #define METER_HH #include "item.hh" +#include "vray.hh" struct Meter: Item { svec args; diff --git a/hdr/paper.hh b/hdr/paper.hh index 84932a36ab..b2ba370b57 100644 --- a/hdr/paper.hh +++ b/hdr/paper.hh @@ -19,6 +19,7 @@ struct Paperdef { Paperdef(); ~Paperdef(); Real interline()const; + Real internote()const; Real rule_thickness()const; Real standard_height()const; Real note_width() const; diff --git a/hdr/pcol.hh b/hdr/pcol.hh index 7cbf93f2ab..f6a38d57aa 100644 --- a/hdr/pcol.hh +++ b/hdr/pcol.hh @@ -11,11 +11,6 @@ struct PCol { PointerList its; PointerList stoppers, starters; - /// Can this be broken? true eg. for bars. - bool breakable()const; - - /// does this column have items, does it have spacings attached? - bool used; /// prebreak is put before end of line. PCol *prebreak; @@ -28,20 +23,28 @@ struct PCol { PCol *postbreak; /** \See{prebreak} */ + PCol *daddy; - /* - if this column is pre or postbreak, then this field points to the parent. - */ + /** 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; - - /****************************************************************/ + PScore * pscore_; + + /****************/ + /// does this column have items, does it have spacings attached? + bool used() const; + void add(Item *i); + + /// Can this be broken? true eg. for bars. + bool breakable()const; Interval width() const; ~PCol(); diff --git a/hdr/proto.hh b/hdr/proto.hh index f80b7f8d0a..33d6f8e27a 100644 --- a/hdr/proto.hh +++ b/hdr/proto.hh @@ -96,6 +96,6 @@ struct Keyitem; struct Local_key_item; struct Clef; struct Clef_item; - +struct Slur; #endif // PROTO_HH diff --git a/hdr/pscore.hh b/hdr/pscore.hh index c434f5b700..00fb79bccc 100644 --- a/hdr/pscore.hh +++ b/hdr/pscore.hh @@ -30,8 +30,13 @@ struct PScore { /// crescs etc; no particular order IPointerList spanners; - /****************************************************************/ + /// broken spanners + IPointerList broken_spans; + /****************/ + + void add_broken(Spanner*); + svec select_items(PStaff*, PCol*); /// before calc_breaking @@ -78,7 +83,7 @@ struct PScore { */ /// return argument as a cursor. - PCursor find_col(PCol *); + PCursor find_col(const PCol *)const; /// delete unused columns void clean_cols(); @@ -94,6 +99,9 @@ struct PScore { /// does curline fit on the paper? bool feasible(svec curline) const; + + /// which is first (left, higher) + int compare_pcols(const PCol*, const PCol*)const; }; /** notes, signs, symbols in a score can be grouped in two ways: horizontally (staffwise), and vertically (columns). #PScore# diff --git a/hdr/request.hh b/hdr/request.hh index 1911f20219..d8ee21ccc7 100644 --- a/hdr/request.hh +++ b/hdr/request.hh @@ -19,6 +19,7 @@ struct Request { virtual Rest_req *rest() {return 0;} virtual Span_req *span() {return 0;} virtual Beam_req *beam() { return 0 ; } + virtual Slur_req *slur() { return 0 ; } virtual Rhythmic_req*rhythmic() { return 0;} virtual Real duration() const { return 0.0; } virtual Request* clone() const =0; @@ -154,6 +155,7 @@ struct Beam_req : Span_req { /// a slur struct Slur_req : Span_req { virtual Request*clone()const; + virtual Slur_req*slur() { return this; } }; diff --git a/hdr/sccol.hh b/hdr/sccol.hh index 44f3fbb16d..f8aceb2304 100644 --- a/hdr/sccol.hh +++ b/hdr/sccol.hh @@ -7,12 +7,14 @@ #ifndef SCCOL_HH #define SCCOL_HH #include "pcol.hh" +#include "vray.hh" struct Score_column { /// indirection to column PCol * pcol_; + /// length of notes/rests in this column svec durations; @@ -47,3 +49,6 @@ instantiate_compare(Score_column&, Score_column::compare); #endif // SCCOL_HH + + + diff --git a/hdr/scoreline.hh b/hdr/scoreline.hh index a8ae77a222..5ebb936b1e 100644 --- a/hdr/scoreline.hh +++ b/hdr/scoreline.hh @@ -17,11 +17,11 @@ Line_of_score { // need to store height of each staff. IPointerList staffs; - const PScore * score; // needed to generate staffs + PScore * pscore_; // needed to generate staffs /****************/ - Line_of_score(svec sv, const PScore *); + Line_of_score(svec sv, PScore *); String TeXstring() const; @@ -30,3 +30,4 @@ Line_of_score { }; #endif + diff --git a/hdr/simplestaff.hh b/hdr/simplestaff.hh index e4c600ba1b..07fc985047 100644 --- a/hdr/simplestaff.hh +++ b/hdr/simplestaff.hh @@ -22,15 +22,15 @@ struct Simple_staff; struct Simple_column : Staff_column { svec notes; + svec slurs; Stem_req *stem_; Beam_req *beam_; Simple_staff* staff_; /****************/ - + Slur_req * find_slur(Voice *); void typeset_item(Item *, int=1); - void typeset_item_directional(Item *, int dir, int=1); Molecule *create_command_mol(Command *com); diff --git a/hdr/simplewalker.hh b/hdr/simplewalker.hh index 5f27957aca..a8db0337aa 100644 --- a/hdr/simplewalker.hh +++ b/hdr/simplewalker.hh @@ -22,7 +22,8 @@ struct Simple_walker: Staff_walker { bool processed_key; bool processed_clef; Clef clef_; - + svec pending_slur_reqs; + svec pending_slurs; /****************/ virtual void do_TYPESET_command(Command*); @@ -30,12 +31,13 @@ struct Simple_walker: Staff_walker { virtual void process_requests(); virtual void reset(); - void do_notes(); + void do_note(Rhythmic_req*); Simple_walker(Simple_staff*); Simple_column *col(); Simple_staff *staff(); void do_local_key(Note_req*n); + int find_slur(const Voice*v); }; diff --git a/hdr/slur.hh b/hdr/slur.hh new file mode 100644 index 0000000000..43359399e8 --- /dev/null +++ b/hdr/slur.hh @@ -0,0 +1,36 @@ +/* + slur.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef SLUR_HH +#define SLUR_HH + +#include "spanner.hh" +#include "fproto.hh" +#include "vray.hh" + +struct Slur : Spanner { + + svec encompass; + int dir; + + bool open_left,open_right; + + /****************/ + + void print()const; + void preprocess(); + void add(Notehead*); + void set_default_dir(); + Interval height() const; + Spanner* broken_at(const PCol*, const PCol*) const; + void process(); +private: + void brew_molecule(); +}; + +#endif // SLUR_HH + + diff --git a/hdr/staffline.hh b/hdr/staffline.hh index be5a7de42b..868198b013 100644 --- a/hdr/staffline.hh +++ b/hdr/staffline.hh @@ -15,8 +15,8 @@ /// one broken line of staff. struct Line_of_staff { - IPointerList brokenspans; - Line_of_score const * scor; + + Line_of_score * line_of_score_; const PStaff *pstaff_; /****************/ @@ -24,6 +24,7 @@ struct Line_of_staff { String TeXstring() const; Line_of_staff(Line_of_score*, PStaff *); Interval height() const; + }; #endif diff --git a/hdr/voice.hh b/hdr/voice.hh index 4e304bb0d9..db2e0872cf 100644 --- a/hdr/voice.hh +++ b/hdr/voice.hh @@ -33,7 +33,7 @@ struct Voicegroup { struct Voice_element { Real duration; const Voicegroup *group; - const Voice *voice; + const Voice *voice_; IPointerList reqs; PointerList granted_items; diff --git a/lilyponddefs.tex b/lilyponddefs.tex index be9aada8a2..1e098eb271 100644 --- a/lilyponddefs.tex +++ b/lilyponddefs.tex @@ -1,5 +1,6 @@ %% %% include file for LilyPond + \def\mdef#1#2{\def#1{{\musicfnt\char#2}}} %% musix defs @@ -11,6 +12,12 @@ \newdimen\interstaffrule \def\musixtwentydefs{ + \font\slurufont=xslu20 + \font\slurdfont=xsld20 + \font\slurhfont=xslz20 + \font\hslurufont=xslhu20 + \font\hslurdfont=xslhd20 + \font\hslurhfont=xslhz20 \font\musicfnt=musix20 \balkhoog=20pt \staffrulethickness=0.4pt @@ -26,6 +33,12 @@ \musixtwentydefs \musixcalc +\def\slurcharh#1{{\slurhfont\char#1}} +\def\slurcharu#1{{\slurufont\char#1}} +\def\slurchard#1{{\slurdfont\char#1}} +\def\hslurcharh#1{{\hslurhfont\char#1}} +\def\hslurcharu#1{{\hslurufont\char#1}} +\def\hslurchard#1{{\hslurdfont\char#1}} \mdef\quartball{'007} \mdef\halfball{'010} diff --git a/maartje.ly b/maartje.ly index 928f7b2838..fcb64323ee 100644 --- a/maartje.ly +++ b/maartje.ly @@ -1,21 +1,29 @@ ritme = rhythmstaff { - voice { $ c2 r32 r32 r16 r8 r4 c2 c2 c2 c2 c2 - c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 $ } + voice { $ c2 c2 + %[c8( )'a8 c8 c8] + c2 c2 + + [fis16 'dis16( fis16 'dis16 ][fis16) 'dis16 fis16 'dis16] + c2 r32 r32 r16 r8 r4 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 $ } } melody= melodicstaff { - - voice { $ fis 'dis 'fis 'gisis $ } - voice { $ 'eses $ start 0.75} - voice { $ 'cis $ start 0.75} - voice { $ f $ start 0.75} - voice { $ gis $ start 0.75} + voice { $ c () `bes $ start 0.5 } + voice { $ + %[fis16 'dis16 fis16 'dis16 fis16 'dis16 fis16 'dis16] + c2 + 'fis ()'gisis $ } + + + voice { $ d () d $ start 0.5 } + voice { $ a () bes $ start 0.5 } + voice { $ fis () g $ start 0.5 } voice { $ ''c2.. r8 r4 r8 r16 r32 r32 - [d8 e8 f8 g8] [d8 e8 f8 g8] + [d8 e8 'f8 g8] [d8 e8 f8 g8] ''fis1 a8 b8 'c8 'd8 ''c8 ```c8 c4 c4 c4 c4 \duration 16 `b16 `a16 `g16 `f16 \duration 4 @@ -32,12 +40,10 @@ score { % staff { melody } commands { meter 4 4 - key $ fis cis gis $ skip 2:0 key $ $ meter 2 4 - skip 19:0 } } diff --git a/objects/Makefile b/objects/Makefile index 701ad6d5b9..585e1df181 100644 --- a/objects/Makefile +++ b/objects/Makefile @@ -1,2 +1,5 @@ dist: - ln Makefile $(DDIR)/objects/ \ No newline at end of file + ln Makefile $(DDIR)/objects/ + +clean: + rm -f *.o diff --git a/src/beam.cc b/src/beam.cc index 88dab8992d..f8ca8b5ab8 100644 --- a/src/beam.cc +++ b/src/beam.cc @@ -93,7 +93,7 @@ Beam::solve_slope() slope *= dir; { - Real inter =paper()->interline()/2; + Real inter =paper()->internote(); Real unitslope = slope*inter; // set beamslope, for setting stems correctly @@ -164,7 +164,8 @@ Beam::width() const void Beam::brew_molecule() { - Real inter=paper()->interline()/2; + assert(left->line == right->line); + Real inter=paper()->internote(); Real sl = slope*inter; Real w = width().length() + paper()->rule_thickness(); Symbol s = paper()->lookup_->beam(sl,w); diff --git a/src/boxes.cc b/src/boxes.cc index ebfc08abfe..b280e45f92 100644 --- a/src/boxes.cc +++ b/src/boxes.cc @@ -1,16 +1,8 @@ #include "boxes.hh" #include "const.hh" +#include "vray.hh" -void -Interval::set_empty() { - min = INFTY; - max = -INFTY; -} -Real -Interval::length() const { - return max-min; -} -Box::Box(svec s) +Box::Box(svec &s) { assert(s.sz() == 4); x.min = s[0]; diff --git a/src/calcideal.cc b/src/calcideal.cc index 051ac4312c..03910ac561 100644 --- a/src/calcideal.cc +++ b/src/calcideal.cc @@ -21,7 +21,7 @@ Score::do_connect(PCol *c1, PCol *c2, Real d) void Score::connect_nonmus(PCol* c1, PCol *c2, Real d) { - if (c2->used && c1->used) { + if (c2->used() && c1->used()) { do_connect(c1,c2,d); // alert! this is broken! diff --git a/src/key.cc b/src/key.cc index 303bf10beb..542549ddf9 100644 --- a/src/key.cc +++ b/src/key.cc @@ -41,7 +41,9 @@ svec Key::read(svec s) { svec newkey; - + for (int j = 0; j < 7; j++) + accidentals[j] = 0; + for (int i=0; i < s.sz(); i++) { int large, small; lookup_notename(large, small, s[i]); diff --git a/src/keyitem.cc b/src/keyitem.cc index d02ed700af..607e144f1a 100644 --- a/src/keyitem.cc +++ b/src/keyitem.cc @@ -43,7 +43,7 @@ Keyitem::brew_molecole() for (int i =0; i < pitch.sz(); i++) { Symbol s= paper()->lookup_->accidental(acc[i]); Atom a(s); - a.translate(Offset(0,c_position + pitch[i] * inter)); + a.translate(Offset(0,(c_position + pitch[i]) * inter)); Molecule m(a); output->add_right(m); } diff --git a/src/lookup.cc b/src/lookup.cc index 5eef666525..b9c369c0fc 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -4,6 +4,12 @@ #include "dimen.hh" #include "tex.hh" +Real +Lookup::internote() +{ + return ball(4).dim.y.length()/2; +} + void Lookup::parse(Text_db&t) { @@ -35,6 +41,7 @@ Lookup::rest(int j) { return (*symtables_)("rests")->lookup(String(j)); } + Symbol Lookup::accidental(int j) { @@ -54,7 +61,7 @@ Lookup::clef(String s) return (*symtables_)("clefs")->lookup(s); } - Symbol +Symbol Lookup::dots(int j) { if (j>3) @@ -74,11 +81,12 @@ Lookup::streepjes(int i) assert(i); int arg; - String idx ; - if (i<0) { + String idx; + + if (i < 0) { idx = "botlines"; arg = -i; - }else { + } else { arg = i; idx = "toplines"; } @@ -121,52 +129,42 @@ Linestaf_symbol::eval(svec w)const /****************************************************************/ -struct Meter_sym:Parametric_symbol { - - Meter_sym(Symtables*s) : Parametric_symbol(s){ } - Symbol eval(svec a) const{ - Symbol s; - s.dim.x = Interval( convert_dimen(0,"pt"), - convert_dimen(10,"pt")); - s.dim.y = Interval(0, convert_dimen(20,"pt") ); // todo - String src = (*symtables_)("param")->lookup("meter").tex; - s.tex = substitute_args(src,a); - return s; - } -}; -/****************************************************************/ - -struct Stem_sym:Parametric_symbol { - Stem_sym(Symtables*s) : Parametric_symbol(s) { } - Symbol eval(svec a) const { - Real y1 = a[0].fvalue(); - Real y2 = a[1].fvalue(); - assert(y1 <= y2); - Symbol s; - s.dim.x = Interval(0,0); - s.dim.y = Interval(y1,y2); +Symbol +Lookup::meter(svec a) +{ + Symbol s; + s.dim.x = Interval( convert_dimen(0,"pt"), + convert_dimen(10,"pt")); + s.dim.y = Interval(0, convert_dimen(20,"pt") ); // todo + String src = (*symtables_)("param")->lookup("meter").tex; + s.tex = substitute_args(src,a); + return s; +} - String src = (*symtables_)("param")->lookup("stem").tex; - s.tex = substitute_args(src,a); - return s; - } -}; -Parametric_symbol * -Lookup::meter(String ) +Symbol +Lookup::stem(Real y1,Real y2) { - return new Meter_sym(symtables_); + assert(y1 <= y2); + Symbol s; + + s.dim.x = Interval(0,0); + s.dim.y = Interval(y1,y2); + + svec a; + a.add(print_dimen(y1)); + a.add(print_dimen(y2)); + + String src = (*symtables_)("param")->lookup("stem").tex; + s.tex = substitute_args(src,a); + return s; } + Parametric_symbol * Lookup::linestaff(int n) { return new Linestaf_symbol(n,symtables_); } -Parametric_symbol* -Lookup::stem() -{ - return new Stem_sym(symtables_); -} diff --git a/src/main.cc b/src/main.cc index c45de7a683..8e499b0204 100644 --- a/src/main.cc +++ b/src/main.cc @@ -27,7 +27,7 @@ void notice() cout << "LilyPond, a music typesetter.\n" "Copyright (C) 1996 by\n" - " Han-Wen Nienhuys \n" + " Han-Wen Nienhuys \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" diff --git a/src/melodicstaff.cc b/src/melodicstaff.cc index fc7ccbb8fb..712ffb7e5f 100644 --- a/src/melodicstaff.cc +++ b/src/melodicstaff.cc @@ -38,7 +38,7 @@ Item * Melodic_staff::get_TYPESET_item(Command*com) { if (com->args[0] == "KEY") { - return new Keyitem(NO_LINES); // urgh. + return new Keyitem(NO_LINES); // urgh. depends on clef. } else return Simple_staff::get_TYPESET_item(com); } diff --git a/src/meter.cc b/src/meter.cc index 0afa8ea1a1..29375b8aba 100644 --- a/src/meter.cc +++ b/src/meter.cc @@ -9,12 +9,11 @@ Meter::Meter(svec a) :args(a) { } + void Meter::preprocess() -{ - Parametric_symbol *p = paper()->lookup_->meter("general"); - Symbol s = p->eval(args); - delete p; +{ + Symbol s = paper()->lookup_->meter(args); output = new Molecule(Atom(s)); } diff --git a/src/molecule.cc b/src/molecule.cc index e8c4d2adec..a664eeb74a 100644 --- a/src/molecule.cc +++ b/src/molecule.cc @@ -1,4 +1,6 @@ #include "glob.hh" +#include "vray.hh" +#include "interval.hh" #include "dimen.hh" #include "string.hh" #include "molecule.hh" @@ -38,6 +40,7 @@ Atom::TeXstring() const return substitute_args(s, a); } +/****************/ String Molecule::TeXstring() const diff --git a/src/notehead.cc b/src/notehead.cc index a103e69b3d..7abc0e6b8e 100644 --- a/src/notehead.cc +++ b/src/notehead.cc @@ -35,7 +35,7 @@ Notehead::brew_molecole() Paperdef *p = paper(); - Real dy = p->interline()/2; + Real dy = p->internote(); Symbol s = p->lookup_->ball(balltype); output = new Molecule(Atom(s)); diff --git a/src/paper.cc b/src/paper.cc index 2b98eef988..5f31611f8e 100644 --- a/src/paper.cc +++ b/src/paper.cc @@ -59,6 +59,12 @@ Paperdef::interline() const { return lookup_->ball(4).dim.y.length(); } + +Real +Paperdef::internote() const +{ + return lookup_->internote(); +} Real Paperdef::note_width()const { diff --git a/src/pcol.cc b/src/pcol.cc index 6e3092a0e3..41cf4fdb67 100644 --- a/src/pcol.cc +++ b/src/pcol.cc @@ -1,4 +1,5 @@ #include "pcol.hh" +#include "pscore.hh" #include "pstaff.hh" #include "debug.hh" @@ -44,24 +45,32 @@ PCol::width() const void PCol::print() const { - #ifndef NPRINT +#ifndef NPRINT mtor << "PCol {"; + if (pscore_) { // ugh + PCursor me=pscore_->find_col(this); + PCursor bot(pscore_->cols.top()); + if (me.ok()) { + mtor << "rank: " << me - bot << '\n'; + } + } mtor << "# symbols: " << its.size() ; if (breakable()){ - mtor << "pre,post: "; + mtor << "\npre,post: "; prebreak->print(); postbreak->print(); + } else if (daddy) { + mtor<<'\n' << ((this == daddy->prebreak) ? "prebreak" : "postbreak"); } mtor << "extent: " << width().min << ", " << width().max << "\n"; mtor << "}\n"; - #endif +#endif } int -PCol::compare(const PCol &, const PCol &) +PCol::compare(const PCol &c1, const PCol &c2) { - assert(false); - return 0 ; + return c1.pscore_->compare_pcols(&c1,&c2); } void @@ -71,8 +80,7 @@ PCol::OK () const assert(prebreak&&postbreak); assert(prebreak->daddy == this); assert(postbreak->daddy == this); - } - + } } void @@ -83,7 +91,10 @@ PCol::set_breakable() prebreak = new PCol(this); postbreak = new PCol(this); - used = true; + prebreak->pscore_ = pscore_; + postbreak->pscore_ = pscore_; + + } bool @@ -98,7 +109,8 @@ PCol::PCol(PCol *parent) prebreak=0; postbreak=0; line=0; - used = false; + + pscore_ = 0; } PCol::~PCol() @@ -112,5 +124,11 @@ PCol::add( Item *i) { its.bottom().add(i); i->pcol_ = this; - used = true; + +} + +bool +PCol::used()const +{ + return breakable() || its.size(); } diff --git a/src/pscore.cc b/src/pscore.cc index 663a14c783..ba1113aa1a 100644 --- a/src/pscore.cc +++ b/src/pscore.cc @@ -13,7 +13,7 @@ void PScore::clean_cols() { for (PCursor c(cols); c.ok(); ) - if (!c->used) { + if (!c->used()) { c.del(); } else c++; @@ -71,8 +71,7 @@ PScore::typeset_spanner(Spanner*sp, PStaff*ps) sp->pstaff_ = ps; spanners.bottom().add(sp); ps->spans.bottom().add(sp); - sp->left->starters.bottom().add(sp); - sp->right->stoppers.bottom().add(sp); + // do not init start/stop fields. These are for broken spans only. } @@ -83,7 +82,7 @@ PScore::add_line(svec curline, svec config) lines.bottom().add(p); for (int i=0; i < curline.sz(); i++){ PCol *c=(PCol *)curline[i]; // so, this isn't really const. - c->hpos= config[i]; + c->hpos = config[i]; } } @@ -104,6 +103,15 @@ PScore::get_spacing(PCol*l, PCol*r) } +int +PScore::compare_pcols(const PCol*a, const PCol*b)const +{ + PCursor ac(find_col(a)); + PCursor bc(find_col(b)); + assert(ac.ok() && bc.ok()); + return ac - bc; +} + /* return all breakable columns */ @@ -121,6 +129,11 @@ PScore::find_breaks() const void PScore::add(PCol *p) { + p->pscore_ = this; + if (p->breakable()){ + p->prebreak->pscore_ = this; + p->postbreak->pscore_ = this; + } cols.bottom().add(p); } @@ -196,10 +209,28 @@ PScore::preprocess() void PScore::postprocess() { - for (PCursor ic(spanners); ic.ok(); ic++) { + for (PCursor ic(broken_spans); ic.ok(); ic++) { ic->process(); } for (PCursor ic(its); ic.ok(); ic++){ ic->postprocess(); } } + +PCursor +PScore::find_col(const PCol *c)const +{ + PCursor cc(cols); + for (; cc.ok(); cc++) + if (cc.ptr() == c || cc->prebreak == c || cc->postbreak == c) + return cc; + return cc; +} + +void +PScore::add_broken(Spanner*s) +{ + broken_spans.bottom().add(s); + s->left->starters.bottom().add (s); + s->right->stoppers.bottom().add (s); +} diff --git a/src/sccol.cc b/src/sccol.cc index 417b967e1c..c29d26cf4a 100644 --- a/src/sccol.cc +++ b/src/sccol.cc @@ -10,7 +10,7 @@ Score_column::Score_column(Real w) bool Score_column::used() { - return pcol_->used; + return pcol_->used(); } void diff --git a/src/scommands.cc b/src/scommands.cc index 00830e4115..2787873adb 100644 --- a/src/scommands.cc +++ b/src/scommands.cc @@ -42,7 +42,7 @@ Score_commands::last_insertion(Real w) Command*c = new Command(w); c->priority = -10000; pc.add(c); - pc ++; + pc++; } return pc; @@ -120,9 +120,9 @@ void Score_commands::insert_between(Command victim, PCursor firstc, PCursor last) { - assert(last->when==firstc->when); PCursor c(firstc+1); - assert(last.ok()); + assert(last->when==firstc->when&&firstc < last&&last.ok()); + while (c < last) { if (c->priority <= victim.priority) { c.insert(new Command(victim)); diff --git a/src/score.cc b/src/score.cc index 6127196174..f421baaae6 100644 --- a/src/score.cc +++ b/src/score.cc @@ -75,7 +75,7 @@ Score::clean_cols() sc->clean_cols(); for (PCursor c(cols_); c.ok(); ) { - if (!c->pcol_->used) { + if (!c->pcol_->used()) { mtor << "removing : "; c->print(); c.del(); diff --git a/src/scoreline.cc b/src/scoreline.cc index 7e40c6a76a..03d0c8482f 100644 --- a/src/scoreline.cc +++ b/src/scoreline.cc @@ -23,16 +23,16 @@ Line_of_score::TeXstring() const Line_of_score::Line_of_score(svec sv, - const PScore *ps) + PScore *ps) { - score = ps; + pscore_ = ps; for (int i=0; i< sv.sz(); i++) { PCol *p=(PCol *) sv[i]; cols.bottom().add(p); p->line=this; } - for (PCursor sc(score->staffs); sc.ok(); sc++) + for (PCursor sc(pscore_->staffs); sc.ok(); sc++) staffs.bottom().add(new Line_of_staff(this, sc)); } /* construct a line with the named columns. Make the line field diff --git a/src/simplestaff.cc b/src/simplestaff.cc index 21cccabcb1..1afe0eed08 100644 --- a/src/simplestaff.cc +++ b/src/simplestaff.cc @@ -49,6 +49,9 @@ Simple_column::process_requests() if (rq->beam()) { beam_ = rq->beam(); } + if (rq->slur()) { + slurs.add(rq->slur()); + } } } diff --git a/src/simplewalker.cc b/src/simplewalker.cc index 710e486947..4918b5e6fa 100644 --- a/src/simplewalker.cc +++ b/src/simplewalker.cc @@ -12,6 +12,7 @@ #include "keyitem.hh" #include "clefitem.hh" #include "keyitem.hh" +#include "slur.hh" #include "localkeyitem.hh" void @@ -91,26 +92,30 @@ Simple_walker::do_local_key(Note_req*n) } void -Simple_walker::do_notes() +Simple_walker::do_note(Rhythmic_req*rq) { Simple_column*c = col(); Simple_staff *s = staff(); - for (int i = 0; i < c->notes.sz(); i ++) { - Rhythmic_req*rq = c->notes[i]; - if (rq->note()) { - Note_req * req = rq->note() ; - Notehead*n = s->get_notehead(req, clef_.c0_pos); - stem_->add(n); - noteheads.add(n); - - if (wantkey) - do_local_key(req); - } + + if (rq->note()) { + Note_req * req = rq->note() ; + const Voice *v = req->elt->voice_; - if (rq->rest()) { - c->typeset_item( s->get_rest(rq->rest()) ); + Notehead*n = s->get_notehead(req, clef_.c0_pos); + stem_->add(n); + noteheads.add(n); + int sidx =find_slur(v); + if (sidx >= 0) { + pending_slurs[sidx]->add(n); } - } + + if (wantkey) + do_local_key(req); + } + + if (rq->rest()) { + c->typeset_item( s->get_rest(rq->rest()) ); + } } void @@ -123,13 +128,25 @@ Simple_walker::process_requests() error("Too many beams"); beam_ = new Beam; } + for (int i=0; i < c->slurs.sz(); i++) { + Slur_req*sl = c->slurs[i]; + + if (sl->spantype == Span_req::START) { + if (find_slur(sl->elt->voice_ )>=0) + error("Too many slurs in voice"); + pending_slur_reqs.add(sl); + pending_slurs.add(new Slur); + } + } if (c->stem_) { stem_ = s->get_stem(c->stem_->stem()); } - do_notes(); - + for (int i = 0; i < c->notes.sz(); i ++) { + do_note(c->notes[i]); + } + if (beam_) { beam_->add(stem_); } @@ -147,7 +164,7 @@ Simple_walker::process_requests() c->typeset_item(noteheads[i]); } noteheads.set_size(0); - + if (local_key_item_) { c->typeset_item_directional(local_key_item_, -1); local_key_item_ = 0; @@ -155,6 +172,21 @@ Simple_walker::process_requests() if (stem_) { stem_ = 0; } + for (int i=0; i < c->slurs.sz(); i++) { + Slur_req*sl = c->slurs[i]; + + if (sl->spantype == Span_req::STOP) { + int idx = find_slur(sl->elt->voice_); + if (idx < 0) + error("can't find slur to end"); + + pscore_->typeset_spanner(pending_slurs[idx], + s->theline); + pending_slurs.del(idx); + pending_slur_reqs.del(idx); + } + } + } Simple_walker::Simple_walker(Simple_staff*s) @@ -191,3 +223,15 @@ Simple_walker::reset() processed_clef =false; processed_key = false; } + +int +Simple_walker::find_slur(const Voice *v) +{ + for (int i=0; i < pending_slur_reqs.sz(); i++) { + if (pending_slur_reqs[i]->elt->voice_ == v) + return i; + } + return -1; +} + + diff --git a/src/slur.cc b/src/slur.cc new file mode 100644 index 0000000000..171f3b04dd --- /dev/null +++ b/src/slur.cc @@ -0,0 +1,105 @@ +#include "slur.hh" +#include "lookup.hh" +#include "paper.hh" +#include "notehead.hh" +#include "pcol.hh" +#include "molecule.hh" +#include "debug.hh" +#include "boxes.hh" + +void +Slur::add(Notehead*n) +{ + encompass.add(n); + dir = 0; + open_right=open_left=false; +} + +Interval +Slur::height() const +{ + return Interval(0,0); // todo +} + +void +Slur::set_default_dir() +{ + int sumpos=0; + for (int i=0; i < encompass.sz(); i ++) { + sumpos += encompass[i]->position; + } + + /* should consult stems */ + Real meanpos = sumpos/Real(encompass.sz()); + if (meanpos < 5) // todo + dir = -1; + else + dir = 1; +} + +void +Slur::print()const +{ + mtor << "Slur.\n"; +} + +void +Slur::preprocess() +{ + right = encompass.last()->pcol_; + left = encompass[0]->pcol_; +} + +Spanner* +Slur::broken_at(const PCol*l, const PCol*r) const +{ + assert(l->line == r->line); + Slur*ret = new Slur(*this); + ret->encompass.set_size(0); + for (int i =0; i < encompass.sz(); i++) { + if (encompass[i]->pcol_->line==l->line) + ret->encompass.add(encompass[i]); + } + if (right != r) + ret->open_right = true; + if (left != l) + ret->open_left = true; + + ret->left = l; + ret->right = r; + return ret; +} + +void +Slur::process() +{ + set_default_dir(); + brew_molecule(); +} + +void +Slur::brew_molecule() +{ + output = new Molecule; + assert(left->line == right->line); + int minp=1000, maxp=-1000; // todo + for (int i=0; iposition, minp); + maxp = MAX(encompass[i]->position, maxp); + } + + assert(encompass.sz()>0); // todo + int pos1 = encompass.last()->position; + int pos2 = encompass[0]->position; + + int dy = pos1-pos2; + + Real w = width().length(); + Real nw = paper()->note_width(); + w -= nw; + Symbol sl = paper()->lookup_->slur(dy , w, dir); + Atom a(sl); + a.translate(Offset(nw,pos2*paper()->internote())); + output->add(a); +} + diff --git a/src/spanner.cc b/src/spanner.cc index 16c3ff19cb..d38a604302 100644 --- a/src/spanner.cc +++ b/src/spanner.cc @@ -33,7 +33,11 @@ Spanner::preprocess() Interval Spanner::width()const { - return Interval(0,right->hpos - left->hpos); + Real r =right->hpos, + l= left->hpos; + assert(r>=l); + + return Interval(0, r-l); } Paperdef* diff --git a/src/staffline.cc b/src/staffline.cc index c83e904bc6..f0f00f1a83 100644 --- a/src/staffline.cc +++ b/src/staffline.cc @@ -25,9 +25,10 @@ Line_of_staff::TeXstring() const // the staff itself: eg lines, accolades s += "\\hbox{"; { - Symbol sym = pstaff_->get_stafsym(scor->score->paper_->linewidth); + Symbol sym = pstaff_->get_stafsym(line_of_score_->pscore_-> // ugh + paper_->linewidth); s+=sym.tex; - PCursor cc(scor->cols); + PCursor cc(line_of_score_->cols); Real lastpos=cc->hpos; // all items in the current line & staff. @@ -57,22 +58,21 @@ Line_of_staff::TeXstring() const Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st) { - scor=sc; + line_of_score_=sc; pstaff_=st; -#if 0 + + const PCol *linestart = sc->cols.top(); const 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); -// if (*brokenstop < *brokenstart) - brokenspans.bottom().add(sp->broken_at(0,0)); - } -#endif - for (PCursor sp(pstaff_->spans); sp.ok(); sp++) { - - brokenspans.bottom().add(sp->broken_at(0,0)); + if ( *brokenstart < *brokenstop) { + line_of_score_->pscore_-> // higghl + add_broken(sp->broken_at(brokenstart,brokenstop)); + } } } @@ -82,10 +82,11 @@ Line_of_staff::height() const { Interval y; { - Symbol s = pstaff_->stafsym->eval(scor->score->paper_->linewidth); + Symbol s = pstaff_->stafsym->eval(line_of_score_->pscore_-> + paper_->linewidth); y = s.dim.y; } - PCursor cc(scor->cols); + PCursor cc(line_of_score_->cols); // all items in the current line & staff. for (; cc.ok(); cc++) { diff --git a/src/stem.cc b/src/stem.cc index fb8e410117..126cc30474 100644 --- a/src/stem.cc +++ b/src/stem.cc @@ -31,6 +31,7 @@ Stem::Stem(int c) void Stem::set_stemend(Real se) { + assert(!output); // todo: margins assert((dir > 0 && se >= maxnote) || (se <= minnote && dir <0)); @@ -126,13 +127,10 @@ Stem::brew_molecole() assert(!output); Paperdef *p =paper(); - Parametric_symbol *stem = p->lookup_->stem(); - - Real dy = p->interline()/2; - String y1 =print_dimen( dy * bot); - String y2 = print_dimen(dy * top); - Symbol ss =stem->eval(y1,y2); - delete stem; + + Real dy = p->internote(); + Symbol ss =p->lookup_->stem(bot*dy,top*dy); + output = new Molecule(Atom(ss)); diff --git a/src/symbol.cc b/src/symbol.cc index 907f1d7282..02723e19b0 100644 --- a/src/symbol.cc +++ b/src/symbol.cc @@ -1,4 +1,6 @@ #include "symbol.hh" +#include "vray.hh" +#include "textdb.hh" Symbol::Symbol() : dim(Interval(0,0),Interval(0,0)) diff --git a/src/symtable.cc b/src/symtable.cc index a28d14670c..39b6fdead0 100644 --- a/src/symtable.cc +++ b/src/symtable.cc @@ -1,4 +1,5 @@ #include "misc.hh" +#include "textdb.hh" #include "dimen.hh" #include "debug.hh" #include "real.hh" @@ -13,8 +14,10 @@ Symtable::lookup(String s) const if (elt_query(s)) return (*this)[s]; else { - error( "Unknown symbol " +s+'\n'); + error( "Unknown symbol `" +s+"'\n"); } + Symbol sy; // unreachable + return sy; } Symtable* @@ -27,7 +30,7 @@ void Symtables::read(Text_db &symini) { while (!symini.eof()) { - Text_record r( symini++); + Text_record r(symini++); if (r[0] == "end" ) return; assert (r[0] == "table"); @@ -55,6 +58,3 @@ Symtables::read(Text_db &symini) (*this)[tabnam] = sp; } } - - - diff --git a/src/template1.cc b/src/template1.cc index e2bae216b6..64834ea93e 100644 --- a/src/template1.cc +++ b/src/template1.cc @@ -8,9 +8,9 @@ #include "scoreline.hh" #include "staffline.hh" -#include "list.cc" + #include "plist.cc" -#include "cursor.cc" + #define IPLC_instantiate(a) IPL_instantiate(a); PL_instantiate(const a) diff --git a/src/template2.cc b/src/template2.cc index a4ce99da1f..23e6aae200 100644 --- a/src/template2.cc +++ b/src/template2.cc @@ -7,9 +7,8 @@ #include "stcol.hh" #include "spanner.hh" -#include "list.cc" #include "plist.cc" -#include "cursor.cc" + IPL_instantiate(Score_column); IPL_instantiate(Staff_column); diff --git a/src/template3.cc b/src/template3.cc index 0042594155..a457b6afbb 100644 --- a/src/template3.cc +++ b/src/template3.cc @@ -1,11 +1,10 @@ #include "request.hh" #include "command.hh" #include "molecule.hh" -#include "list.cc" #include "plist.cc" -#include "cursor.cc" + IPL_instantiate(Atom); IPL_instantiate(Command); IPL_instantiate(Request); -L_instantiate(void*); + diff --git a/src/template4.cc b/src/template4.cc new file mode 100644 index 0000000000..e409a9bd66 --- /dev/null +++ b/src/template4.cc @@ -0,0 +1,4 @@ +#include "list.cc" +#include "cursor.cc" + +L_instantiate(void *); diff --git a/src/tex.cc b/src/tex.cc index ae9dc1b5f3..60d487dfd1 100644 --- a/src/tex.cc +++ b/src/tex.cc @@ -2,6 +2,7 @@ #include "tex.hh" #include "symbol.hh" #include "const.hh" +#include "vray.hh" String vstrut(Real h) diff --git a/src/texslur.cc b/src/texslur.cc new file mode 100644 index 0000000000..413c21869d --- /dev/null +++ b/src/texslur.cc @@ -0,0 +1,187 @@ +#include "lookup.hh" +#include "molecule.hh" +#include +#include "dimen.hh" +#include "debug.hh" + +static +char direction_char(int y_sign) +{ + char c; + switch(y_sign){ + case -1: + c = 'd'; + break; + case 0: + c = 'h'; + break; + case 1: + c = 'u'; + break; + default: + assert(false); + } + return c; +} + +Symbol +Lookup::half_slur_middlepart(Real &dx, int dir) +{ + if (dx >= convert_dimen(400,"pt")) // todo + error ("halfslur too large"); + int widx = int(floor(dx / 4.0)); + dx = widx * 4.0; + widx --; + + Symbol s; + + s.dim.y = Interval(MIN(0,0), MAX(0,0)); + s.dim.x = Interval(0,dx); + + String f = String("\\hslurchar"); + f += direction_char(0); + + int idx = widx; + if (dir < 0) + idx += 128; + + + f+=String( "{" ) + idx + "}"; + s.tex = f; + Atom a(s); + a.translate(Offset(dx/2,0)); + s.tex = a.TeXstring(); + + return s; +} +Symbol +Lookup::half_slur(int dy, Real &dx, int dir, int xpart) +{ + if (!xpart) + return half_slur_middlepart(dx, dir); + + int widx; + + if (dx >= convert_dimen(96,"pt")) + dx = convert_dimen(96,"pt"); + + widx = int(rint(dx/12.0)); + dx = widx*12.0; + widx --; + + Symbol s; + s.dim.x = Interval(0,dx); + s.dim.y = Interval(MIN(0,dy), MAX(0,dy)); + + + String f = String("\\hslurchar"); + + f+= direction_char(dir); + + int hidx = dy; + if (hidx <0) + hidx = -hidx; + hidx --; + int idx =-1; + + + idx = widx * 16 + hidx; + if (xpart < 0) + idx += 128; + + f+=String( "{" ) + idx + "}"; + + + s.tex = f; + + return s; +} + +Symbol +Lookup::slur (int dy , Real &dx, int dir) +{ // ugh. assuming pt here. + assert(dx >=0); + int y_sign = sgn(dy); + + bool large = dy > 16; + + if (y_sign) { + large |= dx>= convert_dimen(4*16, "pt"); + } else + large |= dx>= convert_dimen(4*54, "pt"); + + if (large) { + return big_slur(dy, dx, dir); + } + + int widx = int(floor(dx/4.0)); // slurs better too small.. + dx = 4.0 * widx; + widx--; + int hidx = dy; + if (hidx <0) + hidx = -hidx; + hidx --; + if (hidx > 16) + error("slur to steep"); + + + Symbol s; + s.dim.x = Interval(0,dx); + s.dim.y = Interval(MIN(0,dy), MAX(0,dy)); + + String f = String("\\slurchar") + direction_char(y_sign); + + int idx=-1; + if (y_sign) { + idx = hidx * 16 + widx; + if (dir < 0) + idx += 128; + } else { + if (dx >= convert_dimen(4*54, "pt")) + error("slur too wide"); + idx = widx; + if (dir > 0) + idx += 54; + } + + f+=String( "{" ) + idx + "}"; + s.tex = f; + + Atom a(s); + a.translate(Offset(dx/2,0)); + s.dim = a.extent(); + s.tex = a.TeXstring(); + return s; +} + +Symbol +Lookup::big_slur(int dy , Real &dx, int dir) +{ + assert(dx >= convert_dimen(24,"pt")); + + Real slur_extra =ABS(dy) /2.0 + 2; + int l_dy = Real (dy)/2 + slur_extra*dir; + int r_dy = dy - l_dy; + + Real left_wid = dx/4.0; + Real right_wid = left_wid; + + Atom l = half_slur(l_dy, left_wid, dir, -1); + Atom r = half_slur(r_dy, right_wid, dir, 1); + Real mid_wid = dx - left_wid - right_wid; + Atom m = half_slur(0, mid_wid, dir, 0); + + Molecule mol; + mol.add(l); + Atom a(m); + a.translate(Offset(0,slur_extra * internote())); + mol.add_right(m); + mol.add_right(r); + mol.translate(Offset(l_dy * internote(), 0)); + Symbol s; + s.tex = mol.TeXstring(); + s.dim = mol.extent(); + return s; +} + + diff --git a/src/voice.cc b/src/voice.cc index c713822a4b..fbdb207aab 100644 --- a/src/voice.cc +++ b/src/voice.cc @@ -15,14 +15,14 @@ Voice::Voice() void Voice::add(Voice_element*v) { + v->voice_ = this; elts.bottom().add(v); } void Voice::print() const { - #ifndef NPRINT - +#ifndef NPRINT mtor << "start: "<< start< vec(elts); vec.ok(); vec++) vec->print(); @@ -63,7 +63,7 @@ Voice_element::add(Request*r) Voice_element::Voice_element() { - voice = 0; + voice_ = 0; group = 0; duration = 0.0; } @@ -71,7 +71,7 @@ Voice_element::Voice_element() Voice_element::Voice_element(Voice_element const&src) { duration=src.duration; - voice=src.voice; + voice_=src.voice_; IPointerList__copy(Request*, reqs, src.reqs, clone()); group=src.group; assert(!granted_items.size() && !granted_spanners.size()); diff --git a/src/warn.cc b/src/warn.cc index 426173ee0c..6d35d8cad6 100644 --- a/src/warn.cc +++ b/src/warn.cc @@ -4,15 +4,17 @@ -void warning(String s) +void +warning(String s) { WARN << s; } -void error(String s) +void +error(String s) { - cerr << "\n" << s << "\nexiting..\n"; + cerr << "\nerror: " << s << "\n"; exit(1); } diff --git a/symbol.ini b/symbol.ini index ccebe42afd..4dc2753347 100644 --- a/symbol.ini +++ b/symbol.ini @@ -19,6 +19,10 @@ table balls 4 \quartball 0pt 6pt -2.5pt 2.5pt end +table slur + whole \slurchar%{%} 0pt 0pt 0pt 0pt + half \hslurchar%{%} 0pt 0pt 0pt 0pt +end table accidentals -2 \flatflat 0pt 10.2pt -2.5pt 7.5pt -1 \flat 0pt 6pt -2.5pt 7.5pt -- 2.39.2