]> git.donarmstrong.com Git - lilypond.git/commitdiff
release: 0.0.7 release/0.0.7
authorHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 18 Nov 1996 23:38:26 +0000 (00:38 +0100)
committerHan-Wen Nienhuys <hanwen@xs4all.nl>
Mon, 18 Nov 1996 23:38:26 +0000 (00:38 +0100)
55 files changed:
Makefile
README
Sources.make
TODO
debug.cc
flower/Makefile
flower/Sources.make
flower/TODO
flower/compare.hh
flower/cursor.hh
flower/cursor.inl
flower/list.cc
flower/list.hh
flower/list.inl
flower/pcursor.hh
flower/plist.cc
flower/plist.hh
flower/plist.inl
flower/vray.hh
item.cc
item.hh
lexer.l
lilyponddefs.tex
line.cc
line.hh
lookupsyms.cc
lookupsyms.hh
maartje.ly
main.cc
make_patch
melodicstaff.cc
melodicstaff.hh
molecule.cc
note.cc
paper.cc
paper.hh
parser.y
request.cc
request.hh
rhythmstaff.cc
rhythmstaff.hh
scores.cc
simpleprint.cc
simplestaff.cc
simplestaff.hh
spanner.cc [new file with mode: 0644]
spanner.hh [new file with mode: 0644]
stem.cc [new file with mode: 0644]
stem.hh [new file with mode: 0644]
symbol.ini
symtable.cc
template1.cc
template2.cc
voice.cc
voice.hh

index c85f6fd2ff33d249e78ea2673d1050cfcaeb2782..4f747e6c954ac1d85b406f10360717a73e26aa45 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 MAJVER=0
 MINVER=0
-PATCHLEVEL=6
+PATCHLEVEL=7
 
 # 
 #
diff --git a/README b/README
index b60e7f2bbdd333c9876a0a9f1e9d724f8a1df7f9..41c366eec380fc3c6207ba903dd05b778f3b38e6 100644 (file)
--- a/README
+++ b/README
@@ -19,6 +19,8 @@ You will need GNU C++ v2.7 or better and GNU make.  If you actually
 want to use this, you'd better use the "speedy" compilation flags in
 the Makefile.
 
+why G++ >= 2.7? LilyPond & flower lib uses builtin bool and typeof.
+
 USING
 
 No, you shouldn't. Really. If you're still not discouraged; this is
index deb1a524c45e2918d6d73925115ed9efc87bd58d..fcc62df96c5c4c0a8e3bf02d557dbf225091c110 100644 (file)
@@ -10,7 +10,7 @@ hdr=    qlp.hh linespace.hh qlpsolve.hh\
        misc.hh score.hh notename.hh lexer.hh symtable.hh\
        symbol.hh main.hh dimen.hh paper.hh lookupsyms.hh\
        sccol.hh stcol.hh scommands.hh melodicstaff.hh\
-       identifier.hh simplestaff.hh
+       identifier.hh simplestaff.hh spanner.hh stem.hh
 
 mycc=   qlp.cc qlpsolve.cc \
        break.cc linespace.cc molecule.cc line.cc\
@@ -19,9 +19,11 @@ mycc=   qlp.cc qlpsolve.cc \
        symbol.cc request.cc notename.cc  voice.cc\
        keyword.cc linestaff.cc table.cc command.cc\
        warn.cc debug.cc symtable.cc boxes.cc\
-       pstaff.cc  tstream.cc version.cc\
+       pstaff.cc  tstream.cc\
        calcideal.cc scores.cc identifier.cc \
        dimen.cc paper.cc lookupsyms.cc scommands.cc\
        sccol.cc stcol.cc getcommands.cc simplestaff.cc\
-       melodicstaff.cc simpleprint.cc\
-       template1.cc template2.cc template3.cc
+       melodicstaff.cc simpleprint.cc stem.cc\
+       spanner.cc\
+       template1.cc template2.cc template3.cc\
+       version.cc
\ No newline at end of file
diff --git a/TODO b/TODO
index d60c09dbb723301fdf14310a190418bab04184bb..1f96a09b767ffd26ae1c4566bfcd6385a2fad4ba 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,13 @@
-fonttables -> fontdims
-clear IDENTIFIERs
-Paperdef -> fontsize .
-beam + stem
+       * clefs
 
+       * beam
 
+       * fonttables -> fontdims
+
+       * clear IDENTIFIERs
+
+       * Paperdef -> fontsize .
+
+       * merge Paper, Lookup, Outputfile, and Symtable.
+
+       * all places in the code marked TODO! and ugh/ARGH
index 34859a3c9f70c93242c47e6a4b1589198f816229..d55c90194598e28ce16802aa9abd58e3ef8fd7f2 100644 (file)
--- a/debug.cc
+++ b/debug.cc
@@ -1,12 +1,27 @@
 #include <fstream.h>
+#include <std/new.h>
 #include "debug.hh"
 #include "dstream.hh"
 #include "vector.hh"
 
 Dstream monitor(&cout,".dstreamrc");
 ostream * nulldev = new ofstream("/dev/null");
+
+
+/*
+  want to do a stacktrace .
+  */
+void
+mynewhandler()
+{
+    cerr << "Out of free store memory. Aborting.. "<< flush;
+    assert(false);
+}
+
+
 void
 debug_init()
 {
+    set_new_handler(&mynewhandler);
     set_matrix_debug(monitor);
 }   
index 3e9a70ce15c656506105fa5cbe739664a9ca2bbf..e17cbdb0d8bf9611672ec778fcc97d09a1dc87bc 100644 (file)
@@ -1,6 +1,6 @@
 MAJVER=1
 MINVER=0
-PATCHLEVEL=6
+PATCHLEVEL=7
 
 PACKAGENAME=flower
 VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
index e8b2250ad199c7f4a3e8d97fab79957e8e3af58c..8016e6732358669f9692b5624a265c724e50b9d6 100644 (file)
@@ -4,7 +4,7 @@ cc=lgetopt.cc    string.cc dataf.cc textdb.cc unionfind.cc  \
        matdebug.cc 
 
 templatecc=cursor.cc list.cc tsmat.cc plist.cc
-inl=findcurs.inl link.inl list.inl plist.inl cursor.inl 
+inl=findcurs.inl link.inl list.inl  cursor.inl plist.inl
 hh=cursor.hh pcursor.hh lgetopt.hh link.hh list.hh dstream.hh \
        string.hh stringutil.hh vray.hh textdb.hh textstr.hh  assoc.hh\
        findcurs.hh unionfind.hh compare.hh handle.hh matrix.hh\
index f7070ecd07f59e2e73b0822fb56c0fce08dab805..4d0774ff7c56a71253124feb6937d41553d5d3a9 100644 (file)
@@ -1,7 +1,7 @@
-       * PointerList<T>:List<T> -> PointerList<T>:List<T*>
-
        * PCursor -> Pointer_cursor / PointerCursor ?
 
+       * remove List::List(element)
+
        * efficient copy cons for List
 
        * change String::pos
index 47c7101c87cb9b65029b8dd4874194a836e4375c..9f9d4e5906aa062cf61ad087a8938a981e9fdeea 100644 (file)
@@ -1,13 +1,23 @@
+/*
+  flowerlib
+
+  (c) 1996 Han-Wen Nienhuys
+  */
 #ifndef COMPARE_HH
 #define COMPARE_HH
 
+
+#define one_operator(type, function, op)        \
+inline bool operator op (type t1, type t2) { return function(t1, t2) op 0; }   
+
 /// handy notations for a signed comparison
 #define template_instantiate_compare(type, function, prefix)                           \
-prefix inline bool operator>(type t1, type t2) { return function(t1, t2) > 0; }        \
-prefix inline bool operator>=(type t1, type t2) { return function(t1, t2) >= 0; }      \
-prefix inline bool operator==(type t1, type t2) { return function(t1, t2) == 0; }      \
-prefix inline bool operator<=(type t1, type t2) { return function(t1, t2) <= 0; }      \
-prefix inline bool operator<(type t1, type t2) { return function(t1, t2) < 0; } \
+prefix one_operator(type, function, >)\
+prefix one_operator(type, function, >=)\
+prefix one_operator(type, function, ==)\
+prefix one_operator(type, function, !=)\
+prefix one_operator(type, function, <)\
+prefix one_operator(type, function, <=)\
 prefix inline type MAX(type t1, type t2) {  return (t1 > t2 )? t1 : t2; }\
 prefix inline type MIN(type t1, type t2) {  return (t1 < t2 )? t1 : t2; }\
   \
index 1c61b1a76cd8fa6880fdc813e2abdc164dd9b172..4babf9654516f221d8b11d6fdf4ac248cd9a1fd9 100644 (file)
@@ -16,10 +16,11 @@ class Cursor
       tired of the warning messages.  */
     
     Cursor( const Cursor<T>& cursor );
-    
+
+    T& thing();
     /// return current T
-    T& operator *();           
-    operator T() { return  *(*this); }
+    T& operator *() { return thing(); }
+    operator T() { return thing(); }
     Cursor<T> operator =( const Cursor<T>& c );
 
     /// make cursor with #no# items back
@@ -98,10 +99,6 @@ private:
  */
 
 
-
-
-
-
 /*
   comparisons.
   */
@@ -119,4 +116,4 @@ template_instantiate_compare(Cursor<T>, cursor_compare, template<class T>);
 #include "list.hh"
 #include "cursor.inl"
 
-#endif // __CURSOR_HH //
+#endif // CURSOR_HH 
index bdc242590f7488382820f566df1047be1942f26f..0b077bd811d0aac1cca336eaebafc2e290f67589 100644 (file)
@@ -25,7 +25,7 @@ Cursor<T>::Cursor( const Cursor<T>& cursor ) :
 
 template<class T>
 inline T&
-Cursor<T>::operator *()
+Cursor<T>::thing()
 {
     assert( pointer_ );
     return pointer_->thing();
@@ -42,16 +42,16 @@ Cursor<T>::operator =( const Cursor<T>& c )
 
 template<class T>
 inline void
-Cursor<T>::add( const T& thing )
+Cursor<T>::add( const T& th )
 {
-    list_.add( thing, *this );
+    list_.add( th, *this );
 }
 
 template<class T>
 inline void
-Cursor<T>::insert( const T& thing )
+Cursor<T>::insert( const T& th )
 {
-    list_.insert( thing, *this );
+    list_.insert( th, *this );
 }
 
 template<class T>
index 741e4ee97c87b48830c3d703ae66c69ad80b1d0a..ce5e366cc8259baf192bd6be9d14781dbe6ecd86 100644 (file)
@@ -34,51 +34,64 @@ List<T>::OK() const
     assert(!lp);
 }
 
+
 template<class T>
-Cursor<T>
-List<T>::top()
+inline
+List<T>::~List()
 {
-#if 0 
-    // ?? waarvoor is deze if ? 
-    if ( top_ )                        // equivalent: if ( size_ )
-       {
-       Link<T>* t = top_->previous();
-       assert( t != top_ );    // silly link
-       while ( t )
-           {
-               assert(false);  // this is even more silly.
-           top_ = t;
-           t = top_->previous();
-           }
-       }
-#endif
-    
-// list empty: Cursor not ok()
-    return Cursor<T>( *this, top_ );
+    Cursor<T> next(*this);
+    for ( Cursor<T> c( *this ); c.ok(); c = next ) {
+       next = c;
+       next++;
+       remove( c );
+    }
 }
 
-
 template<class T>
-Cursor<T>
-List<T>::bottom()
+inline void
+List<T>::add( const T& thing, Cursor<T> after_me )
 {
-    /* wat is dit voor zooi? kan dit niet weg?
+    if (!size_) {              // not much choice if list is empty
+        bottom_ = top_ = new Link<T>( thing );
+    } else {                   // add at aprioprate place
+       Link<T> *p =  ( after_me.ok() ) ?
+           after_me.pointer() : bottom().pointer();
+       p->add(thing);
+       if (p == bottom_)       // adjust bottom_ if necessary.
+           bottom_ = p->next();
+    }
 
-    (invarianten!)
-    */
-    if ( bottom_ )             // equivalent: if ( size_ )
-       {
-       Link<T>* b = bottom_->next();
-       assert( b != bottom_ ); // silly link    
-       while ( b )
-           {
-           bottom_ = b;
-           b = bottom_->next();
-           }
-       }
-                               // list empty: Cursor not ok()
-    return Cursor<T>( *this, bottom_ );
+    size_++;
 }
+/** 
+
+  Procedure:
+  \begin{itemize}
+  \item if #after_me# is #ok()#, add after #after_me#, else
+  \item if list !empty simply add to bottom, else
+  \item list is empty: create first \Ref{Link} and initialize 
+  #bottom_# and #top_#.
+  \end{itemize}
+*/
 
+template<class T>
+inline void
+List<T>::insert( const T& thing, Cursor<T> before_me )
+{
+    if (!size_) {
+       bottom_ = top_ = new Link<T>( thing );
+    } else {
+       Link<T> *p = 
+           (before_me.ok())?
+           before_me.pointer() : top().pointer();
+
+       p->insert(thing);
+       if (p == top_)
+           top_ = p->previous();
+    }
+       
+    size_++;
+
+}
 
 #endif
index 5a825fa89ef87ace4a9b7b2ac0bede4c5da0a31d..1516e16642561cd9b384d57c370232ee86f87fd3 100644 (file)
@@ -62,7 +62,7 @@ class List
    items are always stored as copies in List, but:
    #List<String># :  copies of #String# stored 
    #List<String*># : copies of #String*# stored! 
-   (do not use, use \Ref{PointerList}#<String*># instead.)
+   (do not use, use \Ref{PointerList} #<String*># instead.)
  
    {\bf note:} 
    retrieving "invalid" cursors, i.e. 
index 8bdcf158772df21f6764b6fa507742870c022ca8..d71e947050b17bb55f4e4da99cc22a8142ad63f2 100644 (file)
@@ -1,6 +1,8 @@
 // -*-c++-*-
+
 #ifndef LIST_INL
 #define LIST_INL
+
 template<class T>
 inline
 List<T>::List()
@@ -23,83 +25,6 @@ List<T>::List( const T& thing )
     set_empty();
     add( thing, Cursor<T>( *this, bottom_ ) );
 }
-
-template<class T>
-inline
-List<T>::~List()
-{
-    Cursor<T> next(*this);
-    for ( Cursor<T> c( *this ); c.ok(); c = next ) {
-       next = c;
-       next++;
-       remove( c );
-    }
-}
-
-template<class T>
-inline void
-List<T>::add( const T& thing, Cursor<T> after_me )
-{
-#if 0
-    if ( after_me.ok() )
-       after_me.pointer()->add( thing );
-    else if ( size_ )
-        bottom().pointer()->add( thing );
-    else
-        bottom_ = top_ = new Link<T>( thing );
-#endif
-    
-    if (!size_) {              // not much choice if list is empty
-        bottom_ = top_ = new Link<T>( thing );
-    } else {                   // add at aprioprate place
-       Link<T> *p =  ( after_me.ok() ) ?
-           after_me.pointer() : bottom().pointer();
-       p->add(thing);
-       if (p == bottom_)       // adjust bottom_ if necessary.
-           bottom_ = p->next();
-    }
-
-    size_++;
-}
-/** 
-
-  Procedure:
-  \begin{itemize}
-  \item if #after_me# is #ok()#, add after #after_me#, else
-  \item if list !empty simply add to bottom, else
-  \item list is empty: create first \Ref{Link} and initialize 
-  #bottom_# and #top_#.
-  \end{itemize}
-*/
-
-template<class T>
-inline void
-List<T>::insert( const T& thing, Cursor<T> before_me )
-{
-    if (!size_) {
-       bottom_ = top_ = new Link<T>( thing );
-    } else {
-       Link<T> *p = 
-           (before_me.ok())?
-           before_me.pointer() : top().pointer();
-
-       p->insert(thing);
-       if (p == top_)
-           top_ = p->previous();
-    }
-       
-    size_++;
-#if 0 // rewrite hwn 16/9              
-    if ( before_me.ok() )
-        before_me.pointer()->insert( thing );
-    else if ( size_ )
-       top().pointer()->insert( thing );
-    else
-       bottom_ = top_ = new Link<T>( thing );
-    size_++;
-#endif
-}
-
 template<class T>
 inline void
 List<T>::remove( Cursor<T> me )
@@ -119,6 +44,20 @@ List<T>::size() const
     return size_;
 }
 
+template<class T>
+inline Cursor<T>
+List<T>::top()
+{
+    return Cursor<T>( *this, top_ );
+}
+
+
+template<class T>
+inline Cursor<T>
+List<T>::bottom()
+{
+    return Cursor<T>( *this, bottom_ );
+}
 
 
 #endif
index 095bcc45bf697cf0f47362c3c914042c9377c51f..6cc3433e25a2d191eedcc3f38af54ff0607d1a58 100644 (file)
@@ -9,28 +9,46 @@
 #define PCURSOR_HH
 
 
-/// cursor which feels like a pointer
+/// cursor to go with PointerList
 template<class T>
-struct PCursor : public Cursor<T> {
+struct PCursor : public Cursor<void *> {
 
     /// make cursor with #no# items back
     PCursor<T> operator -( int no) const {
-       return PCursor<T> (Cursor<T>::operator-(no));
+       return PCursor<T> (Cursor<void*>::operator-(no));
     }
 
     /// make cursor with #no# items further
     PCursor<T> operator +( int no) const {
-       return PCursor<T> (Cursor<T>::operator+(no));
+       return PCursor<T> (Cursor<void*>::operator+(no));
     }
-    PCursor(const List<T> & l) : Cursor<T> (l) {}
+    PCursor(const PointerList<T> & l) : Cursor<void*> (l) {}
 
-    PCursor( const Cursor<T>& cursor ) : Cursor<T>(cursor) { }
-    T operator ->() const { return  *(*(Cursor<T> *)this); }
+    PCursor( const Cursor<void*>& cursor ) : Cursor<void*>(cursor) { }
+    void* vptr() const { return  * ((Cursor<void*> &) *this); }
 
+    // should return T& ?
+    T ptr() const { return (T) vptr(); }
+    T operator ->() const { return  ptr(); }
+    operator T() { return ptr(); }
+    T operator *() { return ptr(); }
+
+private:
+//    Cursor<void*>::operator void*;
+    // sigh
 };
 /**
- I like  operator->(), so here it is.
-
- Cursor to go with pointer list.
+don't create PointerList<void*>'s
  */
+
+
+template<class T>
+inline  int pcursor_compare(PCursor<T> a,PCursor<T>b)
+{
+    return cursor_compare(Cursor<void*>(b),Cursor<void*> (a));
+}
+
+#include "compare.hh"
+template_instantiate_compare(PCursor<T>, pcursor_compare, template<class T>);
+
 #endif
index bbb0e7428fcba697dc0390ddabaf71524670a485..5c8e47093c9c11799f49b04735db9e13c6749679 100644 (file)
@@ -3,14 +3,10 @@
 // not inlined since it assumes knowledge of destructor.
 template<class T>
 void
-PointerList<T>::remove( Cursor<T> me )
+IPointerList<T>::remove(PCursor<T> me )
 {
     if ( me.ok() ) {
-       delete *me;
-        List<T>::remove( me ); 
+       delete me.ptr();
+        List<void*>::remove(me); 
     }
 }
-
-
-
-
index 8fa126b52777fa5fdbe3880cd7785ad0e6249ec3..1bfc2d4ab43ae1e5c613f9245d177f556d3dc0dc 100644 (file)
 
 /// Use for list of pointers, e.g. PointerList<AbstractType*>.
 template<class T>
-class PointerList : public List<T>
+class PointerList : public List<void *>
 {
  public:
-    PointerList(PointerList&) { set_empty(); }
-    PointerList( const T& thing ) : List<T>( thing ) { }
+    PCursor<T> top() {  return PCursor<T> (List<void*>::top()); }
+    PCursor<T> bottom() { return PCursor<T> (List<void*>::bottom()); }
+    
+    PointerList( const T& thing ) : List<void*>( thing ) { }
     PointerList() {}
-    ///
-    virtual ~PointerList();
-    /**
-      This function deletes deletes the allocated pointers of all links. 
-      #\Ref{~List}# is used to delete the links themselves.
-      */ 
-
- protected:
-    virtual void remove( Cursor<T> me );
+};
+
+
+/// intrusive pl. deletes pointers given to it.
+template<class T>
+struct IPointerList : public PointerList<T> {
+    IPointerList(IPointerList&) { set_empty(); }
+    IPointerList() { }
+protected:
+    virtual void remove( Cursor<void*> me ) { remove (PCursor<T>(me)); }
+    virtual void remove( PCursor<T> me );
 };
 /**
   NOTE:
@@ -37,16 +41,18 @@ class PointerList : public List<T>
   You have to copy this yourself, or use the macro PointerList__copy
   
   */
-#define PointerList__copy(T, to, from, op)   \
+#define IPointerList__copy(T, to, from, op)   \
   for (PCursor<T> _pc_(from); _pc_.ok(); _pc_++)\
       to.bottom().add(_pc_->op)\
   \
 
 
 template<class T>
-void PL_copy(PointerList<T*> &dst,PointerList<T*> const&src);
+void PL_copy(IPointerList<T*> &dst,IPointerList<T*> const&src);
+
 
 #define PL_instantiate(a) L_instantiate(a *); template class PointerList<a*>
+#define IPL_instantiate(a) PL_instantiate(a); template class IPointerList<a*>
 
 #include "plist.inl"
 
index b8cd8d602099a39268c89db40b3636091d618a55..82be3643343763af41c40a9c57a061182e3dcf5d 100644 (file)
@@ -7,36 +7,15 @@
 #ifndef PLIST_INL
 #define PLIST_INL
 
-
-
-template<class T>
-inline
-PointerList<T>::~PointerList()
-{
-    Cursor<T> next(*this);
-    for ( Cursor<T> c( *this ); c.ok(); c = next ) {
-       next = c;
-       next++;
-       remove( c );            // PointerList::remove deletes the  real data
-    }
-}
-
-template<class T>
-inline void
-PointerList_print( PointerList<T> const & l  ) 
-{
-    for (PCursor<T> c(l ); c.ok(); c++ )
-        c->print();  
-}
-
 template<class T>
-inline void
-PL_copy(PointerList<T*> &to,PointerList<T*> const&src)
+void
+PL_copy(IPointerList<T*> &to, IPointerList<T*> const&src)
 {
     for (PCursor<T*> pc(src); pc.ok(); pc++) {
        T *q = pc;
-       T *p=new T(*q) ; // argh, how do i do this in ANSI-C++
+       T *p=new T(*q) ; 
        to.bottom().add(p);
     }
 }
+
 #endif
index c03e651034208436be148ddcf12fb6d2f9b24e87..ab6255109b66260c7e50e474851cc253f20ec94a 100644 (file)
@@ -128,7 +128,7 @@ public:
               int lower = -1, int upper = -1 ) {
        if (lower < 0) {
            lower = 0 ;
-           upper = sz();
+           upper = sz()-1;
        }
        if (lower >= upper)
            return;
diff --git a/item.cc b/item.cc
index 96ec8a890a4c7ed742d2c6b23bb50c612f992975..4a84f477044c45b145e81b17c568dda3670e27a5 100644 (file)
--- a/item.cc
+++ b/item.cc
@@ -3,31 +3,6 @@
 #include "molecule.hh"
 #include "pcol.hh"
 
-String
-Spanner::TeXstring() const
-{
-    assert(right->line);
-    Real w = left->hpos - right->hpos;
-    return strets->eval(w).tex;
-}
-
-Spanner *
-Spanner::broken_at(const PCol *c1, const PCol *c2) const
-{
-    Spanner *sp = new Spanner(*this);
-    sp->left = c1;
-    sp->right = c2;
-    return sp;
-}
-
-Spanner::Spanner()
-{
-    pstaff_=0;
-    strets=0;
-    left = right = 0;
-}
-
-/****************************************************************/
 String
 Item::TeXstring() const
 {
@@ -46,7 +21,10 @@ Item::height() const
     return output->extent().y;
 }
 
-/****************************************************************/
+Item::~Item()
+{
+    delete output;
+}
 
 Item::Item()
 {
diff --git a/item.hh b/item.hh
index 484822533bceddf0f1e4f3fd4b177276e11a71f5..cf3d11c31347dac6f4fbe9f4cb22ec9061e3454c 100644 (file)
--- a/item.hh
+++ b/item.hh
@@ -6,43 +6,27 @@
 #include "string.hh"
 #include "tex.hh"
 
-/// a symbol which is attached between two columns.
-struct Spanner {
-    const PCol *left, *right;
-    Parametric_symbol *strets;
-    PStaff * pstaff_;
-    ///      clone a piece of  this spanner.
-    Spanner *broken_at(const PCol *c1, const PCol *c2) const; 
-    /**
-    PRE
-    c1 >= start, c2  <= stop
-    */
-    String TeXstring () const ;
-    Spanner();
-};
-/** Spanner should know about the items which it should consider:
-    e.g. slurs should be steep enough to "enclose" all those items. This
-    is absolutely necessary for beams, since they have to adjust the
-    length of stems of notes they encompass.
-
-    */
     
-/// a fixed size element of the score
+/// a horizontally fixed size element of the score
 struct Item {
-    virtual Interval width() const;    
-    virtual Interval height() const;
     const PCol * col;
     Molecule *output;
     
     PStaff *pstaff_;
     /** needed for knowing at which staff to output this item
     */
+
+    /****************/
+
+    virtual Interval width() const;    
+    virtual Interval height() const;
     String TeXstring () const ;
     Item();
     void print()const;
+    virtual ~Item();
 };
 /** An item must be part of a Column
 */
 
+
 #endif
diff --git a/lexer.l b/lexer.l
index 008f813bf5410f65759143025a62cf91d733542f..220b07ccf862406585a359b13e53bc59f80404ff 100644 (file)
--- a/lexer.l
+++ b/lexer.l
@@ -36,7 +36,7 @@ PITCH         ['`]*{OPTSIGN}{NOTENAME}
 DURNAME                1|2|4|8|16|32
 DURATION       {DURNAME}\.*
 FULLNOTE       {PITCH}{DURATION}?
-WORD           [a-zA-Z]+
+WORD           [a-zA-Z][a-zA-Z0-9_]+
 REAL           [0-9]+(\.[0-9]*)?
 
 %%
index 24dd6171502106cbc6066359b153ea1ed334ab20..45152140cb1ff898255f8bf5ee4626f369eb927f 100644 (file)
 
 \def\musixtwentydefs{
        \font\musicfnt=musix20
-       \interlinedist=5pt
        \balkhoog=20pt
        \staffrulethickness=0.4pt
+}
+
+\def\musixcalc{
        \interstaffrule=\balkhoog
        \advance\interstaffrule by-\staffrulethickness
        \divide\interstaffrule by 4
-       \advance\interstaffrule by -\staffrulethickness         
+       \advance\interstaffrule by -\staffrulethickness
 }
 
-\def\interstaffline{
-       \vskip 20pt%
-}
 
 \musixtwentydefs
+\musixcalc
 
 \mdef\quartball{'007}
 \mdef\halfball{'010}
 \mdef\doubledot{'01}
 \mdef\tripledot{'02}
 \mdef\mussepline{155}
+\mdef\ieigthflag{45}
+\mdef\isixteenthflag{46}
+\mdef\ithirtysecondflag{47}
+\mdef\ueigthflag{40}
+\mdef\usixteenthflag{41}
+\mdef\uthirtysecondflag{42}
 
 \def\maatstreep{\vrule height\balkhoog}
 \def\finishbar{\vrule height\balkhoog  width 1pt}
 \def\generalmeter#1#2{\vbox to 0pt{\vss\rm\hbox{#1}\hbox{#2}}}
-
 \def\lineseparator{\vbox{\mussepline\vskip -5pt\mussepline}}
-\def\interscoreline{
+
+\def\beauty{
        \par\vskip 10pt\par
        \hskip -5pt\lineseparator% \hbox to 1cm{\kern -5mm\hrulefill}
        \vskip 10pt
 }
 
+\def\interstaffline{%
+       \vskip 10pt
+%      \nointerlineskip
+%      \vbox{\hbox to 0pt{\vrule width20pt height1pt\hss}}
+}
+\def\ugly{\nointerlineskip\par
+\vskip 40pt\par\vbox{\hbox to 0pt{\vrule width30pt height1pt\hss}}\par\vskip 40pt
+}
+\def\interscoreline{\beauty}
 %
 % a staffsymbol with #1 lines, width #2
 % bottom at baseline
-\def\linestafsym#1#2{\hbox to 0pt%
+\def\linestafsym#1#2{\vbox to 0pt{\hbox to 0pt%
   {\vbox to 0pt{\vss%
-       \vskip-\interlinedist
-       \n=0%
+       \kern-\interstaffrule
+       \n=0\nointerlineskip%
        \loop\ifnum\n<#1\advance\n by1%
-               \vskip\interstaffrule \hrule height \staffrulethickness width#2
+               \kern\interstaffrule \hrule height \staffrulethickness  width#2
                \repeat
        }%
-\hss}}
+\hss}}}
 
 \def\vcenter#1{\vbox to 0pt{\vss #1\vss}}
+\def\topalign#1{\vbox to 0pt{#1\vss}}
+
+\def\eigthflag{\topalign{\ueigthflag}}
+\def\sixteenthflag{\topalign{\usixteenthflag}}
+\def\thirtysecondflag{\topalign{\uthirtysecondflag}}
 
 \def\cquartrest{\vcenter\quartrest}
 \def\ceighthrest{\vcenter\eighthrest}
 \def\ldoubledot{\kern-6pt\doubledot}
 \def\ltripledot{\kern-6pt\tripledot}
 
+\def\stem#1#2{\vrule height#2 depth-#1}
+
+\def\placebox#1#2#3{%
+       \vbox to 0pt{\vss\hbox{\raise #1\hbox to 0pt{\kern #2{}#3\hss}}}%
+}
+
 
diff --git a/line.cc b/line.cc
index a6e0f7c68a711764e84a67074f1207e27a7b5761..293214dc3078a6e1df9bc5554e4b47ec640c8cdc 100644 (file)
--- a/line.cc
+++ b/line.cc
@@ -1,19 +1,27 @@
 #include "line.hh"
 #include "dimen.hh"
+#include "spanner.hh"
 #include "symbol.hh"
 #include "paper.hh"
 #include "pcol.hh"
 #include "pscore.hh"
 
+static String
+make_vbox(Interval i)
+{
+    
+    String s("\\vbox to ");
+    s += print_dimen(i.length());
+    s += "{\\vskip "+print_dimen(i.max)+" ";
+    return s;
+}
+
+    
 String
 Line_of_staff::TeXstring() const
 {
-    String s("%line_of_staff\n\\vbox to ");
-    s += print_dimen(maxheight() ) +"{";
-
-    //make some room
-    s += vstrut(base);
-
+    String s("%line_of_staff\n");
+    s+=make_vbox(height());
     // the staff itself: eg lines, accolades
     s += "\\hbox{";
     {
@@ -28,7 +36,8 @@ Line_of_staff::TeXstring() const
            lastpos = cc->hpos;
 
            // moveover
-           s +=String( "\\kern ") + print_dimen(delta);
+           if (delta)
+               s +=String( "\\kern ") + print_dimen(delta);
 
            // now output the items.
 
@@ -46,44 +55,8 @@ Line_of_staff::TeXstring() const
     return s;
 }
 
-String
-Line_of_score::TeXstring() const
-{
-     String s("\\vbox{");
-     for (PCursor<Line_of_staff*> sc(staffs); sc.ok(); sc++){
-        s += sc->TeXstring();
-        if ((sc+1).ok())
-            s+= "\\interstaffline\n";
-     }
-     s += "}";
-     return s;
-}
-
-/// testing this entry
-Line_of_score::Line_of_score(svec<const PCol *> sv,
-                            const PScore *ps)
-{
-    score = ps;
-    for (int i=0; i< sv.sz(); i++) {
-       PCol *p=(PCol *) sv[i];
-       cols.bottom().add(p);
-       p->line=this;
-    }
-
-    for (PCursor<PStaff*> sc(score->staffs); sc.ok(); sc++)
-       staffs.bottom().add(new Line_of_staff(this, sc));    
-}
-/** construct a line with the named columns. Make the line field
-    in each column point to this
-    
-    #sv# isn't really const!!
-    */
-
 Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st)
 {
-    // [don't know how to calc dimensions yet.]
-   height = 0.0;
-   base =0.0;
  
     scor=sc;
     pstaff_=st;
@@ -101,8 +74,8 @@ Line_of_staff::Line_of_staff(Line_of_score * sc, PStaff*st)
 }
 
 
-Real
-Line_of_staff::maxheight() const
+Interval
+Line_of_staff::height() const
 {
     Interval y;
     {
@@ -113,8 +86,6 @@ Line_of_staff::maxheight() const
     
     // all items in the current line & staff.
     for (; cc.ok(); cc++) {
-
-               
        for (PCursor<const Item *> ic(cc->its); ic.ok(); ic++) {
            if (ic->pstaff_ == pstaff_) {
                y.unite(ic->height());
@@ -126,7 +97,41 @@ Line_of_staff::maxheight() const
                assert(false);          
        }
     }
-    return y.max;
+    return y;
+}
+
+
+/****************************************************************/
+String
+Line_of_score::TeXstring() const
+{
+     String s("\\vbox{%<- line of score\n");
+     for (PCursor<Line_of_staff*> sc(staffs); sc.ok(); sc++){
+        s += sc->TeXstring();
+        if ((sc+1).ok())
+            s+= "\\interstaffline\n";
+     }
+     s += "}";
+     return s;
 }
 
+/// testing this entry
+Line_of_score::Line_of_score(svec<const PCol *> sv,
+                            const PScore *ps)
+{
+    score = ps;
+    for (int i=0; i< sv.sz(); i++) {
+       PCol *p=(PCol *) sv[i];
+       cols.bottom().add(p);
+       p->line=this;
+    }
+
+    for (PCursor<PStaff*> sc(score->staffs); sc.ok(); sc++)
+       staffs.bottom().add(new Line_of_staff(this, sc));    
+}
+/** construct a line with the named columns. Make the line field
+    in each column point to this
+    
+    #sv# isn't really const!!
+    */
 
diff --git a/line.hh b/line.hh
index 3e698659e9a2f24a8ec690d572771a101c8d1e20..641ddf257de84bed98a242ca1deacf6c97e3c9d9 100644 (file)
--- a/line.hh
+++ b/line.hh
@@ -34,11 +34,6 @@ Line_of_score {
 
 /// one broken line of staff.
 struct Line_of_staff {
-    Real height;
-
-    /// y-pos of the baseline, measured from the top.
-    Real base;
-    
     PointerList<Spanner *> brokenspans;    
     Line_of_score const * scor;
     const PStaff *pstaff_;
@@ -47,7 +42,7 @@ struct Line_of_staff {
     
     String TeXstring() const;
     Line_of_staff(Line_of_score*, PStaff *);
-    Real maxheight()const;
+    Interval height() const;
 };
 
 #endif
index f0624cad1e0b29dc1822dd888a072726f14f183a..294f2e9af48de818a57721e96f6994f33bd1e9d1 100644 (file)
@@ -49,6 +49,12 @@ Lookup::dots(int j)
     return (*symtables_)("dots")->lookup(j);
 }
 
+Symbol
+Lookup::flag(int j)
+{
+    return (*symtables_)("flags")->lookup(j);
+}
+
 /****************************************************************/
 // bare bones.
 
@@ -66,7 +72,7 @@ Linestaf_symbol::eval(svec<String> w)const
 
     Symbol s;
     s.dim.x = Interval(0,wid);
-    Real dy=lines*convert_dimen(5,"pt");
+    Real dy=(lines-1)*convert_dimen(5,"pt"); // TODO!
     s.dim.y = Interval(0,dy);
     svec<String> a;
     a.add(lines);
@@ -84,7 +90,8 @@ 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(10,"pt"));
+       s.dim.x = Interval( convert_dimen(-5,"pt"),
+                           convert_dimen(5,"pt"));
        s.dim.y = Interval(0, convert_dimen(10,"pt") ); // todo
        String src = (*symtables_)("param")->lookup("meter").tex;
        s.tex = substitute_args(src,a);
@@ -93,6 +100,23 @@ struct Meter_sym:Parametric_symbol {
 };
 /****************************************************************/
 
+struct Stem_sym:Parametric_symbol {
+
+    Stem_sym(Symtables*s) : Parametric_symbol(s) {  }
+    Symbol eval(svec<String> a) const {
+       Real y1 = a[0].fvalue();
+       Real y2 = a[1].fvalue();
+       assert(y1 <= y2);
+       Symbol s;
+       s.dim.x = Interval(0,0);
+       s.dim.y = Interval(y1,y2);
+
+       String src = (*symtables_)("param")->lookup("stem").tex;
+       s.tex = substitute_args(src,a);
+       return s;
+    }
+};
+
 Parametric_symbol *
 Lookup::meter(String )
 {
@@ -105,3 +129,8 @@ Lookup::linestaff(int n)
     return new Linestaf_symbol(n,symtables_);
 }
 
+Parametric_symbol*
+Lookup::stem()
+{
+    return new Stem_sym(symtables_);
+}
index a3c0750d0e4e213cf9ece91b71b4b3b96e3780ea..f7ac3858acb559eb94d73642f8ee76675f209fc2 100644 (file)
@@ -14,7 +14,9 @@ struct Lookup {
     void parse (Text_db&t);
     Parametric_symbol *linestaff(int n);
     Parametric_symbol *meter(String);
+    Parametric_symbol *stem();
     Symbol ball(int);
+    Symbol flag(int);
     Symbol rest(int);
     Symbol bar(String);
     Symbol dots(int);
index 00d4ea8d5ee334872a92def835aecf0fffacd7f1..50ce2cb577a1f630b5e94793349f15722be6e475 100644 (file)
@@ -1,12 +1,10 @@
-
-
 ritme = rhythmstaff {
        voice { $ c2 r32 r32 r16 r8 r4 c2 c2 c2 c2 c2
                c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 $ }
 }
 melody=
 melodicstaff {
-  voice { $ c2.. r8 r4 r8 r16 r32 r32 d8 e8 f8 g8 a8 b8 'c8 c8 r4 c4 c4 c4 c4 c4 c4 $ }
+  voice { $ c2.. r8 r4 r8 r16 r32 r32 d8 e8 f8 g8 ''fis1 a8 b8 'c8 c8 `c8 ``c8 c4 c4  c4 c4 $ }
 }
 score {
        paper {
@@ -14,6 +12,7 @@ score {
        }
        staff { ritme }
        staff { melody }
+%      staff { melody }
        commands {
                meter 4 4
                skip 3:0
diff --git a/main.cc b/main.cc
index 5e518752cff85a9a3834201437da72afa98cbd19..3c33fd959d65069393eb4dbaf2af6b36f2bae719 100644 (file)
--- a/main.cc
+++ b/main.cc
@@ -41,7 +41,7 @@ int
 main (int argc, char **argv)
 {
     Getopt_long oparser(argc, argv,theopts);
-
+    debug_init();
     cout << get_version();
     
     while (long_option_init * opt = oparser()) {
index c2a1e50f8a44027f0132b9c36f6f5544ea911ed0..2e9246f4d759b7c3fd94647b288acd86d98b5c92 100755 (executable)
@@ -2,27 +2,30 @@
 old=$1
 new=$2
 nm=$3-
+
 newarc=$nm$new.tar.gz
 oldarc=$nm$old.tar.gz
-if [ ! -f $newarc ]
-then
-       echo cant find $newarc
-       exit
-fi
-if [ ! -f $oldarc ]
-then
-       echo cant find oldarc
-       exit
-fi
+
+
 if [ ! -x  $nm$new ]
 then
    echo untarring ..
   tar zfxv $nm$new.tar.gz
+  if [ ! -f $newarc ]
+  then
+       echo cant find $newarc
+       exit
+  fi
 fi
 if [ ! -x  $nm$old ]
 then
    echo untarring
    tar zfxv $nm$old.tar.gz
+  if [ ! -f $oldarc ]
+  then
+       echo cant find oldarc
+       exit
+  fi
 fi
 
 #(cd $nm$old; touch depend; make clean)
index 60d9a6fd2e811cc5f5b2c47be7072f27183898b4..83e038652fff0918936d4356eaf6e392f16ba058 100644 (file)
@@ -1,36 +1,60 @@
 #include "melodicstaff.hh"
+#include "stem.hh"
+
 #include "paper.hh"
 #include "molecule.hh"
 #include "linestaff.hh"
 #include "rhythmstaff.hh"
 #include "sccol.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)
 {
-    theline = new Linestaff(5,ps);
+    theline = new Linestaff(NO_LINES,ps);
     Simple_staff::set_output(ps);
 }
 
 void
 Melodic_column::typeset_command(Command *com, int breakst)
 {
-    Item *i = create_command_item(com);
+    Molecule*m=create_command_mol(com);
+    Item *i =new Item;
+    i->output = m;
     typeset_item(i, breakst);
 }
 
 void
 Melodic_column::typeset_req(Request *rq)
 {
-    Item *i = create_req_item(rq);
+    Item *i =new Item;
+    Molecule*m=create_req_mol(rq);
+
     if (rq->note()) {
        int h = rq->note()->height();
        Real dy = staff_->paper()->interline()/2;
-       i->output->translate(Offset(0,(h-2)*dy));
+       m->translate(Offset(0,(h-BOTTOM_POSITION)*dy));
     }
+    i->output = m;
     typeset_item(i);
 }
 
+
+void
+Melodic_column::typeset_stem(Stem_req*rq)
+{
+    Stem * s = new Stem(NO_LINES);
+    int n = the_note->note()->height()-BOTTOM_POSITION;
+    s->minnote =s->maxnote=n;
+    s->flag = rq->stem_number;
+    s->calculate();
+    typeset_item(s);
+    
+    s->brew_molecole();
+}
+
 /*
   creation
   */
index a91a413659b73f5d234481b6c3156423048f01a9..5c417b84a5aafcb7d53a1929b9f7f2d42937283e 100644 (file)
@@ -19,7 +19,8 @@ struct Melodic_staff : public Simple_staff
 
 struct Melodic_column : public Simple_column {
     virtual void typeset_req(Request *rq);
-  virtual void typeset_command(Command *, int brs);
+    virtual void typeset_stem(Stem_req *rq);
+    virtual void typeset_command(Command *, int brs);
   //    virtual void typeset_item(Item*, int=1);
     Melodic_column(Score_column*s,Simple_staff*rs) :
        Simple_column(s,rs) { }
index 5ab384f87d639d710d59c1bca89b412e7e8aaf10..8fca34836bdd420db0ebd7ce93d39f7667fd7b3c 100644 (file)
@@ -29,11 +29,12 @@ String
 Atom::TeXstring() const
 {
     // whugh.. Hard coded...
-    String s("\\raise");
-    s+= print_dimen(off.y) +"\\hbox to 0pt{\\kern ";
-    s+= print_dimen(off.x);
-    s+= sym.tex + "\\hss}";
-    return s;
+    String s("\\placebox{%}{%}{%}");
+    svec<String> a;
+    a.add(print_dimen(off.y));
+    a.add(print_dimen(off.x));
+    a.add(sym.tex);
+    return substitute_args(s, a);
 }
 
 
diff --git a/note.cc b/note.cc
index bb0702f1433eff9c61459a0593f3969ed9e141ac..b897ce0e6647be29b67843c6a2e34fab8fdef257 100644 (file)
--- a/note.cc
+++ b/note.cc
@@ -32,6 +32,7 @@ parse_duration(const char *a, int &j, int &intdur, int &dots)
 }
 
 
+
 void 
 parse_pitch( const char *a, int &j, int &oct, bool & overide_acc,
             int & large, int & small)
@@ -94,6 +95,11 @@ get_note_element(String pitch, String durstr)
 
     Note_req * rq = new Note_req( v);
 
+    if (dur >= 2) {
+       Stem_req * st = new Stem_req(v, dur);
+       v->add(st);
+    }
+    
     int oct, pit, acc;
     bool forceacc;
     parse_pitch(pitch, i, oct, forceacc, pit, acc);
@@ -111,6 +117,7 @@ get_note_element(String pitch, String durstr)
     rq->print();
 
     v->add(rq);
+
     return v;
 }
 
index 6e5e87bda8329aa3338752fe6bdebb69b0ab08da..a0e533f62636a47dc84caec9623cdc6a650d443e 100644 (file)
--- a/paper.cc
+++ b/paper.cc
@@ -38,7 +38,11 @@ Paperdef::interline() const
 {
     return lookup_->ball(4).dim.y.length();
 }
-
+Real
+Paperdef::note_width()const
+{
+    return lookup_->ball(4).dim.x.length( );
+}
 Real
 Paperdef::standard_height() const
 {
index 9ce4d2bf4e475425a7757cc573e9955669ccaa64..e96d9b089fdde78e6b72793e0ba0bea94ee9d1a4 100644 (file)
--- a/paper.hh
+++ b/paper.hh
@@ -15,6 +15,7 @@ struct Paperdef {
     ~Paperdef();
     Real interline()const;
     Real standard_height()const;
+    Real note_width() const;
     void print() const;
 };
 
index 7e2be63a68bb279c649508c531ab22ddb4b37964..4ca199bb7702399edab1befb8ac2e8c01fbc5da2 100644 (file)
--- a/parser.y
+++ b/parser.y
@@ -130,7 +130,7 @@ staff_block:
        | melodicstaff_block
        ;
 
-staffdecl: STAFF '{' IDENTIFIER '}' { $$ = $3->staff(); }
+staffdecl: STAFF '{' IDENTIFIER '}' { $$ = $3->staff()->clone(); }
        ;
 
 rhythmstaff_block:
index 88fdb3349fd18f29343f2e5201800e0e6db9a876..fd032fcfd813ddb6f07199e2d820b87baecc52b8 100644 (file)
@@ -1,6 +1,15 @@
 #include "request.hh"
 #include "debug.hh"
 
+#define VIRTUALCONS(T,R) R *T::clone() const { return  new T(*this); } struct T
+#define RCONS(T) VIRTUALCONS(T, Request)
+
+RCONS(Rest_req);
+RCONS(Rhythmic_req);
+RCONS(Stem_req);
+RCONS(Note_req);
+
+
 void
 Request::print() const    
 {
index 8ebb1468c01ad316c5df4c90104d87f06b68d841..04664966b3e5aeee9c6ea5434fbffbbfa50b357c 100644 (file)
@@ -1,4 +1,4 @@
-// mpp96's second egg of columbus!
+// LilyPond's second egg of columbus!
 #ifndef REQUEST_HH
 #define REQUEST_HH
 
@@ -7,17 +7,19 @@
 
 /// a voice element wants something printed
 struct Request {
-    Voice_element*elt;
+    Voice_element*elt;         // indirection.
     
     /****************/
 
     virtual void print()const ;
     virtual Note_req *note() {return 0;}
+    virtual Stem_req *stem() {return 0;}
     virtual Rest_req *rest() {return 0;}
     virtual  Rhythmic_req*rhythmic() { return 0;}
     Request(Voice_element*);
     Request();
     virtual Real duration() const { return 0.0; }
+    virtual Request* clone() const =0;
 };
 
 /**
@@ -45,7 +47,7 @@ struct Request {
     that voice.
 
     After #Staff# made up her mind (Would #Staff# be a smart
-    name? How about #struct Lily {}# :-), the resultant items and
+    name? How about #struct Susan {}# :-), the resultant items and
     spanners are put on the PScore, and pointers to these items are
     stored in the #Voice_element#. This construction enables the
     beams/stems to look up the balls it has to connect to.  */
@@ -62,6 +64,7 @@ struct Rhythmic_req : Request {
     Rhythmic_req(Voice_element*);
     Rhythmic_req*rhythmic() { return this;}
     void print ()const;
+    Request*clone() const;
 };
 
 /// Put a note of specified type, height, and with accidental on the staff.
@@ -78,6 +81,7 @@ struct Note_req : Rhythmic_req {
     Note_req(Voice_element*v);
     Note_req*note() { return this;}
     virtual void print() const;
+    Request*clone() const;
 };
 /**
 Staff has to decide if the ball should be hanging left or right. This
@@ -95,11 +99,22 @@ struct Rest_req : Rhythmic_req {
     void print()const;
     Rest_req(Voice_element*v) : Rhythmic_req(v) {  }
     Rest_req * rest() { return this;}
+    Request*clone() const ;
 };
 /**
 Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded.
 */
 
+/// attach a stem to the noteball
+struct Stem_req : Request {
+    /// 4,8,16, ..
+    int stem_number;
+    virtual Stem_req *stem() {return this;}
+    Stem_req(Voice_element*v, int s) : Request(v) { stem_number = s; }
+    Request*clone() const;
+};
+
+
 #if 0
 
 ///Put a lyric above or below (?) this staff.
@@ -136,11 +151,6 @@ enum Loudness {
     FFF, FF, F, MF, MP, P, PP, PPP
 } ;
 
-/// attach a stem to the noteball
-struct Stem_req : Request {
-    /// 4,8,16, ..
-    int stem_number ;
-};
 /// requests to start or stop something.
 struct Span_req : Request {
     /// should the spanner start or stop, or is it unwanted?
index 4e564bdf8877835f3d6228a1a16985d5adcf0514..7e2706e02dc723107c77723f50a11e6c8d4820a5 100644 (file)
@@ -1,4 +1,5 @@
 #include "molecule.hh"
+#include "stem.hh"
 #include "linestaff.hh"
 #include "rhythmstaff.hh"
 #include "paper.hh"
@@ -16,19 +17,34 @@ Rhythmic_staff::set_output(PScore*ps)
 void
 Rhythmic_column::typeset_command(Command *com, int breakst)
 {
-    Item *i = create_command_item(com);
-    i->output->translate(Offset(0,
-                               -staff_->score_->paper_->standard_height()/2));
+    Item *i =new Item;
+    Molecule*m = create_command_mol(com);
+    i->output=m;
+    m->translate(Offset(0,
+                       -staff_->score_->paper_->standard_height()/2));
     typeset_item(i, breakst);
 }
 
 void
 Rhythmic_column::typeset_req(Request *rq)
 {
-    Item *i =create_req_item(rq);
+    Item *i =new Item;
+    Molecule*m=create_req_mol(rq);
+    i->output=m;
     typeset_item(i);
 }
 
+void
+Rhythmic_column::typeset_stem(Stem_req*rq)
+{
+    Stem * s = new Stem(0);
+    s->minnote = s->maxnote = 0;
+    s->flag = rq->stem_number;
+    s->calculate();
+    typeset_item(s);
+    s->brew_molecole();
+}
+
 /*
   creation
   */
index 7fe7c6a887ee7173d7431ba1995e365b3d432d16..130f6483b9b6ccce1516270625536a170631e42f 100644 (file)
@@ -21,6 +21,7 @@ struct Rhythmic_staff : public Simple_staff
 /// this does the typesetting
 struct Rhythmic_column : public Simple_column {
     virtual void typeset_req(Request *rq);
+    virtual void typeset_stem(Stem_req *rq);
     virtual void typeset_command(Command *, int brs);
   
 
index 46685d605053be9908837a359c8f158d54b50c00..04efd6e4b1a7ff388ba21052bd0b94147b35a2d0 100644 (file)
--- a/scores.cc
+++ b/scores.cc
@@ -6,6 +6,8 @@ static svec<Score*> sv;
 
 static String outfn="lelie.uit";
 
+// todo: check we don't overwrite default output.
+
 void
 do_scores()
 {
index 91b77617386532c3fb0648469882eca87a6690ca..b8f02c57987a19dc5fd450a41d1a068e259b7976 100644 (file)
@@ -6,10 +6,9 @@
 #include "molecule.hh"
 #include "sccol.hh"
 
-Item *
-Simple_column::create_req_item(Request *rq)
+Molecule *
+Simple_column::create_req_mol(Request *rq)
 {
-    Item *i = new Item;
     Symbol s;
     int dots=0;
 
@@ -29,13 +28,11 @@ Simple_column::create_req_item(Request *rq)
        dm.add(Atom(d));
        m->add_right(dm);
     }
-    i->output=m;
-    return i;
+    return m;
 }
-Item *
-Simple_column::create_command_item(Command *com)
+Molecule *
+Simple_column::create_command_mol(Command *com)
 {
-    Item *i = new Item;
     Symbol s;
 
     if (com -> args[0] ==  "BAR" ) {
@@ -59,8 +56,8 @@ Simple_column::create_command_item(Command *com)
        if (!wid.empty())
            m->translate(Offset(wid.max,0));
     }
-    i->output=m;
-    return i;
+    
+    return m;
 }
 
 void
index 763a9ed3930ff923e6055cd0181610bf72d194bb..97250b48cb9206b51dd8d34f0d11029ed46722a5 100644 (file)
@@ -12,6 +12,7 @@ Simple_column::Simple_column(Score_column*s, Simple_staff *rs)
     : Staff_column(s)
 {
     the_note = 0;
+    stem_ = 0;    
     staff_ = rs;
 }
 
@@ -20,7 +21,6 @@ Simple_staff::Simple_staff()
     theline = 0;
 }
 
-// should integrate handling of BREAK commands into Staff_column
 void
 Simple_column::process_commands( )
 {
@@ -50,7 +50,7 @@ Simple_column::process_commands( )
  accept:
 
     BREAK: all
-    TYPESET: bar, meter
+    TYPESET: bar, meter,
 
     */
 
@@ -64,12 +64,15 @@ Simple_column::process_requests()
            Request *rq= rqc;
            if (rq->rhythmic()){
                if (the_note){
-                   WARN << "too many notes.\n";
-                   return;
+                   WARN << "too many notes.\n";                    
                }
                the_note = rq;
+               
            }
-           break;
+           if (rq->stem()) {
+               stem_ = rq->stem();
+           }
+
        }
 }
 
@@ -80,6 +83,8 @@ Simple_staff::grant_requests()
        Simple_column *rp = (Simple_column*)*cc;
        if (rp->the_note)
            rp->typeset_req( rp->the_note);
+       if (rp->stem_)
+           rp->typeset_stem(rp->stem_->stem());
     }
 }
 
index e2efafe398e870b62362ba4fcfabe098e0f0b1d1..c965765adb8a0a4ffb3a3093be33d8e1010bdf86 100644 (file)
@@ -19,16 +19,18 @@ struct Simple_staff;
 struct Simple_column : Staff_column {
 
     Request *the_note;
+    Stem_req *stem_;
+    
     Simple_staff* staff_;
 
     /****************/
-    
+    virtual void typeset_stem(Stem_req *rq)=0;
     virtual void typeset_req(Request *rq)=0;
     virtual void typeset_command(Command *, int brs)=0;
     virtual void typeset_item(Item *, int=1);
 
-    Item *create_command_item(Command *com);
-    Item *create_req_item(Request *rq);
+    Molecule *create_command_mol(Command *com);
+    Molecule *create_req_mol(Request *rq);
     void take_request(Request *rq);
     
     virtual void process_commands( );
diff --git a/spanner.cc b/spanner.cc
new file mode 100644 (file)
index 0000000..f9eb653
--- /dev/null
@@ -0,0 +1,32 @@
+
+#include "spanner.hh"
+#include "line.hh"
+
+#include "symbol.hh"
+#include "molecule.hh"
+#include "pcol.hh"
+
+String
+Spanner::TeXstring() const
+{
+    assert(right->line);
+    Real w = left->hpos - right->hpos;
+    return strets->eval(w).tex;
+}
+
+Spanner *
+Spanner::broken_at(const PCol *c1, const PCol *c2) const
+{
+    Spanner *sp = new Spanner(*this);
+    sp->left = c1;
+    sp->right = c2;
+    return sp;
+}
+
+Spanner::Spanner()
+{
+    pstaff_=0;
+    strets=0;
+    left = right = 0;
+}
+
diff --git a/spanner.hh b/spanner.hh
new file mode 100644 (file)
index 0000000..542357f
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+  spanner.hh -- part of LilyPond
+
+  (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef SPANNER_HH
+#define SPANNER_HH
+#include "proto.hh"
+
+/// a symbol which is attached between two columns.
+struct Spanner {
+    const PCol *left, *right;
+    Parametric_symbol *strets;
+    PStaff * pstaff_;
+    ///      clone a piece of  this spanner.
+    Spanner *broken_at(const PCol *c1, const PCol *c2) const; 
+    /**
+    PRE
+    c1 >= start, c2  <= stop
+    */
+    /****************/
+    String TeXstring () const ;
+    Spanner();
+};
+/** Spanner should know about the items which it should consider:
+    e.g. slurs should be steep enough to "enclose" all those items. This
+    is absolutely necessary for beams, since they have to adjust the
+    length of stems of notes they encompass.
+
+    */
+#endif
diff --git a/stem.cc b/stem.cc
new file mode 100644 (file)
index 0000000..33198ad
--- /dev/null
+++ b/stem.cc
@@ -0,0 +1,90 @@
+#include "stem.hh"
+#include "dimen.hh" 
+#include "debug.hh"
+#include "pstaff.hh"
+#include "pscore.hh"
+#include "paper.hh"
+#include "lookupsyms.hh"
+#include "molecule.hh"
+
+const int STEMLEN=7;
+
+Stem::Stem(int c)
+{
+    minnote = maxnote = 0;
+    bot = top = 0;
+    flag = 4;
+    staff_center=c;
+}
+
+void
+Stem::print()const
+{
+    mtor << "Stem minmax=["<< minnote<<","<<maxnote<<"], flag: "<<flag;
+    Item::print();
+}
+
+void
+Stem::calculate()
+{
+    assert(minnote<=maxnote);
+    int stafftop = 2*staff_center;
+
+    if (maxnote < -2){
+       bot = minnote;
+       top = staff_center - staff_center/2; // uhh... how about non 5-line staffs?
+       
+    }else if (minnote > stafftop + 2) {
+       top = maxnote;
+       bot = staff_center + staff_center/2;
+       flag = -flag;
+    }else {
+       Real mean = (minnote+maxnote)/2;
+       
+       top = (mean > staff_center) ? maxnote : maxnote+STEMLEN;
+       bot = (mean > staff_center) ? minnote-STEMLEN : minnote;
+       flag = (mean > staff_center) ? -flag : flag;
+    }
+}
+
+Interval
+Stem::width()const
+{
+    if (ABS(flag) <= 4)
+       return Interval(0,0);   // TODO!
+    Paperdef*p= pstaff_->pscore_->paper_;
+    return p->lookup_->flag(flag).dim.x;
+}
+
+void
+Stem::brew_molecole()
+{
+    assert(pstaff_);
+    Paperdef *p = pstaff_->pscore_->paper_;
+    Parametric_symbol *stem = p->lookup_->stem();
+
+    assert(bot!=top);
+    assert(!output);
+    
+    Real dy = p->interline()/2;
+    String y1 =print_dimen( dy * bot);
+    String y2 = print_dimen(dy * top);
+    Symbol ss =stem->eval(y1,y2);
+    output = new Molecule(Atom(ss));
+
+    if (ABS(flag) > 4){
+       Symbol fl = p->lookup_->flag(flag);
+       Molecule m(fl);
+       if (flag < -4){         
+           output->add_bot(m);
+       } else if (flag > 4) {
+           output->add_top(m);
+       } else
+           assert(false); 
+    }
+
+    if (flag > 0){     
+       Real dx = pstaff_->pscore_->paper_->note_width(); // ugh
+       output->translate(Offset(dx,0));
+    }
+}
diff --git a/stem.hh b/stem.hh
new file mode 100644 (file)
index 0000000..039bc51
--- /dev/null
+++ b/stem.hh
@@ -0,0 +1,31 @@
+/*
+  stem.hh -- part of LilyPond
+
+  (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef STEM_HH
+#define STEM_HH
+#include "item.hh"
+
+struct Stem : public Item {
+    // heads the stem encompasses (positions)
+    int minnote, maxnote;
+
+    int staff_center;
+
+    // extent of the stem (positions)
+    int bot, top;
+    
+    // flagtype? 4 none, 8 8th flag, 0 = beam.
+    int flag;
+    
+        
+    /****************/
+    void brew_molecole();
+    void calculate();
+    Stem(int center);
+    void print() const;
+    Interval width() const;    
+};
+#endif
index 3671dae8afdfe8138979d813d26d05630ced9d48..39553133ec372aad26ae97c59160d749d00e0ee0 100644 (file)
@@ -8,9 +8,9 @@ symboltables
 # the "index" entry is hardwired into lilypond.
 
 table balls
-       1       \wholeball      -5pt    5pt     -2.5pt  2.5pt
-       2       \halfball       -5pt    5pt     -2.5pt  2.5pt
-       4       \quartball      -5pt    5pt     -2.5pt  2.5pt
+       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 bars
@@ -37,11 +37,23 @@ end
 table param
        meter   \generalmeter{%}{%}     -3pt    10pt    -5pt    5pt
        linestaf \linestafsym{%}{%}     0pt     0pt     0pt     0pt
+       stem    \stem{%}{%}             0pt     0pt     0pt     0pt
+
 end
 
 table dots
        1       \lsingledot             0pt     8pt     -1pt    1pt
        2       \ldoubledot             0pt     12pt    -1pt    1pt
        3       \ltripledot             0pt     16pt    -1pt    1pt
-end 
+end
+
+table flags
+       8       \eigthflag              0pt     5pt     0pt     0pt     
+       16      \sixteenthflag          0pt     5pt     0pt     0pt
+       32      \thirtysecondflag       0pt     5pt     0pt     0pt
+       -8      \ieigthflag             -5pt    0pt     0pt     0pt
+       -16     \isixteenthflag         -5pt    0pt     0pt     0pt
+       -32     \ithirtysecondflag      -5pt    0pt     0pt     0pt
+end
+
 end # symboltables
\ No newline at end of file
index eedb25a4e5235d6f3d700d52ce5865c16f0fde27..e963b64d12bf6a2e5fda5ccc605657f3a940b7a3 100644 (file)
@@ -13,9 +13,7 @@ Symtable::lookup(String s) const
     if (elt_query(s))
        return (*this)[s];
     else {
-        Symbol unknown;
-       WARN<<"Unknown symbol " << s <<'\n';
-       return unknown;
+       error( "Unknown symbol " +s+'\n');
     }
 }
 
index 01aba139e2762e1fd57aa3ed1ec22e3f2100366e..ece4e2ff18243ed46ae550e243ecb09ea3e9c808 100644 (file)
@@ -5,11 +5,12 @@
 #include "item.hh"
 #include "request.hh"
 #include "command.hh"
+#include "spanner.hh"
 
 #include "list.cc"
-
 #include "plist.cc"
 #include "cursor.cc"
+
 #define PLC_instantiate(a) PL_instantiate(a); PL_instantiate(const a)
 
 PLC_instantiate(Line_of_score);
index 1c54a2cb9490072fddf499c63a7dac2ab5378bef..5e0431c42abe1ab7d64eec7dcc932bf6494b2276 100644 (file)
@@ -5,6 +5,7 @@
 #include "staff.hh"
 #include "sccol.hh"
 #include "stcol.hh"
+#include "spanner.hh"
 
 #include "list.cc"
 #include "plist.cc"
index ae9342b487e1bbe48b5db86345dc19b536ea9a51..379cbae23a073fd23fb22e2cea4caaa0cdc2f1a5 100644 (file)
--- a/voice.cc
+++ b/voice.cc
@@ -1,14 +1,10 @@
 #include "debug.hh"
 #include "voice.hh"
 
-void
-Voice_element::add(Request*r)
+Voice::Voice(Voice const&src)
 {
-    if (r->rhythmic()) {
-       assert (!duration);         
-       duration = r->duration();
-    }
-    reqs.bottom().add(r);
+    PL_copy(elts, src.elts);
+    start = src.start;
 }
 
 Voice::Voice()
@@ -22,13 +18,6 @@ Voice::add(Voice_element*v)
     elts.bottom().add(v);
 }
 
-Voice_element::Voice_element()
-{
-    voice = 0;
-    group = 0;
-    duration = 0.0;
-}
-
 void
 Voice::print() const
 {
@@ -39,6 +28,16 @@ Voice::print() const
        vec->print();
 #endif
 }
+
+Real
+Voice::last() const
+{
+    Real l =start;
+    for (PCursor<Voice_element*> vec(elts); vec.ok(); vec++)
+       l  += vec->duration;
+    return l;
+}
+/****************************************************************/
 void
 Voice_element::print() const
 {
@@ -50,12 +49,29 @@ Voice_element::print() const
     mtor << "}\n";
 #endif
 }
+void
+Voice_element::add(Request*r)
+{
+    if (r->rhythmic()) {
+       assert (!duration);         
+       duration = r->duration();
+    }
+    reqs.bottom().add(r);
+}
 
-Real
-Voice::last() const
+
+Voice_element::Voice_element()
 {
-    Real l =start;
-    for (PCursor<Voice_element*> vec(elts); vec.ok(); vec++)
-       l  += vec->duration;
-    return l;
+    voice = 0;
+    group = 0;
+    duration = 0.0;
+}
+
+Voice_element::Voice_element(Voice_element const&src)
+{
+    duration=src.duration;
+    voice=src.voice;
+    PointerList__copy(Request*, reqs, src.reqs, clone());
+    group=src.group;
+    assert(!granted_items.size() && !granted_spanners.size());
 }
index b409fa4cd34bccfeb058f9c61c03cbff0d64f316..59b0dc831515a06cb05914a5a9e25012163c9a66 100644 (file)
--- a/voice.hh
+++ b/voice.hh
@@ -14,6 +14,7 @@ struct Voice {
     Real when(const Voice_element*)const;
     Real last() const;
     Voice();
+        Voice(    Voice const&);
     void add(Voice_element*);
     void print() const;
 };
@@ -42,7 +43,7 @@ struct Voice_element {
     
     void add(Request*);
     Voice_element();
-
+    Voice_element(Voice_element const & src );
     void print ()const;
 };
 /** Apart from being a container for the requests, Voice_element is