-#class name silence?
+# class name silence?
My_flex_lexer 0
yyFlexLexer 0
-PCol 0
+PCol 1
Score_column 1
Ineq_constrained_qp 1
Spacing_problem 1
Colinfo 1
Mixed_qp 1
PScore 1
+Idealspacing 1
# yydebug
-Parser 1
+Parser 0
# FlexLexer debug
-Lexer 0
+Lexer 1
parse_duration 1
-parse_pitch 1
+parse_pitchmod 1
Col_configuration 1
+Request 1
Note_req 1
Rhythmic_req 1
Rest_req 1
delete_identifiers 1
Command 1
-Staff_commands 0
+Staff_commands 1
Stem 0
Staff 0
Score 0
Voice 0
-Voice_element 0
-Request 0
-Input_cursor 1
\ No newline at end of file
+Voice_element 1
+Input_cursor 1
+Commands_at 0
+Input_command 1
\ No newline at end of file
''!c8.-"text"_v
-
a lot of characters parse differently
than in "command" mode, eg,
OTHER
A correctly parsed .ly does not guarantuee output. A lot (most) of the
-checking is done *after* parsing (some checks are after the break calc!)
-I'm sorry.
+checking is done *after* parsing (some checks even are done after the
+break calc!); I'm sorry.
The parser's job is to construct appropriate objects. It will *only*
detect parse errors.
LilyPond first reads 'symbol.ini', which contains declarations crucial
-to proper operation of LilyPond (symbol tables)
+to proper operation of LilyPond (symbol tables, note names)
This language looks a lot like Rayce's which in turn owes a lot to the
POVRay raytracer. Now, I know, musictypesetting and Raytracing do not
all: kompijl doc
# doc++ documentation of classes
-doc:
+doc: $(progdocs)
-mkdir $(DOCDIR)
- doc++ -p -I -d $(DOCDIR) $(progdocs)
+ doc++ -p -I -d $(DOCDIR) $^
depend: Sources.make .GENERATE
touch depend
--- /dev/null
+pl 17:
+ - robust Input_commands
+ - merged Vertical_/Horizontal music
+ - PARTIALs with duration
+ - modularized lexer: multiple runs
+
+pl 16
+ - notenames configurable
+
+pl 15
+ - grouping code
+ - multibeams (simple)
+
+pl 14
+ - symtables from .ly
+ - Input_command
+ - Input_{score/staff}
+
+pl 13
+ - Horizontal/Vertical music
+ - Input_commands
Compilation:
- - Unix (any decent Linux distrib is fine)
+ - Unix (any decent Linux distribution is fine)
- GNU C++ v2.7 or better
- GNU make.
- - flex
+ - flex (2.5.1 or better)
- bison/yacc
- - The "flower" library
- - which should be available from the same source you got this from.
+ - The "flower" library, which should be available from the
+ same source you got this from.
+ - perl
Operation:
- TeX
- the MusixTeX fonts
-The Makefile uses perl for trivial
-operations, and you could tinker with it to use sed or awk.
+The Makefile uses perl for trivial operations, and you could tinker
+with it to use sed or awk.
COMPILING
USING
-No, you shouldn't. Really. If you're still not discouraged; this is
+At this time, LilyPond is only suited for Quick & Dirty jobs (the
+output quality still is too low). If you're not discouraged; this is
what I type in my xterm:
- lilypond maartje.ly
+ lilypond someinput.ly
tex test
xdvi test&
-This is what the output looks like over here.
+This is what the output looks like over here:
hw:~/musix/spacer$ lilypond maartje.ly
LilyPond version 0.0.16 compiled on Dec 11 1996 at 13:54:27
hw:~/musix/spacer$ xdvi test&
[1] 1468
+Check out kortjakje.ly, it has some comments
+
PROBLEMS
If LilyPond bombs out, then please recompile using -g, and send a gdb
inputcommand.hh grouping.hh
mycc= qlp.cc qlpsolve.cc leastsquares.cc\
- inputcommands.cc inputmusic.cc inputcursor.cc\
+ inputcommands.cc inputmusic.cc \
inputscore.cc inputstaff.cc\
break.cc linespace.cc molecule.cc staffline.cc\
pscore.cc tex.cc item.cc pcol.cc staff.cc \
simplewalker.cc\
texbeam.cc texslur.cc clef.cc key.cc slur.cc beam.cc\
idealspacing.cc inputcommand.cc grouping.cc identifier.cc\
+ lexerinit.cc mylexer.cc\
template1.cc template2.cc template3.cc template4.cc\
version.cc
EXTRACXXFLAGS=-pipe -Wall -W -Wmissing-prototypes
# -Woverloaded-virtual
+#
+# -lefence = ElectricFence.
+#
+# ElectricFence is memory debugger which uses the
+# VM hardware to trap malloc/free errors.
+#
+#EXTRALIB+=-lefence
+
####
#### END USER CONFIGURABLE part.
####
# version info
MAJVER=0
MINVER=0
-PATCHLEVEL=16
+PATCHLEVEL=17
VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
CXXVER=`$(CXX) --version`
SCRIPTS=make_version make_patch genheader
IFILES=dimen.tex symbol.ini kortjakje.ly pavane.ly maartje.ly\
lilyponddefs.tex test.tex .dstreamrc
-OFILES=Makefile Variables.make Sources.make COPYING README
+OFILES=Makefile Variables.make Sources.make COPYING README NEWS
DFILES=$(OFILES) $(IFILES) $(SCRIPTS)
#compiling
cc=lgetopt.cc string.cc dataf.cc textdb.cc unionfind.cc \
smat.cc matrix.cc choleski.cc vector.cc dstream.cc\
- matdebug.cc interval.cc scalar.cc
+ matdebug.cc scalar.cc
-templatecc=cursor.cc list.cc tsmat.cc plist.cc
+templatecc=cursor.cc list.cc tsmat.cc plist.cc interval.cc
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\
smat.hh vsmat.hh vector.hh real.hh choleski.hh\
tsmat.hh tvsmat.hh plist.hh associter.hh fproto.hh\
- interval.hh scalar.hh sstack.hh
+ interval.hh scalar.hh sstack.hh rational.hh
MAJVER=1
MINVER=0
-PATCHLEVEL=16
-
+PATCHLEVEL=17
PACKAGENAME=flower
-VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
-DNAME=$(PACKAGENAME)-$(VERSION)
-DEFINES=-DNDEBUG -O2
-#DEFINES=-g
+
+#PROFILEFLAG=-pg
+DEBUGFLAG=-g -O2
+OPTIFLAG=-DNDEBUG -DNPRINT -O2
+
+#########################################
+
+ifdef PROFILEFLAG
+ DEFINES+=$(OPTIFLAG) $(PROFILEFLAG)
+ EXTRALIB+=-pg
+endif
+
+ifndef DEBUGFLAG
+ DEFINES+=$(OPTIFLAG)
+else
+ DEFINES+=$(DEBUGFLAG)
+endif
+
+
CXXFLAGS+=$(DEFINES) -Wall -W
CXXVER=$(CXX) --version
+
+VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
+DNAME=$(PACKAGENAME)-$(VERSION)
+
include Sources.make
obs=$(cc:.cc=.o)
prefix one_operator(type, function, <)\
prefix one_operator(type, function, <=)\
gpp_minmax(type, prefix)\
-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; }\
+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; }\
\
prefix bool operator<(type t1, type t2) /* stupid fix to allow ; */
/**
template<class T> struct PCursor;
template<class T> struct Link;
template<class T> struct Handle ;
+template<class T>struct Interval_t ;
+#include "real.hh"
+typedef Interval_t<Real> Interval;
struct Choleski_decomposition ;
-struct Interval ;
+
struct long_option_init ;
struct Getopt_long ;
struct Matrix ;
#include "string.hh"
-const Real INFTY = HUGE;
-void
-Interval::set_empty() {
- min = INFTY;
- max = -INFTY;
-}
+template<class T>
+int
+Interval__compare(const Interval_t<T>&a,Interval_t<T> const&b)
+{
+ if (a.left == b.left && a.right == b.right)
+ return 0;
+
+ if (a.left <= b.left && a.right >= b.right)
+ return 1;
-Real
-Interval::length() const {
- assert(max >= min);
- return max-min;
-}
+ if (a.left >= b.left && a.right <= b.right)
+ return -1;
-void
-Interval::unite(Interval h)
-{
- compare(h, *this );
- if (h.min<min)
- min = h.min;
- if (h.max>max)
- max = h.max;
+ assert(false); // not comparable
+
+ return 0;
}
+const Real INFTY = HUGE;
+
+template<class T>
void
-Interval::intersect(Interval h)
-{
- min = MAX(h.min, min);
- max = MIN(h.max, max);
+Interval_t<T>::set_empty() {
+ left = INFTY;
+ right = -INFTY;
}
-Interval
-intersection(Interval a, Interval const&b)
-{
- a.intersect(b);
- return a;
-
+template<class T>
+T
+Interval_t<T>::length() const {
+ assert(right >= left);
+ return right-left;
}
-int
-Interval::compare(const Interval&a,Interval const&b)
+template<class T>
+void
+Interval_t<T>::unite(Interval_t<T> h)
{
- if (a.min == b.min && a.max == b.max)
- return 0;
-
- if (a.min <= b.min && a.max >= b.max)
- return 1;
-
- if (a.min >= b.min && a.max <= b.max)
- return -1;
+ if (h.left<left)
+ left = h.left;
+ if (h.right>right)
+ right = h.right;
+}
- assert(false); // not comparable
+/**
+ smallest Interval which includes *this and #h#
+ */
- return 0;
+template<class T>
+void
+Interval_t<T>::intersect(Interval_t<T> h)
+{
+#if defined (__GNUG__) && ! defined (__STRICT_ANSI__)
+ left = h.left >? left;
+ right = h.right <?right;
+#else
+ left = max(h.left, left);
+ right = min(h.right, right);
+#endif
}
-Interval
-intersect(Interval x, Interval const &y)
+template<class T>
+Interval_t<T>
+intersect(Interval_t<T> x, Interval_t<T> const &y)
{
x.intersect(y);
return x;
}
-
+
+template<class T>
String
-Interval::str() const
+Interval_t<T>::str() const
{
if (empty())
return "[empty]";
String s("[");
- return s + min + "," + max +"]";
+ return s + left + "," + right +"]";
}
+
+template<class T>
bool
-Interval::elt_q(Real r)
+Interval_t<T>::elt_q(T r)
{
- return r >= min && r <= max;
+ return r >= left && r <= right;
}
#include "real.hh"
-/// a Real interval
-struct Interval {
- Real min, max;
+/// a T interval
+template<class T>
+struct Interval_t {
+ T left, right;
/****************/
- Real center() { return (min + max) /2;}
- void translate(Real t) {
- min += t;
- max += t;
+ T center() { return (left + right) /2;}
+ void translate(T t) {
+ left += t;
+ right += t;
}
- Real operator[](int j) {
+ T operator[](int j) {
if (j==-1)
- return min;
+ return left;
else if (j==1)
- return max;
+ return right;
else
assert(false);
- return 0.0;
-
+ return 0;
}
- void unite(Interval h) ;
+ void unite(Interval_t<T> h);
/**
PRE
*this and h are comparable
*/
- void intersect(Interval h);
+ void intersect(Interval_t<T> h);
- Real length() const;
+ T length() const;
void set_empty() ;
- bool empty() const { return min > max; }
- Interval() {
+ bool empty() const { return left > right; }
+ Interval_t() {
set_empty();
}
- Interval(Real m, Real M) {
- min =m;
- max = M;
+ Interval_t(T m, T M) {
+ left =m;
+ right = M;
}
- Interval &operator += (Real r) {
- min += r;
- max +=r;
+ Interval_t<T> &operator += (T r) {
+ left += r;
+ right +=r;
return *this;
}
- bool elt_q(Real r);
- String str() const;
-
- /// partial ordering
- static compare(const Interval&,Interval const&);
- /**
- inclusion ordering. Crash if not comparable.
- */
+ String str() const;
+ bool elt_q(T r);
};
/**
- this represents the closed interval [min,max].
- No invariants
+ this represents the closed interval [left,right].
+ No invariants. T must be a totally ordered ring
+ */
+
+/// partial ordering
+template<class T>
+int Interval__compare(const Interval_t<T>&,Interval_t<T> const&);
+/**
+ inclusion ordering. Crash if not comparable.
*/
-Interval intersection(Interval, Interval const&);
+/****************************************************************
+ INLINE
+ ****************************************************************/
#include "compare.hh"
-instantiate_compare(Interval&, Interval::compare);
+template_instantiate_compare(Interval_t<T>&, Interval__compare, template<class T>);
+template<class T>
+inline Interval_t<T>
+intersection(Interval_t<T> a, Interval_t<T> const&b)
+{
+ a.intersect(b);
+ return a;
+
+}
+
+
+template<class T>
inline
-Interval operator +(double a,Interval i )
+Interval_t<T> operator +(T a,Interval_t<T> i )
{
i += a;
return i;
}
+template<class T>
inline
-Interval operator +(Interval i,double a ){
+Interval_t<T> operator +(Interval_t<T> i,T a ){
return a+i;
}
+typedef Interval_t<Real> Interval;
+
+
+#define Interval__instantiate(T) template struct Interval_t<T>;\
+ template int Interval__compare(const Interval_t<T>&,Interval_t<T> const&)
+
+
#endif // INTERVAL_HH
--- /dev/null
+#include <Rational.h>
#ifndef REAL_HH
#define REAL_HH
-typedef double Real;
-inline Real sqr(Real x){
- return x*x;
-}
-inline Real MIN(Real x, Real y) {
- return (x < y)? x : y;
-}
-inline Real MAX(Real x, Real y) {
- return (x > y) ? x : y;
-}
-inline Real ABS(Real x)
-{
- return (x>0)? x:-x;
-}
-inline
-int sgn(Real x) {
- if (!x)return 0;
- return (x > 0) ?1: -1;
-}
+#include <builtin.h>
+#include <minmax.h>
+#include <std/cmath.h>
+
+typedef double Real;
+
inline Real
distance(Real x,Real y)
{
- return ABS(x-y);
+ return abs(x-y);
}
#endif
#include <stdio.h>
#include "scalar.hh"
+Scalar::Scalar(Rational r)
+ :String(r)
+{
+
+}
+
+Scalar::operator Rational()
+{
+ int p = pos('/');
+ if (!p)
+ return int(*this);
+
+ String s2 = right(len()-p);
+ p--;
+ String s1 = left(p);
+
+ return Rational(s1.value(), s2.value());
+}
+
bool
Scalar::isnum()
{
assert (isnum());
return value();
}
+
bool
Scalar::to_bool() const
{
Scalar(char c) : String(c) {}
Scalar(const char *c) : String(c) {}
Scalar(String s ):String(s) {}
+ Scalar(Rational );
+ operator Rational();
Scalar() {}
bool isnum();
operator Real();
return s;
}
+String::String(Rational r)
+{
+ char * n = Itoa(r.numerator()); // LEAK????
+
+ *this = n;
+ if (r.denominator() != 1) {
+ char * d = Itoa(r.denominator());
+ *this += '/' + String(d);
+ //delete d;
+ }
+/* delete n;
+ */
+}
+
// return array, alloced with new.
char *
String::copy_array() const
// signed comparison, analogous to strcmp;
int
-String::compare( const char* test ) const
+String::compare(const String& s1,const String &s2 )
{
- if (test == (const char *) data)
+ const char * p1=s1.cptr();
+ const char * p2 = s2.cptr();
+ if (p1 == p2)
return 0;
- return strcmp(data, test);
+ return strcmp(p1,p2);
}
#include <string.h>
#include <iostream.h>
-
+#include <Rational.h>
#include "stringutil.hh"
/// init to ""
String() { }
/** needed because other constructors are provided.*/
-
+ String(Rational);
/// String s = "abc";
String( const char* source );
String nomid(int pos, int n ) const;
/// signed comparison, analogous to strcmp;
- int compare( const char* s ) const;
-
+ static int compare(const String& s1,const String& s2);
+
/// index of rightmost c
int lastPos( char c) const;
+
/// index of rightmost element of string
int lastPos( const char* string ) const;
convert to const char *.
*/
+#include "compare.hh"
+
+instantiate_compare(const String &, String::compare);
// because const char* also has an operator ==, this is for safety:
-inline bool operator==(String s1, String s2){ return !(s1.compare(s2));}
-inline bool operator==(String s1, const char *s2){ return !(s1.compare(s2));}
-inline bool operator==(const char *s1, String s2){ return !(s2.compare(s1));}
-inline bool operator!=(String s1, const char *s2 ) { return s1.compare(s2);}
-inline bool operator!=(const char *s1,String s2) { return s2.compare(s1);}
-inline bool operator!=(String s1, String s2 ) { return s1.compare(s2);}
+inline bool operator==(String s1, const char *s2){
+ return s1 == String(s2);
+}
+inline bool operator==(const char *s1, String s2)
+{
+ return String(s1)==s2;
+}
+inline bool operator!=(String s1, const char *s2 ) {
+ return s1!=String(s2);
+}
+inline bool operator!=(const char *s1,String s2) {
+ return String(s2) !=s1;
+}
+
inline String
operator + (String s1, String s2)
void error(String s); // errors
void error_t(String s, Real when);
+
// warnings
void warning(String s);
#define WARN warnout << "warning: "<<__FUNCTION__ << "(): "
extern bool check_debug;
-
#endif
virtual const char*classname() { return "new Identifier"; }
void error();
virtual Input_staff * staff(bool = false) { error(); return 0; }
- virtual Horizontal_music*hmusic(bool = false) { error(); return 0; }
- virtual Vertical_music*vmusic(bool = false) { error(); return 0; }
+ virtual Input_music *music(bool = false) { error(); return 0; }
virtual Music_voice *mvoice(bool = false) { error(); return 0; }
virtual Symtables *symtables(bool = false) { error(); return 0; }
virtual Music_general_chord *mchord(bool = false) { error(); return 0; }
#include "vray.hh"
struct Input_command {
- Real when;
-
/// analogous to argv[]
svec<Scalar> args;
void print()const;
Input_command *get_partial_command(Real u);
Input_command* get_skip_command( int,Real);
Input_command* get_grouping_command( svec<int>);
-
-void
-interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat,
- Real& whole_per_measure);
-
-Input_command *get_bar_command(Real );
+Input_command *get_bar_command( );
#endif // INPUTCOMMAND_HH
#ifndef INPUTCOMMANDS_HH
#define INPUTCOMMANDS_HH
+
#include "pcursor.hh"
#include "proto.hh"
#include "plist.hh"
#include "real.hh"
+struct Commands_at : public IPointerList<Input_command*> {
+ Real when;
-struct Input_cursor : public PCursor<Input_command*>
-{
/// current measure info
Real whole_per_measure;
/// where am i
Real whole_in_measure;
-
- /// Real last when which was read
- Real last;
- int bars;
+ /// idem
- Input_cursor(PCursor<Input_command*>);
- /// hmm. not safe. Should rethink cursor.
- void operator++(int);
- /** warning: no optor -- () defined.. */
- void reset();
- Real when()const;
+ int bars;
+
+ /****************/
+ void print() const;
+ Real barleft();
void add(Input_command*);
void setpartial(Real);
- void addbot(Input_command*);
- void sync();
- void print()const;
- void last_command_here();
+ Commands_at(const Commands_at&);
+ Commands_at(Real, Commands_at*prev);
+};
+
+struct Input_cursor : public PCursor<Commands_at*>
+{
+ /****************/
+ Input_cursor(PCursor<Commands_at*>);
+ Real when()const;
+ void find_moment(Real w);
+ void prev() { operator --(0); }
+ void next() { operator ++(0); }
};
/// the list of commands in Score
-struct Input_commands : public IPointerList<Input_command*> {
+struct Input_commands : public IPointerList<Commands_at*> {
Input_cursor ptr;
-
+
/****************/
void find_moment(Real);
- void do_skip(int & bars, Real & wholes);
- void truncate(Real);
-
+ void add(Input_command c);
+ void do_skip(int bars, Real wholes);
+
Input_commands();
Input_commands(Input_commands const&);
- void add(Input_command);
+
void reset();
void print()const;
Staff_commands *parse() const;
};
+
void
interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat,
Real& whole_per_measure);
#include "plist.hh"
#include "proto.hh"
+#include "voice.hh"
struct Voice_list : public PointerList<Voice*> {
void translate_time(Real dt);
- /// delete stuff; not in destructor!
- void junk();
};
/// ABC for input structures
virtual Voice_list convert()=0;
virtual Real length()=0;
virtual void translate_time(Real dt)=0;
- virtual ~Input_music();
+ virtual ~Input_music(){}
virtual void print() const =0;
// virtual void transpose(...) const =0;
+
+
+ virtual Input_music *clone() const = 0;
+ virtual Simple_music *simple() { return 0; }
};
/**
*/
+/// Simple music consists of one voice
+struct Simple_music : Input_music {
+ Voice voice_;
-///
-struct Vertical_music : Input_music {
- virtual Vertical_music *clone() const = 0;
-
- /// check if it is a simple voice
- virtual Vertical_simple *simple() { return 0;}
-};
-/**
- chord like :
-
- - different music forms which start at the same time ( stacked "vertically" )
-
- This class really doesn't do very much, but it enables you to say
-
- a Music_voice is a List<Vertical_music>
-
- */
-
-///
-struct Horizontal_music : Input_music {
- virtual Voice_list convert()=0;
- virtual Horizontal_music *clone() const = 0;
-};
-/**
- voice like.
-
- different music forms which start after each other ( concatenated,
- stacked "horizontally )
-
- This class really doesn't do very much, but it enables you to say
-
- a Chord is a List<Horizontal_music>
-
- */
-
-/// the most basic element of a chord: a simple voice
-struct Vertical_simple : Vertical_music {
- Voice * voice_; // should be a real member
-
- /****************/
- Vertical_simple(Vertical_simple const&);
- Vertical_simple();
- ~Vertical_simple();
+ /****/
+ virtual Simple_music*simple() { return this; }
void add(Voice_element*);
- virtual Vertical_simple*simple() { return this; }
virtual Real length();
virtual Voice_list convert();
virtual void translate_time(Real dt);
- virtual Vertical_music *clone() const {
- return new Vertical_simple(*this);
+ virtual void print() const;
+ virtual Input_music *clone() const {
+ return new Simple_music(*this);
}
+
+};
+
+/// Complex_music consists of multiple voices
+struct Complex_music : Input_music {
+ IPointerList<Input_music*> elts;
+
+ void add(Input_music*);
+ Complex_music();
+ Complex_music(Complex_music const &);
virtual void print() const ;
+ void concatenate(Complex_music*);
+
};
-/// the only child of Horizontal_music
-struct Music_voice : Horizontal_music {
- IPointerList<Vertical_music*> voice_ ;
+/// multiple stuff after each other
+struct Music_voice : Complex_music {
+
/****************/
- Music_voice() {}
- Music_voice(Music_voice const&);
Real length();
- void add(Vertical_music*);
- void add(Voice_element*);
- virtual Voice_list convert();
virtual void translate_time(Real dt);
- virtual Horizontal_music *clone() const {
+ virtual Voice_list convert();
+ void add_elt(Voice_element*);
+ virtual Input_music *clone() const {
return new Music_voice(*this);
}
- void concatenate(Music_voice*);
virtual void print() const ;
};
-///
-struct Music_general_chord : Vertical_music {
- IPointerList<Horizontal_music*> chord_;
+/**
+ voice like.
+
+ different music forms which start after each other ( concatenated,
+ stacked "horizontally )
+
+ */
+
+/// Multiple musicstuff stacked on top of each other
+struct Music_general_chord : Complex_music {
+ IPointerList<Input_music*> chord_;
/****************/
- Music_general_chord() {}
- Music_general_chord(Music_general_chord const&s);
- void add(Horizontal_music*);
+
virtual Real length();
virtual Voice_list convert();
virtual void translate_time(Real dt);
- virtual Vertical_music *clone() const {
+ void add_elt(Voice_element*);
+ virtual Input_music *clone() const {
return new Music_general_chord(*this);
}
- void concatenate(Music_general_chord*);
+
virtual void print() const ;
};
+/**
+ chord like :
+
+ - different music forms which start at the same time ( stacked "vertically" )
+
+ */
+
#endif // INPUTMUSIC_HH
struct Input_staff {
String type;
IPointerList<Input_command*> commands_;
- IPointerList<Horizontal_music*> music_;
+ IPointerList<Input_music*> music_;
/****************/
- void add(Horizontal_music*m);
+ void add(Input_music*m);
Input_staff(Input_staff&);
Input_staff(String);
void add(svec<Input_command*> &s);
+/*
+ keyword.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef KEYWORD_HH
+#define KEYWORD_HH
+
/* for the keyword table */
struct Keyword_ent
{
Keyword_table(Keyword_ent *);
int lookup(const char *s) const;
};
+
+
+#endif // KEYWORD_HH
+
#ifndef LEXER_HH
#define LEXER_HH
-
+#include <FlexLexer.h>
#include "proto.hh"
-
-void new_input(String s);
+#include "fproto.hh"
+#include "sstack.hh"
+#include "string.hh"
int yylex();
void yyerror(const char *s);
bool busy_parsing();
-int lookup_keyword(String s);
-
-Identifier* lookup_identifier(String s);
-void add_identifier(Identifier*i);
-void delete_identifiers();
void kill_lexer();
+void set_lexer();
+
+struct Input_file {
+ istream*is;
+ int line;
+ String name;
+
+ Input_file(String);
+ ~Input_file();
+};
+
+
+/// lexer with provisions for include files.
+struct My_flex_lexer : yyFlexLexer {
+
+ sstack<Input_file*> include_stack;
+ Assoc<String, Identifier*> *the_id_tab;
+ Keyword_table * keytable;
+ Notename_tab * defaulttab;
+
+ /****************/
+
+ void set(Notename_tab *n);
+ int lookup_keyword(String);
+ void lookup_notename(int &large, int &small, String s);
+ void LexerError(const char *);
+ Identifier*lookup_identifier(String s);
+ My_flex_lexer();
+ void add_identifier(Identifier*i);
+ ~My_flex_lexer();
+ void new_input(String s);
+ bool close_input();
+ int yylex();
+};
+
+extern My_flex_lexer *lexer;
+
#endif
Real internote();
Symbol linestaff(int n, Real w);
-
+ Symbol fill(Box b);
Symbol beam_element(int,int,Real=0);
/// round slope to closest TeXslope
Symbol beam(Real&,Real);
#ifndef MISC_HH
#define MISC_HH
+#include "real.hh"
-double log2(double x) ;
+Real wholes(int dur, int dots);
+
+double log_2(double x) ;
int intlog2(int d);
inline int
ABS(int i)
struct Voicegroup;
struct Voice_list;
-struct Vertical_music;
-struct Horizontal_music;
-struct Horizontal_simple;
-struct Vertical_simple ;
+struct Input_music;
+struct Simple_music;
+struct Complex_music;
struct Music_voice;
struct Music_general_chord;
+
struct Input_score;
struct Input_staff;
struct Input_command;
struct Notename_tab;
+struct Input_file;
+struct Keyword_table;
#endif // PROTO_HH
%
% bare bones version. (written down from memory :-)
-melodie = music {$\octave {}
+% the % is a comment.
+
+% declare music (which will be in *one* staff ) for the lead voice
+
+melodie = music {
+ $ % switch Lilypond in note-mode
+ \octave {} % set the default octave
+ % the default note duratino is 4
%%% theme
- c c g g a a g2 f f e e d d c2
+ c c g g a a
+ g2 % g2 means a "g-1" pitched half-note
+ f f e e d d c2
g g f f e e d d g g f f e e d d
%%% var 1
- c r8 c8 ( ) g r8 g8 ( ) a r8 a8 ( ) g r4
+ c r8 c8 % r8 means an 8th rest.
+ ( % start a slur
+ % NOTE: the slurstart should be directly after the note
+ ) % end a slur.
+ g r8 g8 ( ) a r8 a8 ( ) g r4
f r8 f8 ( ) e4 r8 e8 ( ) d4 r8 d8 ( ) c4 r4
$}
-begeleiding = $\music {
- \octave { ` }
+ % more of this.
+begeleiding =
+$
+ \music { % as you can see, the $ sign obliges
+ % you to precede keyword by a backslash: \
+ \octave { ` } % default octave: 1 below the first octave.
+
%%% theme
- `c c e c f c e c d `b c `a `f `g `c2
+ `c % ` means one octave lower.
+ % Similarly: ' means one higher.
+ c e c f c e c d `b c `a `f `g `c2
\octave { ` }
e `g d `g c `g `b `g e `g d `g c `g `b `g
%%%% var 1
}$
+% create a staff named bstaf
bstaf = staff {
melodic
- music { begeleiding }
- commands {
- clef bass
+ music { begeleiding } % use the declared music
+ commands { % commands with Staff-wide impact.
+ clef bass % bass-clef
+
}
}
+
+% another one
vstaf = staff {
melodic
music { melodie }
+ % default clef is violin clef
}
staff { vstaf }
staff { bstaf }
paper {
- unitspace 2.5cm
+ unitspace 2.5cm % a whole note takes 2.5 cm ideally.
}
commands {
- meter 2 4
- skip 32:0
+ meter 2 4 % a 2/4 meter.
+ skip 32:0 % skip 32 measures, and generate the bars
+ meter 6 8 % another meter
}
}
ritme = staff {rhythmic
music {$
- c8 c2 c2
+ c8
+ c2 c2
%[c8( )'a8 c8 c8]
c2 c2
melody=
staff { melodic
music{$
- c8
+c8
r1
'cis2.. r8
r4 r8 r16 r32 r32
- \duration {4} \chord {
+ \duration {4}
+ {
\music { c () `bes c}
\music { 'fis ()'gisis fis }
\music { d () d dis }
\music { a () bes eis }
\music { fis () g gis }
}
- c4
+ { c4 'c4 }
[d8 e8 'f8 g8] d8 e8 f8 g8
''fis2
$}
commands {
- skip 0:0.125
- skip 1:0 % BUG!!
+% skip 0:0.125
+ skip 3:0 % BUG!!
key $ fis cis gis $
skip 2:0
key $ $
% staff { melody }
commands {
meter 4 4
- partial 0.125 skip 0:0.125
+ partial 8
+ skip 1:0
skip 2:0
meter 2 4
skip 19:0
#(cd $nm$old; touch depend; make clean)
#(cd $nm$new; touch depend; make clean)
-(cd $nm$new; diff -P -c ../$nm$old . > ../patch-$new)
+(cd $nm$new; diff -rP -c ../$nm$old . > ../patch-$new)
rm -rf $nm$old $nm$new
% 11
)`b [`fis `a `b] cis4 `b4 `fis2 r2
cis4 d4()[d cis d e]
- \octave { '` }
+ \octave { }
a4 gis2.
a4 b4()[b a b 'cis] fis4 e4 cis2
e4 fis4 () [fis e fis gis] cis4 `b4()`b8 r8 r4
key $fis cis $
}
}
-
score {
staff {
horn
unitspace 1.5 cm
geometric 1.4
}
- commands { meter 4 4
+ commands {meter 4 4
+
skip 18:0
meter 2 4
skip 1:0
Stem_info(){}
Stem_info(const Stem*);
};
+
Stem_info::Stem_info(const Stem*s)
{
x = s->hpos();
priority=0;
}
-
-
Command::Command(Real w)
{
code = NOP;
#include <fstream.h>
#include <std/new.h>
+#include <stdlib.h>
#include "debug.hh"
#include "dstream.hh"
#include "vector.hh"
{
check_debug =b;
}
+
+
+#if 0 // want to debug mem functions
+
+
+///
+static
+void foobulize(void *p , size_t s)
+{
+// assert(s < 2000000);
+ memset(p, 0xf0, s);
+}
+/**
+ trash a portion of memory. Make sure access to deleted stuff is bogus.
+ */
+void *
+operator new (size_t s)
+{
+ void *p = malloc(s);
+ assert(p);
+// foobulize(p,s);
+ return p;
+}
+
+void
+operator delete(void *p, size_t s)
+{
+ foobulize(p,s);
+ free(p);
+}
+#endif
#include "identparent.hh"
#include "lexer.hh"
+#include "debug.hh"
void
Identifier::error()
{
String e("Wrong identifier type: ");
- yyerror(e + classname());
+ ::error(e + classname());
}
Input_command::Input_command()
{
- when = -1;
}
-Input_command::Input_command(Real w)
+Input_command::Input_command(Real )
{
- when =w;
}
Input_command::operator Command()
{
- Command c(when);
+ Command c;
if (!args.sz())
return c;
}
Input_command *
-get_bar_command(Real w)
+get_bar_command()
{
Input_command*c = new Input_command;
- c->when = w;
+
c->args.add( "BAR");
c->args.add( "|");
void
Input_command::print()const
{
- mtor << "{ at " << when;
+ mtor << "{ ";
if (args.sz()) {
mtor<< " args: ";
for (int i = 0; i<args.sz(); i++)
#include "getcommand.hh"
#include "command.hh"
-Input_commands::Input_commands(Input_commands const&src)
- : ptr(src.ptr)
+void
+Commands_at::print() const
{
- IPointerList<Input_command*> &me(*this);
- const IPointerList<Input_command*> &that(src);
-
- PL_copy(me, that);
+#ifndef NPRINT
+ mtor << "{ at "<<when<<'\n';
+ mtor << "meter " << whole_per_measure
+ << " pos "<< bars << ":" << whole_in_measure <<'\n';
+ for (PCursor<Input_command *> cc(*this); cc.ok(); cc++)
+ cc->print();
+ mtor << "}\n";
+#endif
}
-Input_commands::Input_commands()
- : ptr (bottom())
+Commands_at::Commands_at(Real dt, Commands_at* prev)
{
- Input_command c(0.0);
- bottom().add(new Input_command(c));
- ptr = bottom();
+ if (prev) {
+ assert(dt >0);
+ when = prev->when + dt;
+ whole_per_measure = prev->whole_per_measure;
+ whole_in_measure = prev->whole_in_measure + dt;
+ bars = prev->bars;
+
+ while ( whole_in_measure >= whole_per_measure ) {
+ whole_in_measure -= whole_per_measure;
+ bars ++;
+ }
+ if (!whole_in_measure) {
+ bottom().add(get_bar_command());
+ }
+ } else {
+ whole_per_measure = 1;
+ whole_in_measure =0;
+ when = 0.0;
+ bars = 0;
+ }
}
void
-Input_commands::truncate(Real last)
+Commands_at::add(Input_command *i )
+{
+ bottom().add(i);
+ if (i->args[0] == "METER") { // should check for other meterchanges here.
+ Real l = i->args[1];
+ Real o = i->args[2];
+ whole_per_measure = l/o;
+ }
+}
+
+Commands_at::Commands_at(Commands_at const&src)
{
- bool reset_ = false;
+ when = src.when;
+ whole_in_measure = whole_in_measure;
+ whole_per_measure = whole_per_measure;
+ bars = src.bars;
- if (ptr.when() >= last)
- reset_=true;
- PCursor<Input_command*> i(*this);
+ IPointerList<Input_command*> &me(*this);
+ const IPointerList<Input_command*> &that(src);
- while (i.ok() && i ->when < last)
- i++;
+ PL_copy(me, that);
+}
- while (i.ok())
- i.del();
+void
+Commands_at::setpartial(Real p)
+{
+ if (when)
+ error_t ("Partial measure only allowed at beginning.", when);
+ if (p<0||p > whole_per_measure)
+ error_t ("Partial measure has incorrect size", when);
+ whole_in_measure = whole_per_measure - p;
+}
+Real
+Commands_at::barleft()
+
+{
+ return whole_per_measure-whole_in_measure;
+}
- if (reset_) {
- reset();
+/****************/
+
+void
+Input_cursor::find_moment(Real w)
+{
+ Real last = when();
+ while (1) {
+ if (! ok() ) {
+ *this = PCursor<Commands_at*>(list().bottom());
+ Real dt = (w - when()) <? ptr()->barleft();
+ assert(dt >= 0);
+ Commands_at * c = new Commands_at(dt, *this);
+ add(c);
+ } else if (when() == w ) {
+ return ;
+ } else if (when() > w )
+ break;
+
- while(ptr.ok())
- ptr++;
+ last = when();
+ next();
}
+
+ prev();
+ Real dt = (w - when());
+ Commands_at * c = new Commands_at(dt, *this);
+ add(c);
+ next();
}
-/*
- ugh. This sux.
- */
-void
-Input_commands::find_moment(Real w)
+
+
+/****************/
+Input_commands::Input_commands(Input_commands const&src)
+ : ptr(src.ptr)
{
- assert(w >= ptr.when());
- while (ptr.ok() && ptr.when() < w) {
- ptr++;
- }
+ IPointerList<Commands_at*> &me(*this);
+ const IPointerList<Commands_at*> &that(src);
- if (!ptr.ok()) {
- int bars_left =int(floor( (w - ptr.last + ptr.whole_in_measure)
- /ptr.whole_per_measure));
- if (bars_left) {
- Real bar_when = ptr.last - ptr.whole_in_measure + ptr.whole_per_measure;
- ptr.addbot(get_bar_command(bar_when));
- find_moment(w); // tail-recursion. todo
- } else {
- ptr.addbot(new Input_command(w));
- }
+ PL_copy(me, that);
+}
- } else if (ptr.when() != w) {
- ptr.insert(new Input_command(w));
- ptr--;
- }
+Input_commands::Input_commands()
+ : ptr (bottom())
+{
+ Commands_at * p = new Commands_at(0,0);
+ bottom().add(p);
+ ptr = bottom();
}
void
-Input_commands::do_skip(int & bars, Real & wholes)
+Input_commands::do_skip(int bars, Real wholes)
{
- if (wholes) {
- find_moment(ptr.when() +wholes);
- wholes = 0.0;
+ while (bars > 0) {
+ Real b = ptr->barleft();
+ ptr.find_moment(ptr->when + b);
+ bars --;
}
-
- if (bars) {
- ptr.last_command_here(); // find any METER change commands.
- if (ptr.whole_in_measure){
- Real barleft = ptr.whole_per_measure - ptr.whole_in_measure;
- do_skip(bars, barleft);
- }else {
- find_moment(ptr.when() + bars*ptr.whole_per_measure);
- bars = 0;
- }
+ if (wholes) {
+ ptr.find_moment(ptr->when + wholes);
}
}
void
Input_commands::add(Input_command c)
{
- if (c.args[0] == "PARTIAL") {
- Real p = c.args[1].fvalue();
- ptr.setpartial(p);
-
+ if (c.args[0] == "PARTIAL") {
+ ptr->setpartial(c.args[1]);
} else if (c.args[0] == "METER") {
- int beats_per_meas, one_beat;
- Real r;
-
- interpret_meter(&c, beats_per_meas, one_beat, r);
+ int beats_per_meas = c.args[1];
+ int one_beat = c.args[2];
Input_command *ch = get_meterchange_command(beats_per_meas, one_beat);
- ch->when = ptr.when();
- ptr.add(ch);
-
+ ptr->add(ch);
} else if (c.args[0] == "KEY" || c.args[0] == "CLEF") {
Input_command *ic = new Input_command(c);
- ic->when = ptr.when();
- ptr.add(ic);
+ ptr->add(ic);
} else if (c.args[0] == "SKIP") {
- int bars = c.args[1].value() ;
- Real wholes= c.args[2].fvalue();
- while (bars > 0 || wholes > 0.0) {
- do_skip(bars, wholes);
- }
+ int bars = c.args[1] ;
+ Real wholes= c.args[2];
+ do_skip(bars, wholes);
} else if (c.args[0] == "RESET") {
- reset();
+ ptr= top();
}
}
-void
-Input_commands::reset()
-{
- ptr = top();
- ptr.reset();
-}
-
-
Staff_commands*
Input_commands::parse() const
{
+ print();
Staff_commands*nc = new Staff_commands;
{ /* all pieces should start with a breakable. */
nc->process_add(c);
}
- for (PCursor<Input_command*> cc(*this); cc.ok(); cc++) {
- if (cc->args.sz() && cc->args[0] !="")
- nc->process_add(**cc);
- }
+ for (PCursor<Commands_at*> i(*this); i.ok(); i++)
+ for (PCursor<Input_command *> cc(**i); cc.ok(); cc++) {
+ if (cc->args.sz() && cc->args[0] !="") {
+ Command c = **cc;
+ c.when = i->when;
+ nc->process_add(c);
+ }
+ }
return nc;
}
Input_commands::print() const
{
#ifndef NPRINT
- for (PCursor<Command*> cc(*this); cc.ok() ; cc++) {
+ for (PCursor<Commands_at*> cc(*this); cc.ok() ; cc++) {
cc->print();
}
- ptr.print();
#endif
}
+/****************/
+
+Real
+Input_cursor::when()const
+{
+ return (*this)->when;
+}
+Input_cursor::Input_cursor(PCursor<Commands_at *>c)
+ : PCursor<Commands_at*>(c)
+{
+}
+++ /dev/null
-/*
- it still sucks.
- */
-
-#include "inputcommands.hh"
-#include "inputcommand.hh"
-#include "debug.hh"
-#include "staffcommands.hh"
-#include "getcommand.hh"
-#include "command.hh"
-
-void
-interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat,
- Real& whole_per_measure)
-{
- beats_per_meas = c->args[1].value();
- one_beat = c->args[2].value();
- whole_per_measure = beats_per_meas/Real(one_beat);
-}
-
-Real
-Input_cursor::when()const
-{
- return (*this)->when;
-}
-
-void
-Input_cursor::print() const
-{
-#ifndef NPRINT
- mtor << "meter " << whole_per_measure
- << " pos "<< bars << ":" << whole_in_measure <<'\n';
-#endif
-}
-
-void
-Input_cursor::reset()
-{
- whole_per_measure = 1.0; // ?
- whole_in_measure =0.0;
- bars = 0;
- last=0;
-}
-
-Input_cursor :: Input_cursor(PCursor<Input_command*>c)
- :PCursor<Input_command*>(c)
-{
- reset();
-}
-
-void
-Input_cursor::sync()
-{
- assert(ok());
-
- whole_in_measure += when() - last;
- while (whole_per_measure > 0 && whole_in_measure >= whole_per_measure) {
- bars ++;
- whole_in_measure -= whole_per_measure;
- }
- if (whole_in_measure < 1e-5) // ugr
- whole_in_measure = 0.0;
-}
-
-void
-Input_cursor::operator++(int)
-{
- last = when();
- (*(PCursor<Input_command*> *) this) ++;
-
- if (ok()) {
- sync();
- if (ptr()->args[0] == "METER") {
- int i,j;
- interpret_meter(ptr(), i, j, whole_per_measure);
- }
- }
-}
-
-void
-Input_cursor::addbot(Input_command*c)
-{
- assert(!ok());
- add(c);
-}
-
-
-void
-Input_cursor::add(Input_command*c)
-{
- PCursor<Input_command*> ::add(c);
- (*this)++;
-}
-
-void
-Input_cursor::last_command_here()
-{
- assert(ok());
- PCursor<Input_command*> next = (*this)+1;
- while (next.ok() && next->when == when()){
- *this = next;
- next = *this +1;
-
- }
-}
-
-void
-Input_cursor::setpartial(Real p)
-{
- if (when())
- error_t ("Partial measure only allowed at beginning.", when() );
- if (p<0||p > whole_per_measure)
- error_t ("Partial measure has incorrect size", when());
-
- whole_in_measure = whole_per_measure - p;
-}
#include "debug.hh"
#include "inputmusic.hh"
#include "voice.hh"
-Input_music::~Input_music()
-{
-}
-Vertical_simple::Vertical_simple()
-{
- voice_ = new Voice;
-}
-Vertical_simple::Vertical_simple(Vertical_simple const&s)
-{
- voice_ = new Voice(*s.voice_);
-}
+
void
-Vertical_simple::add(Voice_element*v)
+Simple_music::add(Voice_element*v)
{
- voice_->add(v);
+ voice_.add(v);
}
Real
-Vertical_simple::length()
+Simple_music::length()
{
- return voice_->last();
+ return voice_.last();
}
void
-Vertical_simple::translate_time(Real t)
+Simple_music::translate_time(Real t)
{
- voice_->start += t;
+ voice_.start += t;
}
Voice_list
-Vertical_simple::convert()
+Simple_music::convert()
{
Voice_list l;
- l.bottom().add(new Voice(*voice_));
+ l.bottom().add(new Voice(voice_));
return l;
}
-Vertical_simple::~Vertical_simple()
-{
- delete voice_;
-}
void
-Vertical_simple::print() const
+Simple_music::print() const
{
- mtor << "Vertical_simple {";
- voice_->print();
+ mtor << "Simple_music {";
+ voice_.print();
mtor << "}\n";
}
/****************/
+
void
-Music_voice::print() const
+Complex_music::add(Input_music*v)
+{
+ elts.bottom().add(v);
+}
+
+void
+Complex_music::print() const
{
- mtor << "Music_voice {";
- for (PCursor<Vertical_music*> i(voice_); i.ok(); i++)
+ for (PCursor<Input_music*> i(elts); i.ok(); i++)
i->print();
- mtor << "}\n";
}
void
-Music_voice::concatenate(Music_voice*h)
+Complex_music::concatenate(Complex_music*h)
{
- for (PCursor<Vertical_music*> i(h->voice_); i.ok(); i++)
+ for (PCursor<Input_music*> i(h->elts); i.ok(); i++)
add(i->clone());
}
+Complex_music::Complex_music()
+{
+}
-Music_voice::Music_voice(Music_voice const&s)
+Complex_music::Complex_music(Complex_music const&s)
{
- for (PCursor<Vertical_music*> i(s.voice_); i.ok(); i++)
+ for (PCursor<Input_music*> i(s.elts); i.ok(); i++)
add(i->clone());
}
+/****************************************************************/
+
void
-Music_voice::add(Voice_element*v)
+Music_voice::print() const
{
- PCursor<Vertical_music*> c(voice_.bottom());
+ mtor << "Music_voice {";
+ Complex_music::print();
+ mtor << "}\n";
+}
+
+void
+Music_voice::add_elt(Voice_element*v)
+{
+ PCursor<Input_music*> c(elts.bottom());
if (!c.ok() || !c->simple()) {
- Vertical_simple*vs = new Vertical_simple;
+ Simple_music*vs = new Simple_music;
c.add(vs);
}
- c = voice_.bottom();
- Vertical_simple *s = c->simple();
+ c = elts.bottom();
+ Simple_music *s = c->simple();
s->add(v);
}
-void
-Music_voice::add(Vertical_music*v)
-{
- voice_.bottom().add(v);
-}
-
Real
Music_voice::length()
{
Real l = 0.0;
- for (PCursor<Vertical_music*> i(voice_); i.ok(); i++)
+ for (PCursor<Input_music*> i(elts); i.ok(); i++)
l += i->length();
return l;
}
Voice_list l;
Real here = 0.0;
- for (PCursor<Vertical_music*> i(voice_); i.ok(); i++) {
+ for (PCursor<Input_music*> i(elts); i.ok(); i++) {
Real len = i->length();
Voice_list k(i->convert());
k.translate_time(here);
void
Music_voice::translate_time(Real t)
{
- for (PCursor<Vertical_music*> i(voice_); i.ok(); i++)
- i->translate_time(t);
+ elts.bottom()->translate_time(t);
}
/****************/
+
void
-Music_general_chord::print() const
+Music_general_chord::add_elt(Voice_element*v)
{
- mtor << "Music_general_chord {";
- for (PCursor<Horizontal_music*> i(chord_); i.ok(); i++)
- i->print();
- mtor << "}\n";
+ Simple_music*vs = new Simple_music;
+ vs->add(v);
+ elts.bottom().add(vs);
}
void
-Music_general_chord::concatenate(Music_general_chord*v)
+Music_general_chord::print() const
{
- for (PCursor<Horizontal_music*> i(v->chord_); i.ok(); i++)
- add(i->clone());
+ mtor << "Music_general_chord {";
+ Complex_music::print();
+ mtor << "}\n";
}
void
Music_general_chord::translate_time(Real t)
{
- for (PCursor<Horizontal_music*> i(chord_); i.ok(); i++)
+ for (PCursor<Input_music*> i(elts); i.ok(); i++)
i->translate_time(t);
}
-
-
Real
Music_general_chord::length()
{
Real l =0.0;
- for (PCursor<Horizontal_music*> i(chord_); i.ok(); i++)
- l = MAX(l, i->length());
+ for (PCursor<Input_music*> i(elts); i.ok(); i++)
+ l = l >? i->length();
return l;
}
-void
-Music_general_chord::add(Horizontal_music*h)
-{
- chord_.bottom().add(h);
-}
-
Voice_list
Music_general_chord::convert()
{
Voice_list l;
- for (PCursor<Horizontal_music*> i(chord_); i.ok(); i++) {
+ for (PCursor<Input_music*> i(elts); i.ok(); i++) {
Voice_list k(i->convert());
l.concatenate(k);
}
}
-Music_general_chord::Music_general_chord(
- Music_general_chord const & s)
-{
- for (PCursor<Horizontal_music*> i(s.chord_); i.ok(); i++) {
- add(i->clone());
- }
-}
-
/****************/
void
i->start += x;
}
-void
-Voice_list::junk()
-{
- for (PCursor<Voice*> i(*this); i.ok(); i++)
- delete i.ptr();
-}
}
void
-Input_staff::add(Horizontal_music*m)
+Input_staff::add(Input_music*m)
{
music_.bottom().add(m);
}
else if (type == "rhythmic")
p = new Rhythmic_staff;
- for (PCursor<Horizontal_music*> i(music_); i.ok(); i++) {
+ for (PCursor<Input_music*> i(music_); i.ok(); i++) {
Voice_list vl = i->convert();
p->add(vl);
}
{
for (PCursor<Input_command*> i(s.commands_); i.ok(); i++)
commands_.bottom().add(new Input_command(**i));
- for (PCursor<Horizontal_music*> i(s.music_); i.ok(); i++)
+ for (PCursor<Input_music*> i(s.music_); i.ok(); i++)
add(i);
type = s.type;
mtor << "Input_staff {\n";
for (PCursor<Input_command*> i(commands_); i.ok(); i++)
i->print();
- for (PCursor<Horizontal_music*> i(music_); i.ok(); i++)
+ for (PCursor<Input_music*> i(music_); i.ok(); i++)
i->print();
mtor << "}\n";
#endif
for (int i=0; i < newkey.sz(); i++)
newkey[i] = 0;
- for (int i=0; i < s.sz(); i++) {
+ for (int i=0; i < s.sz(); ) {
int large = s[i++];
int small = s[i++];
newkey[large] = small;
a.translate(Offset(0,(c_position + pitch[i]) * inter));
Molecule m(a);
output->add_right(m);
- }
+ }
+ Molecule m(paper()->lookup_->fill(Box(
+ Interval(0, paper()->note_width()),
+ Interval(0,0))));
+ output->add_right(m);
}
%{ // -*-Fundamental-*-
-#include <fstream.h>
#include <stdio.h>
-#include "glob.hh"
+
#include "string.hh"
#include "notename.hh"
#include "lexer.hh"
-#include "keyword.hh"
#include "vray.hh"
#include "parser.hh"
#include "debug.hh"
-#include "sstack.hh"
-
-struct Input_file {
- istream*is;
- int line;
- String name;
-
- Input_file(String);
- ~Input_file();
-};
-
-/// lexer with provisions for include files.
-struct My_flex_lexer : yyFlexLexer {
- sstack<Input_file*> include_stack;
- void new_input(String s);
- bool close_input();
-};
-My_flex_lexer *lexer=0;
-
-static int last_print;
-const int DOTPRINT=50; // every 50 lines dots
%}
%option c++
%option nodefault
%option yylineno
%option debug
+%option yyclass="My_flex_lexer"
%x notes
%x incl
%x quote
<<EOF>> {
mtor << "<<EOF>>";
- if (! ((My_flex_lexer*) this)->close_input())
+ if (! close_input())
yyterminate(); // can't move this, since it actually rets a YY_NULL
}
%%
-int
-yylex() {
- return lexer->yylex();
-}
-
-void
-yyerror(const char *s)
-{
- String e;
- if (lexer->include_stack.empty()) {
- *mlog << "error at EOF" << s;
- }else
- *mlog << lexer->include_stack.top()->name << ": " <<
- lexer->lineno() << ": error:" << s << '\n';
- exit(1);
-}
-
-
-bool
-busy_parsing()
-{
- return lexer;
-}
-
-void
-kill_lexer()
-{
- delete lexer;
- lexer = 0;
-}
-
-void
-new_input(String s)
-{
- if (!lexer) {
- lexer = new My_flex_lexer;
- lexer->set_debug( !monitor.silence("Lexer") && check_debug);
- }
- lexer->new_input(s);
-}
-
-/****************/
-
-Input_file::Input_file(String s)
-{
- name = s;
- line = 1;
- if (s=="")
- is = &cin;
- else
- is = new ifstream( s ); //
-
- if ( ! *is) {
- String e("cant open " + s);
- if (lexer)
- yyerror(e);
- else
- error(e);
- }
- cout << "["<<s<<flush;
-}
-
-Input_file::~Input_file()
-{
- if (is != &cin)
- delete is;
- cout << "]" << flush;
-}
-/****************/
-
-// set the new input to s, remember old file.
-void
-My_flex_lexer::new_input(String s)
-{
- if (!include_stack.empty())
- include_stack.top()->line = lineno();
-
- Input_file *newin = new Input_file(s);
- include_stack.push(newin);
- switch_streams(newin->is);
- yylineno = 1;
-}
-
-// pop the inputstack.
-bool
-My_flex_lexer::close_input()
-{
- Input_file *old = include_stack.pop();
- bool ok = true;
- if (include_stack.empty()) {
- ok = false;
- } else {
- Input_file *i = include_stack.top();
- switch_streams(i->is);
- yylineno = i->line;
- }
- delete old;
- return ok;
-}
--- /dev/null
+#include <fstream.h>
+#include "lexer.hh"
+#include "debug.hh"
+
+My_flex_lexer *lexer=0;
+
+int
+yylex() {
+ return lexer->yylex();
+}
+
+void
+yyerror(const char *s)
+{
+ lexer->LexerError(s);
+}
+
+bool
+busy_parsing()
+{
+ return lexer;
+}
+
+void
+kill_lexer()
+{
+ delete lexer;
+ lexer = 0;
+}
+
+void
+set_lexer()
+{
+ if (!lexer) {
+ lexer = new My_flex_lexer;
+ lexer->set_debug( !monitor.silence("Lexer") && check_debug);
+ }
+}
+
+Input_file::Input_file(String s)
+{
+ name = s;
+ line = 1;
+ if (s=="")
+ is = &cin;
+ else
+ is = new ifstream( s );
+
+ if ( ! *is) {
+ String e("cant open " + s);
+ error(e);
+ }
+ cout << "["<<s<<flush;
+}
+
+Input_file::~Input_file()
+{
+ if (is != &cin)
+ delete is;
+ cout << "]" << flush;
+}
{
return (*symtables_)("rests")->lookup(String(j));
}
-
+Symbol
+Lookup::fill(Box b)
+{
+ Symbol s( (*symtables_)("param")->lookup("fill"));
+ s.dim = b;
+ return s;
+}
Symbol
Lookup::accidental(int j)
{
void notice()
{
cout <<
+ "\n"
"LilyPond, a music typesetter.\n"
"Copyright (C) 1996 by\n"
" Han-Wen Nienhuys <hanwen@stack.nl>\n"
break;
}
}
- char *arg = oparser.get_next_arg();
-
- if (!arg) arg = "";
- parse_file(arg);
- do_scores();
+ int p=0;
+ char *arg ;
+ while ( (arg= oparser.get_next_arg()) ) {
+ parse_file(arg);
+ do_scores();
+ p++;
+ }
+ if (!p) {
+ parse_file("");
+ do_scores();
+ }
+
exit (0);
}
#include <math.h>
+Real
+wholes(int dur, int dots)
+{
+ Real f = 1.0/Real(dur);
+ Real delta = f;
+
+ while (dots--) {
+ delta /= 2.0;
+ f += delta;
+ }
+ return f;
+}
int
intlog2(int d) {
int i=0;
}
double
-log2(double x) {
+log_2(double x) {
return log(x) /log(2.0);
}
--- /dev/null
+#include "identparent.hh"
+#include "associter.hh"
+#include "lexer.hh"
+#include "parser.hh"
+#include "keyword.hh"
+#include "assoc.hh"
+#include "lexer.hh"
+#include "sstack.hh"
+#include "debug.hh"
+#include "notename.hh"
+
+static Keyword_ent the_key_tab[]={
+ "bar", BAR,
+ "bass", BASS,
+ "clef", CLEF,
+ "cm", CM,
+ "commands", COMMANDS,
+ "duration", DURATIONCOMMAND,
+ "geometric", GEOMETRIC,
+ "in", IN,
+ "key", KEY,
+ "melodic", MELODIC,
+ "meter", METER,
+ "mm", MM,
+ "octave", OCTAVECOMMAND,
+ "output", OUTPUT,
+ "partial", PARTIAL,
+ "paper", PAPER,
+ "pt", PT,
+ "rhythmic", RHYTHMIC,
+ "score", SCORE,
+ "skip", SKIP,
+ "staff", STAFF,
+ "start", START_T,
+ "table", TABLE,
+ "symboltables", SYMBOLTABLES,
+ "notenames", NOTENAMES,
+ "texid", TEXID,
+ "chord", CHORD,
+ "multi", MULTI,
+ "unitspace", UNITSPACE,
+ "violin", VIOLIN,
+ "voice", VOICE,
+ "voices", VOICES,
+ "width", WIDTH,
+ "music", MUSIC,
+ "grouping", GROUPING,
+ 0,0
+};
+
+My_flex_lexer::My_flex_lexer()
+{
+ keytable = new Keyword_table(the_key_tab);
+ the_id_tab = new Assoc<String, Identifier*>;
+ defaulttab = 0;
+}
+
+int
+My_flex_lexer::lookup_keyword(String s)
+{
+ return keytable->lookup(s);
+}
+
+Identifier*
+My_flex_lexer::lookup_identifier(String s)
+{
+ if (!the_id_tab->elt_query(s))
+ return 0;
+
+ return (*the_id_tab)[s];
+}
+
+void
+My_flex_lexer::add_identifier(Identifier*i)
+{
+ delete lookup_identifier(i->name);
+ (*the_id_tab)[i->name] = i;
+}
+
+My_flex_lexer::~My_flex_lexer()
+{
+ delete keytable;
+ delete defaulttab;
+ for (Assoc_iter<String,Identifier*> ai(*the_id_tab); ai.ok(); ai++) {
+ mtor << "deleting: " << ai.key()<<'\n';
+ delete ai.val();
+ }
+ delete the_id_tab;
+}
+
+void
+My_flex_lexer::LexerError(const char *s)
+{
+ if (lexer->include_stack.empty()) {
+ *mlog << "error at EOF" << s;
+ }else
+ *mlog << lexer->include_stack.top()->name << ": " <<
+ lexer->lineno() << ": error:" << s << '\n';
+ exit(1);
+}
+// set the new input to s, remember old file.
+void
+My_flex_lexer::new_input(String s)
+{
+ if (!include_stack.empty())
+ include_stack.top()->line = lineno();
+
+ Input_file *newin = new Input_file(s);
+ include_stack.push(newin);
+ switch_streams(newin->is);
+ yylineno = 1;
+}
+
+// pop the inputstack.
+bool
+My_flex_lexer::close_input()
+{
+ Input_file *old = include_stack.pop();
+ bool ok = true;
+ if (include_stack.empty()) {
+ ok = false;
+ } else {
+ Input_file *i = include_stack.top();
+ switch_streams(i->is);
+ yylineno = i->line;
+ }
+ delete old;
+ return ok;
+}
}
mtor << "oct " << oct;
- mtor << "override: " << overide_acc;
+ mtor << "override: " << overide_acc<<'\n';
}
#include "lexer.hh"
#include "identifier.hh"
-static Notename_tab * defaulttab = 0;
-
-void
-set_notename_tab(Notename_tab*n)
-{
- delete defaulttab;
- defaulttab = n;
-}
-
-void
-lookup_notename(int &large, int &small, String s)
-{
- if (!defaulttab)
- set_notename_tab(lookup_identifier("default_table")->
- notename_tab(true));
-
- defaulttab->lookup(large, small, s);
-}
void
assert(l < 8 && s <= 2 && s >= -2 && l >=0);
notetab[l * 5 + s +2] = n;
}
+/****************/
+void
+My_flex_lexer::set(Notename_tab *n)
+{
+ delete defaulttab;
+ defaulttab = n;
+}
+
+void
+My_flex_lexer::lookup_notename(int &large, int &small, String s)
+{
+ if (!defaulttab)
+ set(lookup_identifier("default_table")->
+ notename_tab(true));
+
+ defaulttab->lookup(large, small, s);
+}
Real
Paperdef::duration_to_dist(Real d)
{
- return whole_width * pow(geometric_, log2(d));
+ return whole_width * pow(geometric_, log_2(d));
}
Real
#include <iostream.h>
#include "lookup.hh"
+
+#include "misc.hh"
#include "lexer.hh"
#include "paper.hh"
#include "inputstaff.hh"
String *string;
const char *consstr;
Paperdef *paper;
- Horizontal_music *horizontal;
- Vertical_music *vertical;
+ Input_music *music;
Music_general_chord *chord;
Music_voice *mvoice;
int i;
%token <ii> NOTENAME
%token <real> REAL
%token <string> STRING
-%token <i> OPEN_REQUEST_PARENS CLOSE_REQUEST_PARENS
+%token <c> OPEN_REQUEST_PARENS CLOSE_REQUEST_PARENS
%token <i> DOTS INT
%type <consstr> unit
%type <intvec> pitch_list
-%type <id> declaration
+%type <id> declaration
+%type <string> declarable_identifier
%type <paper> paper_block paper_body
%type <real> dim
%type <ii> duration
+%type <real> duration_length
%type <el> voice_elt full_element
%type <command> score_command staff_command skipcommand
%type <score> score_block score_body
%type <commandvec> staff_commands_block staff_commands_body
%type <request> post_request pre_request
%type <string> clef_id pitchmod
-%type <vertical> vertical_music
+%type <music> music
%type <chord> music_chord music_chord_body
-%type <horizontal> horizontal_music
+
%type <mvoice> music_voice_body music_voice
%type <interval> dinterval
;
mudela_command:
- notename_tab { set_notename_tab($1); }
+ notename_tab { lexer->set($1); }
;
/*
DECLARATIONS
*/
add_declaration: declaration {
- add_identifier($1);
+ lexer->add_identifier($1);
}
;
+declarable_identifier:
+ NEWIDENTIFIER { $$ = $1; }
+ | IDENTIFIER { $$ = new String($1->name); }
+ ;
+
declaration:
- NEWIDENTIFIER '=' staff_block {
+ declarable_identifier '=' staff_block {
$$ = new Staff_id(*$1, $3);
delete $1; // this sux
}
- | NEWIDENTIFIER '=' music_voice {
+ | declarable_identifier '=' music_voice {
$$ = new M_voice_id(*$1, $3);
delete $1;
}
- | NEWIDENTIFIER '=' music_chord {
+ | declarable_identifier '=' music_chord {
$$ = new M_chord_id(*$1, $3);
delete $1;
}
- | NEWIDENTIFIER '=' symtables {
+ | declarable_identifier '=' symtables {
$$ = new Lookup_id(*$1, $3);
delete $1;
}
- | NEWIDENTIFIER '=' notename_tab {
+ | declarable_identifier '=' notename_tab {
$$ = new Notetab_id(*$1, $3);
delete $1;
}
}
;
+duration_length:
+ duration {
+ $$ = wholes($1[0], $1[1]);
+ }
+ ;
+
skipcommand:
- SKIP int ':' REAL {
+ SKIP int ':' duration_length {
$$ = get_skip_command($2, $4);
}
| METER int int {
$$ = get_meterchange_command($2, $3);
}
- | PARTIAL REAL {
+ | PARTIAL duration_length {
$$ = get_partial_command($2);
}
| GROUPING int_list {
staff_body:
staff_init
- | staff_body horizontal_music {
+ | staff_body music {
$$->add($2);
}
| staff_body staff_commands_block {
/*
MUSIC
*/
-horizontal_music:
+music:
music_voice { $$ = $1; }
+ | music_chord { $$ = $1; }
;
-vertical_music:
- music_chord { $$ = $1; }
- ;
-
-music_voice: MUSIC '{' music_voice_body '}' { $$ = $3; }
+music_voice: MUSIC '{' music_voice_body '}' { $$ = $3; }
;
music_voice_body: {
$$->concatenate($2->mvoice());
}
| music_voice_body full_element {
- $$->add($2);
+ $$->add_elt($2);
}
| music_voice_body voice_command {
}
- | music_voice_body vertical_music {
+ | music_voice_body music {
$$->add($2);
}
;
-music_chord: CHORD '{' music_chord_body '}' { $$ = $3; }
+music_chord: '{' music_chord_body '}' { $$ = $2; }
;
music_chord_body: {
$$ = new Music_general_chord;
}
- | music_voice_body IDENTIFIER {
+ | music_chord_body IDENTIFIER {
$$->concatenate($2->mchord());
}
- | music_chord_body horizontal_music {
+ | music_chord_body music {
$$ -> add($2);
}
+ | music_chord_body full_element {
+ $$ ->add_elt($2);
+ }
;
REAL {
$$ = int($1);
if (ABS($1-Real(int($$))) > 1e-8)
- yyerror("expecting integer number");
+ error("expecting integer number");
}
| INT
;
;
symboldef:
- STRING box {
+ STRING box {
$$ = new Symbol(*$1, *$2);
delete $1;
delete $2;
}
+ | STRING {
+ Box b;
+ $$ = new Symbol(*$1, b);
+ delete $1;
+ }
;
box:
yydebug = !monitor.silence("Parser") && check_debug;
#endif
- new_input("symbol.ini");
+ set_lexer();
+ lexer->new_input("symbol.ini");
yyparse();
- new_input(s);
+ lexer->new_input(s);
yyparse();
-
- delete_identifiers();
kill_lexer();
- *mlog << "\n";
}
Paperdef*
default_paper()
{
- return new Paperdef(lookup_identifier("default_table")->lookup(true));
+ return new Paperdef(lexer->lookup_identifier("default_table")->lookup(true));
}
// update of matrices
Vector Ha = H*a;
Real aHa = a*Ha;
+ Vector addrow(Ha.dim());
if (ABS(aHa) > EPS) {
/*
a != 0, so if Ha = O(EPS), then
if H*a == 0, the constraints are dependent.
*/
- H -= Matrix(Ha , Ha)/(aHa);
+ H -= Matrix(Ha/aHa , Ha);
/*
sorry, don't know how to justify this. ..
*/
- Vector addrow(Ha/(aHa));
+ addrow=Ha;
+ addrow/= aHa;
A -= Matrix(A*a, addrow);
A.insert_row(addrow,A.rows());
}else
/*
*/
- H += Matrix(a,a)/(a*opt->quad*a);
- A -= A*opt->quad*Matrix(a,a)/(a*opt->quad*a);
+ Real q = a*opt->quad*a;
+ H += Matrix(a,a/q);
+ A -= A*opt->quad*Matrix(a,a/q);
}else
WARN << "degenerate constraints";
+ #ifndef NDEBUG
Vector rem_row(A.row(q));
- assert(rem_row.norm() < EPS);
+ assert(rem_row.norm() < EPS);
+ #endif
+
A.delete_row(q);
}
#include "request.hh"
+#include "misc.hh"
#include "debug.hh"
#define VIRTUALCONS(T,R) R *T::clone() const { return new T(*this); } struct T
Rhythmic_req::print();
}
-Real
-wholes(int dur, int dots)
-{
- Real f = 1.0/Real(dur);
- Real delta = f;
-
- while (dots--) {
- delta /= 2.0;
- f += delta;
- }
- return f;
-}
Real
Rhythmic_req::duration() const {
void
Score::process()
{
- *mlog << "Processing ... ";
+ *mlog << "\nProcessing ... ";
assert (paper_);
for (int i=0; i < sv.sz(); i++) {
Score * s = sv[i]->parse();
delete sv[i];
-
+
s->process();
s->output(outfn);
delete s;
-
}
+ sv.set_size(0);
}
void
#include "debug.hh"
#include "string.hh"
#include "inputstaff.hh"
-#include "identparent.hh"
-#include "keyword.hh"
-#include "associter.hh"
-#include "parser.hh"
-static Keyword_ent the_key_tab[]={
- "bar", BAR,
- "bass", BASS,
- "clef", CLEF,
- "cm", CM,
- "commands", COMMANDS,
- "duration", DURATIONCOMMAND,
- "geometric", GEOMETRIC,
- "in", IN,
- "key", KEY,
- "melodic", MELODIC,
- "meter", METER,
- "mm", MM,
- "octave", OCTAVECOMMAND,
- "output", OUTPUT,
- "partial", PARTIAL,
- "paper", PAPER,
- "pt", PT,
- "rhythmic", RHYTHMIC,
- "score", SCORE,
- "skip", SKIP,
- "staff", STAFF,
- "start", START_T,
- "table", TABLE,
- "symboltables", SYMBOLTABLES,
- "notenames", NOTENAMES,
- "texid", TEXID,
- "chord", CHORD,
- "multi", MULTI,
- "unitspace", UNITSPACE,
- "violin", VIOLIN,
- "voice", VOICE,
- "voices", VOICES,
- "width", WIDTH,
- "music", MUSIC,
- "grouping", GROUPING,
- 0,0
-};
-int
-lookup_keyword(String s)
-{
- static Keyword_table table(the_key_tab);
- return table.lookup(s);
-}
-Assoc<String, Identifier*> the_id_tab;
-
-Identifier*
-lookup_identifier(String s)
-{
- if (!the_id_tab.elt_query(s))
- return 0;
-
- return the_id_tab[s];
-}
-
-void
-add_identifier(Identifier*i)
-{
- the_id_tab[i->name] = i;
-}
-
-void
-delete_identifiers()
-{
- for (Assoc_iter<String,Identifier*> ai(the_id_tab); ai.ok(); ai++) {
- mtor << "deleting: " << ai.key()<<'\n';
- delete ai.val();
- }
-}
#include "plist.cc"
+IPL_instantiate(Request);
IPL_instantiate(Score_column);
IPL_instantiate(Staff_column);
IPL_instantiate(Staff);
+#include "request.hh"
#include "command.hh"
#include "inputscore.hh"
#include "inputstaff.hh"
#include "inputmusic.hh"
#include "inputcommand.hh"
+#include "inputcommands.hh"
#include "molecule.hh"
#include "plist.cc"
IPL_instantiate(Atom);
IPL_instantiate(Command);
-
-
+IPL_instantiate(Atom);
+IPL_instantiate(Command);
+IPL_instantiate(Input_command);
+IPL_instantiate(Commands_at);
+IPL_instantiate(Input_staff);
#include "version.hh"
+#include "fversion.hh"
-static char *s = "LilyPond version " VERSIONSTR " compiled on "
- __DATE__ " at " __TIME__ " with " COMPILER "\n";
+static char *s = "LilyPond " VERSIONSTR "/FlowerLib " FVERSIONSTR
+". Compile: " __DATE__ ", " __TIME__ " (" COMPILER ")\n";
const char *
get_version()
texid "\musixsixteendefs"
-
% index TeXstring, xmin xmax ymin ymax
% dims ignored for this table
"param" = table {
"meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt
- "linestaf" "\linestafsym{%}{%}" 0pt 0pt 0pt 0pt
- "stem" "\stem{%}{%}" 0pt 0pt 0pt 0pt
+ "linestaf" "\linestafsym{%}{%}"
+ "stem" "\stem{%}{%}"
+ "fill" "\hbox{}"
}
"dots" = table {
}
"beamslopes" = table {
- "slope" "\beamslope{%}{%}" 0pt 0pt 0pt 0pt
- "horizontal" "\rulesym{%}{%}" 0pt 0pt 0pt 0pt
+ "slope" "\beamslope{%}{%}"
+ "horizontal" "\rulesym{%}{%}"
}
}
% dims ignored for this table
"param" = table {
"meter" "\generalmeter{%}{%}" -3pt 10pt -5pt 5pt
- "linestaf" "\linestafsym{%}{%}" 0pt 0pt 0pt 0pt
- "stem" "\stem{%}{%}" 0pt 0pt 0pt 0pt
+ "linestaf" "\linestafsym{%}{%}"
+ "stem" "\stem{%}{%}"
+ "fill" "\hbox{}"
}
"dots" = table {
}
"beamslopes" = table {
- "slope" "\beamslope{%}{%}" 0pt 0pt 0pt 0pt
- "horizontal" "\rulesym{%}{%}" 0pt 0pt 0pt 0pt
+ "slope" "\beamslope{%}{%}"
+ "horizontal" "\rulesym{%}{%}"
}
}