From ef080c0db8581b808d8436182362c3d34d7bf7a5 Mon Sep 17 00:00:00 2001 From: Han-Wen Nienhuys Date: Wed, 4 Dec 1996 23:14:10 +0100 Subject: [PATCH] release: 0.0.10 --- Documentation/Makefile | 2 +- Documentation/commands | 24 +++++ Makefile | 14 +-- README | 11 +-- Sources.make | 10 +- Make.variables => Variables.make | 4 +- flower/Makefile | 4 +- flower/Sources.make | 4 +- flower/dstream.cc | 4 +- flower/fproto.hh | 1 + flower/handle.hh | 2 +- flower/plist.cc | 10 ++ flower/plist.hh | 2 +- flower/scalar.cc | 38 ++++++++ flower/scalar.hh | 32 +++++++ flower/string.cc | 47 +-------- flower/string.hh | 11 +-- hdr/accidental.hh | 21 +++++ hdr/beam.hh | 4 +- hdr/boxes.hh | 10 +- hdr/clef.hh | 20 ++++ hdr/clefitem.hh | 25 +++++ hdr/key.hh | 39 ++++++++ hdr/keyitem.hh | 27 ++++++ hdr/localkeyitem.hh | 33 +++++++ hdr/lookup.hh | 3 +- hdr/melodicstaff.hh | 5 +- hdr/molecule.hh | 2 +- hdr/parseconstruct.hh | 4 +- hdr/pcol.hh | 10 +- hdr/proto.hh | 8 ++ hdr/pscore.hh | 12 +-- hdr/pstaff.hh | 9 +- hdr/rhythmstaff.hh | 2 +- hdr/sccol.hh | 4 +- hdr/scommands.hh | 4 +- hdr/score.hh | 4 +- hdr/scoreline.hh | 4 +- hdr/simplestaff.hh | 25 ++--- hdr/simplewalker.hh | 44 +++++++++ hdr/staff.hh | 6 +- hdr/staffline.hh | 2 +- hdr/stem.hh | 1 + hdr/swalker.hh | 8 +- hdr/voice.hh | 8 +- kortjakje.ly | 20 ++-- lilyponddefs.tex | 14 ++- maartje.ly | 14 ++- src/accidental.cc | 32 +++++++ src/beam.cc | 21 +++-- src/break.cc | 4 +- src/calcideal.cc | 12 +-- src/clef.cc | 19 ++++ src/clefitem.cc | 34 +++++++ src/command.cc | 2 + src/getcommands.cc | 66 ++++++++++--- src/key.cc | 78 +++++++++++++++ src/keyitem.cc | 50 ++++++++++ src/lexer.l | 4 +- src/localkeyitem.cc | 71 ++++++++++++++ src/lookup.cc | 18 +++- src/melodicstaff.cc | 22 ++++- src/note.cc | 5 +- src/paper.cc | 6 +- src/parser.y | 29 +++++- src/pcol.cc | 10 +- src/pscore.cc | 2 +- src/request.cc | 7 +- src/rhythmstaff.cc | 5 +- src/sccol.cc | 6 +- src/scommands.cc | 145 +++++++++++++++++++++++----- src/score.cc | 4 +- src/simpleprint.cc | 80 +++++++++++++--- src/simplestaff.cc | 5 +- src/simplewalker.cc | 157 ++++++++++++++++++++++++------- src/staff.cc | 26 +++-- src/stem.cc | 11 ++- src/swalker.cc | 32 +++++++ src/table.cc | 4 + src/template1.cc | 18 ++-- src/template2.cc | 11 ++- src/template3.cc | 9 +- src/voice.cc | 2 +- symbol.ini | 19 +++- 84 files changed, 1317 insertions(+), 321 deletions(-) create mode 100644 Documentation/commands rename Make.variables => Variables.make (94%) create mode 100644 flower/scalar.cc create mode 100644 flower/scalar.hh create mode 100644 hdr/accidental.hh create mode 100644 hdr/clef.hh create mode 100644 hdr/clefitem.hh create mode 100644 hdr/key.hh create mode 100644 hdr/keyitem.hh create mode 100644 hdr/localkeyitem.hh create mode 100644 hdr/simplewalker.hh create mode 100644 src/accidental.cc create mode 100644 src/clef.cc create mode 100644 src/clefitem.cc create mode 100644 src/key.cc create mode 100644 src/keyitem.cc create mode 100644 src/localkeyitem.cc diff --git a/Documentation/Makefile b/Documentation/Makefile index e8adae90d7..daf587679e 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -1,5 +1,5 @@ -DOCFILES=CodingStyle algorithms Makefile breaking +DOCFILES=commands CodingStyle algorithms Makefile breaking dist: ln $(DOCFILES) $(DDIR)/Documentation/ \ No newline at end of file diff --git a/Documentation/commands b/Documentation/commands new file mode 100644 index 0000000000..00d5856c67 --- /dev/null +++ b/Documentation/commands @@ -0,0 +1,24 @@ +This table decribes the proper order for the different commands: + + +interpret + which priority + ======================== + + key 200 + clef 190 + meter 180 + bar 170 + +typeset + + which priority + ======================== + + bar 100 + clef 90 + currentclef 80 + key 70 + currentkey 60 + meter 40 + \ No newline at end of file diff --git a/Makefile b/Makefile index 8f05ad90f8..4dcc395210 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -include Make.variables +include Variables.make $(exe): $(obs) $(CXX) -o $@ $^ $(LOADLIBES) @@ -32,23 +32,23 @@ $(OBJECTDIR)/%.o: $(CCDIR)/%.cc rm -f depend realdepend: $(cc) - $(CXX) $(CXXFLAGS) -MM $^ | perl -ne 's/^(.+)\.o/'$(OBJECTDIR)'\/\1.o/; print;' > depend + $(CXX) $(CXXFLAGS) -MM $^ | perl -ne 's#hdr/proto.hh##; s/^(.+)\.o/'$(OBJECTDIR)'\/\1.o/; print;' > depend include depend $(CCDIR)/parser.cc: parser.y $(BISON) -d $< mv $(CCDIR)/parser.tab.h $(HEADERDIR)/parser.hh - mv $(CCDIR)/parser.tab.c $(CCDIR)/parser.cc + mv $(CCDIR)/parser.tab.c $@ parser.hh: parser.cc version.o: $(obs) version.hh -version.hh: Makefile make_version - make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) > $(HEADERDIR)/$@ +hdr/version.hh: Variables.make make_version + make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) > $@ -src/lexer.cc: lexer.l +$(CCDIR)/lexer.cc: lexer.l $(FLEX) -+ -t $< > $@ dist: @@ -65,4 +65,4 @@ dist: TAGS: $(MAKE) -C $(HEADERDIR) TAGS - $(MAKE) -C $(CCDIR) TAGS \ No newline at end of file + $(MAKE) -C $(CCDIR) TAGS diff --git a/README b/README index cfee5ea3c9..c3c4cbd23e 100644 --- a/README +++ b/README @@ -2,9 +2,8 @@ INTRODUCTION -This is a beta version of LilyPond (a music typesetter). This release is -preliminary, please do not distribute. Please send your helpful comments and -patches to me, +This is a beta version of LilyPond (a music typesetter). Please send +your helpful comments and patches to me, hanwen@stack.urc.tue.nl @@ -73,10 +72,10 @@ HOW DOES IT WORK * Use The Source, Luke. If you don't know C++, you can try editing .dstreamrc for copious debugging output. -* also the subdir Documentation/ it contains some in depth matter -on LilyPond algorithms +* the subdir Documentation/ contains some in depth matter on LilyPond +algorithms * The source is commented in the DOC++ style. Check out doc++ at - http://www.ZIB-Berlin.DE/VisPar/doc++/doc++.html + http://www.ZIB-Berlin.DE/VisPar/doc++/doc++.html diff --git a/Sources.make b/Sources.make index 2894394f94..61c32fa41c 100644 --- a/Sources.make +++ b/Sources.make @@ -12,7 +12,9 @@ hdr= qlp.hh linespace.hh qlpsolve.hh\ sccol.hh stcol.hh scommands.hh melodicstaff.hh\ identifier.hh simplestaff.hh spanner.hh stem.hh\ notehead.hh leastsquares.hh beam.hh rest.hh\ - swalker.hh bar.hh meter.hh + swalker.hh bar.hh meter.hh accidental.hh\ + key.hh keyitem.hh localkeyitem.hh simplewalker.hh\ + clef.hh clefitem.hh mycc= qlp.cc qlpsolve.cc \ break.cc linespace.cc molecule.cc staffline.cc\ @@ -28,6 +30,8 @@ mycc= qlp.cc qlpsolve.cc \ melodicstaff.cc simpleprint.cc stem.cc\ spanner.cc notehead.cc leastsquares.cc beam.cc\ texbeam.cc rest.cc swalker.cc scoreline.cc\ - simplewalker.cc bar.cc meter.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\ - version.cc \ No newline at end of file + version.cc diff --git a/Make.variables b/Variables.make similarity index 94% rename from Make.variables rename to Variables.make index 3d83d00ba7..2d27e3be3f 100644 --- a/Make.variables +++ b/Variables.make @@ -18,7 +18,7 @@ EXTRACXXFLAGS=-pipe -Wall -W -pedantic # version info MAJVER=0 MINVER=0 -PATCHLEVEL=9 +PATCHLEVEL=10 VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) # directories @@ -55,7 +55,7 @@ othersrc=lexer.l parser.y SCRIPTS=make_version make_patch genheader IFILES=dimen.tex symbol.ini kortjakje.ly maartje.ly\ lilyponddefs.tex test.tex .dstreamrc -OFILES=Makefile Make.variables Sources.make COPYING README +OFILES=Makefile Variables.make Sources.make COPYING README DFILES=$(OFILES) $(IFILES) $(SCRIPTS) #compiling diff --git a/flower/Makefile b/flower/Makefile index b39b1f213d..46fb7b5ab4 100644 --- a/flower/Makefile +++ b/flower/Makefile @@ -1,11 +1,11 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=10 +PATCHLEVEL=11 PACKAGENAME=flower VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) DNAME=$(PACKAGENAME)-$(VERSION) -DEFINES=-DNDEBUG -DNPRINT -O2 +DEFINES=-DNDEBUG -O2 #DEFINES=-g CXXFLAGS+=$(DEFINES) -Wall -W -pedantic diff --git a/flower/Sources.make b/flower/Sources.make index 7f2f6441a1..044543beee 100644 --- a/flower/Sources.make +++ b/flower/Sources.make @@ -1,7 +1,7 @@ cc=lgetopt.cc string.cc dataf.cc textdb.cc unionfind.cc \ smat.cc matrix.cc choleski.cc vector.cc dstream.cc\ - matdebug.cc interval.cc + matdebug.cc interval.cc scalar.cc templatecc=cursor.cc list.cc tsmat.cc plist.cc inl=findcurs.inl link.inl list.inl cursor.inl plist.inl @@ -10,5 +10,5 @@ hh=cursor.hh pcursor.hh lgetopt.hh link.hh list.hh dstream.hh \ findcurs.hh unionfind.hh compare.hh handle.hh matrix.hh\ smat.hh vsmat.hh vector.hh real.hh choleski.hh\ tsmat.hh tvsmat.hh plist.hh associter.hh fproto.hh\ - interval.hh + interval.hh scalar.hh diff --git a/flower/dstream.cc b/flower/dstream.cc index 6cfc62eb3d..b4267f3502 100644 --- a/flower/dstream.cc +++ b/flower/dstream.cc @@ -1,7 +1,7 @@ #include #include "assoc.hh" #include "dstream.hh" -#include "string.hh" +#include "scalar.hh" #include "textdb.hh" /// indent of each level @@ -118,7 +118,7 @@ Dstream::Dstream(ostream *r, const char * cfg_nm ) r.message("not enough fields in Dstream init."); continue; } - (*silent)[r[0]] = r[1].to_bool(); + (*silent)[r[0]] = Scalar(r[1]).to_bool(); } } diff --git a/flower/fproto.hh b/flower/fproto.hh index 5241a13dd0..672a992dc9 100644 --- a/flower/fproto.hh +++ b/flower/fproto.hh @@ -34,5 +34,6 @@ struct Vector ; class Text_stream; class Data_file ; struct Text_db; +struct Scalar; #endif // FPROTO_HH diff --git a/flower/handle.hh b/flower/handle.hh index 32573998f2..921dc6031c 100644 --- a/flower/handle.hh +++ b/flower/handle.hh @@ -16,7 +16,7 @@ class Handle { refs = 0; } /// point to new object. - void up(T *t, int *r=0) { + void up(T *t, int *r) { if (!r) { refs = new int; *refs = 1; diff --git a/flower/plist.cc b/flower/plist.cc index 5c8e47093c..2581d24279 100644 --- a/flower/plist.cc +++ b/flower/plist.cc @@ -10,3 +10,13 @@ IPointerList::remove(PCursor me ) List::remove(me); } } +template +PCursor +PointerList::find(T what ) const +{ + PCursor i(*this); + for (; i.ok(); i++) + if (i.ptr() == what) + break; + return i; +} diff --git a/flower/plist.hh b/flower/plist.hh index ea2c0ecdae..704a883f83 100644 --- a/flower/plist.hh +++ b/flower/plist.hh @@ -16,8 +16,8 @@ class PointerList : public List public: PCursor top() { return PCursor (List::top()); } PCursor bottom() { return PCursor (List::bottom()); } + PCursor find(T) const; void concatenate(PointerList const &s) { List::concatenate(s); } -// PointerList( const T& thing ) : List( thing ) { } PointerList() {} }; diff --git a/flower/scalar.cc b/flower/scalar.cc new file mode 100644 index 0000000000..b53693928f --- /dev/null +++ b/flower/scalar.cc @@ -0,0 +1,38 @@ +#include +#include "scalar.hh" + +bool +Scalar::isnum() +{ + int conv = false; + if (len()) { + long l =0; + conv = sscanf(data, "%ld", &l); + } + return len() && conv; +} + +Scalar::operator Real() +{ + assert (isnum()); + return fvalue(); +} + +Scalar::operator int() +{ + assert (isnum()); + return value(); +} +bool +Scalar::to_bool() const +{ + if (!len()) + return false; + if (*this == "0") + return false; + String u (*this); + u.upper(); + if (u== "FALSE") + return false; + return true; +} diff --git a/flower/scalar.hh b/flower/scalar.hh new file mode 100644 index 0000000000..5d02d6936c --- /dev/null +++ b/flower/scalar.hh @@ -0,0 +1,32 @@ +/* + scalar.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef SCALAR_HH +#define SCALAR_HH +#include "string.hh" +#include "real.hh" + +/// Perl -like scalar type. +struct Scalar : public String { + + Scalar(Real r) : String(r) {} + Scalar(int i) : String(i) {} + Scalar(char c) : String(c) {} + Scalar(const char *c) : String(c) {} + Scalar(String s ):String(s) {} + Scalar() {} + bool isnum(); + operator Real(); + operator int(); + /// + bool to_bool() const; + /** perl -like string to bool conversion + */ + +}; + +#endif // SCALAR_HH + diff --git a/flower/string.cc b/flower/string.cc index 2e8e8bf5c6..9c6792c021 100644 --- a/flower/string.cc +++ b/flower/string.cc @@ -12,9 +12,10 @@ #include #include #include -//#include "globals.hh" + #include "string.hh" + static char* strlwr( char* s ) { char* p = s; @@ -108,41 +109,14 @@ String::String( const int i, const int n, const char c ) // String convd to const char * } - const char* -String::ptr() const +const char* +String::cptr() const { return data; } -#ifdef CENTRAL_OBJECT // everything derived from Sortable object -// comparisons. -int -String::operator ==( const Sortable& test ) const -{ - const String *s = (const String *) &test; - return *this == *s; -} - -int -String::operator &&(const Object& test) const -{ - const String *s = (const String *) &test; - - int i = min( len(), s->len() ); - return ( i > 0 ) ? - ( !strncmp( data, s->data, i ) ) : 0; -} - -int -String::operator >( const Sortable& test ) const -{ - const String *s = (const String *) &test; - return strcmp( data, s->data ) > 0; -} -#endif - // signed comparison, analogous to strcmp; int String::compare( const char* test ) const @@ -386,16 +360,3 @@ String::reversed() const strrev(s); return retval; } -bool -String::to_bool() const -{ - if (!len()) - return false; - if (*this == "0") - return false; - String u (*this); - u.upper(); - if (u== "FALSE") - return false; - return true; -} diff --git a/flower/string.hh b/flower/string.hh index 77912beda2..8008f06394 100644 --- a/flower/string.hh +++ b/flower/string.hh @@ -49,10 +49,11 @@ public: /// return a "new"-ed copy of contents char *copy_array() const; // return a "new"-ed copy of contents - const char *ptr() const; - const char *ptr() { return ((const String *)this)->ptr(); } + const char *cptr() const; + const char *ptr() { return ((const String *)this)->cptr(); } + /// return the data. Don't use for writing the data. - operator const char *() const { return ptr(); } + operator const char *() const { return cptr(); } String operator =( const String & source ) { data = source.data; return *this; } @@ -114,10 +115,6 @@ public: /// the length of the string int len() const; - /// DO NOT MAKE THIS INTO AN OPERATOR - bool to_bool() const; - /** perl -like string to bool conversion - */ }; /** diff --git a/hdr/accidental.hh b/hdr/accidental.hh new file mode 100644 index 0000000000..ba341a30df --- /dev/null +++ b/hdr/accidental.hh @@ -0,0 +1,21 @@ +/* + accidental.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef ACCIDENTAL_HH +#define ACCIDENTAL_HH +#include "item.hh" + +struct Accidental : Item { + int type,pos; + + void preprocess(); + Accidental(int type, int position); + void print()const; +private: + void brew_molecole(); +}; +#endif // ACCIDENTAL_HH + diff --git a/hdr/beam.hh b/hdr/beam.hh index 4cbc2ea0c2..138175d8ec 100644 --- a/hdr/beam.hh +++ b/hdr/beam.hh @@ -8,11 +8,11 @@ #define BEAM_HH #include "proto.hh" #include "spanner.hh" -#include "list.hh" +#include "plist.hh" /// a beam connects multiple stems struct Beam: public Spanner { - List stems; + PointerList stems; Real slope; Real left_pos; /// -1 below heads, +1 above heads. diff --git a/hdr/boxes.hh b/hdr/boxes.hh index 15beb8c372..e3ea69a3bf 100644 --- a/hdr/boxes.hh +++ b/hdr/boxes.hh @@ -42,7 +42,15 @@ struct Interval { 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.min args); +}; +#endif // CLEF_HH + diff --git a/hdr/clefitem.hh b/hdr/clefitem.hh new file mode 100644 index 0000000000..f44dffcea6 --- /dev/null +++ b/hdr/clefitem.hh @@ -0,0 +1,25 @@ + +/* + clefitem.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef CLEFITEM_HH +#define CLEFITEM_HH +#include "item.hh" + + +struct Clef_item : Item { + String type; + int y_off; + + Clef_item(); + void read(Clef); + void read(String); + void preprocess(); +}; + +#endif // CLEFITEM_HH + + diff --git a/hdr/key.hh b/hdr/key.hh new file mode 100644 index 0000000000..c65beea636 --- /dev/null +++ b/hdr/key.hh @@ -0,0 +1,39 @@ +/* + key.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef KEY_HH +#define KEY_HH + +#include "vray.hh" +#include "string.hh" + +class Key { + svec accidentals; + + /****************/ + +public: + svec read(svec ); + svec oldkey_undo(svec); + + Key(); + void set(int i, int acc); + int acc(int i) { return accidentals[i]; } +}; + +struct Local_key +{ + void reset(Key); + Key& oct(int); + Local_key(); + +private: + svec octaves; +}; + +#endif // KEY_HH + + diff --git a/hdr/keyitem.hh b/hdr/keyitem.hh new file mode 100644 index 0000000000..d5b159368b --- /dev/null +++ b/hdr/keyitem.hh @@ -0,0 +1,27 @@ +/* + keyitem.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef KEYITEM_HH +#define KEYITEM_HH + +#include "item.hh" + +struct Keyitem : Item { + svec pitch; + svec acc; + int c_position; + + /****************/ + + Keyitem(int cposition); + void add(int pitch, int acc); + void read(svec k); + void preprocess(); + +private: + void brew_molecole(); +}; +#endif // KEYITEM_HH diff --git a/hdr/localkeyitem.hh b/hdr/localkeyitem.hh new file mode 100644 index 0000000000..5b045c93ae --- /dev/null +++ b/hdr/localkeyitem.hh @@ -0,0 +1,33 @@ +/* + localkeyitem.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef LOCALKEYITEM_HH +#define LOCALKEYITEM_HH +#include "item.hh" + +struct Local_acc { + int name , acc, octave; + static int compare(Local_acc&, Local_acc&); +}; + +struct Local_key_item : Item { + svec accs; + + int c0_position; + + /****************/ + + Local_key_item(int c0position); + void add(int oct, int pitch, int acc); + + void preprocess(); + +private: + void brew_molecole(); + +}; +#endif // LOCALKEYITEM_HH + diff --git a/hdr/lookup.hh b/hdr/lookup.hh index 6bf89c0093..5be2b25464 100644 --- a/hdr/lookup.hh +++ b/hdr/lookup.hh @@ -27,10 +27,11 @@ struct Lookup { */ Symbol rule_symbol(Real height, Real width); - + Symbol accidental(int); Symbol ball(int); Symbol flag(int); Symbol rest(int); + Symbol clef(String); Symbol bar(String); Symbol dots(int); Lookup(); diff --git a/hdr/melodicstaff.hh b/hdr/melodicstaff.hh index b447102de6..d97bfb17f8 100644 --- a/hdr/melodicstaff.hh +++ b/hdr/melodicstaff.hh @@ -17,9 +17,10 @@ struct Melodic_staff : public Simple_staff virtual void set_output(PScore *); virtual Melodic_staff*clone()const; - + virtual Item* get_TYPESET_item(Command*); virtual Stem * get_stem(Stem_req *rq); - virtual Notehead * get_notehead(Note_req *rq); + virtual Notehead * get_notehead(Note_req *rq, int bot); + virtual Local_key_item* get_local_key_item(); }; #endif // MELODICSTAFF_HH diff --git a/hdr/molecule.hh b/hdr/molecule.hh index 0c69f74040..35060bd92a 100644 --- a/hdr/molecule.hh +++ b/hdr/molecule.hh @@ -25,7 +25,7 @@ struct Atom { /// a group of #Atom#s struct Molecule { - PointerList ats; + IPointerList ats; Molecule() { } Molecule(Atom a) { add(a) ; } diff --git a/hdr/parseconstruct.hh b/hdr/parseconstruct.hh index 259303e1a8..81401852bc 100644 --- a/hdr/parseconstruct.hh +++ b/hdr/parseconstruct.hh @@ -10,8 +10,10 @@ Voice_element * get_note_element(String,String); Voice_element* get_rest_element(String,String); Command * get_bar_command(Real); Staff * get_new_melodicstaff(); +void add_requests( Voice_element*v, svec&req); Command* get_meterchange_command( int,int); Command* get_meter_command( Real,int,int); Command* get_skip_command( int,Real); +Command* get_key_interpret_command(svec); Request* get_request(char); -void add_requests( Voice_element*v, svec&req); +Command*get_clef_interpret_command(String w); diff --git a/hdr/pcol.hh b/hdr/pcol.hh index fa9516edb4..7cbf93f2ab 100644 --- a/hdr/pcol.hh +++ b/hdr/pcol.hh @@ -8,8 +8,8 @@ /// stuff grouped vertically. struct PCol { - List its; - List stoppers, starters; + PointerList its; + PointerList stoppers, starters; /// Can this be broken? true eg. for bars. bool breakable()const; @@ -38,11 +38,11 @@ struct PCol { /// if lines are broken then this column x-coord #hpos# Real hpos; - + /****************************************************************/ - void add(Item*i); - + void add(Item *i); + Interval width() const; ~PCol(); PCol(PCol * parent); diff --git a/hdr/proto.hh b/hdr/proto.hh index d674ca429a..f80b7f8d0a 100644 --- a/hdr/proto.hh +++ b/hdr/proto.hh @@ -89,5 +89,13 @@ struct Stem; struct Notehead; struct Beam; struct Rest; +struct Accidental; +struct Key; +struct Local_key; +struct Keyitem; +struct Local_key_item; +struct Clef; +struct Clef_item; + #endif // PROTO_HH diff --git a/hdr/pscore.hh b/hdr/pscore.hh index 70e783c889..c434f5b700 100644 --- a/hdr/pscore.hh +++ b/hdr/pscore.hh @@ -13,22 +13,22 @@ struct PScore { Paperdef *paper_; // indirection. /// the columns, ordered left to right - PointerList cols; + IPointerList cols; /// the idealspacings, no particular order - PointerList suz; + IPointerList suz; /// the staffs ordered top to bottom - PointerList staffs; + IPointerList staffs; /// all symbols in score. No particular order. - PointerList its; + IPointerList its; /// if broken, the different lines - PointerList lines; + IPointerList lines; /// crescs etc; no particular order - PointerList spanners; + IPointerList spanners; /****************************************************************/ diff --git a/hdr/pstaff.hh b/hdr/pstaff.hh index bf33c6b437..d3057af5e9 100644 --- a/hdr/pstaff.hh +++ b/hdr/pstaff.hh @@ -10,11 +10,12 @@ struct PStaff { Parametric_symbol *stafsym; PScore * pscore_; - virtual Symbol get_stafsym(Real width)const=0; // maybe overkill - - List spans; - List its; + + PointerList spans; + PointerList its; + /****************/ + virtual Symbol get_stafsym(Real width)const=0; // maybe overkill void add(Item*i); PStaff(PScore*); virtual ~PStaff() {} diff --git a/hdr/rhythmstaff.hh b/hdr/rhythmstaff.hh index 46c35107d2..b402584fde 100644 --- a/hdr/rhythmstaff.hh +++ b/hdr/rhythmstaff.hh @@ -17,7 +17,7 @@ struct Rhythmic_staff : public Simple_staff virtual Item *get_TYPESET_item(Command*); virtual Stem *get_stem(Stem_req *rq); - virtual Notehead * get_notehead(Note_req *rq); + virtual Notehead * get_notehead(Note_req *rq, int b); virtual void set_output(PScore *); virtual Rhythmic_staff*clone()const; }; diff --git a/hdr/sccol.hh b/hdr/sccol.hh index f18b659e7e..44f3fbb16d 100644 --- a/hdr/sccol.hh +++ b/hdr/sccol.hh @@ -12,7 +12,7 @@ struct Score_column { /// indirection to column - PCol * pcol; + PCol * pcol_; /// length of notes/rests in this column svec durations; @@ -28,7 +28,7 @@ struct Score_column { return sgn(c1.when - c2.when); } void set_breakable() { - pcol->set_breakable(); + pcol_->set_breakable(); } bool used(); void print() const; diff --git a/hdr/scommands.hh b/hdr/scommands.hh index ae908d7647..110c656368 100644 --- a/hdr/scommands.hh +++ b/hdr/scommands.hh @@ -10,11 +10,11 @@ #include "plist.hh" /// the list of commands in Score -struct Score_commands : public PointerList { +struct Score_commands : public IPointerList { void process_add(Command); Score_commands*parse(Real last)const; void parser_add(Command*); - void add_seq(svec); + void add_seq(svec,bool); void clean(Real last); void set_breakable(Real when); bool is_breakable(Real w); diff --git a/hdr/score.hh b/hdr/score.hh index 176d7fa47a..ea1ef93c23 100644 --- a/hdr/score.hh +++ b/hdr/score.hh @@ -9,11 +9,11 @@ struct Score { /// paper_, staffs_ and commands_ form the problem definition. Paperdef *paper_; - PointerList staffs_; + IPointerList staffs_; Score_commands *commands_; /// "runtime" fields for setting up spacing - PointerList cols_; + IPointerList cols_; PScore *pscore_; /****************************************************************/ diff --git a/hdr/scoreline.hh b/hdr/scoreline.hh index 3da47d30dc..a8ae77a222 100644 --- a/hdr/scoreline.hh +++ b/hdr/scoreline.hh @@ -13,10 +13,10 @@ /// the columns of a score that form one line. struct Line_of_score { - List cols; + PointerList cols; // need to store height of each staff. - PointerList staffs; + IPointerList staffs; const PScore * score; // needed to generate staffs /****************/ diff --git a/hdr/simplestaff.hh b/hdr/simplestaff.hh index c5c025a166..e4c600ba1b 100644 --- a/hdr/simplestaff.hh +++ b/hdr/simplestaff.hh @@ -7,9 +7,11 @@ #ifndef SIMPLESTAFF_HH #define SIMPLESTAFF_HH +#include "key.hh" #include "stcol.hh" #include "staff.hh" #include "swalker.hh" + /* mega-stupido staffs and cols: they do notes one at each moment. */ @@ -24,9 +26,12 @@ struct Simple_column : Staff_column { Beam_req *beam_; Simple_staff* staff_; + /****************/ - virtual void typeset_item(Item *, int=1); + void typeset_item(Item *, int=1); + + void typeset_item_directional(Item *, int dir, int=1); Molecule *create_command_mol(Command *com); @@ -47,9 +52,10 @@ struct Simple_staff : Staff { virtual Item *get_TYPESET_item(Command*); virtual Stem *get_stem(Stem_req *rq)=0; - virtual Notehead *get_notehead(Note_req *rq)=0; + virtual Notehead *get_notehead(Note_req *rq, int b)=0; virtual Rest *get_rest(Rest_req *rq); virtual void set_output(PScore *); + virtual Local_key_item* get_local_key_item(); void process_commands( PCursor &where); virtual void walk(); @@ -57,21 +63,6 @@ struct Simple_staff : Staff { Simple_staff(); }; -struct Simple_walker: Staff_walker { - Stem *stem_; - svecnoteheads; - Beam *beam_; - - /****************/ - - virtual void process_command(Command*); - virtual void process_requests(); - Simple_walker(Simple_staff*); - Simple_column *col(); - Simple_staff *staff(); -}; - - #endif // SIMPLESTAFF_HH diff --git a/hdr/simplewalker.hh b/hdr/simplewalker.hh new file mode 100644 index 0000000000..5f27957aca --- /dev/null +++ b/hdr/simplewalker.hh @@ -0,0 +1,44 @@ +/* + simplewalker.hh -- part of LilyPond + + (c) 1996 Han-Wen Nienhuys +*/ + +#ifndef SIMPLEWALKER_HH +#define SIMPLEWALKER_HH + +#include "proto.hh" + +struct Simple_walker: Staff_walker { + Stem *stem_; + svecnoteheads; + Local_key local_key_; + Key key_; + svec *oldkey_undo; + svec typesetkey; + Beam *beam_; + Local_key_item *local_key_item_; + bool wantkey; // urgh + bool processed_key; + bool processed_clef; + Clef clef_; + + /****************/ + + virtual void do_TYPESET_command(Command*); + virtual void do_INTERPRET_command(Command*); + virtual void process_requests(); + virtual void reset(); + + void do_notes(); + Simple_walker(Simple_staff*); + Simple_column *col(); + Simple_staff *staff(); + + void do_local_key(Note_req*n); +}; + + +#endif // SIMPLEWALKER_HH + + diff --git a/hdr/staff.hh b/hdr/staff.hh index ee95864fa9..a2ac99ed03 100644 --- a/hdr/staff.hh +++ b/hdr/staff.hh @@ -9,13 +9,13 @@ /// base class for a collection of voices. struct Staff { /// synchronous horizontal stuff - PointerList voices; + IPointerList voices; /// commands in chronological order - PointerList commands; + IPointerList commands; /// runtime field - PointerList cols; + IPointerList cols; /// indirections to the Score and PScore Score *score_; diff --git a/hdr/staffline.hh b/hdr/staffline.hh index a04078923c..be5a7de42b 100644 --- a/hdr/staffline.hh +++ b/hdr/staffline.hh @@ -15,7 +15,7 @@ /// one broken line of staff. struct Line_of_staff { - PointerList brokenspans; + IPointerList brokenspans; Line_of_score const * scor; const PStaff *pstaff_; diff --git a/hdr/stem.hh b/hdr/stem.hh index 6b7bc55d7d..adce936320 100644 --- a/hdr/stem.hh +++ b/hdr/stem.hh @@ -46,6 +46,7 @@ struct Stem : public Item { void set_default_stemlen(); void set_default_extents(); void postprocess(); + void preprocess(); Stem(int center); void print() const; Interval width() const; diff --git a/hdr/swalker.hh b/hdr/swalker.hh index c00923ff99..da132dd9d6 100644 --- a/hdr/swalker.hh +++ b/hdr/swalker.hh @@ -17,13 +17,19 @@ struct Staff_walker : public PCursor { int break_status; /****************/ + int priority() const; // Command Real when() const; virtual ~Staff_walker(); Staff_walker(Staff*, PScore*); void process() ; - virtual void process_command(Command *)=0; + void process_command(Command *); + void operator++(int); + /// every time ++ is called + virtual void reset()=0; virtual void process_requests()=0; + virtual void do_TYPESET_command(Command*)=0; + virtual void do_INTERPRET_command(Command*)=0 ; }; /** manage run-time info when walking staffcolumns such as: key, diff --git a/hdr/voice.hh b/hdr/voice.hh index 7180ece99e..4e304bb0d9 100644 --- a/hdr/voice.hh +++ b/hdr/voice.hh @@ -7,7 +7,7 @@ /// class for horizontal stuff. struct Voice { - PointerList elts; + IPointerList elts; Real start; /****************/ @@ -34,10 +34,10 @@ struct Voice_element { Real duration; const Voicegroup *group; const Voice *voice; - PointerList reqs; + IPointerList reqs; - List granted_items; - List granted_spanners; + PointerList granted_items; + PointerList granted_spanners; /****************/ diff --git a/kortjakje.ly b/kortjakje.ly index 4c555c88eb..c4c20cf1b7 100644 --- a/kortjakje.ly +++ b/kortjakje.ly @@ -5,17 +5,20 @@ melodie = voice { $ \octave c %%% theme - c c g g a a g2 f f e e d d c2 - %%% var 1 + c c g g a a g2 f f e e d d c2 + g g f f e e d d g g f f e e d d + %%% var 1 c r8 c8 ( ) g r8 g8 ( ) a r8 a8 ( ) g r4 f r8 f8 ( ) e4 r8 e8 ( ) d4 r8 d8 ( ) c4 r4 $ } begeleiding = voice { - $ \octave ``c + $ \octave `c %%% theme - `c c e c f c e c d `b c `a `f `g `c2 + `c c e c f c e c d `b c `a `f `g `c2 + \octave `c + e `g d `g c `g `b `g e `g d `g c `g `b `g %%%% var 1 r8 e8() c r8 e8() c r8 f8()c r8 e8()c r8 d8()`b r8 c8()`a r8 `a8()`f r8 `e8()`c @@ -35,6 +38,11 @@ score { } commands { meter 2 4 - skip 16:0 + clef bass + skip 2:0 + clef violin +% skip 2:0 + skip 32:0 } -} \ No newline at end of file +} + diff --git a/lilyponddefs.tex b/lilyponddefs.tex index 9cf064fee8..be9aada8a2 100644 --- a/lilyponddefs.tex +++ b/lilyponddefs.tex @@ -36,14 +36,18 @@ \mdef\eighthrest{63} \mdef\sixteenthrest{64} \mdef\thirtysecondrest{65} -\mdef\sharp{'065} -\mdef\flat{'063} -\mdef\natural{'067} +\mdef\sharp{52} +\mdef\flat{50} +\mdef\natural{54} +\mdef\sharpsharp{53} +\mdef\flatflat{51} + \mdef\singledot{'00} \mdef\doubledot{'01} \mdef\tripledot{'02} \mdef\mussepline{155} - +\mdef\violinclef{71} +\mdef\bassclef{73} \mdef\deigthflag{45} \mdef\dsixteenthflag{46} @@ -111,6 +115,8 @@ \def\ldoubledot{\kern-6pt\doubledot} \def\ltripledot{\kern-6pt\tripledot} + + \def\stem#1#2{\vrule height#2 depth-#1} \def\placebox#1#2#3{% diff --git a/maartje.ly b/maartje.ly index 4c32f09c9a..928f7b2838 100644 --- a/maartje.ly +++ b/maartje.ly @@ -5,6 +5,14 @@ ritme = rhythmstaff { 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 { $ ''c2.. r8 r4 r8 r16 r32 r32 [d8 e8 f8 g8] [d8 e8 f8 g8] @@ -12,7 +20,7 @@ melodicstaff { a8 b8 'c8 'd8 ''c8 ```c8 c4 c4 c4 c4 \duration 16 `b16 `a16 `g16 `f16 \duration 4 c `b `a `g `f `e `d `c ``b ``a ``g ``f ``e ``d ``c$ - } + start 1.0 } } score { paper { @@ -24,8 +32,12 @@ score { % staff { melody } commands { meter 4 4 + + key $ fis cis gis $ skip 2:0 + key $ $ meter 2 4 + skip 19:0 } } diff --git a/src/accidental.cc b/src/accidental.cc new file mode 100644 index 0000000000..eb3ca7c7e3 --- /dev/null +++ b/src/accidental.cc @@ -0,0 +1,32 @@ +#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 "<dir = dir; } } - +/* + should use minimum energy formulation (cf linespacing) + */ void Beam::solve_slope() { @@ -88,13 +92,14 @@ Beam::solve_slope() left_pos *= dir; slope *= dir; - {Real inter =paper()->interline()/2; - Real unitslope = slope*inter; - - // set beamslope, for setting stems correctly - // ignoring return. - Symbol sy = paper()->lookup_->beam(unitslope, width().length()); - slope =unitslope / inter; + { + Real inter =paper()->interline()/2; + Real unitslope = slope*inter; + + // set beamslope, for setting stems correctly + // ignoring return. + Symbol sy = paper()->lookup_->beam(unitslope, width().length()); + slope =unitslope / inter; } } diff --git a/src/break.cc b/src/break.cc index de9a704984..6cb1d3303b 100644 --- a/src/break.cc +++ b/src/break.cc @@ -100,7 +100,7 @@ PScore::calc_breaking() while (i < breakpoints.sz()) { // add another measure. - while(breakpoints[i] !=curcol){ + while (breakpoints[i] != curcol.ptr()){ current.add(curcol); curcol++; @@ -118,7 +118,7 @@ PScore::calc_breaking() minimum = current; } else { // we're one col too far. i--; - while (curcol != breakpoints[i]) + while (curcol.ptr() != breakpoints[i]) curcol --; break; diff --git a/src/calcideal.cc b/src/calcideal.cc index 8099e0e4c7..051ac4312c 100644 --- a/src/calcideal.cc +++ b/src/calcideal.cc @@ -50,14 +50,14 @@ Score::calc_idealspacing() for (int i=0; i < sc->durations.sz(); i++) { Real d = sc->durations[i]; Real dist = paper_->duration_to_dist(d); - PCol * c2 = find_col(sc->when + d,true)->pcol; - connect_nonmus(sc->pcol, c2, dist); - c2 = find_col(sc->when + d,false)->pcol; - connect_nonmus(sc->pcol, c2, dist); + PCol * c2 = find_col(sc->when + d,true)->pcol_; + connect_nonmus(sc->pcol_, c2, dist); + c2 = find_col(sc->when + d,false)->pcol_; + connect_nonmus(sc->pcol_, c2, dist); } else if (sc->used()) { // ignore empty columns - PCol * c2 = find_col(sc->when,true)->pcol; - connect_nonmus(sc->pcol,c2,0.0); + PCol * c2 = find_col(sc->when,true)->pcol_; + connect_nonmus(sc->pcol_, c2, 0.0); } } } diff --git a/src/clef.cc b/src/clef.cc new file mode 100644 index 0000000000..d12225e8d6 --- /dev/null +++ b/src/clef.cc @@ -0,0 +1,19 @@ +#include "clef.hh" + +Clef::Clef() +{ + clef_type= "violin"; + c0_pos = -2; +} + +void +Clef::read(svec args) +{ + clef_type = args[0]; + if (clef_type == "violin") { + c0_pos=-2; + } else if (clef_type == "bass") { + c0_pos = 10; + } else + assert(false); +} diff --git a/src/clefitem.cc b/src/clefitem.cc new file mode 100644 index 0000000000..796cda389e --- /dev/null +++ b/src/clefitem.cc @@ -0,0 +1,34 @@ +#include "clefitem.hh" +#include "string.hh" +#include "molecule.hh" +#include "paper.hh" +#include "lookup.hh" +#include "clef.hh" + +Clef_item::Clef_item() +{ + read("violin"); +} +void +Clef_item::read(String t) +{ + type = t; + if (type == "violin") + y_off = 2; + if (type == "bass") + y_off = 6; +} +void +Clef_item::read(Clef k) +{ + read(k.clef_type); +} + +void +Clef_item::preprocess() +{ + Symbol s = paper()->lookup_->clef(type); + output = new Molecule(Atom(s)); + output->translate(Offset(0, paper()->interline()/2 * y_off)); +} + diff --git a/src/command.cc b/src/command.cc index 23edf1ec36..19b7aac6d7 100644 --- a/src/command.cc +++ b/src/command.cc @@ -29,6 +29,8 @@ Command::print() const { #ifndef NPRINT mtor << "command at " << when << ", code " << code << " prio " << priority; + if ( isbreak()) + mtor << "(break separator)"; if (args.sz()) { mtor<< " args: "; for (int i = 0; i which) { Command*c = new Command; - c->when = w; - c->code = TYPESET; - c->args.add( "BAR"); - c->args.add( "|"); - c->priority = 100; + c->code = INTERPRET; + c->args= which; + String k("KEY"); + c->args.insert(k,0 ); + c->priority = 200; + return c; +} + +Command* +get_clef_interpret_command(String w) +{ + Command*c = new Command; + c->code = INTERPRET; + c->args.add("CLEF"); + c->args.add(w); + c->priority = 190; + return c; +} + +Command* +get_key_typeset_command(svec which) +{ + Command*c = new Command; + c->code = TYPESET; + c->args = which; + String k("KEY"); + c->args.insert(k,0 ); + c->priority = 70; + return c; +} + +Command * +get_meterchange_command(int n, int m) +{ + Command*c = new Command; + + c->code = INTERPRET; + c->args.add( "METER"); + c->args.add( n ); + c->args.add( m ); + c->priority = 170; // more than bar return c; } @@ -24,20 +61,19 @@ get_meter_command(Real w, int n, int m) c->args.add( "METER"); c->args.add( n ); c->args.add( m ); - c->priority = 50; // less than bar + c->priority = 40; return c; } -Command * -get_meterchange_command(int n, int m) +Command* +get_bar_command(Real w) { Command*c = new Command; - + c->when = w; c->code = INTERPRET; - c->args.add( "METER"); - c->args.add( n ); - c->args.add( m ); - c->priority = 0; // more than bar + c->args.add( "BAR"); + c->args.add( "|"); + c->priority = 170; return c; } @@ -51,7 +87,7 @@ get_skip_command(int n, Real m) c->args.add( "SKIP"); c->args.add( n ); c->args.add( m ); - c->priority = 0; // more than bar + c->priority = 0; return c; } diff --git a/src/key.cc b/src/key.cc new file mode 100644 index 0000000000..303bf10beb --- /dev/null +++ b/src/key.cc @@ -0,0 +1,78 @@ +#include "key.hh" +#include "notename.hh" + +const int OCTAVES=14; +const int ZEROOCTAVE=7; + +Key::Key() +{ + accidentals.set_size(7); + for (int i= 0; i < 7 ; i++) + accidentals[i] = 0; +} + +Local_key::Local_key() +{ + octaves.set_size(OCTAVES); +} + +Key& +Local_key::oct(int i) +{ + return octaves[i+ZEROOCTAVE]; +} + +void +Key::set(int i, int a) +{ + assert(a > -3 && a < 3); + accidentals[i]=a; +} + + +void +Local_key::reset(Key k) +{ + for (int i= 0; i < OCTAVES ; i++) + octaves[i] = k; +} + +svec +Key::read(svec s) +{ + svec newkey; + + for (int i=0; i < s.sz(); i++) { + int large, small; + lookup_notename(large, small, s[i]); + accidentals[large]=small; + + newkey.add(large); + newkey.add(small); + } + return newkey; +} + +svec +Key::oldkey_undo(svec s) +{ + svec oldkey; + svec newkey; + newkey.set_size(7); + for (int i=0; i < newkey.sz(); i++) + newkey[i] = 0; + + for (int i=0; i < s.sz(); i++) { + int large, small; + lookup_notename(large, small, s[i]); + newkey[large] = small; + } + for (int i=0; i < newkey.sz(); i++) + if (accidentals[i] && accidentals[i] != newkey[i]) { + oldkey.add(i); + oldkey.add(0); + } + + + return oldkey; +} diff --git a/src/keyitem.cc b/src/keyitem.cc new file mode 100644 index 0000000000..d02ed700af --- /dev/null +++ b/src/keyitem.cc @@ -0,0 +1,50 @@ +#include "keyitem.hh" +#include "key.hh" +#include "debug.hh" +#include "molecule.hh" +#include "paper.hh" +#include "lookup.hh" + + +Keyitem::Keyitem(int c) +{ + c_position = c; +} + + +void +Keyitem::read(svec s) +{ + for (int i = 0 ; i< s.sz(); ) { + int note = s[i++]; + int acc = s[i++]; + + add(note, acc); + } +} +void +Keyitem::add(int p, int a) +{ + pitch.add(p); + acc.add(a); +} + +void +Keyitem::preprocess() { + brew_molecole(); +} + +void +Keyitem::brew_molecole() +{ + output = new Molecule; + Real inter = paper()->interline()/2; + + 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)); + Molecule m(a); + output->add_right(m); + } +} diff --git a/src/lexer.l b/src/lexer.l index 1e3443e56e..14892c3406 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -86,11 +86,11 @@ REAL [0-9]+(\.[0-9]*)? \$ { BEGIN(INITIAL); return '$'; } -[\[){] { /* parens () are NO mistake */ +[\[{)] { /* parens () are NO mistake */ yylval.c = YYText()[0]; return OPEN_REQUEST_PARENS; } -[\]()}] { /* parens () are NO mistake */ +[\]}(] { /* parens () are NO mistake */ yylval.c = YYText()[0]; return CLOSE_REQUEST_PARENS; } diff --git a/src/localkeyitem.cc b/src/localkeyitem.cc new file mode 100644 index 0000000000..c8c67e76d8 --- /dev/null +++ b/src/localkeyitem.cc @@ -0,0 +1,71 @@ +#include "localkeyitem.hh" +#include "molecule.hh" +#include "lookup.hh" +#include "paper.hh" + +Local_key_item::Local_key_item(int i) +{ + c0_position = i; +} + +void +Local_key_item::add (int o, int p , int a) +{ + Local_acc l; + l.octave = o; + l.name = p; + l.acc = a; + accs.add(l); +} + +void +Local_key_item::preprocess() +{ + brew_molecole(); +} + +void +Local_key_item::brew_molecole() +{ + accs.sort(Local_acc::compare); + + output = new Molecule; + Molecule*octmol = 0; + int lastoct = -100; + for (int i = 0; i < accs.sz(); i++) { + if (accs[i].octave != lastoct) { + if (octmol){ + Real dy =lastoct*7*paper()->interline()/2; + octmol->translate(Offset(0, dy)); + output->add(*octmol); + delete octmol; + } + octmol= new Molecule; + } + lastoct = accs[i].octave; + Symbol s =paper()->lookup_->accidental(accs[i].acc); + Atom a(s); + Real dy = (accs[i].name + c0_position) * paper()->interline()/2; + a.translate(Offset(0,dy)); + + octmol->add_right(a); + } + + if (octmol){ + Real dy =lastoct*7*paper()->interline()/2; + octmol->translate(Offset(0, dy)); + output->add(*octmol); + delete octmol; + } +} + +int +Local_acc::compare(Local_acc&a, Local_acc&b) +{ + if (a.octave - b.octave) + return a.octave - b.octave; + if (a.name - b.name) + return a.name - b.name; + + assert(false); +}; diff --git a/src/lookup.cc b/src/lookup.cc index d0ce3cb743..5eef666525 100644 --- a/src/lookup.cc +++ b/src/lookup.cc @@ -35,6 +35,11 @@ Lookup::rest(int j) { return (*symtables_)("rests")->lookup(String(j)); } +Symbol +Lookup::accidental(int j) +{ + return (*symtables_)("accidentals")->lookup(String(j)); +} Symbol @@ -42,6 +47,13 @@ Lookup::bar(String s) { return (*symtables_)("bars")->lookup(s); } + +Symbol +Lookup::clef(String s) +{ + return (*symtables_)("clefs")->lookup(s); +} + Symbol Lookup::dots(int j) { @@ -114,9 +126,9 @@ 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(-5,"pt"), - convert_dimen(5,"pt")); - s.dim.y = Interval(0, convert_dimen(10,"pt") ); // todo + 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; diff --git a/src/melodicstaff.cc b/src/melodicstaff.cc index 17916d2f22..fc7ccbb8fb 100644 --- a/src/melodicstaff.cc +++ b/src/melodicstaff.cc @@ -1,4 +1,5 @@ #include "melodicstaff.hh" +#include "keyitem.hh" #include "stem.hh" #include "rest.hh" #include "notehead.hh" @@ -7,9 +8,10 @@ #include "linestaff.hh" #include "rhythmstaff.hh" #include "sccol.hh" +#include "localkeyitem.hh" const int NO_LINES=5; -const int BOTTOM_POSITION=2; // e is on bottom line of 5-staff... + void Melodic_staff::set_output(PScore*ps) @@ -20,7 +22,7 @@ Melodic_staff::set_output(PScore*ps) Notehead* -Melodic_staff::get_notehead(Note_req *rq) +Melodic_staff::get_notehead(Note_req *rq, int bottom) { int b = rq->rhythmic()->balltype; int d = rq->rhythmic()->dots; @@ -28,10 +30,18 @@ Melodic_staff::get_notehead(Note_req *rq) Notehead *n =new Notehead((NO_LINES-1)*2); n->balltype =b; n->dots = d; - n->position = rq->note()->height() - BOTTOM_POSITION; + n->position = rq->note()->height() + bottom; return n; } +Item * +Melodic_staff::get_TYPESET_item(Command*com) +{ + if (com->args[0] == "KEY") { + return new Keyitem(NO_LINES); // urgh. + } else + return Simple_staff::get_TYPESET_item(com); +} Stem * Melodic_staff::get_stem(Stem_req*rq) @@ -57,3 +67,9 @@ Melodic_staff::clone()const { return new Melodic_staff(*this); } + +Local_key_item* Melodic_staff::get_local_key_item() +{ + return new Local_key_item(-2); +} + diff --git a/src/note.cc b/src/note.cc index 0041bb7238..1c1a4cb571 100644 --- a/src/note.cc +++ b/src/note.cc @@ -105,10 +105,7 @@ get_note_element(String pitch, String durstr) int oct, pit, acc; bool forceacc; parse_pitch(pitch, i, oct, forceacc, pit, acc); - char nm = pit + 'c'; - if (nm > 'g') - nm += 'a' - 'h'; - rq->name =nm; + rq->name =pit; rq->octave = oct; rq->accidental = acc; diff --git a/src/paper.cc b/src/paper.cc index 8cd98339d4..2b98eef988 100644 --- a/src/paper.cc +++ b/src/paper.cc @@ -31,7 +31,8 @@ Paperdef::Paperdef() parse(); linewidth = convert_dimen(15,"cm"); // in cm for now whole_width= 8*note_width(); - geometric_ = PHI; +// geometric_ = PHI; + geometric_ = sqrt(2); } void @@ -40,8 +41,7 @@ Paperdef::parse() Text_db symini("symbol.ini"); - while (!symini.eof()) { - + while (!symini.eof()) { Text_record r( symini++); if (r[0] == "symboltables") diff --git a/src/parser.y b/src/parser.y index 691d306e78..376df8226d 100644 --- a/src/parser.y +++ b/src/parser.y @@ -36,11 +36,13 @@ svec pre_reqs, post_reqs; Request* request; int i; char c; + svec * strvec; } %token VOICE STAFF SCORE TITLE RHYTHMSTAFF BAR NOTENAME OUTPUT %token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS %token MELODICSTAFF GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND +%token KEY CLEF VIOLIN BASS %token IDENTIFIER %token NEWIDENTIFIER @@ -64,8 +66,8 @@ svec pre_reqs, post_reqs; %type int %type score_commands_block score_commands_body %type post_request pre_request - - +%type pitch_list +%type clef_id %% mudela: /* empty */ @@ -235,7 +237,7 @@ voice_command: ; voice_elt: - PITCH DURATION { + PITCH DURATION { $$ = get_note_element(*$1, *$2); delete $1; delete $2; @@ -253,6 +255,14 @@ voice_elt: } ; +pitch_list: { + $$ = new svec; + } + | pitch_list PITCH { + $$->add(*$2); + delete $2; + } + score_command: SKIP int ':' REAL { $$ = get_skip_command($2, $4); @@ -260,12 +270,23 @@ score_command: | METER int int { $$ = get_meterchange_command($2, $3); } + | KEY '$' pitch_list '$' {/*UGH*/ + $$ = get_key_interpret_command(*$3); + delete $3; + } + | CLEF clef_id { + $$ = get_clef_interpret_command(*$2); + delete $2; + } /* | PARTIALMEASURE REAL { $$ = get_partial_command($2); }*/ ; - +clef_id: + VIOLIN { $$ = new String("violin"); } + | BASS { $$ = new String("bass"); } + ; int: REAL { $$ = int($1); diff --git a/src/pcol.cc b/src/pcol.cc index 902f57bab2..6e3092a0e3 100644 --- a/src/pcol.cc +++ b/src/pcol.cc @@ -92,7 +92,8 @@ PCol::breakable() const return prebreak||postbreak; } -PCol::PCol(PCol *parent) { +PCol::PCol(PCol *parent) +{ daddy = parent; prebreak=0; postbreak=0; @@ -102,10 +103,8 @@ PCol::PCol(PCol *parent) { PCol::~PCol() { - - delete prebreak; - - delete postbreak; + delete prebreak; + delete postbreak; } void @@ -115,4 +114,3 @@ PCol::add( Item *i) i->pcol_ = this; used = true; } - diff --git a/src/pscore.cc b/src/pscore.cc index 8d7067760f..663a14c783 100644 --- a/src/pscore.cc +++ b/src/pscore.cc @@ -51,7 +51,7 @@ PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat) i->preprocess(); - if (c->daddy && c == c->daddy->prebreak) { // makeshift. + if (0 && c->daddy && c == c->daddy->prebreak) { // makeshift. Interval iv (i->width()); if (!iv.empty()) { diff --git a/src/request.cc b/src/request.cc index 9928f62bed..6f3778a66d 100644 --- a/src/request.cc +++ b/src/request.cc @@ -27,7 +27,7 @@ Request::Request() Note_req::Note_req() { - name = 'c'; + name = 0; octave = 0; accidental = 0; forceacc = false; @@ -36,10 +36,7 @@ Note_req::Note_req() int Note_req::height() const { - int s = name -'c'; - if (s < 0) - s+=7; - return s + octave*7; + return name + octave*7; } Rhythmic_req::Rhythmic_req() diff --git a/src/rhythmstaff.cc b/src/rhythmstaff.cc index e584254bfd..c9a7831c1b 100644 --- a/src/rhythmstaff.cc +++ b/src/rhythmstaff.cc @@ -17,14 +17,17 @@ Rhythmic_staff::set_output(PScore*ps) Item * Rhythmic_staff::get_TYPESET_item(Command *com) { + if (com->args[0] == "KEY" || com->args[0] == "CLEF") + return 0; Item *i = Simple_staff::get_TYPESET_item(com); + if (!i) return 0; i->translate(Offset(0, -score_->paper_->standard_height()/2)); return i; } Notehead* -Rhythmic_staff::get_notehead(Note_req *rq) +Rhythmic_staff::get_notehead(Note_req *rq, int) { int b = rq->rhythmic()->balltype; int d = rq->rhythmic()->dots; diff --git a/src/sccol.cc b/src/sccol.cc index 1dfc8f2176..417b967e1c 100644 --- a/src/sccol.cc +++ b/src/sccol.cc @@ -4,13 +4,13 @@ Score_column::Score_column(Real w) { when = w; - pcol = new PCol(0); + pcol_ = new PCol(0); musical = false; } bool Score_column::used() { - return pcol->used; + return pcol_->used; } void @@ -22,7 +22,7 @@ Score_column::print() const for (int i=0; i < durations.sz(); i++) mtor << durations[i] << " "; mtor << "]\n"; - pcol->print(); + pcol_->print(); mtor << "}\n"; #endif } diff --git a/src/scommands.cc b/src/scommands.cc index 7b8c8ed9c5..00830e4115 100644 --- a/src/scommands.cc +++ b/src/scommands.cc @@ -2,6 +2,10 @@ #include "debug.hh" #include "parseconstruct.hh" +/* + ARG! + */ + /* maybe it's time for a "narrowing" cursor? */ @@ -11,34 +15,61 @@ Score_commands::first(Real w) PCursor pc(*this); while (pc.ok() && pc->when < w) pc++; - - return pc; + if (!pc.ok() || pc->when != w) { + Command *c = new Command(w); + c->priority = 10000; + if (!pc.ok()) + pc.add(c); + else + pc.insert(c); + } + + return pc; } +/* + RETURN: pc->when == w && pc.ok + */ PCursor Score_commands::last_insertion(Real w) { - PCursor pc(*this); - while (pc.ok() && pc->when <= w) - pc++; + PCursor pc(first(w)), next(pc); + while (next.ok() && next->when == w) { + pc=next; + next++; + } + if (pc->priority != -10000) { + Command*c = new Command(w); + c->priority = -10000; + pc.add(c); + pc ++; + } + return pc; } +/* + */ void -Score_commands::add_seq(svec com) +Score_commands::add_seq(svec com, bool checkbreak) { if (!com.sz()) return; + Real when = com[0].when; - PCursor pc(last_insertion(when)); - for (int i = 0; i < com.sz(); i++) { - Command *c = new Command(com[i]); - assert(com[i].when == when); - if (!pc.ok()) - pc.add(c); + PCursor begin(first(when)); + PCursor end(last_insertion(when)); + if (checkbreak && is_breakable(when)) { + if (com[0].priority < 0) + while (begin->code != BREAK_END) + begin++; else - pc.insert(c); + while (end->code != BREAK_PRE) + end--; + } + for (int i = 0; i < com.sz(); i++) { + insert_between(com[i], begin, end); } } @@ -58,16 +89,20 @@ Score_commands::set_breakable(Real when) svec seq; Command k(when); + k.priority = 5; k.code = BREAK_PRE; seq.add(k); + k.priority = 4; k.code = BREAK_MIDDLE; seq.add(k); + k.priority = 3; k.code = BREAK_POST; seq.add(k); + k.priority = 2; k.code = BREAK_END; seq.add(k); - add_seq(seq); + add_seq(seq,false); } bool @@ -87,8 +122,9 @@ Score_commands::insert_between(Command victim, PCursor firstc, { assert(last->when==firstc->when); PCursor c(firstc+1); - while (c != last) { // hmm what if !last.ok()? - if (victim.priority > c->priority) { + assert(last.ok()); + while (c < last) { + if (c->priority <= victim.priority) { c.insert(new Command(victim)); return; } @@ -101,6 +137,7 @@ void Score_commands::add_command_to_break(Command pre, Command mid, Command post) { Real w = pre.when; + assert(w >= 0); PCursor c ( first(w)), f(c), l(c); while (!c->isbreak()) @@ -119,9 +156,10 @@ Score_commands::add_command_to_break(Command pre, Command mid, Command post) f = l; while (!c->isbreak()) c++; - l = c++; - insert_between(post, f, l); + l = c++; assert(l.ok() && l->when ==w && l->code == BREAK_END); + + insert_between(post, f, l); } void @@ -135,23 +173,82 @@ Score_commands::process_add(Command c) { bool encapsulate =false; Real w = c.when; + assert(w >= 0); + Command pre(w); Command mid(w); Command post(w); + if (c.code == INTERPRET) + { // UGH + if (c.args[0] == "BAR") { + Command typeset(w); // kut met peren + typeset.code = TYPESET; + typeset.args = c.args; + typeset.priority = 100; + process_add(typeset); + } else if (c.args[0] == "KEY") { + Command typeset(w); + typeset.code = TYPESET; + typeset.args.add("KEY"); + typeset.priority = 70; + process_add(typeset); + } else if (c.args[0] == "CLEF") { + Command typeset(w); + typeset.code = TYPESET; + typeset.args=c.args; + typeset.priority = 90; + process_add(typeset); + } + } + // kut en peer if (c.code == TYPESET) { if (c.args[0] == "BAR") { set_breakable(w); encapsulate = true; mid = c; pre = c; - } + { /* every line a currentkey. */ + Command kc(w); + kc.code =TYPESET; + kc.args.add( "CURRENTKEY"); + kc.priority = 60; + process_add(kc); + } + { /* every line a currentclef. */ + Command kc(w); + kc.code =TYPESET; + kc.args.add( "CURRENTCLEF"); + kc.priority = 80; + process_add(kc); + } + }else if (c.args[0] == "METER" && is_breakable(w)) { encapsulate = true; mid = c; pre = c; post =c; + }else + if( c.args[0] == "KEY" && is_breakable(c.when)) { + encapsulate = true; + mid = c; + pre = c; + post = c; + }else + if (c.args[0] == "CURRENTKEY" && is_breakable(w)) { + post = c; + encapsulate = true; + }else + if (c.args[0] == "CURRENTCLEF" && is_breakable(w)) { + post = c; + encapsulate = true; + }else + if (c.args[0] == "CLEF" && is_breakable(w)) { + encapsulate = true; + post = c; + pre = c; + mid = c; } } @@ -160,7 +257,7 @@ Score_commands::process_add(Command c) else { svec seq; seq.add(c); - add_seq(seq); + add_seq(seq,true); } } @@ -232,9 +329,9 @@ Score_commands::parse(Real l) const Real wholes=0.0; Real stoppos=0.0; - { + { /* all pieces should start with a breakable. */ Command c(0.0); - c.code = TYPESET; + c.code = INTERPRET; c.args.add("BAR"); c.args.add("empty"); nc->process_add(c); @@ -247,6 +344,10 @@ Score_commands::parse(Real l) const measlen = beats_per_meas/Real(one_beat); nc->process_add(*get_meter_command(wholes, beats_per_meas, one_beat)); } + if (cc->args[0] == "KEY"||cc->args[0] == "CLEF") { + cc->when = wholes; + nc->process_add(**cc); + } if (cc->args[0] == "SKIP") { stoppos = wholes + cc->args[1].value() * measlen + cc->args[2].fvalue(); diff --git a/src/score.cc b/src/score.cc index 1df13365f2..6127196174 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(); @@ -155,7 +155,7 @@ Score::do_pcols() { PCursor sc(cols_); for (; sc.ok(); sc++) { - pscore_->add(sc->pcol); + pscore_->add(sc->pcol_); } } Real diff --git a/src/simpleprint.cc b/src/simpleprint.cc index 395396e22b..eb8c80759c 100644 --- a/src/simpleprint.cc +++ b/src/simpleprint.cc @@ -1,13 +1,9 @@ -#include "lookup.hh" +#include "clefitem.hh" #include "request.hh" -#include "beam.hh" #include "pscore.hh" #include "paper.hh" #include "simplestaff.hh" -#include "molecule.hh" #include "sccol.hh" -#include "stem.hh" -#include "notehead.hh" #include "rest.hh" #include "debug.hh" #include "bar.hh" @@ -16,26 +12,73 @@ Item * Simple_staff::get_TYPESET_item(Command *com) { - Item *s; - if (com -> args[0] == "BAR" ) { + Item *s=0; + svec arg( com->args); + String type =arg[0]; + arg.del(0); + if (type == "BAR" ) { s = new Bar(com->args[1]); - } else if (com->args[0] == "METER") { - svec arg( com->args); - arg.del(0); + } else if (type == "METER") { s = new Meter(arg); - } else - assert(false); - + } else if (type == "CLEF") { + s = new Clef_item; + }else{ + WARN << "ignoring TYPESET command for " << type << '\n'; + + } return s; } + +Interval +itemlist_width(const svec &its) +{ + Interval iv; + for (int j =0; j < its.sz(); j++) + iv.unite(its[j]->width()); + return iv; +} + void Simple_column::typeset_item(Item *i, int breakst) { assert(i); - // ugh - staff_->pscore_->typeset_item(i, score_column->pcol, + + staff_->pscore_->typeset_item(i, score_column->pcol_, staff_->theline,breakst); + + if (breakst == BREAK_PRE - BREAK_PRE) { + + svec to_move( + staff_->pscore_->select_items(staff_->theline, + score_column->pcol_->prebreak)); + Interval column_wid = itemlist_width(to_move); + assert(!column_wid.empty()); + + for (int j=0; j < to_move.sz(); j++) { + to_move[j]->translate(Offset(-column_wid.max, 0)); + } + } +} + +void +Simple_column::typeset_item_directional(Item *i, int dir, int breakst) +{ + assert(i); + PCol * c=score_column->pcol_; + if (breakst == 0) + c = c->prebreak; + else if (breakst == 2) + c = c->postbreak; + + svec to_move(staff_->pscore_->select_items(staff_->theline, + c)); + typeset_item(i, breakst); + + Interval column_wid = itemlist_width(to_move); + if (column_wid.empty()) + column_wid = Interval(0,0); + i->translate(Offset(column_wid[dir] - i->width()[-dir], 0)); } void @@ -53,3 +96,10 @@ Simple_staff::get_rest(Rest_req*rq) int d = rq->rhythmic()->dots; return new Rest(b, d); } + +Local_key_item* +Simple_staff::get_local_key_item() +{ + return 0; +} + diff --git a/src/simplestaff.cc b/src/simplestaff.cc index 5150d5478a..21cccabcb1 100644 --- a/src/simplestaff.cc +++ b/src/simplestaff.cc @@ -1,11 +1,12 @@ #include "request.hh" #include "swalker.hh" #include "debug.hh" +#include "clef.hh" #include "staff.hh" #include "command.hh" #include "simplestaff.hh" #include "sccol.hh" - +#include "simplewalker.hh" @@ -50,11 +51,13 @@ Simple_column::process_requests() } } } + Staff_column* Simple_staff::create_col(Score_column*s) { return new Simple_column(s,this); } + void Simple_staff::walk() { diff --git a/src/simplewalker.cc b/src/simplewalker.cc index ad9019ac33..710e486947 100644 --- a/src/simplewalker.cc +++ b/src/simplewalker.cc @@ -1,73 +1,144 @@ #include "request.hh" +#include "clef.hh" #include "beam.hh" #include "pscore.hh" #include "simplestaff.hh" +#include "simplewalker.hh" #include "sccol.hh" #include "stem.hh" #include "notehead.hh" #include "rest.hh" #include "debug.hh" +#include "keyitem.hh" +#include "clefitem.hh" +#include "keyitem.hh" +#include "localkeyitem.hh" void -Simple_walker::process_command(Command*com) +Simple_walker::do_INTERPRET_command(Command*com) { - switch (com->code){ - case BREAK_PRE: - case BREAK_MIDDLE: - case BREAK_POST: - case BREAK_END: - (*this)->score_column->set_breakable(); - break_status = com->code- BREAK_PRE; - break; - case INTERPRET: - break; + if (com->args[0] == "BAR") { + local_key_.reset(key_); + } else if (com->args[0] == "KEY") { + svec s(com->args); + s.del(0); + if (com->when) { + assert(!oldkey_undo); + oldkey_undo = new svec( key_.oldkey_undo(s)); + } - case TYPESET: - { - Item* i = staff()->get_TYPESET_item(com); - col()->typeset_item(i, break_status); + typesetkey = key_.read(s); + local_key_.reset(key_); + } else if (com->args[0] == "CLEF") { + svec s(com->args); + s.del(0); + clef_.read(s); + } else { + WARN << " ignoring INTERPRET command: " << com->args[0]; } - break; - - default : - break; - } } void -Simple_walker::process_requests() +Simple_walker::do_TYPESET_command(Command*com) { - Simple_column*c = col(); - Simple_staff *s = staff(); - if (c->beam_&& c->beam_->spantype == Span_req::START) { - if (beam_) - error("Too many beams"); - beam_ = new Beam; - } + /* ignore these commands if non-default versions have been + processed. */ + if (com->args[0] == "CURRENTKEY") + if (processed_key) + return; + else + com->args[0] = "KEY"; - if (c->stem_) { - stem_ = s->get_stem(c->stem_->stem()); - c->typeset_item(stem_); - } + if (com->args[0] == "CURRENTCLEF") + if (processed_clef) { + return; + } else + com->args[0] = "CLEF"; + + Item* i = staff()->get_TYPESET_item(com); + if (!i) + return; + + if (com->args[0] == "KEY") { + if (oldkey_undo) { + ((Keyitem*) i)->read(*oldkey_undo); + delete oldkey_undo; + oldkey_undo = 0; + } + processed_key = true; + ((Keyitem*) i)->read(typesetkey); // ugh + } + + if (com->args[0] == "CLEF") { + processed_clef =true; + ((Clef_item*)i)->read(clef_); + } + col()->typeset_item_directional(i, 1, break_status); +} + +void +Simple_walker::do_local_key(Note_req*n) +{ + if ( local_key_.oct(n->octave).acc(n->name) != n->accidental) { + if (!local_key_item_) { + local_key_item_ = staff()->get_local_key_item(); + } + + local_key_item_->add(n->octave, n->name, n->accidental); + local_key_.oct(n->octave).set(n->name, n->accidental); + } +} + +void +Simple_walker::do_notes() +{ + 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()) { - Notehead*n = s->get_notehead(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->rest()) { c->typeset_item( s->get_rest(rq->rest()) ); } + } +} + +void +Simple_walker::process_requests() +{ + Simple_column*c = col(); + Simple_staff *s = staff(); + if (c->beam_&& c->beam_->spantype == Span_req::START) { + if (beam_) + error("Too many beams"); + beam_ = new Beam; } + if (c->stem_) { + stem_ = s->get_stem(c->stem_->stem()); + } + do_notes(); + if (beam_) { beam_->add(stem_); } - + if (stem_) { + c->typeset_item(stem_); + /* needed, otherwise placement of + local_key fucks up */ + stem_->set_default_extents(); + } if (c->beam_&& c->beam_->spantype == Span_req::STOP) { pscore_->typeset_spanner(beam_, s->theline); beam_ = 0; @@ -77,6 +148,10 @@ Simple_walker::process_requests() } noteheads.set_size(0); + if (local_key_item_) { + c->typeset_item_directional(local_key_item_, -1); + local_key_item_ = 0; + } if (stem_) { stem_ = 0; } @@ -87,6 +162,13 @@ Simple_walker::Simple_walker(Simple_staff*s) { stem_ = 0; beam_ =0; + oldkey_undo = 0; + + Local_key_item * i = s->get_local_key_item(); + wantkey =i; + delete i; + local_key_item_ = 0; + reset(); } @@ -103,4 +185,9 @@ Simple_walker::col() return (Simple_column*) *(*this); } - +void +Simple_walker::reset() +{ + processed_clef =false; + processed_key = false; +} diff --git a/src/staff.cc b/src/staff.cc index 3a32801b2f..4b3322fcef 100644 --- a/src/staff.cc +++ b/src/staff.cc @@ -36,30 +36,36 @@ Staff::get_col(Real w, bool mus) { Score_column* sc = score_->find_col(w,mus); assert(sc->when == w); - PCursor stc(cols); - for (; stc.ok(); stc++) { - if (*stc->score_column > *sc) // too far + + PCursor i(cols); + for (; i.ok(); i++) { + if (*i->score_column > *sc) // too far break; - if (sc == stc->score_column) - return stc; + if (sc == i->score_column) + return i; } + /* post: *sc > *->score_column || !i.ok() */ Staff_column* newst = create_col(sc); - if (!stc.ok()) { + if (!i.ok()) { cols.bottom().add(newst); return cols.bottom(); } if (mus) { - stc.insert(newst); + i.insert(newst); return newst; } - if ((stc-1)->when() == newst->when()) { - stc--; +// ; assert((i-1).ok()) + // todo! + + // making a fix at 2:30 am, with several beers drunk. + if ((i-1).ok()&& (i-1)->when() == newst->when()) { + i--; } - stc.insert(newst); + i.insert(newst); return newst; } diff --git a/src/stem.cc b/src/stem.cc index fdb47f9755..fb8e410117 100644 --- a/src/stem.cc +++ b/src/stem.cc @@ -113,7 +113,9 @@ Stem::width()const if (!print_flag || ABS(flag) <= 4) return Interval(0,0); // TODO! Paperdef*p= paper(); - return p->lookup_->flag(flag).dim.x; + Interval r(p->lookup_->flag(flag).dim.x); + r+= stem_xoffset; + return r; } void @@ -154,3 +156,10 @@ Stem::hpos()const { return pcol_->hpos + stem_xoffset; } + + +void +Stem::preprocess() +{ + +} diff --git a/src/swalker.cc b/src/swalker.cc index db48fd1f82..54872ec83b 100644 --- a/src/swalker.cc +++ b/src/swalker.cc @@ -1,6 +1,7 @@ #include "request.hh" #include "swalker.hh" #include "stcol.hh" +#include "sccol.hh" Staff_walker::~Staff_walker() {} @@ -30,3 +31,34 @@ Staff_walker::process() process_requests(); } + +void +Staff_walker::process_command(Command*com) +{ + switch (com->code){ + case BREAK_PRE: + case BREAK_MIDDLE: + case BREAK_POST: + case BREAK_END: + (*this)->score_column->set_breakable(); + break_status = com->code- BREAK_PRE; + break; + case INTERPRET: + do_INTERPRET_command(com); + break; + + case TYPESET: + do_TYPESET_command(com); + break; + + default : + break; + } +} + +void +Staff_walker::operator++(int i) +{ + PCursor::operator++(i); + reset(); +} diff --git a/src/table.cc b/src/table.cc index 1f302259e9..f2407904a1 100644 --- a/src/table.cc +++ b/src/table.cc @@ -10,6 +10,7 @@ static Keyword_ent the_key_tab[]={ "voice", VOICE, "rhythmstaff", RHYTHMSTAFF, "melodicstaff", MELODICSTAFF, + "clef", CLEF, "score", SCORE, "bar", BAR, "output", OUTPUT, @@ -20,6 +21,8 @@ static Keyword_ent the_key_tab[]={ "mm", MM, "paper", PAPER, "width", WIDTH, + "violin", VIOLIN, + "bass", BASS, "meter", METER, "unitspace", UNITSPACE, "skip", SKIP, @@ -28,6 +31,7 @@ static Keyword_ent the_key_tab[]={ "staff", STAFF, "geometric", GEOMETRIC, "duration", DURATIONCOMMAND, + "key", KEY, 0,0 } ; diff --git a/src/template1.cc b/src/template1.cc index fd2431130e..e2bae216b6 100644 --- a/src/template1.cc +++ b/src/template1.cc @@ -12,14 +12,14 @@ #include "plist.cc" #include "cursor.cc" -#define PLC_instantiate(a) PL_instantiate(a); PL_instantiate(const a) +#define IPLC_instantiate(a) IPL_instantiate(a); PL_instantiate(const a) -L_instantiate(Stem*); -PLC_instantiate(Line_of_score); -PLC_instantiate(Line_of_staff); -PLC_instantiate(Item); -PLC_instantiate(Spanner); -PLC_instantiate(PStaff); -PLC_instantiate(Idealspacing); -PLC_instantiate(PCol); +IPLC_instantiate(Stem*); +IPLC_instantiate(Line_of_score); +IPLC_instantiate(Line_of_staff); +IPLC_instantiate(Item); +IPLC_instantiate(Spanner); +IPLC_instantiate(PStaff); +IPLC_instantiate(Idealspacing); +IPLC_instantiate(PCol); diff --git a/src/template2.cc b/src/template2.cc index 01695c863f..a4ce99da1f 100644 --- a/src/template2.cc +++ b/src/template2.cc @@ -10,10 +10,11 @@ #include "list.cc" #include "plist.cc" #include "cursor.cc" -PL_instantiate(Score_column); -PL_instantiate(Staff_column); -PL_instantiate(Staff); -PL_instantiate(Voice_element); -PL_instantiate(Voice); + +IPL_instantiate(Score_column); +IPL_instantiate(Staff_column); +IPL_instantiate(Staff); +IPL_instantiate(Voice_element); +IPL_instantiate(Voice); diff --git a/src/template3.cc b/src/template3.cc index 92921bb29a..0042594155 100644 --- a/src/template3.cc +++ b/src/template3.cc @@ -4,9 +4,8 @@ #include "list.cc" #include "plist.cc" #include "cursor.cc" -PL_instantiate(Atom); -PL_instantiate(Command); -PL_instantiate(Request); - - +IPL_instantiate(Atom); +IPL_instantiate(Command); +IPL_instantiate(Request); +L_instantiate(void*); diff --git a/src/voice.cc b/src/voice.cc index 14883e1499..c713822a4b 100644 --- a/src/voice.cc +++ b/src/voice.cc @@ -72,7 +72,7 @@ Voice_element::Voice_element(Voice_element const&src) { duration=src.duration; voice=src.voice; - PointerList__copy(Request*, reqs, src.reqs, clone()); + IPointerList__copy(Request*, reqs, src.reqs, clone()); group=src.group; assert(!granted_items.size() && !granted_spanners.size()); } diff --git a/symbol.ini b/symbol.ini index e1e2f3f2a0..ccebe42afd 100644 --- a/symbol.ini +++ b/symbol.ini @@ -7,15 +7,29 @@ symboltables # 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 +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 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{%} -7pt 7pt 0pt 0pt - botlines \botlines{%} -7pt 7pt 0pt 0pt + toplines \toplines{%} -3pt 9pt 0pt 0pt + botlines \botlines{%} -3pt 9pt 0pt 0pt end table bars @@ -43,7 +57,6 @@ table param meter \generalmeter{%}{%} -3pt 10pt -5pt 5pt linestaf \linestafsym{%}{%} 0pt 0pt 0pt 0pt stem \stem{%}{%} 0pt 0pt 0pt 0pt - end table dots -- 2.39.5