]> git.donarmstrong.com Git - lilypond.git/commitdiff
release: 0.0.10 release/0.0.10
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 4 Dec 1996 22:14:10 +0000 (23:14 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Wed, 4 Dec 1996 22:14:10 +0000 (23:14 +0100)
85 files changed:
Documentation/Makefile
Documentation/commands [new file with mode: 0644]
Make.variables [deleted file]
Makefile
README
Sources.make
Variables.make [new file with mode: 0644]
flower/Makefile
flower/Sources.make
flower/dstream.cc
flower/fproto.hh
flower/handle.hh
flower/plist.cc
flower/plist.hh
flower/scalar.cc [new file with mode: 0644]
flower/scalar.hh [new file with mode: 0644]
flower/string.cc
flower/string.hh
hdr/accidental.hh [new file with mode: 0644]
hdr/beam.hh
hdr/boxes.hh
hdr/clef.hh [new file with mode: 0644]
hdr/clefitem.hh [new file with mode: 0644]
hdr/key.hh [new file with mode: 0644]
hdr/keyitem.hh [new file with mode: 0644]
hdr/localkeyitem.hh [new file with mode: 0644]
hdr/lookup.hh
hdr/melodicstaff.hh
hdr/molecule.hh
hdr/parseconstruct.hh
hdr/pcol.hh
hdr/proto.hh
hdr/pscore.hh
hdr/pstaff.hh
hdr/rhythmstaff.hh
hdr/sccol.hh
hdr/scommands.hh
hdr/score.hh
hdr/scoreline.hh
hdr/simplestaff.hh
hdr/simplewalker.hh [new file with mode: 0644]
hdr/staff.hh
hdr/staffline.hh
hdr/stem.hh
hdr/swalker.hh
hdr/voice.hh
kortjakje.ly
lilyponddefs.tex
maartje.ly
src/accidental.cc [new file with mode: 0644]
src/beam.cc
src/break.cc
src/calcideal.cc
src/clef.cc [new file with mode: 0644]
src/clefitem.cc [new file with mode: 0644]
src/command.cc
src/getcommands.cc
src/key.cc [new file with mode: 0644]
src/keyitem.cc [new file with mode: 0644]
src/lexer.l
src/localkeyitem.cc [new file with mode: 0644]
src/lookup.cc
src/melodicstaff.cc
src/note.cc
src/paper.cc
src/parser.y
src/pcol.cc
src/pscore.cc
src/request.cc
src/rhythmstaff.cc
src/sccol.cc
src/scommands.cc
src/score.cc
src/simpleprint.cc
src/simplestaff.cc
src/simplewalker.cc
src/staff.cc
src/stem.cc
src/swalker.cc
src/table.cc
src/template1.cc
src/template2.cc
src/template3.cc
src/voice.cc
symbol.ini

index e8adae90d7086933eb6c84290ce0b8b11b046902..daf587679e763264d02022409cde17e732733706 100644 (file)
@@ -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 (file)
index 0000000..00d5856
--- /dev/null
@@ -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/Make.variables b/Make.variables
deleted file mode 100644 (file)
index 3d83d00..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-####
-#### USER CONFIGURABLE
-####
-
-# speedy
-#DEFINES=-DNDEBUG -DNPRINT -O2
-
-# lots of debugging info
-DEFINES=-g
-
-# turn off -pipe if linker doesn't support it
-EXTRACXXFLAGS=-pipe -Wall -W  -pedantic 
-
-####
-#### EN USER CONFIGURABLE part.
-####
-
-# version info
-MAJVER=0
-MINVER=0
-PATCHLEVEL=9
-VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
-
-# directories
-TOPDIR  := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
-OBJECTDIR=objects
-HEADERDIR=hdr
-CCDIR=src
-
-vpath %.cc $(CCDIR)
-vpath %.hh $(HEADERDIR)
-vpath %.y $(CCDIR)
-vpath %.l $(CCDIR)
-vpath %.o $(OBJECTDIR)
-
-# 
-#
-include Sources.make
-progdocs=$(hdr) $(mycc)
-gencc=parser.cc lexer.cc
-cc=$(mycc) $(gencc)
-obs=$(cc:.cc=.o) 
-
-
-#dist
-.EXPORT_ALL_VARIABLES:
-
-DOCDIR=docdir
-
-PACKAGENAME=lilypond
-DNAME=$(PACKAGENAME)-$(VERSION)
-
-# distribution files.
-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
-DFILES=$(OFILES) $(IFILES) $(SCRIPTS)
-
-#compiling
-LOADLIBES=-L$(FLOWERDIR) -lflower
-FLOWERDIR=../flower
-
-CXXFLAGS=$(DEFINES) -I$(HEADERDIR) -I$(FLOWERDIR) $(EXTRACXXFLAGS)
-FLEX=flex
-BISON=bison
-exe=$(PACKAGENAME)
-OUTPUT_OPTION=$< -o $@
-DDIR=$(TOPDIR)/$(DNAME)
-SUBDIRS=Documentation $(OBJECTDIR) $(CCDIR) $(HEADERDIR)
index 8f05ad90f839b19f01c0242eb1443df79a895004..4dcc395210a1f8f54211a81023c355e640954930 100644 (file)
--- 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 cfee5ea3c95a4be44240cd2e4e18f1419f9550ef..c3c4cbd23e35bc678db43322d58d9a5798d1716f 100644 (file)
--- 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
index 2894394f94bac0cd36253f0f78adc7ac94371623..61c32fa41c6551d604e6a2c63ac516653f65d492 100644 (file)
@@ -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/Variables.make b/Variables.make
new file mode 100644 (file)
index 0000000..2d27e3b
--- /dev/null
@@ -0,0 +1,71 @@
+####
+#### USER CONFIGURABLE
+####
+
+# speedy
+#DEFINES=-DNDEBUG -DNPRINT -O2
+
+# lots of debugging info
+DEFINES=-g
+
+# turn off -pipe if linker doesn't support it
+EXTRACXXFLAGS=-pipe -Wall -W  -pedantic 
+
+####
+#### EN USER CONFIGURABLE part.
+####
+
+# version info
+MAJVER=0
+MINVER=0
+PATCHLEVEL=10
+VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
+
+# directories
+TOPDIR  := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
+OBJECTDIR=objects
+HEADERDIR=hdr
+CCDIR=src
+
+vpath %.cc $(CCDIR)
+vpath %.hh $(HEADERDIR)
+vpath %.y $(CCDIR)
+vpath %.l $(CCDIR)
+vpath %.o $(OBJECTDIR)
+
+# 
+#
+include Sources.make
+progdocs=$(hdr) $(mycc)
+gencc=parser.cc lexer.cc
+cc=$(mycc) $(gencc)
+obs=$(cc:.cc=.o) 
+
+
+#dist
+.EXPORT_ALL_VARIABLES:
+
+DOCDIR=docdir
+
+PACKAGENAME=lilypond
+DNAME=$(PACKAGENAME)-$(VERSION)
+
+# distribution files.
+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 Variables.make Sources.make COPYING README
+DFILES=$(OFILES) $(IFILES) $(SCRIPTS)
+
+#compiling
+LOADLIBES=-L$(FLOWERDIR) -lflower
+FLOWERDIR=../flower
+
+CXXFLAGS=$(DEFINES) -I$(HEADERDIR) -I$(FLOWERDIR) $(EXTRACXXFLAGS)
+FLEX=flex
+BISON=bison
+exe=$(PACKAGENAME)
+OUTPUT_OPTION=$< -o $@
+DDIR=$(TOPDIR)/$(DNAME)
+SUBDIRS=Documentation $(OBJECTDIR) $(CCDIR) $(HEADERDIR)
index b39b1f213d7685532f2c52bcc85f7350f428c3e1..46fb7b5ab41f0a8805218a92dccc198bff680eba 100644 (file)
@@ -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
 
index 7f2f6441a1d4ec0647dc3260ff1c4af3c32340e7..044543beee9723e6ef6a157b3de9a9c23995b85c 100644 (file)
@@ -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
 
index 6cfc62eb3ded390c3a96555f3a1a9f36e4a6f4ac..b4267f35021cb7cb2b795b41069d624f5f1d9629 100644 (file)
@@ -1,7 +1,7 @@
 #include <fstream.h>
 #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();
     }
 
 }
index 5241a13dd0fc227936eda7285528fd6043fcbcdd..672a992dc99701baf3508104f32e5a2558b0dd52 100644 (file)
@@ -34,5 +34,6 @@ struct Vector  ;
 class Text_stream;
 class Data_file ;
 struct Text_db;
+struct Scalar;
 #endif // FPROTO_HH
 
index 32573998f270c8916ffe1257bfe677ef466875bd..921dc6031c4a1d77e7f55dc15da3f3cdd89c894b 100644 (file)
@@ -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;
index 5c8e47093c9c11799f49b04735db9e13c6749679..2581d24279d75b90447255bb10e7976787fb9b3f 100644 (file)
@@ -10,3 +10,13 @@ IPointerList<T>::remove(PCursor<T> me )
         List<void*>::remove(me); 
     }
 }
+template<class T>
+PCursor<T> 
+PointerList<T>::find(T what ) const
+{
+    PCursor<T> i(*this);
+    for (; i.ok(); i++)
+       if (i.ptr() == what)
+          break;
+    return i;    
+}
index ea2c0ecdae3ea9137c5ebb4c7a77911094b10c1e..704a883f83f488b1397d78c0acd65292109dbef6 100644 (file)
@@ -16,8 +16,8 @@ class PointerList : public List<void *>
  public:
     PCursor<T> top() {  return PCursor<T> (List<void*>::top()); }
     PCursor<T> bottom() { return PCursor<T> (List<void*>::bottom()); }
+    PCursor<T> find(T) const;
     void concatenate(PointerList<T> const &s) { List<void*>::concatenate(s); }
-//    PointerList( const T& thing ) : List<void*>( thing ) { }
     PointerList() {}
 };
 
diff --git a/flower/scalar.cc b/flower/scalar.cc
new file mode 100644 (file)
index 0000000..b536939
--- /dev/null
@@ -0,0 +1,38 @@
+#include <stdio.h>
+#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 (file)
index 0000000..5d02d69
--- /dev/null
@@ -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
+
index 2e8e8bf5c6f33e5f7849fefaf4a1a70c2faee518..9c6792c0217cb86d523e4aa68ba82f077ec63b3b 100644 (file)
 #include <stdio.h>
 #include <ctype.h>
 #include <assert.h>
-//#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;
-}
index 77912beda2f1bd3b79797375d66459a799cecf72..8008f06394f9bb567932a1a205bac356a233d526 100644 (file)
@@ -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 (file)
index 0000000..ba341a3
--- /dev/null
@@ -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
+
index 4cbc2ea0c20d20044b426a5efd1b998ceabe2e6f..138175d8ec536bc33f006899a69fb1fb5e4a92a3 100644 (file)
@@ -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<Stem*> stems;
+    PointerList<Stem*> stems;
     Real slope;
     Real left_pos;
     /// -1 below heads, +1 above heads.
index 15beb8c37201a9ee78056922874497697e00f37e..e3ea69a3bf98563ea0ed6b29f24e3eed86f34cd2 100644 (file)
@@ -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<min)
            min = h.min;
diff --git a/hdr/clef.hh b/hdr/clef.hh
new file mode 100644 (file)
index 0000000..5220696
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+  clef.hh -- part of LilyPond
+
+  (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef CLEF_HH
+#define CLEF_HH
+#include "string.hh"
+#include "vray.hh"
+
+struct Clef {
+    int c0_pos;
+    String clef_type;
+
+    Clef();
+    void read(svec<String> args);    
+};
+#endif // CLEF_HH
+
diff --git a/hdr/clefitem.hh b/hdr/clefitem.hh
new file mode 100644 (file)
index 0000000..f44dffc
--- /dev/null
@@ -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 (file)
index 0000000..c65beea
--- /dev/null
@@ -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<int> accidentals;
+
+    /****************/
+
+public:
+    svec<int> read(svec<String> );
+    svec<int> oldkey_undo(svec<String>);
+
+    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<Key> octaves;
+};
+
+#endif // KEY_HH
+
+
diff --git a/hdr/keyitem.hh b/hdr/keyitem.hh
new file mode 100644 (file)
index 0000000..d5b1593
--- /dev/null
@@ -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<int> pitch;
+    svec<int> acc;
+    int c_position;
+
+    /****************/
+    
+    Keyitem(int cposition);
+    void add(int pitch, int acc);
+    void read(svec<int> k);
+    void preprocess();
+
+private:
+    void brew_molecole();
+};
+#endif // KEYITEM_HH
diff --git a/hdr/localkeyitem.hh b/hdr/localkeyitem.hh
new file mode 100644 (file)
index 0000000..5b045c9
--- /dev/null
@@ -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<Local_acc> 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
+
index 6bf89c0093a68331c5a881755ca6fd9c710898e7..5be2b254644b8b0923fe6b79b1603ac69041ec5e 100644 (file)
@@ -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();
index b447102de6ab4b6abc2172469dd5bebc699a7f33..d97bfb17f8b1bf9fc36d5c83a583dc82270b0401 100644 (file)
@@ -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
index 0c69f74040de1632861c417011340b87ea8ce8f5..35060bd92adf8d3724b3a3573330efca2c4804b3 100644 (file)
@@ -25,7 +25,7 @@ struct Atom {
 
 /// a group of #Atom#s
 struct Molecule {
-    PointerList<Atom*> ats;
+    IPointerList<Atom*> ats;
 
     Molecule() { }
     Molecule(Atom a) { add(a) ; }
index 259303e1a84234000a2e2ef2a0d029fd49749fca..81401852bccd2937c3d2f62b24b4aa4c9d562a7f 100644 (file)
@@ -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<Request*>&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<String>);
 Request* get_request(char);
-void add_requests( Voice_element*v, svec<Request*>&req);
+Command*get_clef_interpret_command(String w);
index fa9516edb4ec145fdf76229ac9791e44d3bc1c94..7cbf93f2ab2fa3e72dbaf4f9f39b11e381ff2623 100644 (file)
@@ -8,8 +8,8 @@
 
 /// stuff grouped vertically.
 struct PCol {
-    List<const Item*> its;
-    List<const Spanner*> stoppers, starters;
+    PointerList<const Item*> its;
+    PointerList<const Spanner*> 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);
index d674ca429aeefbba2c7ac1cc2e47ede7e540d980..f80b7f8d0a17e8eb0fea84a74570fb77a192dce8 100644 (file)
@@ -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
 
index 70e783c889c561b700f49873c49b0b8339cb535f..c434f5b700636ec098dbbffe67fe9c0800c01b64 100644 (file)
@@ -13,22 +13,22 @@ struct PScore {
     Paperdef *paper_;          // indirection.
     
     /// the columns, ordered left to right
-    PointerList<PCol *> cols;
+    IPointerList<PCol *> cols;
 
     /// the idealspacings, no particular order
-    PointerList<Idealspacing*> suz;
+    IPointerList<Idealspacing*> suz;
 
     /// the staffs ordered top to bottom
-    PointerList<PStaff*> staffs;
+    IPointerList<PStaff*> staffs;
 
     /// all symbols in score. No particular order.
-    PointerList<Item*> its;
+    IPointerList<Item*> its;
 
     /// if broken, the different lines
-    PointerList<Line_of_score*> lines;
+    IPointerList<Line_of_score*> lines;
 
     /// crescs etc; no particular order
-    PointerList<Spanner *> spanners;
+    IPointerList<Spanner *> spanners;
 
     /****************************************************************/
 
index bf33c6b4374955b5f32cefec2b76ff0e80321b4d..d3057af5e9ed7c3259d56552563f90d055d3ba1b 100644 (file)
@@ -10,11 +10,12 @@ struct PStaff {
     Parametric_symbol *stafsym;
     PScore * pscore_;
     
-    virtual Symbol get_stafsym(Real width)const=0; // maybe overkill
-
-    List<const Spanner*> spans;
-    List<Item*> its;
+    
+    PointerList<const Spanner*> spans;
+    PointerList<Item*> its;
 
+    /****************/
+    virtual Symbol get_stafsym(Real width)const=0; // maybe overkill
     void add(Item*i);
     PStaff(PScore*);
     virtual ~PStaff() {}
index 46c35107d260949962a4147412e0475a0f9eccf8..b402584fde3c94c3c5a03c5af031a950d11870cf 100644 (file)
@@ -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;
 };
index f18b659e7e65943fc2c36af5c2341b7f20499d53..44f3fbb16deb235c267a266a6bc023a6cd726583 100644 (file)
@@ -12,7 +12,7 @@
 struct Score_column {
 
     /// indirection to column
-    PCol * pcol;
+    PCol * pcol_;
     /// length of notes/rests in this column
     svec<Real> 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;
index ae908d7647d59a2bb6b562d292e46bdcd65350a9..110c6563688775cc09220d10dc42f9c7003396e6 100644 (file)
 #include "plist.hh"
 
 /// the list of commands in Score
-struct Score_commands : public PointerList<Command*> {
+struct Score_commands : public IPointerList<Command*> {
     void process_add(Command);
     Score_commands*parse(Real last)const;
     void parser_add(Command*);
-    void add_seq(svec<Command>);
+    void add_seq(svec<Command>,bool);
     void clean(Real last);
     void set_breakable(Real when);
     bool is_breakable(Real w);
index 176d7fa47a0f7e55f9217eb2666f8c9346e6bf10..ea1ef93c237f35430dbffdc9deb01f9ac11c159f 100644 (file)
@@ -9,11 +9,11 @@
 struct Score {
     /// paper_, staffs_ and commands_ form the problem definition.
     Paperdef *paper_;
-    PointerList<Staff *> staffs_;
+    IPointerList<Staff*> staffs_;
     Score_commands *commands_;
     
     /// "runtime" fields for setting up spacing    
-    PointerList<Score_column*> cols_;
+    IPointerList<Score_column*> cols_;
     PScore *pscore_;
 
     /****************************************************************/
index 3da47d30dc62b2224422d9b7c9b62202895f8309..a8ae77a222f9315a6649787252b2db7588019625 100644 (file)
 /// the columns of a score that form one line.
 struct
 Line_of_score {
-    List<const PCol *> cols;
+    PointerList<const PCol *> cols;
 
     // need to store height of each staff.
-    PointerList<Line_of_staff*> staffs;
+    IPointerList<Line_of_staff*> staffs;
     const PScore * score;      // needed to generate staffs
 
     /****************/
index c5c025a1660aabcb881ca9b097cdcbcb077467ff..e4c600ba1b4503a843d96730382c93654cd36fb7 100644 (file)
@@ -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<Command*> &where);
     virtual void walk();
@@ -57,21 +63,6 @@ struct Simple_staff : Staff {
     Simple_staff();
 };
 
-struct Simple_walker: Staff_walker {
-    Stem *stem_;
-    svec<Notehead *>noteheads;
-    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 (file)
index 0000000..5f27957
--- /dev/null
@@ -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_;
+    svec<Notehead *>noteheads;
+    Local_key local_key_;
+    Key key_;
+    svec<int> *oldkey_undo;
+    svec<int> 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
+
+
index ee95864fa980ef1965a43c452af56d8bcedf37bb..a2ac99ed034b92ca357b100b47bb9eafa2bd5dff 100644 (file)
@@ -9,13 +9,13 @@
 /// base class for a collection of voices.
 struct Staff {
     /// synchronous horizontal stuff
-    PointerList<Voice*> voices;
+    IPointerList<Voice*> voices;
 
     /// commands in chronological order
-    PointerList<Command *> commands;
+    IPointerList<Command *> commands;
 
     /// runtime field
-    PointerList<Staff_column*> cols;
+    IPointerList<Staff_column*> cols;
 
     /// indirections to the Score and PScore
     Score *score_;
index a04078923ccea4c89381a80686e858011c76073d..be5a7de42bf9c87a2ee11bdae28740d3400ada38 100644 (file)
@@ -15,7 +15,7 @@
 
 /// one broken line of staff.
 struct Line_of_staff {
-    PointerList<Spanner *> brokenspans;    
+    IPointerList<Spanner *> brokenspans;    
     Line_of_score const * scor;
     const PStaff *pstaff_;
 
index 6b7bc55d7d0cdaf31c7fa3c2096c150ed677673b..adce936320c5bd2d1b4d20eb8f0ad397af9723d9 100644 (file)
@@ -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;
index c00923ff99079c65d471b4ae2bdfb8b5253e03eb..da132dd9d6275c51fb0e26548ea8c241275f78a4 100644 (file)
@@ -17,13 +17,19 @@ struct Staff_walker : public PCursor<Staff_column*> {
     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,
index 7180ece99ec6af9fd137fa51a291705ba7e11a2c..4e304bb0d90f72dd7e68c03dd9f17502d8491415 100644 (file)
@@ -7,7 +7,7 @@
 
 /// class for  horizontal stuff.
 struct Voice {
-    PointerList<Voice_element *> elts;
+    IPointerList<Voice_element *> elts;
     Real start;
 
     /****************/
@@ -34,10 +34,10 @@ struct Voice_element {
     Real duration;
     const Voicegroup *group;
     const Voice *voice;
-    PointerList<Request*> reqs;
+    IPointerList<Request*> reqs;
 
-    List<const Item *> granted_items;
-    List<const Spanner *> granted_spanners;
+   PointerList<const Item *> granted_items;
+    PointerList<const Spanner *> granted_spanners;
 
     /****************/
     
index 4c555c88eb744c34ba69e34b45e0d62884dacc96..c4c20cf1b7307cbb27a0d4af4010b30679690734 100644 (file)
@@ -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
+}
+
index 9cf064fee846ceb95f86b303a7928d4cb78c2e61..be9aada8a27c6101e32b1804f609fd4cfaadd254 100644 (file)
 \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}
 \def\ldoubledot{\kern-6pt\doubledot}
 \def\ltripledot{\kern-6pt\tripledot}
 
+
+
 \def\stem#1#2{\vrule height#2 depth-#1}
 
 \def\placebox#1#2#3{%
index 4c32f09c9a0ec45024badad17e30a3bdfd4b1c57..928f7b28388639612e5f7afb325dbeb668aca73a 100644 (file)
@@ -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 (file)
index 0000000..eb3ca7c
--- /dev/null
@@ -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 "<<type;
+    Item::print();
+}
index 49214c91f277ad5db850b9b112a2abe6a3fbad30..88dab8992d94d0d1d8853b07f42d3125fab924c6 100644 (file)
@@ -15,6 +15,8 @@ struct Stem_info {
     Real miny;
     int no_beams;
 
+    ///////////////
+    
     Stem_info(){}
     Stem_info(const Stem*);
 };
@@ -58,7 +60,9 @@ Beam::set_default_dir()
        sc->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;
     }
 }
 
index de9a704984ea9efa3ab0dac418fbb5f3054f4486..6cb1d3303b4a4d823aa4bb1c5278f8496b212080 100644 (file)
@@ -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;
index 8099e0e4c71e04f5c9f1eef963b18bc237cc85f8..051ac4312c99be55bf39d4fedb618d5a9f94bc58 100644 (file)
@@ -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 (file)
index 0000000..d12225e
--- /dev/null
@@ -0,0 +1,19 @@
+#include "clef.hh"
+
+Clef::Clef()
+{
+    clef_type= "violin";
+    c0_pos = -2;
+}
+
+void
+Clef::read(svec<String> 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 (file)
index 0000000..796cda3
--- /dev/null
@@ -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));
+}
+
index 23edf1ec36c649ecd7322a893f6e8ea23c9e7b10..19b7aac6d74e616b6a7bd6dd728edb258ab2d41e 100644 (file)
@@ -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<args.sz(); i++)
index 1f9362c59cdd8651da2b37d7c4ba8ba22f18ef9c..04170f582a200b7fcf477d5c71d6279428bf2014 100644 (file)
@@ -2,15 +2,52 @@
 #include "parseconstruct.hh"
 #include "command.hh"
 
+
 Command*
-get_bar_command(Real w)
+get_key_interpret_command(svec<String> 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<String> 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 (file)
index 0000000..303bf10
--- /dev/null
@@ -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<int>
+Key::read(svec<String> s)
+{
+    svec<int> 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<int>
+Key::oldkey_undo(svec<String> s)
+{
+    svec<int> oldkey;
+    svec<int> 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 (file)
index 0000000..d02ed70
--- /dev/null
@@ -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<int> 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);   
+    }    
+}
index 1e3443e56e9b2671f067a1fde2814a4f9d25585c..14892c3406a22542767ae07668bc633010a25d02 100644 (file)
@@ -86,11 +86,11 @@ REAL                [0-9]+(\.[0-9]*)?
 <notes>\$      {
        BEGIN(INITIAL); return '$';
 }
-<notes>[\[){]  { /* parens () are NO mistake */
+<notes>[\[{)]  { /* parens () are NO mistake */
        yylval.c = YYText()[0];
        return OPEN_REQUEST_PARENS;
 }
-<notes>[\]()}] { /* parens () are NO mistake */
+<notes>[\]}(]  { /* 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 (file)
index 0000000..c8c67e7
--- /dev/null
@@ -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);
+};
index d0ce3cb7435954df947dde61da21a3b286f61992..5eef666525b69a631e34814fdcdce17a486300cc 100644 (file)
@@ -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<String> 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;
index 17916d2f228df22d559a269c731d5d806ce67bfb..fc7ccbb8fb9fab09da210465b41d64d83906c41b 100644 (file)
@@ -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);
+}
+
index 0041bb723879d68c5bdb9d793b18cf40b901cc1d..1c1a4cb5718ec175c079a35f39c1b62560b76fe3 100644 (file)
@@ -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;
index 8cd98339d4575baf0ef7e53a2b7ce5ea6bf086cf..2b98eef98850598172b65dcbc9fe104c057c5580 100644 (file)
@@ -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")
index 691d306e7889420a610941a1fdee33ccb05ea437..376df8226d3e2d741af57c28f3b6105e7240954d 100644 (file)
@@ -36,11 +36,13 @@ svec<Request*> pre_reqs, post_reqs;
     Request* request;
     int i;
     char c;
+    svec<String> * 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 <id>  IDENTIFIER
 %token <string> NEWIDENTIFIER 
@@ -64,8 +66,8 @@ svec<Request*> pre_reqs, post_reqs;
 %type <i> int
 %type <scommands> score_commands_block score_commands_body
 %type <request> post_request pre_request
-
-
+%type <strvec> pitch_list
+%type <string> 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<String>;
+       }
+       | 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);
index 902f57bab22bdec8e40025cf5efdbaf77cf0b154..6e3092a0e334f145e20726dd97e4e4bf215b05d0 100644 (file)
@@ -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;
 }
-
index 8d7067760f804c0af1aeb8eafc5e9ac5746ddffa..663a14c783d7d74604c2ac9fa1901ef3ac353b7f 100644 (file)
@@ -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()) {
index 9928f62bed3d1a28c2364074f7d887a854740b8f..6f3778a66d5d0af9730f12f1d0880af70d821d2e 100644 (file)
@@ -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()
index e584254bfd21dd60a457354f9edd9f1e569d934d..c9a7831c1b373fedb672c6d554bb916ecf78af15 100644 (file)
@@ -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;
index 1dfc8f21764c9c898fef527a15071410e42caa3e..417b967e1c94588ed0164aae43b1689fcef3d4df 100644 (file)
@@ -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
 }
index 7b8c8ed9c53bbc185f7afc9975677cdacc6fbf67..00830e4115cd920f9abb00c0c1014163cb8a307c 100644 (file)
@@ -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<Command*> 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<Command*>
 Score_commands::last_insertion(Real w)
 {    
-    PCursor<Command*> pc(*this);    
-    while (pc.ok() && pc->when <= w)
-       pc++;
+    PCursor<Command*> 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<Command> com)
+Score_commands::add_seq(svec<Command> com, bool checkbreak)
 {
     if (!com.sz())
        return;
+    
     Real when = com[0].when;
 
-    PCursor<Command*> 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<Command*> begin(first(when));
+    PCursor<Command*> 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<Command> 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<Command*> firstc,
 {
     assert(last->when==firstc->when);
     PCursor<Command*> 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<Command*> 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<Command> 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();
index 1df13365f22900bf4ebcf957bab1c28e4a3ff57c..61271961743a9ed70e48ce20137abfc4da36dcb6 100644 (file)
@@ -75,7 +75,7 @@ Score::clean_cols()
        sc->clean_cols();
     
     for (PCursor<Score_column*> 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<Score_column*> sc(cols_);
     for (; sc.ok(); sc++) {
-       pscore_->add(sc->pcol);
+       pscore_->add(sc->pcol_);
     }
 }
 Real
index 395396e22b4ec596c5b26e491e25f4d6c5149c98..eb8c80759ce1ea1653f14a53dc008650ec09d2c1 100644 (file)
@@ -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"
 Item *
 Simple_staff::get_TYPESET_item(Command *com)
 {
-    Item *s;
-    if (com -> args[0] ==  "BAR" ) {
+    Item *s=0;
+    svec<String> 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<String> 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<Item*> &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<Item*> 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<Item*> 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;
+}
+
index 5150d5478aefef8914c41e7ac1b6cfcd84e41a64..21cccabcb135abcebd9e81740ed9af9dedd6fe30 100644 (file)
@@ -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()
 {
index ad9019ac3369ece76f8999f2c2da80768e78e221..710e48694789797b97a444ca201e01a31e9d4fef 100644 (file)
 #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<String> s(com->args);
+       s.del(0);
+       if (com->when) {
+           assert(!oldkey_undo);
+           oldkey_undo = new svec<int>( 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<String> 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;
+}
index 3a32801b2f33b1d65bba1275fa01555ff317a6ef..4b3322fcef00f4d8244d8e3a485f2d0d657e3f80 100644 (file)
@@ -36,30 +36,36 @@ Staff::get_col(Real w, bool mus)
 {
     Score_column* sc = score_->find_col(w,mus);
     assert(sc->when == w);
-    PCursor<Staff_column *> stc(cols);
-    for (; stc.ok(); stc++) {
-       if (*stc->score_column > *sc) // too far
+    
+    PCursor<Staff_column *> 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;
 }
index fdb47f97556d77d6e34eba83504eb6f2ed87993a..fb8e410117babe727c60b56a0e31e8bee686b89d 100644 (file)
@@ -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()
+{
+}
index db48fd1f8241e6d98683def24109780c0d380ef7..54872ec83bae2f88266064d5d3329742a0a19d50 100644 (file)
@@ -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<Staff_column*>::operator++(i);
+    reset();
+}
index 1f302259e9f500920f8bd91d470276bd1491a633..f2407904a186f30d7742e0c73e52a3fd88b03d39 100644 (file)
@@ -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
 } ;
 
index fd2431130e1ef1e0135e124d61f629f7caee3a37..e2bae216b66cdb790636b94fc61deb9698f4990e 100644 (file)
 #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);
 
index 01695c863fa07ef2143d18d97bfbf708652b86e8..a4ce99da1fac3421f17a24d02d97a332e78071d2 100644 (file)
 #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);
 
 
index 92921bb29a897b9c7c20bb1f8249df15f39b984a..00425941557697c1d7b088e5dc99d2c61eabb24f 100644 (file)
@@ -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*);
index 14883e149966d9997b6029168cd9e297cfb1c1ec..c713822a4b26c5eb21dae28a58f7d3186ee014c7 100644 (file)
@@ -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());
 }
index e1e2f3f2a01ff84aafc5cd8eb1dd1a11e0d99031..ccebe42afd5f8275eb6fa42334ef9e08e1fab5d6 100644 (file)
@@ -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