-DOCFILES=CodingStyle algorithms Makefile breaking
+DOCFILES=commands CodingStyle algorithms Makefile breaking
dist:
ln $(DOCFILES) $(DDIR)/Documentation/
\ No newline at end of file
--- /dev/null
+This table decribes the proper order for the different commands:
+
+
+interpret
+ which priority
+ ========================
+
+ key 200
+ clef 190
+ meter 180
+ bar 170
+
+typeset
+
+ which priority
+ ========================
+
+ bar 100
+ clef 90
+ currentclef 80
+ key 70
+ currentkey 60
+ meter 40
+
\ No newline at end of file
+++ /dev/null
-####
-#### USER CONFIGURABLE
-####
-
-# speedy
-#DEFINES=-DNDEBUG -DNPRINT -O2
-
-# lots of debugging info
-DEFINES=-g
-
-# turn off -pipe if linker doesn't support it
-EXTRACXXFLAGS=-pipe -Wall -W -pedantic
-
-####
-#### EN USER CONFIGURABLE part.
-####
-
-# version info
-MAJVER=0
-MINVER=0
-PATCHLEVEL=9
-VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
-
-# directories
-TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
-OBJECTDIR=objects
-HEADERDIR=hdr
-CCDIR=src
-
-vpath %.cc $(CCDIR)
-vpath %.hh $(HEADERDIR)
-vpath %.y $(CCDIR)
-vpath %.l $(CCDIR)
-vpath %.o $(OBJECTDIR)
-
-#
-#
-include Sources.make
-progdocs=$(hdr) $(mycc)
-gencc=parser.cc lexer.cc
-cc=$(mycc) $(gencc)
-obs=$(cc:.cc=.o)
-
-
-#dist
-.EXPORT_ALL_VARIABLES:
-
-DOCDIR=docdir
-
-PACKAGENAME=lilypond
-DNAME=$(PACKAGENAME)-$(VERSION)
-
-# distribution files.
-othersrc=lexer.l parser.y
-SCRIPTS=make_version make_patch genheader
-IFILES=dimen.tex symbol.ini kortjakje.ly maartje.ly\
- lilyponddefs.tex test.tex .dstreamrc
-OFILES=Makefile Make.variables Sources.make COPYING README
-DFILES=$(OFILES) $(IFILES) $(SCRIPTS)
-
-#compiling
-LOADLIBES=-L$(FLOWERDIR) -lflower
-FLOWERDIR=../flower
-
-CXXFLAGS=$(DEFINES) -I$(HEADERDIR) -I$(FLOWERDIR) $(EXTRACXXFLAGS)
-FLEX=flex
-BISON=bison
-exe=$(PACKAGENAME)
-OUTPUT_OPTION=$< -o $@
-DDIR=$(TOPDIR)/$(DNAME)
-SUBDIRS=Documentation $(OBJECTDIR) $(CCDIR) $(HEADERDIR)
-include Make.variables
+include Variables.make
$(exe): $(obs)
$(CXX) -o $@ $^ $(LOADLIBES)
rm -f depend
realdepend: $(cc)
- $(CXX) $(CXXFLAGS) -MM $^ | perl -ne 's/^(.+)\.o/'$(OBJECTDIR)'\/\1.o/; print;' > depend
+ $(CXX) $(CXXFLAGS) -MM $^ | perl -ne 's#hdr/proto.hh##; s/^(.+)\.o/'$(OBJECTDIR)'\/\1.o/; print;' > depend
include depend
$(CCDIR)/parser.cc: parser.y
$(BISON) -d $<
mv $(CCDIR)/parser.tab.h $(HEADERDIR)/parser.hh
- mv $(CCDIR)/parser.tab.c $(CCDIR)/parser.cc
+ mv $(CCDIR)/parser.tab.c $@
parser.hh: parser.cc
version.o: $(obs) version.hh
-version.hh: Makefile make_version
- make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) > $(HEADERDIR)/$@
+hdr/version.hh: Variables.make make_version
+ make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) > $@
-src/lexer.cc: lexer.l
+$(CCDIR)/lexer.cc: lexer.l
$(FLEX) -+ -t $< > $@
dist:
TAGS:
$(MAKE) -C $(HEADERDIR) TAGS
- $(MAKE) -C $(CCDIR) TAGS
\ No newline at end of file
+ $(MAKE) -C $(CCDIR) TAGS
INTRODUCTION
-This is a beta version of LilyPond (a music typesetter). This release is
-preliminary, please do not distribute. Please send your helpful comments and
-patches to me,
+This is a beta version of LilyPond (a music typesetter). Please send
+your helpful comments and patches to me,
hanwen@stack.urc.tue.nl
* Use The Source, Luke. If you don't know C++, you can try editing
.dstreamrc for copious debugging output.
-* also the subdir Documentation/ it contains some in depth matter
-on LilyPond algorithms
+* the subdir Documentation/ contains some in depth matter on LilyPond
+algorithms
* The source is commented in the DOC++ style.
Check out doc++ at
- http://www.ZIB-Berlin.DE/VisPar/doc++/doc++.html
+ http://www.ZIB-Berlin.DE/VisPar/doc++/doc++.html
sccol.hh stcol.hh scommands.hh melodicstaff.hh\
identifier.hh simplestaff.hh spanner.hh stem.hh\
notehead.hh leastsquares.hh beam.hh rest.hh\
- swalker.hh bar.hh meter.hh
+ swalker.hh bar.hh meter.hh accidental.hh\
+ key.hh keyitem.hh localkeyitem.hh simplewalker.hh\
+ clef.hh clefitem.hh
mycc= qlp.cc qlpsolve.cc \
break.cc linespace.cc molecule.cc staffline.cc\
melodicstaff.cc simpleprint.cc stem.cc\
spanner.cc notehead.cc leastsquares.cc beam.cc\
texbeam.cc rest.cc swalker.cc scoreline.cc\
- simplewalker.cc bar.cc meter.cc\
+ simplewalker.cc bar.cc meter.cc accidental.cc\
+ key.cc keyitem.cc localkeyitem.cc\
+ clef.cc clefitem.cc\
template1.cc template2.cc template3.cc\
- version.cc
\ No newline at end of file
+ version.cc
--- /dev/null
+####
+#### USER CONFIGURABLE
+####
+
+# speedy
+#DEFINES=-DNDEBUG -DNPRINT -O2
+
+# lots of debugging info
+DEFINES=-g
+
+# turn off -pipe if linker doesn't support it
+EXTRACXXFLAGS=-pipe -Wall -W -pedantic
+
+####
+#### EN USER CONFIGURABLE part.
+####
+
+# version info
+MAJVER=0
+MINVER=0
+PATCHLEVEL=10
+VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
+
+# directories
+TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
+OBJECTDIR=objects
+HEADERDIR=hdr
+CCDIR=src
+
+vpath %.cc $(CCDIR)
+vpath %.hh $(HEADERDIR)
+vpath %.y $(CCDIR)
+vpath %.l $(CCDIR)
+vpath %.o $(OBJECTDIR)
+
+#
+#
+include Sources.make
+progdocs=$(hdr) $(mycc)
+gencc=parser.cc lexer.cc
+cc=$(mycc) $(gencc)
+obs=$(cc:.cc=.o)
+
+
+#dist
+.EXPORT_ALL_VARIABLES:
+
+DOCDIR=docdir
+
+PACKAGENAME=lilypond
+DNAME=$(PACKAGENAME)-$(VERSION)
+
+# distribution files.
+othersrc=lexer.l parser.y
+SCRIPTS=make_version make_patch genheader
+IFILES=dimen.tex symbol.ini kortjakje.ly maartje.ly\
+ lilyponddefs.tex test.tex .dstreamrc
+OFILES=Makefile Variables.make Sources.make COPYING README
+DFILES=$(OFILES) $(IFILES) $(SCRIPTS)
+
+#compiling
+LOADLIBES=-L$(FLOWERDIR) -lflower
+FLOWERDIR=../flower
+
+CXXFLAGS=$(DEFINES) -I$(HEADERDIR) -I$(FLOWERDIR) $(EXTRACXXFLAGS)
+FLEX=flex
+BISON=bison
+exe=$(PACKAGENAME)
+OUTPUT_OPTION=$< -o $@
+DDIR=$(TOPDIR)/$(DNAME)
+SUBDIRS=Documentation $(OBJECTDIR) $(CCDIR) $(HEADERDIR)
MAJVER=1
MINVER=0
-PATCHLEVEL=10
+PATCHLEVEL=11
PACKAGENAME=flower
VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
DNAME=$(PACKAGENAME)-$(VERSION)
-DEFINES=-DNDEBUG -DNPRINT -O2
+DEFINES=-DNDEBUG -O2
#DEFINES=-g
CXXFLAGS+=$(DEFINES) -Wall -W -pedantic
cc=lgetopt.cc string.cc dataf.cc textdb.cc unionfind.cc \
smat.cc matrix.cc choleski.cc vector.cc dstream.cc\
- matdebug.cc interval.cc
+ matdebug.cc interval.cc scalar.cc
templatecc=cursor.cc list.cc tsmat.cc plist.cc
inl=findcurs.inl link.inl list.inl cursor.inl plist.inl
findcurs.hh unionfind.hh compare.hh handle.hh matrix.hh\
smat.hh vsmat.hh vector.hh real.hh choleski.hh\
tsmat.hh tvsmat.hh plist.hh associter.hh fproto.hh\
- interval.hh
+ interval.hh scalar.hh
#include <fstream.h>
#include "assoc.hh"
#include "dstream.hh"
-#include "string.hh"
+#include "scalar.hh"
#include "textdb.hh"
/// indent of each level
r.message("not enough fields in Dstream init.");
continue;
}
- (*silent)[r[0]] = r[1].to_bool();
+ (*silent)[r[0]] = Scalar(r[1]).to_bool();
}
}
class Text_stream;
class Data_file ;
struct Text_db;
+struct Scalar;
#endif // FPROTO_HH
refs = 0;
}
/// point to new object.
- void up(T *t, int *r=0) {
+ void up(T *t, int *r) {
if (!r) {
refs = new int;
*refs = 1;
List<void*>::remove(me);
}
}
+template<class T>
+PCursor<T>
+PointerList<T>::find(T what ) const
+{
+ PCursor<T> i(*this);
+ for (; i.ok(); i++)
+ if (i.ptr() == what)
+ break;
+ return i;
+}
public:
PCursor<T> top() { return PCursor<T> (List<void*>::top()); }
PCursor<T> bottom() { return PCursor<T> (List<void*>::bottom()); }
+ PCursor<T> find(T) const;
void concatenate(PointerList<T> const &s) { List<void*>::concatenate(s); }
-// PointerList( const T& thing ) : List<void*>( thing ) { }
PointerList() {}
};
--- /dev/null
+#include <stdio.h>
+#include "scalar.hh"
+
+bool
+Scalar::isnum()
+{
+ int conv = false;
+ if (len()) {
+ long l =0;
+ conv = sscanf(data, "%ld", &l);
+ }
+ return len() && conv;
+}
+
+Scalar::operator Real()
+{
+ assert (isnum());
+ return fvalue();
+}
+
+Scalar::operator int()
+{
+ assert (isnum());
+ return value();
+}
+bool
+Scalar::to_bool() const
+{
+ if (!len())
+ return false;
+ if (*this == "0")
+ return false;
+ String u (*this);
+ u.upper();
+ if (u== "FALSE")
+ return false;
+ return true;
+}
--- /dev/null
+/*
+ scalar.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef SCALAR_HH
+#define SCALAR_HH
+#include "string.hh"
+#include "real.hh"
+
+/// Perl -like scalar type.
+struct Scalar : public String {
+
+ Scalar(Real r) : String(r) {}
+ Scalar(int i) : String(i) {}
+ Scalar(char c) : String(c) {}
+ Scalar(const char *c) : String(c) {}
+ Scalar(String s ):String(s) {}
+ Scalar() {}
+ bool isnum();
+ operator Real();
+ operator int();
+ ///
+ bool to_bool() const;
+ /** perl -like string to bool conversion
+ */
+
+};
+
+#endif // SCALAR_HH
+
#include <stdio.h>
#include <ctype.h>
#include <assert.h>
-//#include "globals.hh"
+
#include "string.hh"
+
static char* strlwr( char* s )
{
char* p = s;
// String convd to const char *
}
- const char*
-String::ptr() const
+const char*
+String::cptr() const
{
return data;
}
-#ifdef CENTRAL_OBJECT // everything derived from Sortable object
-// comparisons.
-int
-String::operator ==( const Sortable& test ) const
-{
- const String *s = (const String *) &test;
- return *this == *s;
-}
-
-int
-String::operator &&(const Object& test) const
-{
- const String *s = (const String *) &test;
-
- int i = min( len(), s->len() );
- return ( i > 0 ) ?
- ( !strncmp( data, s->data, i ) ) : 0;
-}
-
-int
-String::operator >( const Sortable& test ) const
-{
- const String *s = (const String *) &test;
- return strcmp( data, s->data ) > 0;
-}
-#endif
-
// signed comparison, analogous to strcmp;
int
String::compare( const char* test ) const
strrev(s);
return retval;
}
-bool
-String::to_bool() const
-{
- if (!len())
- return false;
- if (*this == "0")
- return false;
- String u (*this);
- u.upper();
- if (u== "FALSE")
- return false;
- return true;
-}
/// return a "new"-ed copy of contents
char *copy_array() const; // return a "new"-ed copy of contents
- const char *ptr() const;
- const char *ptr() { return ((const String *)this)->ptr(); }
+ const char *cptr() const;
+ const char *ptr() { return ((const String *)this)->cptr(); }
+
/// return the data. Don't use for writing the data.
- operator const char *() const { return ptr(); }
+ operator const char *() const { return cptr(); }
String operator =( const String & source ) { data = source.data; return *this; }
/// the length of the string
int len() const;
- /// DO NOT MAKE THIS INTO AN OPERATOR
- bool to_bool() const;
- /** perl -like string to bool conversion
- */
};
/**
--- /dev/null
+/*
+ accidental.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef ACCIDENTAL_HH
+#define ACCIDENTAL_HH
+#include "item.hh"
+
+struct Accidental : Item {
+ int type,pos;
+
+ void preprocess();
+ Accidental(int type, int position);
+ void print()const;
+private:
+ void brew_molecole();
+};
+#endif // ACCIDENTAL_HH
+
#define BEAM_HH
#include "proto.hh"
#include "spanner.hh"
-#include "list.hh"
+#include "plist.hh"
/// a beam connects multiple stems
struct Beam: public Spanner {
- List<Stem*> stems;
+ PointerList<Stem*> stems;
Real slope;
Real left_pos;
/// -1 below heads, +1 above heads.
min += t;
max += t;
}
-
+ Real operator[](int j) {
+ if (j==-1)
+ return min;
+ else if (j==1)
+ return max;
+ else
+ assert(false);
+
+ }
void unite(Interval h) {
if (h.min<min)
min = h.min;
--- /dev/null
+/*
+ clef.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef CLEF_HH
+#define CLEF_HH
+#include "string.hh"
+#include "vray.hh"
+
+struct Clef {
+ int c0_pos;
+ String clef_type;
+
+ Clef();
+ void read(svec<String> args);
+};
+#endif // CLEF_HH
+
--- /dev/null
+
+/*
+ clefitem.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef CLEFITEM_HH
+#define CLEFITEM_HH
+#include "item.hh"
+
+
+struct Clef_item : Item {
+ String type;
+ int y_off;
+
+ Clef_item();
+ void read(Clef);
+ void read(String);
+ void preprocess();
+};
+
+#endif // CLEFITEM_HH
+
+
--- /dev/null
+/*
+ key.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef KEY_HH
+#define KEY_HH
+
+#include "vray.hh"
+#include "string.hh"
+
+class Key {
+ svec<int> accidentals;
+
+ /****************/
+
+public:
+ svec<int> read(svec<String> );
+ svec<int> oldkey_undo(svec<String>);
+
+ Key();
+ void set(int i, int acc);
+ int acc(int i) { return accidentals[i]; }
+};
+
+struct Local_key
+{
+ void reset(Key);
+ Key& oct(int);
+ Local_key();
+
+private:
+ svec<Key> octaves;
+};
+
+#endif // KEY_HH
+
+
--- /dev/null
+/*
+ keyitem.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef KEYITEM_HH
+#define KEYITEM_HH
+
+#include "item.hh"
+
+struct Keyitem : Item {
+ svec<int> pitch;
+ svec<int> acc;
+ int c_position;
+
+ /****************/
+
+ Keyitem(int cposition);
+ void add(int pitch, int acc);
+ void read(svec<int> k);
+ void preprocess();
+
+private:
+ void brew_molecole();
+};
+#endif // KEYITEM_HH
--- /dev/null
+/*
+ localkeyitem.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef LOCALKEYITEM_HH
+#define LOCALKEYITEM_HH
+#include "item.hh"
+
+struct Local_acc {
+ int name , acc, octave;
+ static int compare(Local_acc&, Local_acc&);
+};
+
+struct Local_key_item : Item {
+ svec<Local_acc> accs;
+
+ int c0_position;
+
+ /****************/
+
+ Local_key_item(int c0position);
+ void add(int oct, int pitch, int acc);
+
+ void preprocess();
+
+private:
+ void brew_molecole();
+
+};
+#endif // LOCALKEYITEM_HH
+
*/
Symbol rule_symbol(Real height, Real width);
-
+ Symbol accidental(int);
Symbol ball(int);
Symbol flag(int);
Symbol rest(int);
+ Symbol clef(String);
Symbol bar(String);
Symbol dots(int);
Lookup();
virtual void set_output(PScore *);
virtual Melodic_staff*clone()const;
-
+ virtual Item* get_TYPESET_item(Command*);
virtual Stem * get_stem(Stem_req *rq);
- virtual Notehead * get_notehead(Note_req *rq);
+ virtual Notehead * get_notehead(Note_req *rq, int bot);
+ virtual Local_key_item* get_local_key_item();
};
#endif // MELODICSTAFF_HH
/// a group of #Atom#s
struct Molecule {
- PointerList<Atom*> ats;
+ IPointerList<Atom*> ats;
Molecule() { }
Molecule(Atom a) { add(a) ; }
Voice_element* get_rest_element(String,String);
Command * get_bar_command(Real);
Staff * get_new_melodicstaff();
+void add_requests( Voice_element*v, svec<Request*>&req);
Command* get_meterchange_command( int,int);
Command* get_meter_command( Real,int,int);
Command* get_skip_command( int,Real);
+Command* get_key_interpret_command(svec<String>);
Request* get_request(char);
-void add_requests( Voice_element*v, svec<Request*>&req);
+Command*get_clef_interpret_command(String w);
/// stuff grouped vertically.
struct PCol {
- List<const Item*> its;
- List<const Spanner*> stoppers, starters;
+ PointerList<const Item*> its;
+ PointerList<const Spanner*> stoppers, starters;
/// Can this be broken? true eg. for bars.
bool breakable()const;
/// if lines are broken then this column x-coord #hpos#
Real hpos;
-
+
/****************************************************************/
- void add(Item*i);
-
+ void add(Item *i);
+
Interval width() const;
~PCol();
PCol(PCol * parent);
struct Notehead;
struct Beam;
struct Rest;
+struct Accidental;
+struct Key;
+struct Local_key;
+struct Keyitem;
+struct Local_key_item;
+struct Clef;
+struct Clef_item;
+
#endif // PROTO_HH
Paperdef *paper_; // indirection.
/// the columns, ordered left to right
- PointerList<PCol *> cols;
+ IPointerList<PCol *> cols;
/// the idealspacings, no particular order
- PointerList<Idealspacing*> suz;
+ IPointerList<Idealspacing*> suz;
/// the staffs ordered top to bottom
- PointerList<PStaff*> staffs;
+ IPointerList<PStaff*> staffs;
/// all symbols in score. No particular order.
- PointerList<Item*> its;
+ IPointerList<Item*> its;
/// if broken, the different lines
- PointerList<Line_of_score*> lines;
+ IPointerList<Line_of_score*> lines;
/// crescs etc; no particular order
- PointerList<Spanner *> spanners;
+ IPointerList<Spanner *> spanners;
/****************************************************************/
Parametric_symbol *stafsym;
PScore * pscore_;
- virtual Symbol get_stafsym(Real width)const=0; // maybe overkill
-
- List<const Spanner*> spans;
- List<Item*> its;
+
+ PointerList<const Spanner*> spans;
+ PointerList<Item*> its;
+ /****************/
+ virtual Symbol get_stafsym(Real width)const=0; // maybe overkill
void add(Item*i);
PStaff(PScore*);
virtual ~PStaff() {}
virtual Item *get_TYPESET_item(Command*);
virtual Stem *get_stem(Stem_req *rq);
- virtual Notehead * get_notehead(Note_req *rq);
+ virtual Notehead * get_notehead(Note_req *rq, int b);
virtual void set_output(PScore *);
virtual Rhythmic_staff*clone()const;
};
struct Score_column {
/// indirection to column
- PCol * pcol;
+ PCol * pcol_;
/// length of notes/rests in this column
svec<Real> durations;
return sgn(c1.when - c2.when);
}
void set_breakable() {
- pcol->set_breakable();
+ pcol_->set_breakable();
}
bool used();
void print() const;
#include "plist.hh"
/// the list of commands in Score
-struct Score_commands : public PointerList<Command*> {
+struct Score_commands : public IPointerList<Command*> {
void process_add(Command);
Score_commands*parse(Real last)const;
void parser_add(Command*);
- void add_seq(svec<Command>);
+ void add_seq(svec<Command>,bool);
void clean(Real last);
void set_breakable(Real when);
bool is_breakable(Real w);
struct Score {
/// paper_, staffs_ and commands_ form the problem definition.
Paperdef *paper_;
- PointerList<Staff *> staffs_;
+ IPointerList<Staff*> staffs_;
Score_commands *commands_;
/// "runtime" fields for setting up spacing
- PointerList<Score_column*> cols_;
+ IPointerList<Score_column*> cols_;
PScore *pscore_;
/****************************************************************/
/// the columns of a score that form one line.
struct
Line_of_score {
- List<const PCol *> cols;
+ PointerList<const PCol *> cols;
// need to store height of each staff.
- PointerList<Line_of_staff*> staffs;
+ IPointerList<Line_of_staff*> staffs;
const PScore * score; // needed to generate staffs
/****************/
#ifndef SIMPLESTAFF_HH
#define SIMPLESTAFF_HH
+#include "key.hh"
#include "stcol.hh"
#include "staff.hh"
#include "swalker.hh"
+
/*
mega-stupido staffs and cols: they do notes one at each moment.
*/
Beam_req *beam_;
Simple_staff* staff_;
+
/****************/
- virtual void typeset_item(Item *, int=1);
+ void typeset_item(Item *, int=1);
+
+ void typeset_item_directional(Item *, int dir, int=1);
Molecule *create_command_mol(Command *com);
virtual Item *get_TYPESET_item(Command*);
virtual Stem *get_stem(Stem_req *rq)=0;
- virtual Notehead *get_notehead(Note_req *rq)=0;
+ virtual Notehead *get_notehead(Note_req *rq, int b)=0;
virtual Rest *get_rest(Rest_req *rq);
virtual void set_output(PScore *);
+ virtual Local_key_item* get_local_key_item();
void process_commands( PCursor<Command*> &where);
virtual void walk();
Simple_staff();
};
-struct Simple_walker: Staff_walker {
- Stem *stem_;
- svec<Notehead *>noteheads;
- Beam *beam_;
-
- /****************/
-
- virtual void process_command(Command*);
- virtual void process_requests();
- Simple_walker(Simple_staff*);
- Simple_column *col();
- Simple_staff *staff();
-};
-
-
#endif // SIMPLESTAFF_HH
--- /dev/null
+/*
+ simplewalker.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef SIMPLEWALKER_HH
+#define SIMPLEWALKER_HH
+
+#include "proto.hh"
+
+struct Simple_walker: Staff_walker {
+ Stem *stem_;
+ svec<Notehead *>noteheads;
+ Local_key local_key_;
+ Key key_;
+ svec<int> *oldkey_undo;
+ svec<int> typesetkey;
+ Beam *beam_;
+ Local_key_item *local_key_item_;
+ bool wantkey; // urgh
+ bool processed_key;
+ bool processed_clef;
+ Clef clef_;
+
+ /****************/
+
+ virtual void do_TYPESET_command(Command*);
+ virtual void do_INTERPRET_command(Command*);
+ virtual void process_requests();
+ virtual void reset();
+
+ void do_notes();
+ Simple_walker(Simple_staff*);
+ Simple_column *col();
+ Simple_staff *staff();
+
+ void do_local_key(Note_req*n);
+};
+
+
+#endif // SIMPLEWALKER_HH
+
+
/// base class for a collection of voices.
struct Staff {
/// synchronous horizontal stuff
- PointerList<Voice*> voices;
+ IPointerList<Voice*> voices;
/// commands in chronological order
- PointerList<Command *> commands;
+ IPointerList<Command *> commands;
/// runtime field
- PointerList<Staff_column*> cols;
+ IPointerList<Staff_column*> cols;
/// indirections to the Score and PScore
Score *score_;
/// one broken line of staff.
struct Line_of_staff {
- PointerList<Spanner *> brokenspans;
+ IPointerList<Spanner *> brokenspans;
Line_of_score const * scor;
const PStaff *pstaff_;
void set_default_stemlen();
void set_default_extents();
void postprocess();
+ void preprocess();
Stem(int center);
void print() const;
Interval width() const;
int break_status;
/****************/
+
int priority() const; // Command
Real when() const;
virtual ~Staff_walker();
Staff_walker(Staff*, PScore*);
void process() ;
- virtual void process_command(Command *)=0;
+ void process_command(Command *);
+ void operator++(int);
+ /// every time ++ is called
+ virtual void reset()=0;
virtual void process_requests()=0;
+ virtual void do_TYPESET_command(Command*)=0;
+ virtual void do_INTERPRET_command(Command*)=0 ;
};
/**
manage run-time info when walking staffcolumns such as: key,
/// class for horizontal stuff.
struct Voice {
- PointerList<Voice_element *> elts;
+ IPointerList<Voice_element *> elts;
Real start;
/****************/
Real duration;
const Voicegroup *group;
const Voice *voice;
- PointerList<Request*> reqs;
+ IPointerList<Request*> reqs;
- List<const Item *> granted_items;
- List<const Spanner *> granted_spanners;
+ PointerList<const Item *> granted_items;
+ PointerList<const Spanner *> granted_spanners;
/****************/
melodie = voice {
$ \octave c
%%% theme
- c c g g a a g2 f f e e d d c2
- %%% var 1
+ c c g g a a g2 f f e e d d c2
+ g g f f e e d d g g f f e e d d
+ %%% var 1
c r8 c8 ( ) g r8 g8 ( ) a r8 a8 ( ) g r4
f r8 f8 ( ) e4 r8 e8 ( ) d4 r8 d8 ( ) c4 r4
$
}
begeleiding = voice {
- $ \octave ``c
+ $ \octave `c
%%% theme
- `c c e c f c e c d `b c `a `f `g `c2
+ `c c e c f c e c d `b c `a `f `g `c2
+ \octave `c
+ e `g d `g c `g `b `g e `g d `g c `g `b `g
%%%% var 1
r8 e8() c r8 e8() c r8 f8()c r8 e8()c
r8 d8()`b r8 c8()`a r8 `a8()`f r8 `e8()`c
}
commands {
meter 2 4
- skip 16:0
+ clef bass
+ skip 2:0
+ clef violin
+% skip 2:0
+ skip 32:0
}
-}
\ No newline at end of file
+}
+
\mdef\eighthrest{63}
\mdef\sixteenthrest{64}
\mdef\thirtysecondrest{65}
-\mdef\sharp{'065}
-\mdef\flat{'063}
-\mdef\natural{'067}
+\mdef\sharp{52}
+\mdef\flat{50}
+\mdef\natural{54}
+\mdef\sharpsharp{53}
+\mdef\flatflat{51}
+
\mdef\singledot{'00}
\mdef\doubledot{'01}
\mdef\tripledot{'02}
\mdef\mussepline{155}
-
+\mdef\violinclef{71}
+\mdef\bassclef{73}
\mdef\deigthflag{45}
\mdef\dsixteenthflag{46}
\def\ldoubledot{\kern-6pt\doubledot}
\def\ltripledot{\kern-6pt\tripledot}
+
+
\def\stem#1#2{\vrule height#2 depth-#1}
\def\placebox#1#2#3{%
melody=
melodicstaff {
+
+ voice { $ fis 'dis 'fis 'gisis $ }
+ voice { $ 'eses $ start 0.75}
+ voice { $ 'cis $ start 0.75}
+ voice { $ f $ start 0.75}
+ voice { $ gis $ start 0.75}
+
+
voice { $
''c2.. r8 r4 r8 r16 r32 r32
[d8 e8 f8 g8] [d8 e8 f8 g8]
a8 b8 'c8 'd8 ''c8 ```c8 c4 c4 c4 c4
\duration 16 `b16 `a16 `g16 `f16 \duration 4
c `b `a `g `f `e `d `c ``b ``a ``g ``f ``e ``d ``c$
- }
+ start 1.0 }
}
score {
paper {
% staff { melody }
commands {
meter 4 4
+
+ key $ fis cis gis $
skip 2:0
+ key $ $
meter 2 4
+
skip 19:0
}
}
--- /dev/null
+#include "accidental.hh"
+#include "debug.hh"
+#include "molecule.hh"
+#include "paper.hh"
+#include "lookup.hh"
+
+Accidental::Accidental(int t, int p)
+{
+ type = t;
+ pos = p;
+}
+
+void
+Accidental::preprocess()
+{
+ brew_molecole();
+}
+
+void
+Accidental::brew_molecole()
+{
+ Symbol s =paper()->lookup_->accidental(type);
+ output = new Molecule(Atom(s));
+ output->translate(Offset(0, pos * paper()->interline()/2));
+}
+
+void
+Accidental::print()const
+{
+ mtor << "Accidental "<<type;
+ Item::print();
+}
Real miny;
int no_beams;
+ ///////////////
+
Stem_info(){}
Stem_info(const Stem*);
};
sc->dir = dir;
}
}
-
+/*
+ should use minimum energy formulation (cf linespacing)
+ */
void
Beam::solve_slope()
{
left_pos *= dir;
slope *= dir;
- {Real inter =paper()->interline()/2;
- Real unitslope = slope*inter;
-
- // set beamslope, for setting stems correctly
- // ignoring return.
- Symbol sy = paper()->lookup_->beam(unitslope, width().length());
- slope =unitslope / inter;
+ {
+ Real inter =paper()->interline()/2;
+ Real unitslope = slope*inter;
+
+ // set beamslope, for setting stems correctly
+ // ignoring return.
+ Symbol sy = paper()->lookup_->beam(unitslope, width().length());
+ slope =unitslope / inter;
}
}
while (i < breakpoints.sz()) {
// add another measure.
- while(breakpoints[i] !=curcol){
+ while (breakpoints[i] != curcol.ptr()){
current.add(curcol);
curcol++;
minimum = current;
} else { // we're one col too far.
i--;
- while (curcol != breakpoints[i])
+ while (curcol.ptr() != breakpoints[i])
curcol --;
break;
for (int i=0; i < sc->durations.sz(); i++) {
Real d = sc->durations[i];
Real dist = paper_->duration_to_dist(d);
- PCol * c2 = find_col(sc->when + d,true)->pcol;
- connect_nonmus(sc->pcol, c2, dist);
- c2 = find_col(sc->when + d,false)->pcol;
- connect_nonmus(sc->pcol, c2, dist);
+ PCol * c2 = find_col(sc->when + d,true)->pcol_;
+ connect_nonmus(sc->pcol_, c2, dist);
+ c2 = find_col(sc->when + d,false)->pcol_;
+ connect_nonmus(sc->pcol_, c2, dist);
}
else if (sc->used()) { // ignore empty columns
- PCol * c2 = find_col(sc->when,true)->pcol;
- connect_nonmus(sc->pcol,c2,0.0);
+ PCol * c2 = find_col(sc->when,true)->pcol_;
+ connect_nonmus(sc->pcol_, c2, 0.0);
}
}
}
--- /dev/null
+#include "clef.hh"
+
+Clef::Clef()
+{
+ clef_type= "violin";
+ c0_pos = -2;
+}
+
+void
+Clef::read(svec<String> args)
+{
+ clef_type = args[0];
+ if (clef_type == "violin") {
+ c0_pos=-2;
+ } else if (clef_type == "bass") {
+ c0_pos = 10;
+ } else
+ assert(false);
+}
--- /dev/null
+#include "clefitem.hh"
+#include "string.hh"
+#include "molecule.hh"
+#include "paper.hh"
+#include "lookup.hh"
+#include "clef.hh"
+
+Clef_item::Clef_item()
+{
+ read("violin");
+}
+void
+Clef_item::read(String t)
+{
+ type = t;
+ if (type == "violin")
+ y_off = 2;
+ if (type == "bass")
+ y_off = 6;
+}
+void
+Clef_item::read(Clef k)
+{
+ read(k.clef_type);
+}
+
+void
+Clef_item::preprocess()
+{
+ Symbol s = paper()->lookup_->clef(type);
+ output = new Molecule(Atom(s));
+ output->translate(Offset(0, paper()->interline()/2 * y_off));
+}
+
{
#ifndef NPRINT
mtor << "command at " << when << ", code " << code << " prio " << priority;
+ if ( isbreak())
+ mtor << "(break separator)";
if (args.sz()) {
mtor<< " args: ";
for (int i = 0; i<args.sz(); i++)
#include "parseconstruct.hh"
#include "command.hh"
+
Command*
-get_bar_command(Real w)
+get_key_interpret_command(svec<String> which)
{
Command*c = new Command;
- c->when = w;
- c->code = TYPESET;
- c->args.add( "BAR");
- c->args.add( "|");
- c->priority = 100;
+ c->code = INTERPRET;
+ c->args= which;
+ String k("KEY");
+ c->args.insert(k,0 );
+ c->priority = 200;
+ return c;
+}
+
+Command*
+get_clef_interpret_command(String w)
+{
+ Command*c = new Command;
+ c->code = INTERPRET;
+ c->args.add("CLEF");
+ c->args.add(w);
+ c->priority = 190;
+ return c;
+}
+
+Command*
+get_key_typeset_command(svec<String> which)
+{
+ Command*c = new Command;
+ c->code = TYPESET;
+ c->args = which;
+ String k("KEY");
+ c->args.insert(k,0 );
+ c->priority = 70;
+ return c;
+}
+
+Command *
+get_meterchange_command(int n, int m)
+{
+ Command*c = new Command;
+
+ c->code = INTERPRET;
+ c->args.add( "METER");
+ c->args.add( n );
+ c->args.add( m );
+ c->priority = 170; // more than bar
return c;
}
c->args.add( "METER");
c->args.add( n );
c->args.add( m );
- c->priority = 50; // less than bar
+ c->priority = 40;
return c;
}
-Command *
-get_meterchange_command(int n, int m)
+Command*
+get_bar_command(Real w)
{
Command*c = new Command;
-
+ c->when = w;
c->code = INTERPRET;
- c->args.add( "METER");
- c->args.add( n );
- c->args.add( m );
- c->priority = 0; // more than bar
+ c->args.add( "BAR");
+ c->args.add( "|");
+ c->priority = 170;
return c;
}
c->args.add( "SKIP");
c->args.add( n );
c->args.add( m );
- c->priority = 0; // more than bar
+ c->priority = 0;
return c;
}
--- /dev/null
+#include "key.hh"
+#include "notename.hh"
+
+const int OCTAVES=14;
+const int ZEROOCTAVE=7;
+
+Key::Key()
+{
+ accidentals.set_size(7);
+ for (int i= 0; i < 7 ; i++)
+ accidentals[i] = 0;
+}
+
+Local_key::Local_key()
+{
+ octaves.set_size(OCTAVES);
+}
+
+Key&
+Local_key::oct(int i)
+{
+ return octaves[i+ZEROOCTAVE];
+}
+
+void
+Key::set(int i, int a)
+{
+ assert(a > -3 && a < 3);
+ accidentals[i]=a;
+}
+
+
+void
+Local_key::reset(Key k)
+{
+ for (int i= 0; i < OCTAVES ; i++)
+ octaves[i] = k;
+}
+
+svec<int>
+Key::read(svec<String> s)
+{
+ svec<int> newkey;
+
+ for (int i=0; i < s.sz(); i++) {
+ int large, small;
+ lookup_notename(large, small, s[i]);
+ accidentals[large]=small;
+
+ newkey.add(large);
+ newkey.add(small);
+ }
+ return newkey;
+}
+
+svec<int>
+Key::oldkey_undo(svec<String> s)
+{
+ svec<int> oldkey;
+ svec<int> newkey;
+ newkey.set_size(7);
+ for (int i=0; i < newkey.sz(); i++)
+ newkey[i] = 0;
+
+ for (int i=0; i < s.sz(); i++) {
+ int large, small;
+ lookup_notename(large, small, s[i]);
+ newkey[large] = small;
+ }
+ for (int i=0; i < newkey.sz(); i++)
+ if (accidentals[i] && accidentals[i] != newkey[i]) {
+ oldkey.add(i);
+ oldkey.add(0);
+ }
+
+
+ return oldkey;
+}
--- /dev/null
+#include "keyitem.hh"
+#include "key.hh"
+#include "debug.hh"
+#include "molecule.hh"
+#include "paper.hh"
+#include "lookup.hh"
+
+
+Keyitem::Keyitem(int c)
+{
+ c_position = c;
+}
+
+
+void
+Keyitem::read(svec<int> s)
+{
+ for (int i = 0 ; i< s.sz(); ) {
+ int note = s[i++];
+ int acc = s[i++];
+
+ add(note, acc);
+ }
+}
+void
+Keyitem::add(int p, int a)
+{
+ pitch.add(p);
+ acc.add(a);
+}
+
+void
+Keyitem::preprocess() {
+ brew_molecole();
+}
+
+void
+Keyitem::brew_molecole()
+{
+ output = new Molecule;
+ Real inter = paper()->interline()/2;
+
+ for (int i =0; i < pitch.sz(); i++) {
+ Symbol s= paper()->lookup_->accidental(acc[i]);
+ Atom a(s);
+ a.translate(Offset(0,c_position + pitch[i] * inter));
+ Molecule m(a);
+ output->add_right(m);
+ }
+}
<notes>\$ {
BEGIN(INITIAL); return '$';
}
-<notes>[\[){] { /* parens () are NO mistake */
+<notes>[\[{)] { /* parens () are NO mistake */
yylval.c = YYText()[0];
return OPEN_REQUEST_PARENS;
}
-<notes>[\]()}] { /* parens () are NO mistake */
+<notes>[\]}(] { /* parens () are NO mistake */
yylval.c = YYText()[0];
return CLOSE_REQUEST_PARENS;
}
--- /dev/null
+#include "localkeyitem.hh"
+#include "molecule.hh"
+#include "lookup.hh"
+#include "paper.hh"
+
+Local_key_item::Local_key_item(int i)
+{
+ c0_position = i;
+}
+
+void
+Local_key_item::add (int o, int p , int a)
+{
+ Local_acc l;
+ l.octave = o;
+ l.name = p;
+ l.acc = a;
+ accs.add(l);
+}
+
+void
+Local_key_item::preprocess()
+{
+ brew_molecole();
+}
+
+void
+Local_key_item::brew_molecole()
+{
+ accs.sort(Local_acc::compare);
+
+ output = new Molecule;
+ Molecule*octmol = 0;
+ int lastoct = -100;
+ for (int i = 0; i < accs.sz(); i++) {
+ if (accs[i].octave != lastoct) {
+ if (octmol){
+ Real dy =lastoct*7*paper()->interline()/2;
+ octmol->translate(Offset(0, dy));
+ output->add(*octmol);
+ delete octmol;
+ }
+ octmol= new Molecule;
+ }
+ lastoct = accs[i].octave;
+ Symbol s =paper()->lookup_->accidental(accs[i].acc);
+ Atom a(s);
+ Real dy = (accs[i].name + c0_position) * paper()->interline()/2;
+ a.translate(Offset(0,dy));
+
+ octmol->add_right(a);
+ }
+
+ if (octmol){
+ Real dy =lastoct*7*paper()->interline()/2;
+ octmol->translate(Offset(0, dy));
+ output->add(*octmol);
+ delete octmol;
+ }
+}
+
+int
+Local_acc::compare(Local_acc&a, Local_acc&b)
+{
+ if (a.octave - b.octave)
+ return a.octave - b.octave;
+ if (a.name - b.name)
+ return a.name - b.name;
+
+ assert(false);
+};
{
return (*symtables_)("rests")->lookup(String(j));
}
+Symbol
+Lookup::accidental(int j)
+{
+ return (*symtables_)("accidentals")->lookup(String(j));
+}
Symbol
{
return (*symtables_)("bars")->lookup(s);
}
+
+Symbol
+Lookup::clef(String s)
+{
+ return (*symtables_)("clefs")->lookup(s);
+}
+
Symbol
Lookup::dots(int j)
{
Meter_sym(Symtables*s) : Parametric_symbol(s){ }
Symbol eval(svec<String> a) const{
Symbol s;
- s.dim.x = Interval( convert_dimen(-5,"pt"),
- convert_dimen(5,"pt"));
- s.dim.y = Interval(0, convert_dimen(10,"pt") ); // todo
+ s.dim.x = Interval( convert_dimen(0,"pt"),
+ convert_dimen(10,"pt"));
+ s.dim.y = Interval(0, convert_dimen(20,"pt") ); // todo
String src = (*symtables_)("param")->lookup("meter").tex;
s.tex = substitute_args(src,a);
return s;
#include "melodicstaff.hh"
+#include "keyitem.hh"
#include "stem.hh"
#include "rest.hh"
#include "notehead.hh"
#include "linestaff.hh"
#include "rhythmstaff.hh"
#include "sccol.hh"
+#include "localkeyitem.hh"
const int NO_LINES=5;
-const int BOTTOM_POSITION=2; // e is on bottom line of 5-staff...
+
void
Melodic_staff::set_output(PScore*ps)
Notehead*
-Melodic_staff::get_notehead(Note_req *rq)
+Melodic_staff::get_notehead(Note_req *rq, int bottom)
{
int b = rq->rhythmic()->balltype;
int d = rq->rhythmic()->dots;
Notehead *n =new Notehead((NO_LINES-1)*2);
n->balltype =b;
n->dots = d;
- n->position = rq->note()->height() - BOTTOM_POSITION;
+ n->position = rq->note()->height() + bottom;
return n;
}
+Item *
+Melodic_staff::get_TYPESET_item(Command*com)
+{
+ if (com->args[0] == "KEY") {
+ return new Keyitem(NO_LINES); // urgh.
+ } else
+ return Simple_staff::get_TYPESET_item(com);
+}
Stem *
Melodic_staff::get_stem(Stem_req*rq)
{
return new Melodic_staff(*this);
}
+
+Local_key_item* Melodic_staff::get_local_key_item()
+{
+ return new Local_key_item(-2);
+}
+
int oct, pit, acc;
bool forceacc;
parse_pitch(pitch, i, oct, forceacc, pit, acc);
- char nm = pit + 'c';
- if (nm > 'g')
- nm += 'a' - 'h';
- rq->name =nm;
+ rq->name =pit;
rq->octave = oct;
rq->accidental = acc;
parse();
linewidth = convert_dimen(15,"cm"); // in cm for now
whole_width= 8*note_width();
- geometric_ = PHI;
+// geometric_ = PHI;
+ geometric_ = sqrt(2);
}
void
Text_db symini("symbol.ini");
- while (!symini.eof()) {
-
+ while (!symini.eof()) {
Text_record r( symini++);
if (r[0] == "symboltables")
Request* request;
int i;
char c;
+ svec<String> * strvec;
}
%token VOICE STAFF SCORE TITLE RHYTHMSTAFF BAR NOTENAME OUTPUT
%token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS
%token MELODICSTAFF GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND
+%token KEY CLEF VIOLIN BASS
%token <id> IDENTIFIER
%token <string> NEWIDENTIFIER
%type <i> int
%type <scommands> score_commands_block score_commands_body
%type <request> post_request pre_request
-
-
+%type <strvec> pitch_list
+%type <string> clef_id
%%
mudela: /* empty */
;
voice_elt:
- PITCH DURATION {
+ PITCH DURATION {
$$ = get_note_element(*$1, *$2);
delete $1;
delete $2;
}
;
+pitch_list: {
+ $$ = new svec<String>;
+ }
+ | pitch_list PITCH {
+ $$->add(*$2);
+ delete $2;
+ }
+
score_command:
SKIP int ':' REAL {
$$ = get_skip_command($2, $4);
| METER int int {
$$ = get_meterchange_command($2, $3);
}
+ | KEY '$' pitch_list '$' {/*UGH*/
+ $$ = get_key_interpret_command(*$3);
+ delete $3;
+ }
+ | CLEF clef_id {
+ $$ = get_clef_interpret_command(*$2);
+ delete $2;
+ }
/* | PARTIALMEASURE REAL {
$$ = get_partial_command($2);
}*/
;
-
+clef_id:
+ VIOLIN { $$ = new String("violin"); }
+ | BASS { $$ = new String("bass"); }
+ ;
int:
REAL {
$$ = int($1);
return prebreak||postbreak;
}
-PCol::PCol(PCol *parent) {
+PCol::PCol(PCol *parent)
+{
daddy = parent;
prebreak=0;
postbreak=0;
PCol::~PCol()
{
-
- delete prebreak;
-
- delete postbreak;
+ delete prebreak;
+ delete postbreak;
}
void
i->pcol_ = this;
used = true;
}
-
i->preprocess();
- if (c->daddy && c == c->daddy->prebreak) { // makeshift.
+ if (0 && c->daddy && c == c->daddy->prebreak) { // makeshift.
Interval iv (i->width());
if (!iv.empty()) {
Note_req::Note_req()
{
- name = 'c';
+ name = 0;
octave = 0;
accidental = 0;
forceacc = false;
int
Note_req::height() const
{
- int s = name -'c';
- if (s < 0)
- s+=7;
- return s + octave*7;
+ return name + octave*7;
}
Rhythmic_req::Rhythmic_req()
Item *
Rhythmic_staff::get_TYPESET_item(Command *com)
{
+ if (com->args[0] == "KEY" || com->args[0] == "CLEF")
+ return 0;
Item *i = Simple_staff::get_TYPESET_item(com);
+ if (!i) return 0;
i->translate(Offset(0,
-score_->paper_->standard_height()/2));
return i;
}
Notehead*
-Rhythmic_staff::get_notehead(Note_req *rq)
+Rhythmic_staff::get_notehead(Note_req *rq, int)
{
int b = rq->rhythmic()->balltype;
int d = rq->rhythmic()->dots;
Score_column::Score_column(Real w)
{
when = w;
- pcol = new PCol(0);
+ pcol_ = new PCol(0);
musical = false;
}
bool
Score_column::used() {
- return pcol->used;
+ return pcol_->used;
}
void
for (int i=0; i < durations.sz(); i++)
mtor << durations[i] << " ";
mtor << "]\n";
- pcol->print();
+ pcol_->print();
mtor << "}\n";
#endif
}
#include "debug.hh"
#include "parseconstruct.hh"
+/*
+ ARG!
+ */
+
/*
maybe it's time for a "narrowing" cursor?
*/
PCursor<Command*> pc(*this);
while (pc.ok() && pc->when < w)
pc++;
-
- return pc;
+ if (!pc.ok() || pc->when != w) {
+ Command *c = new Command(w);
+ c->priority = 10000;
+ if (!pc.ok())
+ pc.add(c);
+ else
+ pc.insert(c);
+ }
+
+ return pc;
}
+/*
+ RETURN: pc->when == w && pc.ok
+ */
PCursor<Command*>
Score_commands::last_insertion(Real w)
{
- PCursor<Command*> pc(*this);
- while (pc.ok() && pc->when <= w)
- pc++;
+ PCursor<Command*> pc(first(w)), next(pc);
+ while (next.ok() && next->when == w) {
+ pc=next;
+ next++;
+ }
+ if (pc->priority != -10000) {
+ Command*c = new Command(w);
+ c->priority = -10000;
+ pc.add(c);
+ pc ++;
+ }
+
return pc;
}
+/*
+ */
void
-Score_commands::add_seq(svec<Command> com)
+Score_commands::add_seq(svec<Command> com, bool checkbreak)
{
if (!com.sz())
return;
+
Real when = com[0].when;
- PCursor<Command*> pc(last_insertion(when));
- for (int i = 0; i < com.sz(); i++) {
- Command *c = new Command(com[i]);
- assert(com[i].when == when);
- if (!pc.ok())
- pc.add(c);
+ PCursor<Command*> begin(first(when));
+ PCursor<Command*> end(last_insertion(when));
+ if (checkbreak && is_breakable(when)) {
+ if (com[0].priority < 0)
+ while (begin->code != BREAK_END)
+ begin++;
else
- pc.insert(c);
+ while (end->code != BREAK_PRE)
+ end--;
+ }
+ for (int i = 0; i < com.sz(); i++) {
+ insert_between(com[i], begin, end);
}
}
svec<Command> seq;
Command k(when);
+ k.priority = 5;
k.code = BREAK_PRE;
seq.add(k);
+ k.priority = 4;
k.code = BREAK_MIDDLE;
seq.add(k);
+ k.priority = 3;
k.code = BREAK_POST;
seq.add(k);
+ k.priority = 2;
k.code = BREAK_END;
seq.add(k);
- add_seq(seq);
+ add_seq(seq,false);
}
bool
{
assert(last->when==firstc->when);
PCursor<Command*> c(firstc+1);
- while (c != last) { // hmm what if !last.ok()?
- if (victim.priority > c->priority) {
+ assert(last.ok());
+ while (c < last) {
+ if (c->priority <= victim.priority) {
c.insert(new Command(victim));
return;
}
Score_commands::add_command_to_break(Command pre, Command mid, Command post)
{
Real w = pre.when;
+ assert(w >= 0);
PCursor<Command*> c ( first(w)), f(c), l(c);
while (!c->isbreak())
f = l;
while (!c->isbreak())
c++;
- l = c++;
- insert_between(post, f, l);
+ l = c++;
assert(l.ok() && l->when ==w && l->code == BREAK_END);
+
+ insert_between(post, f, l);
}
void
{
bool encapsulate =false;
Real w = c.when;
+ assert(w >= 0);
+
Command pre(w);
Command mid(w);
Command post(w);
+ if (c.code == INTERPRET)
+ { // UGH
+ if (c.args[0] == "BAR") {
+ Command typeset(w); // kut met peren
+ typeset.code = TYPESET;
+ typeset.args = c.args;
+ typeset.priority = 100;
+ process_add(typeset);
+ } else if (c.args[0] == "KEY") {
+ Command typeset(w);
+ typeset.code = TYPESET;
+ typeset.args.add("KEY");
+ typeset.priority = 70;
+ process_add(typeset);
+ } else if (c.args[0] == "CLEF") {
+ Command typeset(w);
+ typeset.code = TYPESET;
+ typeset.args=c.args;
+ typeset.priority = 90;
+ process_add(typeset);
+ }
+ }
+ // kut en peer
if (c.code == TYPESET) {
if (c.args[0] == "BAR") {
set_breakable(w);
encapsulate = true;
mid = c;
pre = c;
- }
+ { /* every line a currentkey. */
+ Command kc(w);
+ kc.code =TYPESET;
+ kc.args.add( "CURRENTKEY");
+ kc.priority = 60;
+ process_add(kc);
+ }
+ { /* every line a currentclef. */
+ Command kc(w);
+ kc.code =TYPESET;
+ kc.args.add( "CURRENTCLEF");
+ kc.priority = 80;
+ process_add(kc);
+ }
+ }else
if (c.args[0] == "METER" && is_breakable(w)) {
encapsulate = true;
mid = c;
pre = c;
post =c;
+ }else
+ if( c.args[0] == "KEY" && is_breakable(c.when)) {
+ encapsulate = true;
+ mid = c;
+ pre = c;
+ post = c;
+ }else
+ if (c.args[0] == "CURRENTKEY" && is_breakable(w)) {
+ post = c;
+ encapsulate = true;
+ }else
+ if (c.args[0] == "CURRENTCLEF" && is_breakable(w)) {
+ post = c;
+ encapsulate = true;
+ }else
+ if (c.args[0] == "CLEF" && is_breakable(w)) {
+ encapsulate = true;
+ post = c;
+ pre = c;
+ mid = c;
}
}
else {
svec<Command> seq;
seq.add(c);
- add_seq(seq);
+ add_seq(seq,true);
}
}
Real wholes=0.0;
Real stoppos=0.0;
- {
+ { /* all pieces should start with a breakable. */
Command c(0.0);
- c.code = TYPESET;
+ c.code = INTERPRET;
c.args.add("BAR");
c.args.add("empty");
nc->process_add(c);
measlen = beats_per_meas/Real(one_beat);
nc->process_add(*get_meter_command(wholes, beats_per_meas, one_beat));
}
+ if (cc->args[0] == "KEY"||cc->args[0] == "CLEF") {
+ cc->when = wholes;
+ nc->process_add(**cc);
+ }
if (cc->args[0] == "SKIP") {
stoppos = wholes + cc->args[1].value() * measlen +
cc->args[2].fvalue();
sc->clean_cols();
for (PCursor<Score_column*> c(cols_); c.ok(); ) {
- if (!c->pcol->used) {
+ if (!c->pcol_->used) {
mtor << "removing : ";
c->print();
c.del();
{
PCursor<Score_column*> sc(cols_);
for (; sc.ok(); sc++) {
- pscore_->add(sc->pcol);
+ pscore_->add(sc->pcol_);
}
}
Real
-#include "lookup.hh"
+#include "clefitem.hh"
#include "request.hh"
-#include "beam.hh"
#include "pscore.hh"
#include "paper.hh"
#include "simplestaff.hh"
-#include "molecule.hh"
#include "sccol.hh"
-#include "stem.hh"
-#include "notehead.hh"
#include "rest.hh"
#include "debug.hh"
#include "bar.hh"
Item *
Simple_staff::get_TYPESET_item(Command *com)
{
- Item *s;
- if (com -> args[0] == "BAR" ) {
+ Item *s=0;
+ svec<String> arg( com->args);
+ String type =arg[0];
+ arg.del(0);
+ if (type == "BAR" ) {
s = new Bar(com->args[1]);
- } else if (com->args[0] == "METER") {
- svec<String> arg( com->args);
- arg.del(0);
+ } else if (type == "METER") {
s = new Meter(arg);
- } else
- assert(false);
-
+ } else if (type == "CLEF") {
+ s = new Clef_item;
+ }else{
+ WARN << "ignoring TYPESET command for " << type << '\n';
+
+ }
return s;
}
+
+Interval
+itemlist_width(const svec<Item*> &its)
+{
+ Interval iv;
+ for (int j =0; j < its.sz(); j++)
+ iv.unite(its[j]->width());
+ return iv;
+}
+
void
Simple_column::typeset_item(Item *i, int breakst)
{
assert(i);
- // ugh
- staff_->pscore_->typeset_item(i, score_column->pcol,
+
+ staff_->pscore_->typeset_item(i, score_column->pcol_,
staff_->theline,breakst);
+
+ if (breakst == BREAK_PRE - BREAK_PRE) {
+
+ svec<Item*> to_move(
+ staff_->pscore_->select_items(staff_->theline,
+ score_column->pcol_->prebreak));
+ Interval column_wid = itemlist_width(to_move);
+ assert(!column_wid.empty());
+
+ for (int j=0; j < to_move.sz(); j++) {
+ to_move[j]->translate(Offset(-column_wid.max, 0));
+ }
+ }
+}
+
+void
+Simple_column::typeset_item_directional(Item *i, int dir, int breakst)
+{
+ assert(i);
+ PCol * c=score_column->pcol_;
+ if (breakst == 0)
+ c = c->prebreak;
+ else if (breakst == 2)
+ c = c->postbreak;
+
+ svec<Item*> to_move(staff_->pscore_->select_items(staff_->theline,
+ c));
+ typeset_item(i, breakst);
+
+ Interval column_wid = itemlist_width(to_move);
+ if (column_wid.empty())
+ column_wid = Interval(0,0);
+ i->translate(Offset(column_wid[dir] - i->width()[-dir], 0));
}
void
int d = rq->rhythmic()->dots;
return new Rest(b, d);
}
+
+Local_key_item*
+Simple_staff::get_local_key_item()
+{
+ return 0;
+}
+
#include "request.hh"
#include "swalker.hh"
#include "debug.hh"
+#include "clef.hh"
#include "staff.hh"
#include "command.hh"
#include "simplestaff.hh"
#include "sccol.hh"
-
+#include "simplewalker.hh"
}
}
}
+
Staff_column*
Simple_staff::create_col(Score_column*s)
{
return new Simple_column(s,this);
}
+
void
Simple_staff::walk()
{
#include "request.hh"
+#include "clef.hh"
#include "beam.hh"
#include "pscore.hh"
#include "simplestaff.hh"
+#include "simplewalker.hh"
#include "sccol.hh"
#include "stem.hh"
#include "notehead.hh"
#include "rest.hh"
#include "debug.hh"
+#include "keyitem.hh"
+#include "clefitem.hh"
+#include "keyitem.hh"
+#include "localkeyitem.hh"
void
-Simple_walker::process_command(Command*com)
+Simple_walker::do_INTERPRET_command(Command*com)
{
- switch (com->code){
- case BREAK_PRE:
- case BREAK_MIDDLE:
- case BREAK_POST:
- case BREAK_END:
- (*this)->score_column->set_breakable();
- break_status = com->code- BREAK_PRE;
- break;
- case INTERPRET:
- break;
+ if (com->args[0] == "BAR") {
+ local_key_.reset(key_);
+ } else if (com->args[0] == "KEY") {
+ svec<String> s(com->args);
+ s.del(0);
+ if (com->when) {
+ assert(!oldkey_undo);
+ oldkey_undo = new svec<int>( key_.oldkey_undo(s));
+ }
- case TYPESET:
- {
- Item* i = staff()->get_TYPESET_item(com);
- col()->typeset_item(i, break_status);
+ typesetkey = key_.read(s);
+ local_key_.reset(key_);
+ } else if (com->args[0] == "CLEF") {
+ svec<String> s(com->args);
+ s.del(0);
+ clef_.read(s);
+ } else {
+ WARN << " ignoring INTERPRET command: " << com->args[0];
}
- break;
-
- default :
- break;
- }
}
void
-Simple_walker::process_requests()
+Simple_walker::do_TYPESET_command(Command*com)
{
- Simple_column*c = col();
- Simple_staff *s = staff();
- if (c->beam_&& c->beam_->spantype == Span_req::START) {
- if (beam_)
- error("Too many beams");
- beam_ = new Beam;
- }
+ /* ignore these commands if non-default versions have been
+ processed. */
+ if (com->args[0] == "CURRENTKEY")
+ if (processed_key)
+ return;
+ else
+ com->args[0] = "KEY";
- if (c->stem_) {
- stem_ = s->get_stem(c->stem_->stem());
- c->typeset_item(stem_);
- }
+ if (com->args[0] == "CURRENTCLEF")
+ if (processed_clef) {
+ return;
+ } else
+ com->args[0] = "CLEF";
+
+ Item* i = staff()->get_TYPESET_item(com);
+ if (!i)
+ return;
+
+ if (com->args[0] == "KEY") {
+ if (oldkey_undo) {
+ ((Keyitem*) i)->read(*oldkey_undo);
+ delete oldkey_undo;
+ oldkey_undo = 0;
+ }
+ processed_key = true;
+ ((Keyitem*) i)->read(typesetkey); // ugh
+ }
+
+ if (com->args[0] == "CLEF") {
+ processed_clef =true;
+ ((Clef_item*)i)->read(clef_);
+ }
+ col()->typeset_item_directional(i, 1, break_status);
+}
+
+void
+Simple_walker::do_local_key(Note_req*n)
+{
+ if ( local_key_.oct(n->octave).acc(n->name) != n->accidental) {
+ if (!local_key_item_) {
+ local_key_item_ = staff()->get_local_key_item();
+ }
+
+ local_key_item_->add(n->octave, n->name, n->accidental);
+ local_key_.oct(n->octave).set(n->name, n->accidental);
+ }
+}
+
+void
+Simple_walker::do_notes()
+{
+ Simple_column*c = col();
+ Simple_staff *s = staff();
for (int i = 0; i < c->notes.sz(); i ++) {
Rhythmic_req*rq = c->notes[i];
if (rq->note()) {
- Notehead*n = s->get_notehead(rq->note());
+ Note_req * req = rq->note() ;
+ Notehead*n = s->get_notehead(req, clef_.c0_pos);
stem_->add(n);
noteheads.add(n);
+
+ if (wantkey)
+ do_local_key(req);
}
if (rq->rest()) {
c->typeset_item( s->get_rest(rq->rest()) );
}
+ }
+}
+
+void
+Simple_walker::process_requests()
+{
+ Simple_column*c = col();
+ Simple_staff *s = staff();
+ if (c->beam_&& c->beam_->spantype == Span_req::START) {
+ if (beam_)
+ error("Too many beams");
+ beam_ = new Beam;
}
+ if (c->stem_) {
+ stem_ = s->get_stem(c->stem_->stem());
+ }
+ do_notes();
+
if (beam_) {
beam_->add(stem_);
}
-
+ if (stem_) {
+ c->typeset_item(stem_);
+ /* needed, otherwise placement of
+ local_key fucks up */
+ stem_->set_default_extents();
+ }
if (c->beam_&& c->beam_->spantype == Span_req::STOP) {
pscore_->typeset_spanner(beam_, s->theline);
beam_ = 0;
}
noteheads.set_size(0);
+ if (local_key_item_) {
+ c->typeset_item_directional(local_key_item_, -1);
+ local_key_item_ = 0;
+ }
if (stem_) {
stem_ = 0;
}
{
stem_ = 0;
beam_ =0;
+ oldkey_undo = 0;
+
+ Local_key_item * i = s->get_local_key_item();
+ wantkey =i;
+ delete i;
+ local_key_item_ = 0;
+ reset();
}
return (Simple_column*) *(*this);
}
-
+void
+Simple_walker::reset()
+{
+ processed_clef =false;
+ processed_key = false;
+}
{
Score_column* sc = score_->find_col(w,mus);
assert(sc->when == w);
- PCursor<Staff_column *> stc(cols);
- for (; stc.ok(); stc++) {
- if (*stc->score_column > *sc) // too far
+
+ PCursor<Staff_column *> i(cols);
+ for (; i.ok(); i++) {
+ if (*i->score_column > *sc) // too far
break;
- if (sc == stc->score_column)
- return stc;
+ if (sc == i->score_column)
+ return i;
}
+ /* post: *sc > *->score_column || !i.ok() */
Staff_column* newst = create_col(sc);
- if (!stc.ok()) {
+ if (!i.ok()) {
cols.bottom().add(newst);
return cols.bottom();
}
if (mus) {
- stc.insert(newst);
+ i.insert(newst);
return newst;
}
- if ((stc-1)->when() == newst->when()) {
- stc--;
+// ; assert((i-1).ok())
+ // todo!
+
+ // making a fix at 2:30 am, with several beers drunk.
+ if ((i-1).ok()&& (i-1)->when() == newst->when()) {
+ i--;
}
- stc.insert(newst);
+ i.insert(newst);
return newst;
}
if (!print_flag || ABS(flag) <= 4)
return Interval(0,0); // TODO!
Paperdef*p= paper();
- return p->lookup_->flag(flag).dim.x;
+ Interval r(p->lookup_->flag(flag).dim.x);
+ r+= stem_xoffset;
+ return r;
}
void
{
return pcol_->hpos + stem_xoffset;
}
+
+
+void
+Stem::preprocess()
+{
+
+}
#include "request.hh"
#include "swalker.hh"
#include "stcol.hh"
+#include "sccol.hh"
Staff_walker::~Staff_walker() {}
process_requests();
}
+
+void
+Staff_walker::process_command(Command*com)
+{
+ switch (com->code){
+ case BREAK_PRE:
+ case BREAK_MIDDLE:
+ case BREAK_POST:
+ case BREAK_END:
+ (*this)->score_column->set_breakable();
+ break_status = com->code- BREAK_PRE;
+ break;
+ case INTERPRET:
+ do_INTERPRET_command(com);
+ break;
+
+ case TYPESET:
+ do_TYPESET_command(com);
+ break;
+
+ default :
+ break;
+ }
+}
+
+void
+Staff_walker::operator++(int i)
+{
+ PCursor<Staff_column*>::operator++(i);
+ reset();
+}
"voice", VOICE,
"rhythmstaff", RHYTHMSTAFF,
"melodicstaff", MELODICSTAFF,
+ "clef", CLEF,
"score", SCORE,
"bar", BAR,
"output", OUTPUT,
"mm", MM,
"paper", PAPER,
"width", WIDTH,
+ "violin", VIOLIN,
+ "bass", BASS,
"meter", METER,
"unitspace", UNITSPACE,
"skip", SKIP,
"staff", STAFF,
"geometric", GEOMETRIC,
"duration", DURATIONCOMMAND,
+ "key", KEY,
0,0
} ;
#include "plist.cc"
#include "cursor.cc"
-#define PLC_instantiate(a) PL_instantiate(a); PL_instantiate(const a)
+#define IPLC_instantiate(a) IPL_instantiate(a); PL_instantiate(const a)
-L_instantiate(Stem*);
-PLC_instantiate(Line_of_score);
-PLC_instantiate(Line_of_staff);
-PLC_instantiate(Item);
-PLC_instantiate(Spanner);
-PLC_instantiate(PStaff);
-PLC_instantiate(Idealspacing);
-PLC_instantiate(PCol);
+IPLC_instantiate(Stem*);
+IPLC_instantiate(Line_of_score);
+IPLC_instantiate(Line_of_staff);
+IPLC_instantiate(Item);
+IPLC_instantiate(Spanner);
+IPLC_instantiate(PStaff);
+IPLC_instantiate(Idealspacing);
+IPLC_instantiate(PCol);
#include "list.cc"
#include "plist.cc"
#include "cursor.cc"
-PL_instantiate(Score_column);
-PL_instantiate(Staff_column);
-PL_instantiate(Staff);
-PL_instantiate(Voice_element);
-PL_instantiate(Voice);
+
+IPL_instantiate(Score_column);
+IPL_instantiate(Staff_column);
+IPL_instantiate(Staff);
+IPL_instantiate(Voice_element);
+IPL_instantiate(Voice);
#include "list.cc"
#include "plist.cc"
#include "cursor.cc"
-PL_instantiate(Atom);
-PL_instantiate(Command);
-PL_instantiate(Request);
-
-
+IPL_instantiate(Atom);
+IPL_instantiate(Command);
+IPL_instantiate(Request);
+L_instantiate(void*);
{
duration=src.duration;
voice=src.voice;
- PointerList__copy(Request*, reqs, src.reqs, clone());
+ IPointerList__copy(Request*, reqs, src.reqs, clone());
group=src.group;
assert(!granted_items.size() && !granted_spanners.size());
}
# be careful with editing this:
# the "index" entry is hardwired into lilypond.
+table clefs
+ violin \violinclef 0pt 16pt -12.5pt 22.5pt
+ bass \bassclef 0pt 16pt 0pt 20pt
+ viola \violaclef 0pt 16pt 0pt 20pt
+end
+
table balls
1 \wholeball 0pt 7.5pt -2.5pt 2.5pt
2 \halfball 0pt 6pt -2.5pt 2.5pt
4 \quartball 0pt 6pt -2.5pt 2.5pt
end
+table accidentals
+ -2 \flatflat 0pt 10.2pt -2.5pt 7.5pt
+ -1 \flat 0pt 6pt -2.5pt 7.5pt
+ 0 \natural 0pt 6pt -7.5pt 7.5pt
+ 1 \sharp 0pt 6pt -7.5pt 7.5pt
+ 2 \sharpsharp 0pt 6pt -2.5pt 7.5pt
+end
+
table streepjes
- toplines \toplines{%} -7pt 7pt 0pt 0pt
- botlines \botlines{%} -7pt 7pt 0pt 0pt
+ toplines \toplines{%} -3pt 9pt 0pt 0pt
+ botlines \botlines{%} -3pt 9pt 0pt 0pt
end
table bars
meter \generalmeter{%}{%} -3pt 10pt -5pt 5pt
linestaf \linestafsym{%}{%} 0pt 0pt 0pt 0pt
stem \stem{%}{%} 0pt 0pt 0pt 0pt
-
end
table dots