summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--README2
-rw-r--r--Sources.make10
-rw-r--r--TODO15
-rw-r--r--debug.cc15
-rw-r--r--flower/Makefile2
-rw-r--r--flower/Sources.make2
-rw-r--r--flower/TODO4
-rw-r--r--flower/compare.hh20
-rw-r--r--flower/cursor.hh13
-rw-r--r--flower/cursor.inl10
-rw-r--r--flower/list.cc87
-rw-r--r--flower/list.hh2
-rw-r--r--flower/list.inl93
-rw-r--r--flower/pcursor.hh38
-rw-r--r--flower/plist.cc10
-rw-r--r--flower/plist.hh34
-rw-r--r--flower/plist.inl29
-rw-r--r--flower/vray.hh2
-rw-r--r--item.cc30
-rw-r--r--item.hh32
-rw-r--r--lexer.l2
-rw-r--r--lilyponddefs.tex50
-rw-r--r--line.cc101
-rw-r--r--line.hh7
-rw-r--r--lookupsyms.cc33
-rw-r--r--lookupsyms.hh2
-rw-r--r--maartje.ly5
-rw-r--r--main.cc2
-rwxr-xr-xmake_patch23
-rw-r--r--melodicstaff.cc32
-rw-r--r--melodicstaff.hh3
-rw-r--r--molecule.cc11
-rw-r--r--note.cc7
-rw-r--r--paper.cc6
-rw-r--r--paper.hh1
-rw-r--r--parser.y2
-rw-r--r--request.cc9
-rw-r--r--request.hh26
-rw-r--r--rhythmstaff.cc24
-rw-r--r--rhythmstaff.hh1
-rw-r--r--scores.cc2
-rw-r--r--simpleprint.cc17
-rw-r--r--simplestaff.cc15
-rw-r--r--simplestaff.hh8
-rw-r--r--spanner.cc32
-rw-r--r--spanner.hh33
-rw-r--r--stem.cc90
-rw-r--r--stem.hh31
-rw-r--r--symbol.ini20
-rw-r--r--symtable.cc4
-rw-r--r--template1.cc3
-rw-r--r--template2.cc1
-rw-r--r--voice.cc56
-rw-r--r--voice.hh3
55 files changed, 707 insertions, 407 deletions
diff --git a/Makefile b/Makefile
index c85f6fd2ff..4f747e6c95 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
MAJVER=0
MINVER=0
-PATCHLEVEL=6
+PATCHLEVEL=7
#
#
diff --git a/README b/README
index b60e7f2bbd..41c366eec3 100644
--- 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
diff --git a/Sources.make b/Sources.make
index deb1a524c4..fcc62df96c 100644
--- a/Sources.make
+++ b/Sources.make
@@ -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 d60c09dbb7..1f96a09b76 100644
--- 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
diff --git a/debug.cc b/debug.cc
index 34859a3c9f..d55c901945 100644
--- 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);
}
diff --git a/flower/Makefile b/flower/Makefile
index 3e9a70ce15..e17cbdb0d8 100644
--- a/flower/Makefile
+++ b/flower/Makefile
@@ -1,6 +1,6 @@
MAJVER=1
MINVER=0
-PATCHLEVEL=6
+PATCHLEVEL=7
PACKAGENAME=flower
VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
diff --git a/flower/Sources.make b/flower/Sources.make
index e8b2250ad1..8016e67323 100644
--- a/flower/Sources.make
+++ b/flower/Sources.make
@@ -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\
diff --git a/flower/TODO b/flower/TODO
index f7070ecd07..4d0774ff7c 100644
--- a/flower/TODO
+++ b/flower/TODO
@@ -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
diff --git a/flower/compare.hh b/flower/compare.hh
index 47c7101c87..9f9d4e5906 100644
--- a/flower/compare.hh
+++ b/flower/compare.hh
@@ -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; }\
\
diff --git a/flower/cursor.hh b/flower/cursor.hh
index 1c61b1a76c..4babf96545 100644
--- a/flower/cursor.hh
+++ b/flower/cursor.hh
@@ -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
diff --git a/flower/cursor.inl b/flower/cursor.inl
index bdc242590f..0b077bd811 100644
--- a/flower/cursor.inl
+++ b/flower/cursor.inl
@@ -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>
diff --git a/flower/list.cc b/flower/list.cc
index 741e4ee97c..ce5e366cc8 100644
--- a/flower/list.cc
+++ b/flower/list.cc
@@ -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
diff --git a/flower/list.hh b/flower/list.hh
index 5a825fa89e..1516e16642 100644
--- a/flower/list.hh
+++ b/flower/list.hh
@@ -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.
diff --git a/flower/list.inl b/flower/list.inl
index 8bdcf15877..d71e947050 100644
--- a/flower/list.inl
+++ b/flower/list.inl
@@ -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
diff --git a/flower/pcursor.hh b/flower/pcursor.hh
index 095bcc45bf..6cc3433e25 100644
--- a/flower/pcursor.hh
+++ b/flower/pcursor.hh
@@ -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
diff --git a/flower/plist.cc b/flower/plist.cc
index bbb0e7428f..5c8e47093c 100644
--- a/flower/plist.cc
+++ b/flower/plist.cc
@@ -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);
}
}
-
-
-
-
diff --git a/flower/plist.hh b/flower/plist.hh
index 8fa126b527..1bfc2d4ab4 100644
--- a/flower/plist.hh
+++ b/flower/plist.hh
@@ -11,21 +11,25 @@
/// 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"
diff --git a/flower/plist.inl b/flower/plist.inl
index b8cd8d6020..82be364334 100644
--- a/flower/plist.inl
+++ b/flower/plist.inl
@@ -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
diff --git a/flower/vray.hh b/flower/vray.hh
index c03e651034..ab6255109b 100644
--- a/flower/vray.hh
+++ b/flower/vray.hh
@@ -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 96ec8a890a..4a84f47704 100644
--- a/item.cc
+++ b/item.cc
@@ -4,31 +4,6 @@
#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
{
return output->TeXstring();
@@ -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 484822533b..cf3d11c313 100644
--- 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 008f813bf5..220b07ccf8 100644
--- 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]*)?
%%
diff --git a/lilyponddefs.tex b/lilyponddefs.tex
index 24dd617150..45152140cb 100644
--- a/lilyponddefs.tex
+++ b/lilyponddefs.tex
@@ -12,20 +12,20 @@
\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}
@@ -43,32 +43,52 @@
\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}
@@ -79,4 +99,10 @@
\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 a6e0f7c68a..293214dc30 100644
--- 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 3e698659e9..641ddf257d 100644
--- 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
diff --git a/lookupsyms.cc b/lookupsyms.cc
index f0624cad1e..294f2e9af4 100644
--- a/lookupsyms.cc
+++ b/lookupsyms.cc
@@ -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_);
+}
diff --git a/lookupsyms.hh b/lookupsyms.hh
index a3c0750d0e..f7ac3858ac 100644
--- a/lookupsyms.hh
+++ b/lookupsyms.hh
@@ -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);
diff --git a/maartje.ly b/maartje.ly
index 00d4ea8d5e..50ce2cb577 100644
--- a/maartje.ly
+++ b/maartje.ly
@@ -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 5e518752cf..3c33fd959d 100644
--- 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()) {
diff --git a/make_patch b/make_patch
index c2a1e50f8a..2e9246f4d7 100755
--- a/make_patch
+++ b/make_patch
@@ -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)
diff --git a/melodicstaff.cc b/melodicstaff.cc
index 60d9a6fd2e..83e038652f 100644
--- a/melodicstaff.cc
+++ b/melodicstaff.cc
@@ -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
*/
diff --git a/melodicstaff.hh b/melodicstaff.hh
index a91a413659..5c417b84a5 100644
--- a/melodicstaff.hh
+++ b/melodicstaff.hh
@@ -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) { }
diff --git a/molecule.cc b/molecule.cc
index 5ab384f87d..8fca34836b 100644
--- a/molecule.cc
+++ b/molecule.cc
@@ -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 bb0702f143..b897ce0e66 100644
--- 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;
}
diff --git a/paper.cc b/paper.cc
index 6e5e87bda8..a0e533f626 100644
--- 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
{
diff --git a/paper.hh b/paper.hh
index 9ce4d2bf4e..e96d9b089f 100644
--- 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;
};
diff --git a/parser.y b/parser.y
index 7e2be63a68..4ca199bb77 100644
--- 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:
diff --git a/request.cc b/request.cc
index 88fdb3349f..fd032fcfd8 100644
--- a/request.cc
+++ b/request.cc
@@ -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
{
diff --git a/request.hh b/request.hh
index 8ebb1468c0..04664966b3 100644
--- a/request.hh
+++ b/request.hh
@@ -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?
diff --git a/rhythmstaff.cc b/rhythmstaff.cc
index 4e564bdf88..7e2706e02d 100644
--- a/rhythmstaff.cc
+++ b/rhythmstaff.cc
@@ -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
*/
diff --git a/rhythmstaff.hh b/rhythmstaff.hh
index 7fe7c6a887..130f6483b9 100644
--- a/rhythmstaff.hh
+++ b/rhythmstaff.hh
@@ -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);
diff --git a/scores.cc b/scores.cc
index 46685d6050..04efd6e4b1 100644
--- 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()
{
diff --git a/simpleprint.cc b/simpleprint.cc
index 91b7761738..b8f02c5798 100644
--- a/simpleprint.cc
+++ b/simpleprint.cc
@@ -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
diff --git a/simplestaff.cc b/simplestaff.cc
index 763a9ed393..97250b48cb 100644
--- a/simplestaff.cc
+++ b/simplestaff.cc
@@ -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());
}
}
diff --git a/simplestaff.hh b/simplestaff.hh
index e2efafe398..c965765adb 100644
--- a/simplestaff.hh
+++ b/simplestaff.hh
@@ -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
index 0000000000..f9eb65367b
--- /dev/null
+++ b/spanner.cc
@@ -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
index 0000000000..542357f7a2
--- /dev/null
+++ b/spanner.hh
@@ -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
index 0000000000..33198addde
--- /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
index 0000000000..039bc5182c
--- /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
diff --git a/symbol.ini b/symbol.ini
index 3671dae8af..39553133ec 100644
--- a/symbol.ini
+++ b/symbol.ini
@@ -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
diff --git a/symtable.cc b/symtable.cc
index eedb25a4e5..e963b64d12 100644
--- a/symtable.cc
+++ b/symtable.cc
@@ -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');
}
}
diff --git a/template1.cc b/template1.cc
index 01aba139e2..ece4e2ff18 100644
--- a/template1.cc
+++ b/template1.cc
@@ -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);
diff --git a/template2.cc b/template2.cc
index 1c54a2cb94..5e0431c42a 100644
--- a/template2.cc
+++ b/template2.cc
@@ -5,6 +5,7 @@
#include "staff.hh"
#include "sccol.hh"
#include "stcol.hh"
+#include "spanner.hh"
#include "list.cc"
#include "plist.cc"
diff --git a/voice.cc b/voice.cc
index ae9342b487..379cbae23a 100644
--- 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());
}
diff --git a/voice.hh b/voice.hh
index b409fa4cd3..59b0dc8315 100644
--- 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