diff options
59 files changed, 978 insertions, 357 deletions
diff --git a/.dstreamrc b/.dstreamrc index 64944330bc..a449d3f574 100644 --- a/.dstreamrc +++ b/.dstreamrc @@ -17,8 +17,9 @@ Note_req 1 Rhythmic_req 1 Rest_req 1 delete_identifiers 1 -Command 0 +Command 1 Staff_commands 0 +Stem 0 Staff 0 Score 0 Voice 0 diff --git a/Documentation/Makefile b/Documentation/Makefile index ea2f12ed55..577debd174 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -1,6 +1,6 @@ DOCFILES=commands CodingStyle algorithms Makefile breaking\ - slurfont pointers design + slurfont pointers design literature dist: ln $(DOCFILES) $(DDIR)/Documentation/
\ No newline at end of file diff --git a/Documentation/literature b/Documentation/literature new file mode 100644 index 0000000000..0085806013 --- /dev/null +++ b/Documentation/literature @@ -0,0 +1,76 @@ +\chapter{References \& Further reading} + +Herbert Chlapik, + +Ren\'e Roelofs, ``Een Geautomatiseerd Systeem voor het Afdrukken van +Muziek'' afstudeerscriptie Bestuurlijke informatica, no 45327, Erasmus +universiteit Rotterdam, 1991. (``An automated system for printing +music'' Master's Thesis Management and Computer Science.) + +G. Read, ``Modern Rhythmic Notation.'' Indiana University Press, 1978. + +C. Roemer, The Art of Music Copying. Roerick music co., Sherman Oaks (CA), 1973. + +Donemus, Uitgeven van muziek. Donemus Amsterdam, 1900 + +W.A. Hegazy and J. S. Gourlay. Optimal line breaking in music. In +``Document Manipulation and Typography'',J.C. van Vliet (ed) 1988. + +\begin{verbatim} +Date: Thu, 03 Aug 1995 22:55:48 -0700 +From: Mark Basinski <basinski@arizona.edu> +To: Han-Wen Nienhuys <hanwen@stack.urc.tue.nl> +Newsgroups: comp.music, comp.text.tex +Subject: Re: [WANTED] references on typesetting music + +(A copy of this message has also been posted to the following newsgroups: +comp.music, comp.text.tex) + +In article <3vqr50$den@turtle.stack.urc.tue.nl>, hanwen@stack.urc.tue.nl +(Han-Wen Nienhuys) wrote: + +> I am currently typesetting music with a preprocessor to the TeX package +> MusiXTeX, and I want to enhance this preprocessor with an some sort of +> algorithm to do spacing. Currently the output looks nice, but there are some +> flaws in the spacing when I combine accidentals, slurs, triplets and strange +> pitchjumps and so on. Therefore I am interested in all literature on +> typesetting music. The FAQS for comp.music did not have any references. +> +Probably the best 2 reference books are: + +1) ``Teach yourself the art of music engraving and processing'' by Ted Ross +(3rd edition), published by Hansen House, Miami Beach, FL. + +Hansen House +1820 West Ave. +Miami, FL 33139 +(305) 532-5461 + +This is about *engraving* i.e. professional music typesetting, and includes +some good spacing tables + +2) ``Music Notation'' by Gardner Read (2nd edition), published by Taplinger +Publishing, New York. + +This is as close to the ``standard'' reference work for music notation issues +as one is likely to get. + +Some others (of varying usefulness): + +Donato, Anthony. Preparing Music Manuscript. Englewood Cliffs: +Prentice-Hall, 1963. + +Heussenstamm, George. The Norton Manual of Music Notation. New York: +Norton, 1987. + +Karkoshka, Erdhard. Notation in New Music. Trans. Ruth Koenig. New York: +Praeger Publishers, 1972. Out of print. + +Roemer, Clinton. The Art of Music Copying. Roerick Music. Sherman Oaks, 1973. + +Rosecrans, Glen. Music Notation Primer. New York: Passantino, 1979. + +Stone, Kurt. Music Notation in the Twentieth Century. New York: Norton, 1980. + +\end{verbatim} + @@ -4,8 +4,8 @@ $(exe): $(obs) $(CXX) -o $@ $^ $(LOADLIBES) clean: - $(MAKE) -C objects clean - rm -f $(exe) *.o $(DOCDIR)/* core +# $(MAKE) -C objects clean + rm -f $(exe) objects/*.o $(DOCDIR)/* core distclean: clean rm -f depend version.hh $(gencc) .GENERATE *~ @@ -37,9 +37,18 @@ realdepend: $(cc) include depend +parsheadorig=$(CCDIR)/parser.tab.h +parsheadnew=$(HEADERDIR)/parser.hh + +# +# take some trouble to avoid overwriting the old y.tab.h $(CCDIR)/parser.cc: parser.y $(BISON) -d $< - mv $(CCDIR)/parser.tab.h $(HEADERDIR)/parser.hh + (if diff -q $(parsheadorig) $(parsheadnew); then \ + echo leaving $(parsheadnew); \ + else \ + mv $(parsheadorig) $(parsheadnew); \ + fi ) mv $(CCDIR)/parser.tab.c $@ parser.hh: parser.cc diff --git a/Sources.make b/Sources.make index 7aa12eb13b..7a648e169b 100644 --- a/Sources.make +++ b/Sources.make @@ -17,7 +17,7 @@ hdr= qlp.hh linespace.hh qlpsolve.hh\ clef.hh clefitem.hh slur.hh inputcommands.hh\ getcommand.hh inputmusic.hh \ inputscore.hh inputstaff.hh identparent.hh\ - inputcommand.hh + inputcommand.hh grouping.hh mycc= qlp.cc qlpsolve.cc leastsquares.cc\ inputcommands.cc inputmusic.cc inputcursor.cc\ @@ -32,13 +32,14 @@ mycc= qlp.cc qlpsolve.cc leastsquares.cc\ calcideal.cc scores.cc \ dimen.cc paper.cc lookup.cc staffcommands.cc\ sccol.cc stcol.cc getcommands.cc simplestaff.cc\ - melodicstaff.cc simpleprint.cc stem.cc\ - spanner.cc notehead.cc \ - rest.cc swalker.cc scoreline.cc\ - simplewalker.cc bar.cc meter.cc accidental.cc\ - keyitem.cc localkeyitem.cc\ - clefitem.cc texbeam.cc texslur.cc clef.cc key.cc slur.cc beam.cc\ - idealspacing.cc inputcommand.cc\ + melodicstaff.cc simpleprint.cc\ + spanner.cc \ + notehead.cc stem.cc \ + rest.cc bar.cc meter.cc keyitem.cc localkeyitem.cc clefitem.cc\ + swalker.cc scoreline.cc\ + simplewalker.cc\ + texbeam.cc texslur.cc clef.cc key.cc slur.cc beam.cc\ + idealspacing.cc inputcommand.cc grouping.cc\ template1.cc template2.cc template3.cc template4.cc\ version.cc diff --git a/Variables.make b/Variables.make index 886a59aa4b..34bfb9fb6f 100644 --- a/Variables.make +++ b/Variables.make @@ -2,12 +2,9 @@ #### USER CONFIGURABLE #### -# speedy -#DEFINES=-DNDEBUG -DNPRINT -O2 - -# lots of debugging info -DEFINES=-g - +#PROFILEFLAG=-pg +OPTIFLAG=-DNDEBUG -DNPRINT -O2 +DEBUGFLAG=-g # turn off -pipe if linker doesn't support it EXTRACXXFLAGS=-pipe -Wall -W -pedantic @@ -15,10 +12,23 @@ EXTRACXXFLAGS=-pipe -Wall -W -pedantic #### EN USER CONFIGURABLE part. #### +ifdef PROFILEFLAG + DEFINES+=$(OPTIFLAG) $(PROFILEFLAG) + EXTRALIB+=-pg +endif + +ifndef DEBUGFLAG + DEFINES+=$(OPTIFLAG) +else + DEFINES+=$(DEBUGFLAG) +endif + + + # version info MAJVER=0 MINVER=0 -PATCHLEVEL=14 +PATCHLEVEL=15 VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) # directories @@ -59,7 +69,7 @@ OFILES=Makefile Variables.make Sources.make COPYING README DFILES=$(OFILES) $(IFILES) $(SCRIPTS) #compiling -LOADLIBES=-L$(FLOWERDIR) -lflower +LOADLIBES=-L$(FLOWERDIR) -lflower $(EXTRALIB) FLOWERDIR=../flower CXXFLAGS=$(DEFINES) -I$(HEADERDIR) -I$(FLOWERDIR) $(EXTRACXXFLAGS) @@ -1,4 +1,4 @@ -\font\musicfnt=musix20 +\font\musicfnt=musix16 \font\slurfont=xslhu20 \def\thefont{\musicfnt} diff --git a/flower/Variables.make b/flower/Variables.make index e0f94d6555..83a740ac4a 100644 --- a/flower/Variables.make +++ b/flower/Variables.make @@ -1,13 +1,13 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=14 +PATCHLEVEL=15 PACKAGENAME=flower VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) DNAME=$(PACKAGENAME)-$(VERSION) DEFINES=-DNDEBUG -O2 #DEFINES=-g -CXXFLAGS+=$(DEFINES) -Wall -W -pedantic +CXXFLAGS+=$(DEFINES) -Wall -W CXXVER=$(CXX) --version include Sources.make diff --git a/flower/compare.hh b/flower/compare.hh index df278a2bfb..40bc9d2951 100644 --- a/flower/compare.hh +++ b/flower/compare.hh @@ -19,7 +19,8 @@ operator op(type t1, type t2)\ return (t1 opp t2) ? t1 : t2;\ }\ -#ifdef __GNUC__ + +#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) #define gpp_minmax(type, prefix)\ prefix gpp_minmax_operator(type, <?, <)\ prefix gpp_minmax_operator(type, >?, >) diff --git a/flower/cursor.hh b/flower/cursor.hh index 6d40bb270d..428a52748f 100644 --- a/flower/cursor.hh +++ b/flower/cursor.hh @@ -84,7 +84,7 @@ class Cursor /// access the list this came from List<T>& list() const ; Link<T>* pointer(); - + static int compare(Cursor<T> a,Cursor<T>b) { return a-b; } private: List<T>& list_; Link<T>* pointer_; @@ -104,13 +104,8 @@ private: */ #include "compare.hh" -template<class T> -inline int cursor_compare(Cursor<T> a,Cursor<T>b) -{ - return a-b; -} -template_instantiate_compare(Cursor<T>, cursor_compare, template<class T>); +template_instantiate_compare(Cursor<T>, Cursor<T>::compare, template<class T>); #include "pcursor.hh" #include "list.hh" diff --git a/flower/interval.cc b/flower/interval.cc index 6cc2a7916e..6fac1f55dc 100644 --- a/flower/interval.cc +++ b/flower/interval.cc @@ -31,6 +31,29 @@ Interval::intersect(Interval h) min = MAX(h.min, min); max = MIN(h.max, max); } +Interval +intersection(Interval a, Interval const&b) +{ + a.intersect(b); + return a; + +} +int +Interval::compare(const Interval&a,Interval const&b) +{ + if (a.min == b.min && a.max == b.max) + return 0; + + if (a.min <= b.min && a.max >= b.max) + return 1; + + if (a.min >= b.min && a.max <= b.max) + return -1; + + assert(false); // not comparable + + return 0; +} Interval intersect(Interval x, Interval const &y) @@ -48,3 +71,8 @@ Interval::operator String() const return s + min + "," + max +"]"; } +bool +Interval::elt_q(Real r) +{ + return r >= min && r <= max; +} diff --git a/flower/interval.hh b/flower/interval.hh index 6f9fa63f67..a7a269153b 100644 --- a/flower/interval.hh +++ b/flower/interval.hh @@ -48,13 +48,23 @@ struct Interval { max +=r; return *this; } - + bool elt_q(Real r); operator String() const; -}; + /// partial ordering + static compare(const Interval&,Interval const&); +}; +/** + this represents the closed interval [min,max] + */ Interval intersection(Interval, Interval const&); +#include "compare.hh" + +instantiate_compare(Interval&, Interval::compare); + #endif // INTERVAL_HH + diff --git a/flower/pcursor.hh b/flower/pcursor.hh index c9cc53411f..eeaa866ea8 100644 --- a/flower/pcursor.hh +++ b/flower/pcursor.hh @@ -11,21 +11,21 @@ /// cursor to go with PointerList template<class T> -struct PCursor : public Cursor<void *> { - - /// make cursor with #no# items back - PCursor<T> operator -( int no) const { - return PCursor<T> (Cursor<void*>::operator-(no)); - } - int operator -(PCursor<T> op) const { - return Cursor<void*>::operator-(op); - } - /// make cursor with #no# items further - PCursor<T> operator +( int no) const { - return PCursor<T> (Cursor<void*>::operator+(no)); - } +struct PCursor : private Cursor<void *> { + friend class IPointerList<T>; +public: + Cursor<void*>::ok; + Cursor<void*>::del; + Cursor<void*>::backspace; - PCursor(const PointerList<T> & l) : Cursor<void*> (l) {} + PointerList<T> &list() { return (PointerList<T>&)Cursor<void*>::list(); } + PCursor<T> operator++(int) { return Cursor<void*>::operator++(0);} + PCursor<T> operator--(int) { return Cursor<void*>::operator--(0); } + PCursor<T> operator+=(int i) { return Cursor<void*>::operator+=(i);} + PCursor<T> operator-=(int i) { return Cursor<void*>::operator-=(i); } + PCursor<T> operator -(int no) const { return Cursor<void*>::operator-(no);} + int operator -(PCursor<T> op) const { return Cursor<void*>::operator-(op);} + PCursor<T> operator +( int no) const {return Cursor<void*>::operator+(no);} PCursor(const PointerList<T> & l) : Cursor<void*> (l) {} PCursor( const Cursor<void*>& cursor ) : Cursor<void*>(cursor) { } void* vptr() const { return * ((Cursor<void*> &) *this); } @@ -36,11 +36,10 @@ struct PCursor : public Cursor<void *> { operator T() { return ptr(); } T operator *() { return ptr(); } void add(const T& p ) { Cursor<void*>::add((void*) p); } - void insert(const T& p ) { Cursor<void*>::insert((void*) p);} - -private: -// Cursor<void*>::operator void*; - // sigh + void insert(const T& p ) { Cursor<void*>::insert((void*) p);} + static int compare(PCursor<T> a,PCursor<T>b) { + return Cursor<void*>::compare(a,b); + } }; /** don't create PointerList<void*>'s. @@ -49,13 +48,8 @@ private: */ -template<class T> -inline int pcursor_compare(PCursor<T> a,PCursor<T>b) -{ - return cursor_compare(Cursor<void*>(a),Cursor<void*> (b)); -} #include "compare.hh" -template_instantiate_compare(PCursor<T>, pcursor_compare, template<class T>); +template_instantiate_compare(PCursor<T>, PCursor<T>::compare, template<class T>); #endif diff --git a/flower/real.hh b/flower/real.hh index 1f2187c8c1..68e90f9b71 100644 --- a/flower/real.hh +++ b/flower/real.hh @@ -21,5 +21,9 @@ int sgn(Real x) { if (!x)return 0; return (x > 0) ?1: -1; } - +inline Real +distance(Real x,Real y) +{ + return ABS(x-y); +} #endif diff --git a/flower/vray.hh b/flower/vray.hh index 302499b256..180008c4c6 100644 --- a/flower/vray.hh +++ b/flower/vray.hh @@ -105,13 +105,16 @@ public: T& last(int j=0) { return (*this)[size-j-1]; } + T last(int j=0) const { + return (*this)[size-j-1]; + } void swap (int i,int j) { T t((*this)[i]); (*this)[i]=(*this)[j]; (*this)[j]=t; } bool empty() { return !size; } - void insert(T&k, int j) { + void insert(T k, int j) { assert(j >=0 && j<= size); set_size(size+1); for (int i=size-1; i > j; i--) diff --git a/hdr/beam.hh b/hdr/beam.hh index 138175d8ec..be2cb8f94c 100644 --- a/hdr/beam.hh +++ b/hdr/beam.hh @@ -34,6 +34,7 @@ struct Beam: public Spanner { void set_stemlens(); private: + Molecule stem_beams(Stem *here, Stem *next, Stem *prev); void solve_slope(); void brew_molecule(); }; diff --git a/hdr/grouping.hh b/hdr/grouping.hh new file mode 100644 index 0000000000..a6e93bf840 --- /dev/null +++ b/hdr/grouping.hh @@ -0,0 +1,33 @@ +/* + grouping.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef GROUPING_HH +#define GROUPING_HH + +#include "interval.hh" +#include "vray.hh" + +struct Rhythmic_grouping { + Interval t; + + svec<Rhythmic_grouping*> children; + /****************/ + + void split_half(); + Real last(); + Rhythmic_grouping* sub_grouping(Interval v); + void split_grouping(Rhythmic_grouping &initial_grouping); + void split_grouping(svec<Real> initial_grouping); + svec<Real> get_bounds(); + Rhythmic_grouping(Interval); + Rhythmic_grouping(svec<Interval> notes, + svec<Real> initial_grouping); + + void print() const; + ~Rhythmic_grouping(); +}; + +#endif // GROUPING_HH diff --git a/hdr/identifier.hh b/hdr/identifier.hh index c5d7a5b5b7..3ac537f63e 100644 --- a/hdr/identifier.hh +++ b/hdr/identifier.hh @@ -8,17 +8,24 @@ #ifndef IDENTIFIER_HH #define IDENTIFIER_HH #include "identparent.hh" +#include "symtable.hh" #include "inputstaff.hh" #include "inputmusic.hh" #define make_id_class(Idclass, Class, accessor) \ struct Idclass : Identifier {\ Idclass(String s, Class*st):Identifier(s) { data = st; }\ - virtual Class* accessor() { return (Class*) data; }\ + virtual Class* accessor(bool copy=false) {\ + if (copy)\ + return new Class(* (Class*) data);\ + else\ + return (Class*) data;\ + }\ ~Idclass() { delete accessor(); }\ }\ - +make_id_class(Lookup_id, Lookup, lookup); +make_id_class(Symtables_id, Symtables, symtables); make_id_class(Staff_id, Input_staff, staff); make_id_class(M_chord_id, Music_general_chord, mchord); make_id_class(M_voice_id, Music_voice, mvoice); diff --git a/hdr/identparent.hh b/hdr/identparent.hh index d8d3cb1735..dafeed96fa 100644 --- a/hdr/identparent.hh +++ b/hdr/identparent.hh @@ -17,12 +17,14 @@ struct Identifier Identifier(String n) : name(n) { } virtual ~Identifier() {} - virtual Input_staff * staff() { assert(false); } - virtual Voice_list * voices() { assert(false); } - virtual Horizontal_music*hmusic() { assert(false); } - virtual Vertical_music*vmusic() { assert(false); } - virtual Music_voice *mvoice() { assert(false); } - virtual Music_general_chord *mchord() { assert(false); } + + virtual Input_staff * staff(bool = false) { assert(false); } + virtual Horizontal_music*hmusic(bool = false) { assert(false); } + virtual Vertical_music*vmusic(bool = false) { assert(false); } + virtual Music_voice *mvoice(bool = false) { assert(false); } + virtual Symtables *symtables(bool = false) { assert(false); } + virtual Music_general_chord *mchord(bool = false) { assert(false); } + virtual Lookup*lookup(bool = false) { assert(false); } }; #endif // IDENTPARENT_HH diff --git a/hdr/inputcommand.hh b/hdr/inputcommand.hh index aeec3b8ad3..21aeaeacb4 100644 --- a/hdr/inputcommand.hh +++ b/hdr/inputcommand.hh @@ -10,7 +10,6 @@ #include "scalar.hh" #include "vray.hh" - struct Input_command { Real when; @@ -28,6 +27,7 @@ Input_command* get_clef_interpret_command(String w); Input_command *get_reset_command(); Input_command *get_partial_command(Real u); Input_command* get_skip_command( int,Real); +Input_command* get_grouping_command( svec<int>); void interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat, diff --git a/hdr/lookup.hh b/hdr/lookup.hh index 90a27fd60f..7e59dac0fa 100644 --- a/hdr/lookup.hh +++ b/hdr/lookup.hh @@ -10,10 +10,12 @@ struct Lookup { Symtables *symtables_; - + String texsetting; /****************/ + void add(String, Symtable*); + Real internote(); - void parse (Text_db&t); + Symbol linestaff(int n, Real w); Symbol beam_element(int,int,Real=0); @@ -44,6 +46,7 @@ struct Lookup { Lookup(); + Lookup(Lookup const &); ~Lookup(); }; diff --git a/hdr/melodicstaff.hh b/hdr/melodicstaff.hh index 733eae3fef..45785e4c02 100644 --- a/hdr/melodicstaff.hh +++ b/hdr/melodicstaff.hh @@ -19,7 +19,7 @@ struct Melodic_staff : public Simple_staff virtual void set_output(PScore *); virtual Item* get_TYPESET_item(Command*); - virtual Stem * get_stem(Stem_req *rq); + virtual Stem * get_stem(Stem_req *rq,Real); virtual Notehead * get_notehead(Note_req *rq, int bot); virtual Local_key_item* get_local_key_item(); }; diff --git a/hdr/misc.hh b/hdr/misc.hh index 64c8ca4102..763ebbc250 100644 --- a/hdr/misc.hh +++ b/hdr/misc.hh @@ -2,6 +2,13 @@ #define MISC_HH +double log2(double x) ; +int intlog2(int d); +inline int +ABS(int i) +{ + return (i < 0)?-i:i; +} #endif diff --git a/hdr/paper.hh b/hdr/paper.hh index b2ba370b57..b03d1f7621 100644 --- a/hdr/paper.hh +++ b/hdr/paper.hh @@ -6,6 +6,7 @@ struct Paperdef { Lookup *lookup_; String outfile; + Real linewidth; /// how much space does a whole note take (ideally?) @@ -15,8 +16,9 @@ struct Paperdef { Real geometric_; /****************/ - void parse(); - Paperdef(); + void reinit(); + Paperdef(Lookup*); + void set(Lookup*); ~Paperdef(); Real interline()const; Real internote()const; diff --git a/hdr/rhythmstaff.hh b/hdr/rhythmstaff.hh index 2c099afa0b..8591e3c1a0 100644 --- a/hdr/rhythmstaff.hh +++ b/hdr/rhythmstaff.hh @@ -16,7 +16,7 @@ struct Rhythmic_staff : public Simple_staff /****************/ virtual Item *get_TYPESET_item(Command*); - virtual Stem *get_stem(Stem_req *rq); + virtual Stem *get_stem(Stem_req *rq,Real); virtual Notehead * get_notehead(Note_req *rq, int b); virtual void set_output(PScore *); }; diff --git a/hdr/simplestaff.hh b/hdr/simplestaff.hh index 07fc985047..faf1002d53 100644 --- a/hdr/simplestaff.hh +++ b/hdr/simplestaff.hh @@ -24,6 +24,7 @@ struct Simple_column : Staff_column { svec<Rhythmic_req *> notes; svec<Slur_req *> slurs; Stem_req *stem_; + Real stem_requester_len; Beam_req *beam_; Simple_staff* staff_; @@ -51,7 +52,7 @@ struct Simple_staff : Staff { Staff_column*create_col(Score_column*); virtual Item *get_TYPESET_item(Command*); - virtual Stem *get_stem(Stem_req *rq)=0; + virtual Stem *get_stem(Stem_req *rq, Real)=0; virtual Notehead *get_notehead(Note_req *rq, int b)=0; virtual Rest *get_rest(Rest_req *rq); virtual void set_output(PScore *); diff --git a/hdr/stem.hh b/hdr/stem.hh index adce936320..372011d1b1 100644 --- a/hdr/stem.hh +++ b/hdr/stem.hh @@ -10,12 +10,17 @@ /// the rule attached to the ball struct Stem : public Item { + Real note_length; + // heads the stem encompasses (positions) int minnote, maxnote; /// false if in beam bool print_flag; + int beams_left; + int beams_right; + /// needed for determining direction/length int staff_center; @@ -26,7 +31,8 @@ struct Stem : public Item { */ Real stemlen; - // flagtype? 4 none, 8 8th flag, 0 = beam. + + /// flagtype? 4 none, 8 8th flag, 0 = beam. int flag; ///geen gedonder, jij gaat onder @@ -41,14 +47,15 @@ struct Stem : public Item { /// ensure that this Stem also encompasses the Notehead #n# void add(Notehead*n); Real hpos()const; + void print() const; void set_stemend(Real); void set_default_dir(); void set_default_stemlen(); void set_default_extents(); void postprocess(); void preprocess(); - Stem(int center); - void print() const; + Stem(int center, Real duration); + Interval width() const; private: diff --git a/hdr/symbol.hh b/hdr/symbol.hh index 3c664dfbaa..62de3be496 100644 --- a/hdr/symbol.hh +++ b/hdr/symbol.hh @@ -1,5 +1,6 @@ #ifndef SYMBOL_HH #define SYMBOL_HH + #include "string.hh" #include "boxes.hh" #include "proto.hh" diff --git a/hdr/symtable.hh b/hdr/symtable.hh index a1443a7d3b..b4217c12b8 100644 --- a/hdr/symtable.hh +++ b/hdr/symtable.hh @@ -9,13 +9,17 @@ struct Symtable : public Assoc<String, Symbol> { Symbol lookup(String)const; + }; struct Symtables : private Assoc<String, Symtable*> { - void read(Text_db&) ; + Symtable* operator()(String s); - + ~Symtables(); + Symtables(); + Symtables(Symtables const&); + Assoc<String, Symtable*>::add; }; diff --git a/lilyponddefs.tex b/lilyponddefs.tex index 152d461d64..fe056efa23 100644 --- a/lilyponddefs.tex +++ b/lilyponddefs.tex @@ -4,8 +4,8 @@ \def\mdef#1#2{\def#1{{\musicfnt\char#2}}} %% musix defs - \parindent=0pt - \newdimen\interlinedist +\parindent=0pt +\newdimen\interlinedist \newcount\n \newdimen\balkhoog \newdimen\staffrulethickness @@ -21,6 +21,21 @@ \font\musicfnt=musix20 \balkhoog=20pt \staffrulethickness=0.4pt + + \musixcalc +} +\def\musixsixteendefs{ + \font\slurufont=xslu16 + \font\slurdfont=xsld16 + \font\slurhfont=xslz20 % sigh + \font\hslurufont=xslhu16 + \font\hslurdfont=xslhd16 + \font\hslurhfont=xslhz20 + \font\musicfnt=musix16 + \balkhoog=16pt + \staffrulethickness=0.4pt + + \musixcalc } \def\musixcalc{ @@ -31,8 +46,6 @@ } -\musixtwentydefs -\musixcalc \def\slurcharh#1{{\slurhfont\char#1}} \def\slurcharu#1{{\slurufont\char#1}} \def\slurchard#1{{\slurdfont\char#1}} @@ -87,8 +100,6 @@ \def\interstaffline{% \vskip 10pt -% \nointerlineskip -% \vbox{\hbox to 0pt{\vrule width20pt height1pt\hss}} } \def\ugly{\nointerlineskip\par \vskip 40pt\par\vbox{\hbox to 0pt{\vrule width30pt height1pt\hss}}\par\vskip 40pt diff --git a/maartje.ly b/maartje.ly index 5178885f0f..d580b626ec 100644 --- a/maartje.ly +++ b/maartje.ly @@ -5,7 +5,16 @@ ritme = staff {rhythmic 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 $} + c2 r32 r32 r16 r8 r4 + [c8. c16] + [c16 c8.] + [c16 c16 c8] + [c16 c8 c16] + + c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 + + + $} } melody= @@ -29,6 +38,8 @@ staff { melodic ''fis2 a8 b8 'c8 'd8 ''c8 ```c8 c4 c4 c4 c4 \duration{ 16 } `b `a `g `f \duration{ 4} + + c `b `a `g `f `e `d `c ``b ``a ``g ``f ``e ``d ``c $} @@ -47,6 +58,7 @@ score { paper { geometric 1.4 unitspace 3.0 cm +% symboltables { table_sixteen} } staff { ritme } staff { melody } diff --git a/objects/Makefile b/objects/Makefile deleted file mode 100644 index 585e1df181..0000000000 --- a/objects/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -dist: - ln Makefile $(DDIR)/objects/ - -clean: - rm -f *.o @@ -49,6 +49,7 @@ score { horn } paper { + symboltables { table_sixteen} unitspace 1.5 cm geometric 1.4 } diff --git a/src/accidental.cc b/src/accidental.cc deleted file mode 100644 index eb3ca7c7e3..0000000000 --- a/src/accidental.cc +++ /dev/null @@ -1,32 +0,0 @@ -#include "accidental.hh" -#include "debug.hh" -#include "molecule.hh" -#include "paper.hh" -#include "lookup.hh" - -Accidental::Accidental(int t, int p) -{ - type = t; - pos = p; -} - -void -Accidental::preprocess() -{ - brew_molecole(); -} - -void -Accidental::brew_molecole() -{ - Symbol s =paper()->lookup_->accidental(type); - output = new Molecule(Atom(s)); - output->translate(Offset(0, pos * paper()->interline()/2)); -} - -void -Accidental::print()const -{ - mtor << "Accidental "<<type; - Item::print(); -} diff --git a/src/beam.cc b/src/beam.cc index af61c10ad2..6c7e6599cf 100644 --- a/src/beam.cc +++ b/src/beam.cc @@ -1,4 +1,5 @@ #include "beam.hh" +#include "misc.hh" #include "debug.hh" #include "symbol.hh" #include "molecule.hh" @@ -61,6 +62,7 @@ Beam::set_default_dir() sc->dir = dir; } } + /* should use minimum energy formulation (cf linespacing) */ @@ -116,10 +118,18 @@ Beam::calculate() solve_slope(); } + void Beam::process() { calculate(); + + for (PCursor<Stem*> i(stems); i.ok(); i++) + i->beams_left = i->beams_right = intlog2(ABS(i->flag)) - 2; + + stems.top()->beams_left = 0; + stems.bottom()->beams_right = 0; + brew_molecule(); set_stemlens(); } @@ -152,6 +162,61 @@ Beam::width() const return Interval( (*me->stems.top()) ->hpos(), (*me->stems.bottom()) ->hpos() ); } +/* + beams to go with one stem. + */ +Molecule +Beam::stem_beams(Stem *here, Stem *next, Stem *prev) +{ + assert( !next || next->hpos() > here->hpos() ); + assert( !prev || prev->hpos() < here->hpos() ); + Real dy=paper()->internote()*2; + Real stemdx = paper()->rule_thickness(); + Real sl = slope*paper()->internote(); + Molecule leftbeams; + Molecule rightbeams; + + /* half beams extending to the left. */ + if (prev) { + int lhalfs= lhalfs = here->beams_left - prev->beams_right ; + int lwholebeams= here->beams_left <? prev->beams_right ; + Real w = (here->hpos() - prev->hpos())/4; + Atom a = paper()->lookup_->beam(sl, w); + a.translate(Offset (-w, -w * sl)); + for (int j = 0; j < lhalfs; j++) { + Atom b(a); + b.translate(Offset(0, -dir * dy * (lwholebeams+j))); + leftbeams.add( b ); + } + } + + if (next){ + int rhalfs = here->beams_right - next->beams_left; + int rwholebeams = here->beams_right <? next->beams_left; // g++ + + Real w = next->hpos() - here->hpos(); + Atom a = paper()->lookup_->beam(sl, w + stemdx); + + int j = 0; + for (; j < rwholebeams; j++) { + Atom b(a); + b.translate(Offset(0, -dir * dy * j)); + rightbeams.add( b ); + } + w /= 4; + a = paper()->lookup_->beam(sl, w); + + for (; j < rwholebeams + rhalfs; j++) { + Atom b(a); + b.translate(Offset(0, -dir * dy * j)); + rightbeams.add(b ); + } + + } + leftbeams.add(rightbeams); + return leftbeams; +} + void Beam::brew_molecule() @@ -159,20 +224,32 @@ Beam::brew_molecule() 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); + + output = new Molecule; slope = sl / inter; + Real x0 = stems.top()->hpos(); - Atom a(s); - - Real dx = width().min -left->hpos; - a.translate(Offset(dx,left_pos*inter)); - output = new Molecule(a); + for (PCursor<Stem*> i(stems); i.ok(); i++) { + PCursor<Stem*> p(i-1); + PCursor<Stem*> n(i+1); + Stem * prev = p.ok() ? p.ptr() : 0; + Stem * next = n.ok() ? n.ptr() : 0; + + Molecule sb = stem_beams(i, next, prev); + Real x = i->hpos()-x0; + sb.translate(Offset(x, (x * slope + left_pos)* inter)); + output->add(sb); + } + output->translate(Offset(x0 - left->hpos,0)); } void Beam::print()const { - mtor << "Beam, slope " <<slope << "left ypos " << left_pos<<'\n'; +#ifndef NPRINT + mtor << "{ slope " <<slope << "left ypos " << left_pos; + Spanner::print(); + mtor << "}\n"; +#endif } diff --git a/src/getcommands.cc b/src/getcommands.cc index 5b12009ff9..8a133bdd5c 100644 --- a/src/getcommands.cc +++ b/src/getcommands.cc @@ -40,18 +40,4 @@ get_meter_command(Real w, int n, int m) c->priority = 40; return c; } -#if 0 -Command* -get_bar_command(Real w) -{ - Command*c = new Command; - c->when = w; - c->code = INTERPRET; - c->args.add( "BAR"); - c->args.add( "|"); - c->priority = 170; - return c; -} - -#endif diff --git a/src/grouping.cc b/src/grouping.cc new file mode 100644 index 0000000000..e07de1254a --- /dev/null +++ b/src/grouping.cc @@ -0,0 +1,148 @@ +#include "grouping.hh" +#include "debug.hh" + +Interval +vec_union(svec<Interval> notes) +{ + Interval u; + u.set_empty(); + for (int i =0 ; i < notes.sz() ; i++) { + u.unite(notes[i]); + } + return u; +} + +svec<Real> +default_bounds(Interval t) +{ + svec<Real> bounds; + Real dt = t.length(); + bounds.add(t.min); + bounds.add(t.min + dt/2); + return bounds; +} + +svec<Real> +Rhythmic_grouping::get_bounds() +{ + svec<Real> bounds; + if (children.sz()) { + for (int i=0; i < children.sz(); i++) { + bounds.add(children[i]->t.min); + } + } else { + default_bounds(t); + } +// bounds.add(t.max ); + return bounds; +} + +Real +Rhythmic_grouping::last() +{ + return t.max; +} + +void +Rhythmic_grouping::split_grouping(svec<Real> bounds) +{ + int lasti =0; + svec<Rhythmic_grouping*> 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; +} + +void +Rhythmic_grouping::split_half() +{ + svec<Real> bounds = default_bounds(t); + bounds.add(t.max); + split_grouping(bounds); + + for (int i=0; i < children.sz(); i++) { + if (children[i]->children.sz()) + children[i]->split_half(); + } +} + +Rhythmic_grouping* +Rhythmic_grouping::sub_grouping(Interval v) +{ + return 0; // todo! +} +void +Rhythmic_grouping::split_grouping(Rhythmic_grouping &initial_grouping) +{ + svec<Rhythmic_grouping*> newgrp; + svec<Real> 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(); + } + } +} + +Rhythmic_grouping::Rhythmic_grouping(Interval i) +{ + t=i; +} + +Rhythmic_grouping::Rhythmic_grouping(svec<Interval> notes, + svec<Real> initial_grouping) +{ + t = vec_union(notes); + for (int i=0; i < notes.sz(); i++) { + children.add(new Rhythmic_grouping(notes[i])); + } + split_grouping(initial_grouping); +} + +Rhythmic_grouping::~Rhythmic_grouping() +{ + for (int i=0; i < children.sz(); i++) { + delete children[i]; + } +} + +void +Rhythmic_grouping::print()const +{ + mtor << "{ " << t << "\n"; + for (int i=0; i < children.sz(); i++) { + children[i]->print(); + } + mtor << "}"; +} + + diff --git a/src/inputcommand.cc b/src/inputcommand.cc index c0bdb96919..121271e4f0 100644 --- a/src/inputcommand.cc +++ b/src/inputcommand.cc @@ -21,7 +21,7 @@ Input_command::operator Command() c.code = INTERPRET; String s = args[0]; - int p; + int p=0; if (s == "KEY") p = 200; else if (s=="CLEF") @@ -30,6 +30,8 @@ Input_command::operator Command() p = 180; else if (s == "BAR") p = 170; + else if (s == "GROUPING") + p = 160; c.priority = p; c.args = args; @@ -48,6 +50,17 @@ get_partial_command(Real u) } Input_command* +get_grouping_command(svec<int>a ) +{ + Input_command*c = new Input_command; + c->args.add("GROUPING"); + for (int i=0; i < a.sz(); i ++) + c->args.add(a[i]); + + return c; +} + +Input_command* get_key_interpret_command(svec<String>a ) { Input_command*c = new Input_command; diff --git a/src/inputscore.cc b/src/inputscore.cc index 89ec2bd4e9..5043354f0c 100644 --- a/src/inputscore.cc +++ b/src/inputscore.cc @@ -47,7 +47,7 @@ Input_score::~Input_score() Input_score::Input_score() { - paper_=new Paperdef; + paper_= 0; } void diff --git a/src/item.cc b/src/item.cc index 914c924a99..4a8ea949d6 100644 --- a/src/item.cc +++ b/src/item.cc @@ -60,8 +60,10 @@ Item::Item() void Item::print() const { - assert(output); - output->print(); +#ifndef NPRINT + if (output) + output->print(); +#endif } Paperdef* diff --git a/src/lexer.l b/src/lexer.l index aaacf06df5..f83cf144df 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -39,7 +39,7 @@ DURNAME 1|2|4|8|16|32 DURATION {DURNAME}\.* FULLNOTE {PITCH}{DURATION}? WORD [a-zA-Z][a-zA-Z0-9_]+ -REAL [0-9]+(\.[0-9]*)? +REAL -?[0-9]+(\.[0-9]*)? %% @@ -86,7 +86,7 @@ REAL [0-9]+(\.[0-9]*)? } <notes>[ \t\n]+ { } -<notes>%.*$ { +<notes>[%#].*$ { } <notes>\$ { diff --git a/src/linespace.cc b/src/linespace.cc index e8a767f9ee..fbab62449b 100644 --- a/src/linespace.cc +++ b/src/linespace.cc @@ -22,6 +22,7 @@ Spacing_problem::col_id(const PCol *w)const if (cols[i].pcol_ == w) return i; assert(false); + return -1; } void diff --git a/src/lookup.cc b/src/lookup.cc index c22e3aaf55..7376f3c1d4 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -5,26 +5,35 @@ #include "tex.hh" #include "scalar.hh" -Real -Lookup::internote() + +Lookup::Lookup() { - return ball(4).dim.y.length()/2; + texsetting = "\\unknowntexsetting"; + symtables_ = new Symtables; } -void -Lookup::parse(Text_db&t) +Lookup::Lookup(Lookup const &s) +{ + texsetting = s.texsetting; + symtables_ = new Symtables(*s.symtables_); +} +Lookup::~Lookup() { - symtables_->read(t) ; + delete symtables_; } -Lookup::Lookup() +void +Lookup::add(String s, Symtable*p) { - symtables_ = new Symtables; + symtables_->add(s, p); } -Lookup::~Lookup() +/****************/ + +Real +Lookup::internote() { - delete symtables_; + return ball(4).dim.y.length()/2; } Symbol @@ -100,8 +109,6 @@ Lookup::streepjes(int i) return ret; } -/****************************************************************/ -// bare bones. Symbol @@ -122,9 +129,6 @@ Lookup::linestaff(int lines, Real wid) return s; } -/****************************************************************/ - - Symbol Lookup::meter(svec<Scalar> a) @@ -156,5 +160,3 @@ Lookup::stem(Real y1,Real y2) s.tex = substitute_args(src,a); return s; } - - diff --git a/src/melodicstaff.cc b/src/melodicstaff.cc index b6d1ea59d7..ed4383fced 100644 --- a/src/melodicstaff.cc +++ b/src/melodicstaff.cc @@ -45,9 +45,9 @@ Melodic_staff::get_TYPESET_item(Command*com) } Stem * -Melodic_staff::get_stem(Stem_req*rq) +Melodic_staff::get_stem(Stem_req*rq, Real dur) { - Stem * s = new Stem(NO_LINES-1); + Stem * s = new Stem(NO_LINES-1, dur); s->flag = rq->stem_number; return s; } diff --git a/src/misc.cc b/src/misc.cc index 54746fd836..51baac1211 100644 --- a/src/misc.cc +++ b/src/misc.cc @@ -3,12 +3,19 @@ #include <math.h> -int intlog2(int d) { +int +intlog2(int d) { int i=0; while (!(d&1)) { - d/= 2; i++; + d/= 2; + i++; } assert(!(d/2)); return i; } +double +log2(double x) { + return log(x) /log(2.0); +} + diff --git a/src/notehead.cc b/src/notehead.cc index 7abc0e6b8e..fcbd6745eb 100644 --- a/src/notehead.cc +++ b/src/notehead.cc @@ -17,8 +17,10 @@ Notehead::Notehead(int ss) void Notehead::print()const { +#ifndef NPRINT mtor << "Head "<<balltype<<", position = "<< position << "dots " << dots; Item::print(); +#endif } void diff --git a/src/paper.cc b/src/paper.cc index 5f31611f8e..29fcd240e4 100644 --- a/src/paper.cc +++ b/src/paper.cc @@ -1,15 +1,11 @@ #include <math.h> - +#include "misc.hh" #include "paper.hh" #include "debug.hh" #include "lookup.hh" #include "dimen.hh" #include "textdb.hh" -double log2(double x) { - return log(x) /log(2.0); -} - // golden ratio const Real PHI = (1+sqrt(5))/2; @@ -20,38 +16,33 @@ Paperdef::duration_to_dist(Real d) { return whole_width * pow(geometric_, log2(d)); } + Real Paperdef::rule_thickness()const { return convert_dimen(0.4, "pt"); } -Paperdef::Paperdef() + +Paperdef::Paperdef(Lookup *l) { - lookup_ = new Lookup(); - parse(); + lookup_ = l; + linewidth = convert_dimen(15,"cm"); // in cm for now - whole_width= 8*note_width(); -// geometric_ = PHI; - geometric_ = sqrt(2); + whole_width = 8 * note_width(); + geometric_ = sqrt(2); } -void -Paperdef::parse() +Paperdef::~Paperdef() { - Text_db symini("symbol.ini"); - - - while (!symini.eof()) { - Text_record r( symini++); - - if (r[0] == "symboltables") - lookup_->parse(symini); - } + delete lookup_; } -Paperdef::~Paperdef() +void +Paperdef::set(Lookup*l) { + assert(l != lookup_); delete lookup_; + lookup_ = l; } Real diff --git a/src/parser.y b/src/parser.y index 23c779ed7d..87c685a4d9 100644 --- a/src/parser.y +++ b/src/parser.y @@ -1,5 +1,6 @@ %{ // -*-Fundamental-*- #include <iostream.h> +#include "lookup.hh" #include "lexer.hh" #include "paper.hh" @@ -20,10 +21,13 @@ #endif svec<Request*> pre_reqs, post_reqs; + +Paperdef*default_paper(); %} -%union { +%union { + Request * request; Real real; Input_command *command; Identifier *id; @@ -32,7 +36,6 @@ svec<Request*> pre_reqs, post_reqs; String *string; const char *consstr; Paperdef *paper; - Request* request; Horizontal_music *horizontal; Vertical_music *vertical; Music_general_chord *chord; @@ -42,16 +45,25 @@ svec<Request*> pre_reqs, post_reqs; svec<String> * strvec; svec<Input_command*> *commandvec; - Voice_list *voicelist; - Input_staff *staff; - Input_score *score; + svec<int> *intvec; + + Input_staff *staff; + Input_score *score; + Symtables * symtables; + Symtable * symtable; + Symbol * symbol; + Lookup*lookup; + Interval *interval; + Box *box; } %token VOICE STAFF SCORE TITLE BAR NOTENAME OUTPUT %token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS %token GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND %token KEY CLEF VIOLIN BASS MULTI TABLE CHORD VOICES -%token PARTIAL RHYTHMIC MELODIC MUSIC +%token PARTIAL RHYTHMIC MELODIC MUSIC GROUPING + +%token END SYMBOLTABLES TEXID TABLE %token <id> IDENTIFIER %token <string> NEWIDENTIFIER @@ -60,7 +72,6 @@ svec<Request*> pre_reqs, post_reqs; %token <string> STRING %token <i> OPEN_REQUEST_PARENS CLOSE_REQUEST_PARENS - %type <consstr> unit %type <id> declaration @@ -72,6 +83,7 @@ svec<Request*> pre_reqs, post_reqs; %type <score> score_block score_body %type <staff> staff_block staff_init staff_body %type <i> int +%type <intvec> int_list %type <commandvec> score_commands_block score_commands_body %type <commandvec> staff_commands_block staff_commands_body %type <request> post_request pre_request @@ -82,6 +94,12 @@ svec<Request*> pre_reqs, post_reqs; %type <horizontal> horizontal_music %type <mvoice> music_voice_body music_voice +%type <interval> dinterval +%type <box> box +%type <symtable> symtable symtable_body +%type <lookup> symtables symtables_body +%type <symbol> symboldef + %% @@ -91,6 +109,7 @@ mudela: /* empty */ } | mudela add_declaration { } ; + /* DECLARATIONS */ @@ -112,13 +131,20 @@ declaration: $$ = new M_chord_id(*$1, $3); delete $1; } + | NEWIDENTIFIER '=' symtables { + $$ = new Lookup_id(*$1, $3); + delete $1; + } ; /* SCORE */ -score_block: SCORE '{' score_body '}' { $$ = $3; } +score_block: SCORE '{' score_body '}' { $$ = $3; + if (!$$->paper_) + $$->paper_ = default_paper(); + } ; score_body: { $$ = new Input_score; } @@ -178,8 +204,13 @@ score_command: | PARTIAL REAL { $$ = get_partial_command($2); } + | GROUPING int_list { + $$ = get_grouping_command(*$2); + delete $2; + } ; - + + /* PAPER @@ -189,25 +220,29 @@ paper_block: ; paper_body: - /* empty */ { $$ = new Paperdef; } + /* empty */ { + $$ = default_paper(); + } | paper_body WIDTH dim { $$->linewidth = $3;} | paper_body OUTPUT STRING { $$->outfile = *$3; delete $3; } + | paper_body symtables { $$->set($2); } | paper_body UNITSPACE dim { $$->whole_width = $3; } | paper_body GEOMETRIC REAL { $$->geometric_ = $3; } ; + /* STAFFs */ staff_block: - STAFF '{' staff_body '}' { $$ = $3; } + STAFF '{' staff_body '}' { $$ = $3; } ; staff_init: - IDENTIFIER { $$ = new Input_staff(*$1->staff()); } + IDENTIFIER { $$ = $1->staff(true); } | RHYTHMIC { $$ = new Input_staff("rhythmic"); } @@ -355,7 +390,14 @@ int: } ; - +int_list: + /* */ { + $$ = new svec<int>; + } + | int { + $$->add($1); + } + ; dim: REAL unit { $$ = convert_dimen($1,$2); } @@ -372,6 +414,64 @@ clef_id: VIOLIN { $$ = new String("violin"); } | BASS { $$ = new String("bass"); } ; +/* + symbol tables +*/ +symtables: + SYMBOLTABLES '{' symtables_body '}' { $$ = $3; } + ; + +symtables_body: + { + $$ = new Lookup; + } + | IDENTIFIER { + $$ = new Lookup(*$1->lookup(true)); + } + | symtables_body TEXID STRING { + $$->texsetting = *$3; + delete $3; + } + | symtables_body STRING '=' symtable { + $$->add(*$2, $4); + delete $2; + } + ; + +symtable: + TABLE '{' symtable_body '}' { $$ = $3; } + ; + +symtable_body: + { $$ = new Symtable; } + | symtable_body STRING symboldef { + $$->add(*$2, *$3); + delete $2; + delete $3; + } + ; + +symboldef: + STRING box { + $$ = new Symbol(*$1, *$2); + delete $1; + delete $2; + } + ; + +box: + dinterval dinterval { + $$ = new Box(*$1, *$2); + delete $1; + delete $2; + } + ; + +dinterval: dim dim { + $$ = new Interval($1, $2); + } + ; + %% void @@ -380,13 +480,22 @@ parse_file(String s) *mlog << "Parsing ... "; #ifdef YYDEBUG - yydebug = !monitor.silence("Parser") & check_debug; + yydebug = !monitor.silence("Parser") && check_debug; #endif + new_input("symbol.ini"); + yyparse(); new_input(s); yyparse(); + delete_identifiers(); kill_lexer(); *mlog << "\n"; } +Paperdef* +default_paper() +{ + return new Paperdef( + lookup_identifier("default_table")->lookup(true)); +} diff --git a/src/pscore.cc b/src/pscore.cc index 378ad37f0a..fcd03ca55a 100644 --- a/src/pscore.cc +++ b/src/pscore.cc @@ -1,5 +1,6 @@ // utility functions for PScore #include "debug.hh" +#include "lookup.hh" #include "spanner.hh" #include "paper.hh" #include "molecule.hh" @@ -147,6 +148,7 @@ PScore::output(Tex_stream &ts) { int l=1; + ts << "\n "<< paper_->lookup_->texsetting << "%(Tex id)\n"; for (PCursor<Line_of_score*> lic(lines); lic.ok(); lic++) { ts << "% line of score no. " << l++ <<"\n"; ts << lic->TeXstring(); diff --git a/src/rhythmstaff.cc b/src/rhythmstaff.cc index d5f26dcd43..a446bd33ec 100644 --- a/src/rhythmstaff.cc +++ b/src/rhythmstaff.cc @@ -43,9 +43,9 @@ Rhythmic_staff::get_notehead(Note_req *rq, int) } Stem * -Rhythmic_staff::get_stem(Stem_req*rq) +Rhythmic_staff::get_stem(Stem_req*rq, Real l) { - Stem * s = new Stem(0); + Stem * s = new Stem(0,l); s->flag = rq->stem_number; return s; } diff --git a/src/score.cc b/src/score.cc index 57336936b5..2be27345d3 100644 --- a/src/score.cc +++ b/src/score.cc @@ -12,8 +12,7 @@ Score::process() { *mlog << "Processing ... "; - if (!paper_) - paper_ = new Paperdef; + assert (paper_); /// distribute commands to disciples pscore_ = new PScore(paper_); diff --git a/src/simplestaff.cc b/src/simplestaff.cc index 6437b65c3a..9fe16b5937 100644 --- a/src/simplestaff.cc +++ b/src/simplestaff.cc @@ -14,6 +14,7 @@ Simple_column::Simple_column(Score_column*s, Simple_staff *rs) : Staff_column(s) { + stem_requester_len = 0; stem_ = 0; staff_ = rs; beam_ = 0; @@ -45,6 +46,7 @@ Simple_column::process_requests() } if (rq->stem()) { stem_ = rq->stem(); + stem_requester_len = v_elts[i]->duration; } if (rq->beam()) { diff --git a/src/simplewalker.cc b/src/simplewalker.cc index 8d056e59ce..f275cd272e 100644 --- a/src/simplewalker.cc +++ b/src/simplewalker.cc @@ -144,7 +144,7 @@ Simple_walker::process_requests() } if (c->stem_) { - stem_ = s->get_stem(c->stem_->stem()); + stem_ = s->get_stem(c->stem_->stem(), c->stem_requester_len); } for (int i = 0; i < c->notes.sz(); i ++) { diff --git a/src/spanner.cc b/src/spanner.cc index d38a604302..2d34f9e477 100644 --- a/src/spanner.cc +++ b/src/spanner.cc @@ -50,8 +50,11 @@ void Spanner::print()const { #ifndef NPRINT - mtor << "Spanner { Output "; - output->print(); + mtor << "Spanner { "; + if (output) { + mtor << "Output "; + output->print(); + } mtor << "}\n"; #endif diff --git a/src/stem.cc b/src/stem.cc index 5fa4d9ee30..84e24c5986 100644 --- a/src/stem.cc +++ b/src/stem.cc @@ -6,16 +6,15 @@ #include "lookup.hh" #include "molecule.hh" #include "pcol.hh" +#include "misc.hh" const int STEMLEN=7; -static int -ABS(int i) { - return (i < 0)?-i:i; -} - -Stem::Stem(int c) +Stem::Stem(int c, Real len) { + note_length = len; + beams_left = 0; + beams_right = 0; minnote = 1000; // invalid values maxnote = -1000; bot = top = 0; @@ -27,7 +26,19 @@ Stem::Stem(int c) stem_xoffset=0; } +void +Stem::print() const +{ +#ifndef NPRINT + mtor << "{\n"; + mtor << "flag "<< flag << " print_flag " << print_flag + << "min,max [" << minnote << ", " << maxnote << "]"; + + Item::print(); + mtor << "}\n"; +#endif +} void Stem::set_stemend(Real se) { @@ -49,15 +60,10 @@ Stem::add(Notehead *n) if ( p < minnote) minnote = p; if ( p> maxnote) - maxnote = p; -} -void -Stem::print()const -{ - mtor << "Stem minmax=["<< minnote<<","<<maxnote<<"], flag: "<<flag; - Item::print(); + maxnote = p; } + void Stem::set_default_dir() { diff --git a/src/symtable.cc b/src/symtable.cc index 39b6fdead0..bc5d173869 100644 --- a/src/symtable.cc +++ b/src/symtable.cc @@ -5,8 +5,25 @@ #include "real.hh" #include "symbol.hh" #include "assoc.hh" +#include "associter.hh" #include "symtable.hh" +Symtables::Symtables() +{ +} + +Symtables::Symtables(Symtables const &s) +{ + for (Assoc_iter<String, Symtable*> i(s); i.ok(); i++) { + add(i.key(), new Symtable(*i.val())); + } +} +Symtables::~Symtables() +{ + for (Assoc_iter<String, Symtable*> i(*this); i.ok(); i++) { + delete i.val(); + } +} Symbol Symtable::lookup(String s) const @@ -25,36 +42,3 @@ Symtables::operator()(String s) { return Assoc<String, Symtable*>::operator[](s); } - -void -Symtables::read(Text_db &symini) -{ - while (!symini.eof()) { - Text_record r(symini++); - if (r[0] == "end" ) - return; - assert (r[0] == "table"); - - String tabnam = r[1]; - Symtable * sp = new Symtable; - while (!symini.eof()){ - r = symini++; - if (r[0] == "end") - break; - - if (r.sz() != 6) - error("Not enough fields in symbol init"); - - int i=0; - String id=r[i++]; - String tex=r[i++]; - svec<Real> dims; - for (int j=0; j < 4; j++) - dims.add( parse_dimen(r[i++])); - - Symbol s(tex, Box(dims)); - (*sp)[id] = s; - } - (*this)[tabnam] = sp; - } -} diff --git a/src/table.cc b/src/table.cc index cfb0db0cb9..a61676159a 100644 --- a/src/table.cc +++ b/src/table.cc @@ -31,6 +31,8 @@ static Keyword_ent the_key_tab[]={ "staff", STAFF, "start", START_T, "table", TABLE, + "symboltables", SYMBOLTABLES, + "texid", TEXID, "chord", CHORD, "multi", MULTI, "unitspace", UNITSPACE, @@ -39,6 +41,7 @@ static Keyword_ent the_key_tab[]={ "voices", VOICES, "width", WIDTH, "music", MUSIC, + "grouping", GROUPING, 0,0 }; @@ -69,8 +72,7 @@ add_identifier(Identifier*i) void delete_identifiers() -{ - +{ for (Assoc_iter<String,Identifier*> ai(the_id_tab); ai.ok(); ai++) { mtor << "deleting: " << ai.key()<<'\n'; delete ai.val(); diff --git a/src/texslur.cc b/src/texslur.cc index 799b9e7e6d..4a7fe02bc2 100644 --- a/src/texslur.cc +++ b/src/texslur.cc @@ -8,7 +8,7 @@ static char direction_char(int y_sign) { - char c; + char c='#'; switch(y_sign){ case -1: c = 'd'; diff --git a/symbol.ini b/symbol.ini index 5b1d6e303e..3e149c7a66 100644 --- a/symbol.ini +++ b/symbol.ini @@ -1,89 +1,187 @@ - - - -symboltables -# index TeXstring, xmin xmax ymin ymax - -# be careful with editing this: -# the "index" entry is hardwired into lilypond. - -table clefs - violin \violinclef 0pt 16pt -12.5pt 22.5pt - bass \bassclef 0pt 16pt 0pt 20pt - viola \violaclef 0pt 16pt 0pt 20pt - violin_change \cviolinclef 0pt 16pt -12.5pt 22.5pt - bass_change \cbassclef 0pt 16pt 0pt 20pt - viola_change \cviolaclef 0pt 16pt 0pt 20pt -end - -table balls - 1 \wholeball 0pt 7.5pt -2.5pt 2.5pt - 2 \halfball 0pt 6pt -2.5pt 2.5pt - 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 - 0 \natural 0pt 6pt -7.5pt 7.5pt - 1 \sharp 0pt 6pt -7.5pt 7.5pt - 2 \sharpsharp 0pt 6pt -2.5pt 7.5pt -end - -table streepjes - toplines \toplines{%} -3pt 9pt 0pt 0pt - botlines \botlines{%} -3pt 9pt 0pt 0pt -end - -table bars - empty \emptybar 0pt 0pt 0pt 0pt - | \maatstreep 0pt 5pt -12pt 12pt - || \finishbar 0pt 2pt -12pt 12pt -end - -table rests - 1 \wholerest -5pt 1pt -1pt 1pt - 2 \halfrest -5pt 1pt -1pt 1pt - 4 \quartrest -5pt 2pt -5pt 5pt - 8 \eighthrest 0pt 5pt 0pt 8pt - 16 \sixteenthrest 0pt 6pt 0pt 12pt - 32 \thirtysecondrest 0pt 6pt 0pt 16pt -end - -table meters - C \fourfourmeter 0pt 10pt -5pt 5pt - C2 \allabreve 0pt 10pt -5pt 5pt -end - -# dims ignored for this table -table param - meter \generalmeter{%}{%} -3pt 10pt -5pt 5pt - linestaf \linestafsym{%}{%} 0pt 0pt 0pt 0pt - stem \stem{%}{%} 0pt 0pt 0pt 0pt -end - -table dots - 1 \lsingledot 0pt 8pt -1pt 1pt - 2 \ldoubledot 0pt 12pt -1pt 1pt - 3 \ltripledot 0pt 16pt -1pt 1pt -end - -table flags - 8 \eigthflag 0pt 5pt 0pt 0pt - 16 \sixteenthflag 0pt 5pt 0pt 0pt - 32 \thirtysecondflag 0pt 5pt 0pt 0pt - -8 \deigthflag 0pt 5pt 0pt 0pt - -16 \dsixteenthflag 0pt 5pt 0pt 0pt - -32 \dthirtysecondflag 0pt 5pt 0pt 0pt -end - -table beamslopes - slope \beamslope{%}{%} 0pt 0pt 0pt 0pt - horizontal \rulesym{%}{%} 0pt 0pt 0pt 0pt -end - -end # symboltables
\ No newline at end of file +% +% spacing info for LilyPond. Do not edit this. It has a lot of hard-wired stringconstants +% +% + +table_sixteen = symboltables { + + texid "\musixsixteendefs" + + + % index TeXstring, xmin xmax ymin ymax + + + "clefs" = table { + "violin" "\violinclef" 0pt 16pt -12.5pt 22.5pt + "bass" "\bassclef" 0pt 16pt 0pt 20pt + "viola" "\violaclef" 0pt 16pt 0pt 20pt + "violin_change" "\cviolinclef" 0pt 16pt -12.5pt 22.5pt + "bass_change" "\cbassclef" 0pt 16pt 0pt 20pt + "viola_change" "\cviolaclef" 0pt 16pt 0pt 20pt + } + + "balls" = table { + "1" "\wholeball" 0pt 6pt -2 pt 2pt + "2" "\halfball" 0pt 5pt -2 pt 2pt + "4" "\quartball" 0pt 5pt -2 pt 2pt + } + + "slur" = table { + "whole" "\slurchar%{%}" 0pt 0pt 0pt 0pt + "half" "\hslurchar%{%}" 0pt 0pt 0pt 0pt + } + "accidentals" = table { + "-2" "\flatflat" 0pt 10.2pt -2.5pt 7.5pt + "-1" "\flat" 0pt 6pt -2.5pt 7.5pt + "0" "\natural" 0pt 6pt -7.5pt 7.5pt + "1" "\sharp" 0pt 6pt -7.5pt 7.5pt + "2" "\sharpsharp" 0pt 6pt -2.5pt 7.5pt + } + + "streepjes" = table { + "toplines" "\toplines{%}" -3pt 9pt 0pt 0pt + "botlines" "\botlines{%}" -3pt 9pt 0pt 0pt + } + + "bars" = table { + "empty" "\emptybar" 0pt 0pt 0pt 0pt + "|" "\maatstreep" 0pt 5pt -12pt 12pt + "||" "\finishbar" 0pt 2pt -12pt 12pt + } + + "rests" = table { + "1" "\wholerest" -5pt 1pt -1pt 1pt + "2" "\halfrest" -5pt 1pt -1pt 1pt + "4" "\quartrest" -5pt 2pt -5pt 5pt + "8" "\eighthrest" 0pt 5pt 0pt 8pt + "16" "\sixteenthrest" 0pt 6pt 0pt 12pt + "32" "\thirtysecondrest" 0pt 6pt 0pt 16pt + } + + "meters" = table { + "C" "\fourfourmeter" 0pt 10pt -5pt 5pt + "C2" "\allabreve" 0pt 10pt -5pt 5pt + } + + % dims ignored for this table + "param" = table { + "meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt + "linestaf" "\linestafsym{%}{%}" 0pt 0pt 0pt 0pt + "stem" "\stem{%}{%}" 0pt 0pt 0pt 0pt + } + + "dots" = table { + "1" "\lsingledot" 0pt 8pt -1pt 1pt + "2" "\ldoubledot" 0pt 12pt -1pt 1pt + "3" "\ltripledot" 0pt 16pt -1pt 1pt + } + + "flags" = table { + "8" "\eigthflag" 0pt 5pt 0pt 0pt + "16" "\sixteenthflag" 0pt 5pt 0pt 0pt + "32" "\thirtysecondflag" 0pt 5pt 0pt 0pt + "-8" "\deigthflag" 0pt 5pt 0pt 0pt + "-16" "\dsixteenthflag" 0pt 5pt 0pt 0pt + "-32" "\dthirtysecondflag" 0pt 5pt 0pt 0pt + } + + "beamslopes" = table { + "slope" "\beamslope{%}{%}" 0pt 0pt 0pt 0pt + "horizontal" "\rulesym{%}{%}" 0pt 0pt 0pt 0pt + } + +} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +table_twenty = symboltables { + + texid "\musixtwentydefs" + + + % index TeXstring, xmin xmax ymin ymax + % be careful with editing this: + % the "index" entry is hardwired into lilypond. + + "clefs" = table { + "violin" "\violinclef" 0pt 16pt -12.5pt 22.5pt + "bass" "\bassclef" 0pt 16pt 0pt 20pt + "viola" "\violaclef" 0pt 16pt 0pt 20pt + "violin_change" "\cviolinclef" 0pt 16pt -12.5pt 22.5pt + "bass_change" "\cbassclef" 0pt 16pt 0pt 20pt + "viola_change" "\cviolaclef" 0pt 16pt 0pt 20pt + } + + "balls" = table { + "1" "\wholeball" 0pt 7.5pt -2.5pt 2.5pt + "2" "\halfball" 0pt 6pt -2.5pt 2.5pt + "4" "\quartball" 0pt 6pt -2.5pt 2.5pt + } + + "slur" = table { + "whole" "\slurchar%{%}" 0pt 0pt 0pt 0pt + "half" "\hslurchar%{%}" 0pt 0pt 0pt 0pt + } + "accidentals" = table { + "-2" "\flatflat" 0pt 10.2pt -2.5pt 7.5pt + "-1" "\flat" 0pt 6pt -2.5pt 7.5pt + "0" "\natural" 0pt 6pt -7.5pt 7.5pt + "1" "\sharp" 0pt 6pt -7.5pt 7.5pt + "2" "\sharpsharp" 0pt 6pt -2.5pt 7.5pt + } + + "streepjes" = table { + "toplines" "\toplines{%}" -3pt 9pt 0pt 0pt + "botlines" "\botlines{%}" -3pt 9pt 0pt 0pt + } + + "bars" = table { + "empty" "\emptybar" 0pt 0pt 0pt 0pt + "|" "\maatstreep" 0pt 5pt -12pt 12pt + "||" "\finishbar" 0pt 2pt -12pt 12pt + } + + "rests" = table { + "1" "\wholerest" -5pt 1pt -1pt 1pt + "2" "\halfrest" -5pt 1pt -1pt 1pt + "4" "\quartrest" -5pt 2pt -5pt 5pt + "8" "\eighthrest" 0pt 5pt 0pt 8pt + "16" "\sixteenthrest" 0pt 6pt 0pt 12pt + "32" "\thirtysecondrest" 0pt 6pt 0pt 16pt + } + + "meters" = table { + "C" "\fourfourmeter" 0pt 10pt -5pt 5pt + "C2" "\allabreve" 0pt 10pt -5pt 5pt + } + + % dims ignored for this table + "param" = table { + "meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt + "linestaf" "\linestafsym{%}{%}" 0pt 0pt 0pt 0pt + "stem" "\stem{%}{%}" 0pt 0pt 0pt 0pt + } + + "dots" = table { + "1" "\lsingledot" 0pt 8pt -1pt 1pt + "2" "\ldoubledot" 0pt 12pt -1pt 1pt + "3" "\ltripledot" 0pt 16pt -1pt 1pt + } + + "flags" = table { + "8" "\eigthflag" 0pt 5pt 0pt 0pt + "16" "\sixteenthflag" 0pt 5pt 0pt 0pt + "32" "\thirtysecondflag" 0pt 5pt 0pt 0pt + "-8" "\deigthflag" 0pt 5pt 0pt 0pt + "-16" "\dsixteenthflag" 0pt 5pt 0pt 0pt + "-32" "\dthirtysecondflag" 0pt 5pt 0pt 0pt + } + + "beamslopes" = table { + "slope" "\beamslope{%}{%}" 0pt 0pt 0pt 0pt + "horizontal" "\rulesym{%}{%}" 0pt 0pt 0pt 0pt + } + +} + +default_table = symboltables { table_sixteen }
\ No newline at end of file |