=head2 COMMENTS
The source is commented in the DOC++ style. Check out doc++ at
-F<http://www.ZIB-Berlin.DE/VisPar/doc++/doc++.html>
+http://www.zib.de/Visual/software/doc++/index.html
/// short description
class Class {
- ///
- Data data_member_;
+ /// short description
/**
- ..
+ long description
*/
+ Data data_member_;
/****************/
/// short memo
- member();
/**
long doco of member()
*/
+ member();
};
/**
Class documentation.
multiple staffs in one score
=item *
-multiple stafftypes (melodic, rhythmic)
+multiple stafftypes (melodic, rhythmic) [broken from pl28 on]
=item *
beams, slurs, chords, super/subscripts (accents and text),
clef changes, meter changes, cadenza-mode, declaring markings
in the music, repeat bars
-
=back
=head1 DESIGN CONSIDERATIONS
=head1 EXAMPLES
-At this time, LilyPond is only suited for Quick & Dirty jobs (the
-output quality of multistaff material still is too low). If you're not
-discouraged; this is what I type in my xterm:
+At this time, LilyPond output looks nice, but is not of production
+quality. If you're not discouraged; this is what I type in my xterm:
lilypond someinput.ly
tex test
(most) of the checking is done B<after> parsing (some checks even are
done after the break calc!); I'm sorry.
+[outdated]
+
The parser's job is to construct appropriate objects. It will B<only>
detect parse errors.
identifier = score { .. }
-So you have to signal that to the tokenizer. This is done with
+So you have to signal this to the tokenizer. This is done with
'$'. '$' is a delimiter, which used by the tokenizer only. The same
goes for lyrics, it has a '@' delimiter.
$(CXX) -o $@ $^ $(LOADLIBES)
-.PHONY: clean
+.PHONY: clean docxx
clean:
rm -f $(exe) $(DOCDIR)/* core $(obs) $(ALLDEPS)
$(MAKE) -C Documentation doc
# doc++ documentation of classes
-docpp: $(progdocs)
- -mkdir $(DOCDIR)
- doc++ -p -I -d $(DOCDIR) $^
+docxx: $(progdocs)
+ doc++ -p -d $(DOCDIR) $^
$(OBJECTDIR)/%.o: $(CCDIR)/%.cc
$(DODEP)\
+pl 30
+
+Features
+ - better multivoice spacing
+ - move rest in multivoice staff
+ - errors in TeX output now warnings
+ - progress indicator
+ - music processing speedup.
+Internal
+ - make spanner for staffsym; scrap Line_pstaff
+ - scrap simplestaff (Rhythmic_staff temporarily disabled)
+ - docxx 3.0 format comments
+ - split register source files
+ - hardcoded dimensions compile time
+ - Lookup::tex_hairpin
+Bugs
+ - non G-clef clefs
+ - script junking (2x)
+ - empty files
+ - beam::center (plet position!)
+
pl 29
- - multiplatform Makefile
- - context errors: bugfixes
+ - multiplatform Makefile (JN)
+ - context errors: bugfixes (JN)
pl 28
Doc
- Request_register
Bugfix
- - Script.cc : float exception
- - Request::Request(Request) copying of definition pointer
+ - Script.cc : float exception (MB)
+ - Request::Request(Request) copying of definition pointer (JN)
- cleaned dependencies for broken spanners
- stupid typo in Staff_elem::post_processing()
- init of hpos in PCol::PCol
# sourcefiles to be shipped. Also for dependencies
hdr= bar.hh beam.hh boxes.hh break.hh clef.hh clefitem.hh\
- colhpos.hh command.hh complexwalker.hh complexstaff.hh\
+ colhpos.hh command.hh complexcolumn.hh \
+ complexwalker.hh complexstaff.hh\
const.hh debug.hh dimen.hh directionalspanner.hh\
- getcommand.hh glob.hh grouping.hh idealspacing.hh\
+ getcommand.hh glob.hh grouping.hh headreg.hh idealspacing.hh\
identifier.hh identparent.hh inputcommand.hh inputcommands.hh\
inputmusic.hh inputscore.hh inputstaff.hh item.hh key.hh keyitem.hh\
- keyword.hh leastsquares.hh lexer.hh linespace.hh linepstaff.hh\
- localkeyitem.hh lookup.hh \
+ keyword.hh leastsquares.hh lexer.hh linespace.hh \
+ localkeyitem.hh localkeyreg.hh lookup.hh \
lyriccolumn.hh lyricitem.hh lyricstaff.hh lyricwalker.hh\
- main.hh melodicstaff.hh meter.hh misc.hh\
+ main.hh meter.hh misc.hh\
molecule.hh moment.hh notehead.hh notename.hh offset.hh paper.hh\
parseconstruct.hh pcol.hh proto.hh pscore.hh pstaff.hh qlp.hh\
- qlpsolve.hh register.hh request.hh rest.hh rhythmstaff.hh\
+ qlpsolve.hh register.hh request.hh rest.hh \
sccol.hh score.hh\
- scoreline.hh script.hh scriptdef.hh simplestaff.hh simplewalker.hh\
- slur.hh source.hh sourcefile.hh spanner.hh staff.hh staffcommands.hh\
- staffelem.hh staffline.hh\
+ scoreline.hh script.hh scriptdef.hh scriptreg.hh \
+ slur.hh slurreg.hh source.hh sourcefile.hh\
+ spanner.hh staff.hh staffcommands.hh\
+ staffelem.hh staffline.hh staffsym.hh stembeamreg.hh\
stcol.hh stem.hh staffwalker.hh symbol.hh symtable.hh\
- tex.hh textdef.hh\
- textitem.hh textspanner.hh timedescription.hh tstream.hh voice.hh\
+ tex.hh textdef.hh \
+ textitem.hh textreg.hh textspanner.hh timedescription.hh \
+ tstream.hh voice.hh\
voicegroup.hh
mycc=bar.cc beam.cc boxes.cc break.cc calcideal.cc clef.cc\
- clefitem.cc colhpos.cc command.cc complexstaff.cc complexwalker.cc \
- complexprint.cc debug.cc dimen.cc\
+ clefitem.cc colhpos.cc command.cc\
+ complexstaff.cc complexwalker.cc \
+ complexprint.cc debug.cc dimen.cc\
directionalspanner.cc\
- getcommands.cc grouping.cc groupregs.cc idealspacing.cc identifier.cc\
+ getcommands.cc grouping.cc groupregs.cc headreg.cc\
+ idealspacing.cc identifier.cc\
inputcommand.cc inputcommands.cc inputmusic.cc inputscore.cc\
inputstaff.cc item.cc key.cc keyitem.cc keyword.cc\
- leastsquares.cc lexerinit.cc linespace.cc linepstaff.cc\
- localkeyitem.cc lookup.cc\
+ leastsquares.cc lexerinit.cc linespace.cc \
+ localkeyitem.cc localkeyreg.cc lookup.cc\
lyriccolumn.cc lyricitem.cc lyricstaff.cc lyricwalker.cc\
- main.cc melodicstaff.cc meter.cc\
- misc.cc molecule.cc mylexer.cc note.cc notehead.cc notename.cc\
+ main.cc meter.cc\
+ misc.cc molecule.cc mylexer.cc note.cc notehead.cc notename.cc\
paper.cc pcol.cc pscore.cc pstaff.cc qlp.cc qlpsolve.cc\
- register.cc request.cc rest.cc rhythmstaff.cc sccol.cc score.cc\
- scoreline.cc scores.cc script.cc scriptdef.cc simpleprint.cc\
- simplestaff.cc simplewalker.cc slur.cc source.cc sourcefile.cc\
+ register.cc request.cc rest.cc sccol.cc score.cc\
+ scoreline.cc scores.cc script.cc scriptdef.cc scriptreg.cc \
+ slur.cc\
+ slurreg.cc source.cc sourcefile.cc\
spanner.cc staff.cc\
- staffcommands.cc staffelem.cc staffline.cc stcol.cc stem.cc\
+ staffcommands.cc staffelem.cc staffline.cc staffsym.cc\
+ stembeamreg.cc\
+ stcol.cc stem.cc\
staffwalker.cc symbol.cc symtable.cc tex.cc texbeam.cc\
- texslur.cc textdef.cc textitem.cc textspanner.cc\
+ texslur.cc textdef.cc textitem.cc textreg.cc textspanner.cc\
timedescription.cc tstream.cc voice.cc voiceregs.cc voicegroup.cc\
warn.cc windhoos-suck-suck-suck-thank-you-cygnus.cc wordwrap.cc\
template1.cc template2.cc template3.cc template4.cc\
-
- ./input/standchen.ly.rej
-
- ./src/stem.cc.rej
-
- * scrap simplestaff
+This is an assorted collection of stuff that will be done, might be
+done, or is an idea that I want to think about
BUGS
* first clef isn't printed
- * accidental placement for other clefs
+ * key undo
+
+ * key print if
SEVERELY LACKING:
* grace notes
+ * dynamics (hairpins)
+
INPUTLANGUAGE
* lose the $ and @ ?
SMALLISH PROJECTS
+ * binsearch for notenames
+
* stafftypes: voice names/ instrument names.
- * make spanner for staffsym
-
- * Lookup::tex_glissando, Lookup::tex_bracket,
- Lookup::tex_cresc, Lookup::tex_decresc (use texbeam.cc as an
+ * Lookup::tex_glissando, Lookup::tex_bracket, (use texbeam.cc as an
example.)
* Decent TeX titledefs (\tempo, \metron, etc. )
* beam generation.
-
* all errors
FUTURE
+ * warning: beam(): Beam too narrow: beam gen not per stem
+
* put scripts on barcommands
* glissando
* itemcolumns
- * dependencies: -> implement children more elegantly. Handle
- spanner with broken deps.
-
* use an embedded language: scheme, lisp, S-lang, Perl, ?
* y -dims in internote?
* Spacing_request for manually adjusting spacing
- * Staff_group.
+ * Staff_group, Score_request_register.
* SHIT: meters/bars should be aligned, which is difficult if
we get different keychanges in different staffs.
* MusixTeX output possible?
* PostScript output (esp. Beams, Slurs, etc)
+
+ * caching breakpoints
\ No newline at end of file
+# -*-make-*-
+
# version info
MAJVER=0
MINVER=0
-PATCHLEVEL=29
+PATCHLEVEL=30
+
include Site.make
+
####
#### USER CONFIGURABLE
####
# ElectricFence is a memory debugger which uses the
# VM hardware to trap malloc/free errors.
#
-#EXTRALIB+=-lefence
+
+EXTRALIB= #+=-lefence
####
#### END USER CONFIGURABLE part.
# directories
TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
+
OBJECTDIR=objects
HEADERDIR=hdr
CCDIR=src
INITDIR=init
DEPDIR=deps
INPUTDIR=input
-#vpath %.cc $(CCDIR)
-#vpath %.hh $(HEADERDIR)
-#vpath %.y $(CCDIR)
-#vpath %.l $(CCDIR)
-#vpath %.o $(OBJECTDIR)
-#vpath %.dep $(DEPDIR)
#
#
ALLDEPS=$(addprefix $(DEPDIR)/,$(cc:.cc=.dep))
STABLEOBS=$(addprefix $(OBJECTDIR)/,$(stablecc:.cc=.o))
HEADERS=$(addprefix $(HEADERDIR)/,$(hdr))
-progdocs=$(HEADERS) $(addprefix $(CCDIR)/, $(mycc))
+progdocs=$(HEADERS) #$(CCSOURCE)
+
#dist
.EXPORT_ALL_VARIABLES:
-DOCDIR=docdir
+DOCDIR=docxx
PACKAGENAME=lilypond
DNAME=$(PACKAGENAME)-$(VERSION)
#!/bin/sh
# unclobber current dir.
-rm -v *.aux *.log `grep -li "^% Creator: LilyPond" *.out *.uit` *.orig *~
+rm -vf *.aux *.log `grep -li "^% Creator: LilyPond" *.out` *.orig *~
+
+# docxx mess
+rm -vf *.class HIER*.html dxxgifs.tex gifs.db icon?.gif logo.gif down.gif \
+ aindex.html index.html
PREFIX=${PREFIX:-.}
echo using PREFIX=$PREFIX
-NEEDFLOWERVER=1.0.25
+NEEDFLOWERVER=1.0.26
flowertar=flower-$NEEDFLOWERVER
here=`pwd`
cd ..
fversion.hh: Variables.make make_version
make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) "$(CXX) `$(CXXVER)`" > $@
+.PHONY: docxx
+docxx: $(hh) $(cc) $(templatecc) $(inl)
+ -mkdir docxx
+ doc++ -p -d docxx $(hh) $(cc) $(templatecc) $(inl)
dist:
-mkdir $(DDIR)
+pl 26
+ - docxx 3.0
pl 25
- merge sstack and Array
+
pl 24
- small fix in vector print
+
pl 23
- win32 patches (JN)
+
pl 22
- Array::add -> Array::push
\ No newline at end of file
MAJVER=1
MINVER=0
-PATCHLEVEL=25
+PATCHLEVEL=26
+
PACKAGENAME=flower
#PROFILEFLAG=-pg
};
/// hungarian: map
+/** mindblowingly stupid Associative array implementation
+ */
template<class K, class V>
struct Assoc {
Array< Assoc_ent_<K,V> > arr;
- /****************/
+ /* ************** */
int find(K key) const {
for (int i = 0; i < arr.size(); i++) {
int i = find_creat(key);
arr[i].val = val;
}
- /**
+ /*
should create "set" template
*/
V& operator[](K key) {
return arr[find(key)].val;
}
};
-/** mindblowingly stupid Associative array implementation
- */
#endif
K key() { return assoc_.arr[i].key; }
V &val() { return assoc_.arr[i].val; }
};
-/*
- Iterator
- */
#endif
#include "matrix.hh"
+/**
+ structure for using the LU decomposition of a positive definite .
+
+ #P# is split into
+
+ LD transpose(L)
+ */
struct Choleski_decomposition {
/// lower triangle of Choleski decomposition
/// diagonal
Vector D;
///Create decomposition of P
- Choleski_decomposition(Matrix P);
/**
PRE
P needs to be symmetric positive definite
*/
+ Choleski_decomposition(Matrix P);
Vector solve(Vector rhs) const;
- Vector operator * (Vector rhs) const { return solve (rhs); }
- /**
+ /**
solve Px = rhs
*/
-
- Matrix inverse() const;
- /**
+Vector operator * (Vector rhs) const { return solve (rhs); }
+ /**
return the inverse of the matrix P.
*/
- Matrix original() const;
+ Matrix inverse() const;
/**
return P, calc'ed from L and D
*/
+ Matrix original() const;
+
};
-/**
- structure for using the LU decomposition of a positive definite .
-
- #P# is split into
-
- LD transpose(L)
- */
-
-
#endif
#endif
/// handy notations for a signed comparison
+/**
+ make the operators{<,<=,==,>=,>} and the MAX and MIN of two.
+ Please fill a & in the type argument if necessary.
+ */
#define template_instantiate_compare(type, function, prefix) \
prefix one_operator(type, function, >)\
prefix one_operator(type, function, >=)\
prefix inline type min(type t1, type t2) { return (t1 < t2 )? t1 : t2; }\
\
prefix bool operator<(type t1, type t2) /* stupid fix to allow ; */
- /**
- make the operators{<,<=,==,>=,>} and the MAX and MIN of two.
- Please fill a & in the type argument if necessary.
- */
#include "link.hh"
template<class T> class List;
-///
+/// iterator to List
+/**
+ add and insert extend the list
+ items are always stored as copies in List, but:
+ List<String> : copies of String stored
+ List<String*> : copies of String* stored!
+
+ the operations add and insert actually delegate the work to List class.
+ */
template<class T>
class Cursor
{
public:
- Cursor( const List<T>& list, Link<T>* pointer = 0 );
/** this isn't true, actually, #list# surely isn't const, but I get
tired of the warning messages. */
+ Cursor( const List<T>& list, Link<T>* pointer = 0 );
Cursor( const Cursor<T>& cursor );
bool backward();
/// put (copy) after me in List
- void add( const T& thing );
/**
analogously to editor. ok() interpreted as at end
of line.
cursor points to same object, cursor.next() is newly added
object.
*/
+ void add( const T& thing );
/// put (copy) before me in List
- void insert( const T& thing );
/**
analogously to editor. ok() interpreted as at begin of
line.
is newly inserted object.
*/
+ void insert( const T& thing );
///
void backspace();
List<T>& list_;
Link<T>* pointer_;
};
-/**
- add and insert extend the list
- items are always stored as copies in List, but:
- List<String> : copies of String stored
- List<String*> : copies of String* stored!
-
- the operations add and insert actually delegate the work to List class.
- */
/*
#ifndef CURSOR_INL
#define CURSOR_INL
#include <assert.h>
-//#include "list.hh"
+
template<class T>
inline
}
/// get a char.
+/**
+ Only class member who uses text_file::get
+ */
char
Data_file::data_get() {
char c = get();
return c;
}
-/**
- Only class member who uses text_file::get
- */
/// read line, gobble '\n'
String Data_file::get_line()
return false;
return (*silent)[s];
}
-///
+
+/** only output possibility. Delegates all conversion to String class.
+ */
Dstream &
Dstream::operator<<(String s)
{
return *this;
}
-/** only output possibility. Delegates all conversion to String class.
- */
Dstream::Dstream(ostream *r, const char * cfg_nm )
{
struct Assoc;
/// debug stream
+ /**
+ a class for providing debug output of nested structures,
+ with indents according to \{\}()[].
+
+ One can turn on and off specific messages using the Assoc silent.
+ This can be done automatically:
+
+ #define DEBUG dstream_.identify_as(__PRETTY_FUNCTION__)
+
+ DEBUG << "a message\n";
+
+ Init for the class names which should be silent can be given in a rc file.
+
+ */
class Dstream
{
ostream *os;
bool silence(String);
- Dstream(ostream *r, const char * rcfile);
/**
if rcfile == 0, then do not read any rc file
*/
+ Dstream(ostream *r, const char * rcfile);
virtual ~Dstream();
Dstream &identify_as(String s);
Dstream &operator << (String s);
};
- /**
- a class for providing debug output of nested structures,
- with indents according to \{\}()[].
-
- One can turn on and off specific messages using the Assoc silent.
- This can be done automatically:
-
- #define DEBUG dstream_.identify_as(__PRETTY_FUNCTION__)
-
- DEBUG << "a message\n";
-
- Init for the class names which should be silent can be given in a rc file.
-
- */
#endif
/// a T interval
+/**
+ this represents the closed interval [left,right].
+ No invariants. T must be a totally ordered ring
+ */
template<class T>
struct Interval_t {
T left, right;
- /****************/
+ /* ************** */
T center() { return (left + right) / T(2);}
void translate(T t) {
T max()const { return right;}
T min()const{ return left; }
T &min(){ return left; }
- void unite(Interval_t<T> h);
/**
PRE
*this and h are comparable
*/
+ void unite(Interval_t<T> h);
void intersect(Interval_t<T> h);
T length() const;
String str() const;
bool elt_q(T r);
};
-/**
- this represents the closed interval [left,right].
- No invariants. T must be a totally ordered ring
- */
/// partial ordering
template<class T>
};
-///
+/// C++ for version of long_getopt.
+/** For processing GNU style command line arguments. No pointer
+ (return values, arguments) contents are copied. */
class Getopt_long {
public:
- ///
+ /** errorcodes: no error, argument expected, no argument expected,
+ unknown option, illegal argument (eg. int expected). */
enum Errorcod { E_NOERROR = 0, E_ARGEXPECT, E_NOARGEXPECT, E_UNKNOWNOPTION,
E_ILLEGALARG } ;
- /** errorcodes: no error, argument expected, no argument expected,
- unknown option, illegal argument (eg. int expected). */
private:
void report(Errorcod c);
public:
/// what to do with errors
- void seterror(ostream *os);
/**
report messages on #*os#, and abort.
if #os# is null, then do not report nor abort, just set #error#
*/
+ void seterror(ostream *os);
/// argument. Set to 0 if not present
char* optarg;
Getopt_long(int c, char **v, long_option_init *lo);
/// get the next option
- long_option_init *operator()();
/**
- RETURN: pointer to next option found.
+ @return pointer to next option found.
0 if error occurred, or next argument is no option.
*/
+ long_option_init *operator()();
char *current_arg();
char * get_next_arg();
Errorcod error;
};
-/**
- C++ for version of long_getopt. For processing GNU style command line arguments.
- No pointer (return values, arguments) contents are copied.
- */
#endif
template<class T> class Link;
/// all-purpose doubly linked list
+/**
+ a doubly linked list;
+ List can be seen as all items written down on paper,
+ from top to bottom
+
+ class Cursor is used to extend List
+
+ items are always stored as copies in List, but:
+ #List<String># : copies of #String# stored
+ #List<String*># : copies of #String*# stored!
+ (do not use, use \Ref{PointerList} #<String*># instead.)
+
+ {\bf note:}
+ retrieving "invalid" cursors, i.e.
+ #top()/bottom()# from empty list, #find()# without success,
+ results in a nonvalid Cursor ( #!ok()# )
+
+
+ INVARIANTEN!
+*/
+
template<class T>
class List
{
void concatenate(List<T> const &s);
/// make *this empty
- void set_empty();
- /**
+ /**
POST:
size == 0
WARNING:
contents lost, and not deleted.
*/
-
+ void set_empty();
+
/// add after after_me
void add( const T& thing, Cursor<T> &after_me );
/// put thing before #before_me#
void insert( const T& thing, Cursor<T> &before_me );
-
- void remove( Cursor<T> me );
- /** Remove link pointed to by me. Destructor of contents called
+ /** Remove link pointed to by me. Destructor of contents called
(nop for pointers)
POST
WARNING: do not use #me# after calling
*/
+ void remove( Cursor<T> me );
+
- /****************/
+ /* ************** */
int size_;
Link<T>* top_;
Link<T>* bottom_;
};
-/**
- a doubly linked list;
- List can be seen as all items written down on paper,
- from top to bottom
-
- class Cursor is used to extend List
-
- items are always stored as copies in List, but:
- #List<String># : copies of #String# stored
- #List<String*># : copies of #String*# stored!
- (do not use, use \Ref{PointerList} #<String*># instead.)
-
- {\bf note:}
- retrieving "invalid" cursors, i.e.
- #top()/bottom()# from empty list, #find()# without success,
- results in a nonvalid Cursor ( #!ok()# )
-
-
- INVARIANTEN!
-*/
-
#include "list.inl"
#include "cursor.hh"
#include "vector.hh"
/// a Real matrix
+/** This is a class for a nonsquare block of #Real#s. The
+ implementation of sparse matrices is done in the appropriate #smat#
+ class. Matrix only does the mathematical actions (adding,
+ multiplying, etc.)
+
+
+ TODO
+ implement ref counting? */
+
+
class Matrix {
virtual_smat *dat;
int rows() const { return dat->rows(); }
/// return the size of a matrix
- int dim() const;
/**
- PRE
+ @pre
the matrix needs to be square.
*/
+ int dim() const;
// Matrix() { dat = 0; }
~Matrix() { delete dat; }
void operator/=(Real a) { (*this) *= 1/a; }
/// add a row
- void insert_row(Vector v,int k);
/**
add a row to the matrix before row k
v.dim() == cols()
0 <= k <= rows()
*/
+ void insert_row(Vector v,int k);
///
- void delete_row(int k) { dat->delete_row(k); }
/**
delete a row from this matrix.
PRE
0 <= k < rows();
*/
+ void delete_row(int k) { dat->delete_row(k); }
void delete_column(int k) { dat->delete_column(k); }
- ///
- Matrix(int n);
+
/**
square n matrix, initialised to null
*/
- ///
- Matrix(int n, int m);
+ Matrix(int n);
+
/**
n x m matrix, init to 0
*/
+ Matrix(int n, int m);
Matrix(const Matrix &m);
/// dyadic product: v * w.transpose
Real norm() const;
/// swap
- void swap_columns(int c1, int c2);
/**
PRE
0 <= c1,c2 < cols()
*/
+ void swap_columns(int c1, int c2);
/// swap
- void swap_rows(int c1, int c2);
/**
PRE
0 <= c1,c2 < rows()
*/
+ void swap_rows(int c1, int c2);
Vector row(int ) const;
void print() const;
};
-/** This is a class for a nonsquare block of #Real#s. The
- implementation of sparse matrices is done in the appropriate #smat#
- class. Matrix only does the mathematical actions (adding,
- multiplying, etc.)
-
-
- TODO
- implement ref counting? */
-
-
inline Vector
operator *(Vector &v, const Matrix& m) { return m.left_multiply(v); }
Matrix operator *(const Matrix& m1,const Matrix &m2);
#define PATHSEP '/'
#endif
-
+/**
+ INPUT: path the original full filename
+ OUTPUT: 4 components of the path. They can be empty
+*/
void
split_path(String path,
String &drive, String &dirs, String &filebase, String &extension)
filebase = path;
}
}
-/**
- INPUT: path the original full filename
- OUTPUT: 4 components of the path. They can be empty
-*/
-
File_path::File_path(String pref)
{
}
-///
+///find a file
+/**
+ It will search in the current dir, in the construction-arg, and
+ in any other added path, in this order.
+ */
String
File_path::find(String nm)
{
}
return "";
}
-/**
- It will search in the current dir, in the construction-arg, and
- in any other added path, in this order.
- */
/// searching directory for file.
+/**
+
+ Abstraction of PATH variable. An interface for searching input files.
+ Search a number of dirs for a file.
+
+ Should use kpathsea?
+
+*/
+
class File_path : private Array<String>
{
public:
Array<String>::push;
void add(String str) { push(str); }
};
-/**
-
- Abstraction of PATH variable. An interface for searching input files.
- Search a number of dirs for a file.
-
- Should use kpathsea?
-
-*/
-
/// split path into its components
void split_path(String path, String &drive, String &dirs, String &filebase, String &extension);
/// cursor to go with PointerList
+/**
+ don't create PointerList<void*>'s.
+ This cursor is just an interface class for Cursor. It takes care of the
+ appropriate type casts
+ */
template<class T>
struct PCursor : private Cursor<void *> {
friend class IPointerList<T>;
return Cursor<void*>::compare(a,b);
}
};
-/**
- don't create PointerList<void*>'s.
- This cursor is just an interface class for Cursor. It takes care of the
- appropriate type casts
- */
#include "list.hh"
/// Use for list of pointers, e.g. PointerList<AbstractType*>.
+/**
+ This class does no deletion of the pointers, but it knows how to
+ copy itself (shallow copy). We could have derived it from List<T>,
+ but this design saves a lot of code dup; for all PointerLists in the
+ program only one parent List<void*> is instantiated. */
template<class T>
class PointerList : public List<void *>
{
void concatenate(PointerList<T> const &s) { List<void*>::concatenate(s); }
PointerList() {}
};
-/**
- This class does no deletion of the pointers, but it knows how to
- copy itself (shallow copy). We could have derived it from List<T>,
- but this design saves a lot of code dup; for all PointerLists in the
- program only one parent List<void*> is instantiated. */
/// pl. which deletes pointers given to it.
-template<class T>
-struct IPointerList : public PointerList<T> {
- IPointerList(const IPointerList&) { set_empty(); }
- IPointerList() { }
- ~IPointerList();
-};
/**
NOTE:
You have to copy this yourself, or use the macro PointerList__copy
*/
+template<class T>
+struct IPointerList : public PointerList<T> {
+ IPointerList(const IPointerList&) { set_empty(); }
+ IPointerList() { }
+ ~IPointerList();
+};
#define IPointerList__copy(T, to, from, op) \
for (PCursor<T> _pc_(from); _pc_.ok(); _pc_++)\
operator Real();
operator int();
///
- operator bool() const;
/** perl -like string to bool conversion
*/
+ operator bool() const;
};
{
return new Full_storage(*this);
}
-/****************************************************************/
+
virtual_smat *
virtual_smat::get_full(int n, int m)
#include "stringutil.hh"
/// the smart string class.
+/**
+
+ Intuitive string class. provides
+
+ ref counting through #String_handle#
+
+ conversion from bool, int, double, char *, char.
+
+ conversion to int, upcase, downcase
+
+
+ printable.
+
+ indexing (pos, posAny, lastPos)
+
+ cutting (left, right, mid)
+
+ concat (+=, +)
+
+ signed comparison (<, >, ==, etc)
+
+ No operator[] is provided, since this would be enormously slow. If needed,
+ convert to const char *.
+*/
class String
{
protected:
public:
/// init to ""
- String() { }
/** needed because other constructors are provided.*/
+ String() { }
String(Rational);
/// String s = "abc";
String( const char* source );
int lastPos( const char* string ) const;
/// index of leftmost c
- int pos(char c ) const;
/**
RETURN:
0 if not found, else index + 1
*/
+ int pos(char c ) const;
int pos(const char* string ) const;
int posAny(const char* string ) const;
int len() const;
};
-/**
-
- Intuitive string class. provides
-
- ref counting thru #String_handle#
-
- conversion from bool, int, double, char *, char.
-
- conversion to int, upcase, downcase
-
-
- printable.
-
- indexing (pos, posAny, lastPos)
-
- cutting (left, right, mid)
-
- concat (+=, +)
-
- signed comparison (<, >, ==, etc)
-
- No operator[] is provided, since this would be enormously slow. If needed,
- convert to const char *.
-*/
#include "compare.hh"
const INITIALMAX=8;
class String_handle;
+
/// Internal String struct
+/**
+ the data itself. Handles simple tasks (resizing, resetting)
+ */
+
class StringData {
// GNU malloc: storage overhead is 8 bytes anyway.
}
+ /** POST: maxlen >= j.
+ IN: j, maximum stringlength.
+ contents thrown away.
+ */
void setmax(int j) {
OKW();
if (j > maxlen) {
length = 0;
}
}
+
/** POST: maxlen >= j.
- IN: j, maximum stringlength.
- contents thrown away.
- */
- ///
+ IN: j, maximum stringlength.
+ contents are kept if it grows.
+ */
void remax(int j) {
OKW();
if (j > maxlen) {
// length = strlen(string);
}
}
- /** POST: maxlen >= j.
- IN: j, maximum stringlength.
- contents are kept if it grows.
- */
/// check if writeable.
void OKW() {
}
};
-/**
- the data itself. Handles simple tasks (resizing, resetting)
- */
-/****************************************************************/
/// ref. counting for strings
+/**
+ handles ref. counting, and provides a very thin
+ interface using char *
+ */
class String_handle {
StringData* data;
void trunc(int j) { copy(); data->trunc(j); }
int len() const { return data->length; }
};
-/**
- handles ref. counting, and provides a very thin
- interface using char *
- */
-
#ifdef NDEBUG
#if (NDEBUG == BLONDE)
#include "textstr.hh"
-/**: do "#" comments, read quote enclosed fields */
-
+/** do "#" comments, read quote enclosed fields */
/// a "const" Array. Contents can't be changed.
class Text_record : Array<String>
{
Array<String>::size;
};
+/**
+ add a subrec/fieldsep/record separator
+ */
/// abstraction for a datafile
class Text_db : private Data_file
{
}
};
-
-/**
- add a subrec/fieldsep/record separator
- */
#endif
+
#ifndef TEXTSTR_HH
#define TEXTSTR_HH
#include "varray.hh"
/// line counting input stream.
+/**
+ a stream for textfiles. linecounting. Thin interface getchar and
+ ungetchar. (ungetc is unlimited)
+
+ should protect get and unget against improper use
+*/
+
+
class Text_stream
{
int line_no;
// could just have used streams.
FILE *f;
- Array<char> pushback;
+ Array<char> pushback;
String name;
public:
/// GNU format message.
void message(String s);
};
-/**
- a stream for textfiles. linecounting. Thin interface getchar and
- ungetchar. (ungetc is unlimited)
-
- should protect get and unget against improper use
-*/
-
-
/// read a data file
class Data_file : private Text_stream
{
#include "varray.hh"
/// a matrix storage baseclass.
+/** base class for interface with matrix storageclasses. There are no
+ iterators for matrixclasses, since matrices are (like arrays)
+ explicitly int-indexed.
+
+ Iteration is provided by *_next, *_ok, which update and check both
+ index variables simultaneously.
+
+ TODO
+ determine type of product matrix.
+
+*/
class virtual_smat {
virtual int cols() const = 0;
/// set the size. contents lost
- virtual void set_size(int i, int j) = 0;
/**
PRE
i >=0, j>=0
*/
+ virtual void set_size(int i, int j) = 0;
/// set the size to square dimen. contents lost
virtual void set_size(int i) = 0;
PRE
i>=0
*/
- /// set the size to i
- virtual void resize(int i, int j) = 0;
+ /// set the size to i,j
/**
keep contents. If enlarged contents unspecified
i>=0, j>=0
*/
+ virtual void resize(int i, int j) = 0;
/// set the size to square dimen. contents kept
- virtual void resize(int i) = 0;
/**
Keep contents. If enlarged contents are unspecified
PRE
i>=0
*/
+ virtual void resize(int i) = 0;
/// access an element
- virtual Real& elem(int i,int j) = 0;
/**
access an element.
in the 0-part of a sparse matrix.
*/
+ virtual Real& elem(int i,int j) = 0;
/// access a element, no modify
virtual const Real& elem(int i, int j) const = 0;
#endif
/// add a row
- virtual void insert_row(int k)=0;
/**
add a row to the matrix before row k. Contents
of added row are unspecified
0 <= k <= rows()
*/
-
+ virtual void insert_row(int k)=0;
+
/// delete a row
- virtual void delete_row(int k)=0;
- /**
+ /**
delete a row from this matrix.
PRE
0 <= k < rows();
- */
+ */virtual void delete_row(int k)=0;
+
virtual ~virtual_smat() { }
virtual virtual_smat *clone()=0;
/// is there a next?
- virtual bool mult_ok(int i, int j) const=0;
- /**
+ /**
at end of matrix? when doing loop
for(i=0; i<h; i++)
for(j=0; j<w; j++)
...
- */
+ */ virtual bool mult_ok(int i, int j) const=0;
+
/// iterate
- virtual void mult_next(int &i, int &j) const = 0;
- /**
+ /**
walk through matrix (regular multiply)
get next j for row i, or get next row i and reset j.
this will make sparse matrix implementation easy.
PRE
mult_ok(i,j)
- */
- virtual bool trans_ok(int i, int j) const=0;
- /**
+ */virtual void mult_next(int &i, int &j) const = 0;
+ /**
valid matrix entry. return false if at end of row
*/
- virtual void trans_next(int &i, int &j) const = 0;
+ virtual bool trans_ok(int i, int j) const=0;
+
/**
walk through matrix (transposed multiply).
Get next i (for column j)
PRE
ver_ok(i,j)
*/
+ virtual void trans_next(int &i, int &j) const = 0;
/// generate a "Full_storage" matrix
virtual_smat<Real> *get_full(int n, int m);
};
-/** base class for interface with matrix storageclasses. There are no
- iterators for matrixclasses, since matrices are (like arrays)
- explicitly int-indexed.
-
- Iteration is provided by *_next, *_ok, which update and check both
- index variables simultaneously.
-
- TODO
- determine type of product matrix.
-
-*/
#endif
}
///scaleable array/stack template, for T with def ctor.
+/**
+
+ This template implements a scaleable vector. With (or without) range
+ checking. It may be flaky for objects with complicated con- and
+ destructors. The type T should have a default constructor. It is
+ best suited for simple types, such as int, double or String
+
+ It uses stack terminology, (push, pop, top), and can be used as a stack.
+ */
template<class T>
class Array {
protected:
return r;
}
};
-/**
-
- This template implements a scaleable vector. With (or without) range
- checking. It may be flaky for objects with complicated con- and
- destructors. The type T should have a default constructor. It is
- best suited for simple types, such as int, double or String
-
- It uses stack terminology, (push, pop, top), and can be used as a stack.
- */
#endif
void set_matrix_debug(Dstream&ds);
/// a row of numbers
+/**
+ a vector. Storage is handled in Array, Vector only does the mathematics.
+ */
class Vector {
Array<Real> dat;
public:
/// set to j-th element of unit-base
void set_unit(int j) ;
};
-/**
- a vector. Storage is handled in Array, Vector only does the mathematics.
- */
inline Vector
operator+(Vector a, Vector const &b) {
virtual int cols() const = 0;
/// set the size. contents lost
- virtual void set_size(int i, int j) = 0;
/**
PRE
i >=0, j>=0
*/
+ virtual void set_size(int i, int j) = 0;
/// set the size to square dimen. contents lost
virtual void set_size(int i) = 0;
/**
-#!/bin/sh
-def=`echo $1 | sed s/\\\./_/ | tr a-z A-Z`
+#!/usr/bin/perl -w
-cat << HERE
-/*
- $1 -- part of LilyPond
+die "arg needed\n" if (!($#ARGV+1));
+my $fn = $ARGV[0];
+my $hh_q = ($fn =~ /hh$/ );
+my $MAILADRESS=$ENV{MAILADRESS};
+my @pw=(getpwuid($<));
+my $username=$pw[6];
+my $what="implement ";
+$what = "declare " if ($hh_q);
+my $headstr ="/*
+ $fn -- $what
- (c) 1997 $USERNAME <$MAILADRESS>
-*/
+ source file of the LilyPond music typesetter
-HERE
+ (c) 1997 $username <$MAILADRESS>
+*/\n";
+
+my $startdef= $fn;
+$startdef =~ s/\./_/;
+$startdef =~ tr/a-z/A-Z/;
+my $terminatestr="\n";
+if ($hh_q) {
+ $headstr .= "\n\n#ifndef $startdef\n#define $startdef\n";
+ $terminatestr .= "#endif // $startdef\n"
+}
+
+print $headstr, $terminatestr;
-if [ $1 != `basename .hh` ]
-then
-cat <<EOF
-#ifndef $def
-#define $def
-#endif // $def
-EOF
-fi
#include "directionalspanner.hh"
#include "plist.hh"
-/// a beam connects multiple stems
+/** a beam connects multiple stems Beam adjusts the stems its owns to
+make sure that they reach the beam and that point in the correct
+direction */
struct Beam: public Directional_spanner {
PointerList<Stem*> stems;
Real slope;
Real left_pos;
- /// dir: -1 below heads, +1 above heads.
+
- /****************/
+ /* *************** */
const char * name() const;
virtual Interval width()const;
void solve_slope();
Molecule*brew_molecule_p()const;
};
-/** Beam adjusts the stems its owns to make sure that they reach the
- beam and that point in the correct direction */
#endif // BEAM_HH
PScore &pscore_;
Real linelength;
- /****************/
+ /* *************** */
Break_algorithm(PScore&);
#include "scalar.hh"
#include "varray.hh"
-struct Clef {
- int c0_pos;
- String clef_type;
+/// where is c-0 in the staff?
+class Clef {
+
+public:
+ int c0_position_i_;
+ String clef_type_str_;
Clef();
- void read(Array<Scalar> args);
+ void set_type(String);
};
#endif // CLEF_HH
bool change;
- /****************/
+ /* *************** */
Clef_item();
void read(Clef);
Array<Real> config;
Real energy;
- /****************/
+ /* ************** */
void OK()const;
Col_hpositions();
#include "varray.hh"
#include "scalar.hh"
+/// what kind of command?
enum Commandcode {
NOP,
INTERPRET,
};
/// set a nonrythmical symbol
-struct Command {
- Commandcode code;
-
- /// analogous to argv[]
- Array<Scalar> args;
-
- ///
- int priority;
- /** in what order relative to other TYPESET commands (eg, bar
- should precede meter). Highest priority first. */
-
- /****************/
-
- Command();
-// Command(Moment w);
- bool isbreak()const;
- void print() const;
-};
/**
A nonrhythmical "thing" in a staff is called a "command".
*/
+struct Command {
+ Commandcode code;
+
+ /// analogous to argv[]
+ Array<Scalar> args;
+
+
+ /** in what order relative to other TYPESET commands (eg, bar
+ should precede meter). Highest priority first. */
+ int priority;
+
+ /* *************** */
+
+ Command();
+ bool isbreak()const;
+ void print() const;
+};
#endif
--- /dev/null
+/*
+ complexcolumn.hh -- declare Complex_column
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef COMPLEXCOLUMN_HH
+#define COMPLEXCOLUMN_HH
+
+/// column of Complex_staff: store one request
+struct Complex_column : Staff_column {
+
+ Array<Request*> first_l_arr_;
+ Array<Request*> second_l_arr_;
+
+ Complex_staff* staff_l_;
+
+ /* *************** */
+
+ Slur_req *find_slur(Voice *);
+
+ void typeset_item(Item *, int=1);
+ void typeset_item_directional(Item *, int dir, int=1);
+ Molecule *create_command_mol(Command *com);
+
+ void take_request(Request *rq);
+ virtual void setup_requests();
+
+ Complex_column(Score_column*s,Complex_staff*rs);
+};
+
+#endif // COMPLEXCOLUMN_HH
/*
- complexstaff.hh -- part of LilyPond
+ complexstaff.hh -- declare Complex_staff
(c) 1996,1997 Han-Wen Nienhuys <hanwen@stack.nl>
*/
#include "stcol.hh"
#include "staff.hh"
#include "staffwalker.hh"
-
-/// column of Complex_staff: store one request
-struct Complex_column : Staff_column {
-
- Array<Request*> first_l_arr_;
- Array<Request*> second_l_arr_;
-
- Complex_staff* staff_l_;
-
- /****************/
-
- Slur_req *find_slur(Voice *);
-
- void typeset_item(Item *, int=1);
- void typeset_item_directional(Item *, int dir, int=1);
- Molecule *create_command_mol(Command *com);
-
- void take_request(Request *rq);
- virtual void setup_requests();
-
- Complex_column(Score_column*s,Complex_staff*rs);
-};
+#include "complexcolumn.hh"
/// Complex staff: one voicegroup at a time
struct Complex_staff : Staff {
/// indirection to the PStaff.
- PStaff *theline_l_;
+ PStaff *pstaff_l_;
- /****************/
+ /* *************** */
Staff_column*create_col(Score_column*);
virtual Item *get_TYPESET_item(Command*);
virtual void set_output(PScore *);
#ifndef COMPLEXWALKER_HH
#define COMPLEXWALKER_HH
-// this SUX
#include "proto.hh"
#include "grouping.hh"
#include "voicegroup.hh"
#include "key.hh"
#include "clef.hh"
#include "register.hh"
+#include "localkeyreg.hh"
struct Complex_walker: Staff_walker {
Local_key local_key_;
IPointerList<Voice_registers *> voice_reg_list_;
IPointerList<Voice_group_registers*> group_reg_list_;
- Assoc<const Voice *, Voice_group_registers *> voice_group_map_;
+ Assoc<Voice *, Voice_group_registers *> voice_group_map_;
Local_key_register local_key_reg_;
Array<Staff_elem_info> announce_info_arr_;
- /****************/
- void do_change_group(const Voice * v, String group_id_str);
-
- Voice_registers *find_voice_reg(Voice*v_l);
+ /* *************** */
+ Voice_registers *find_voice_reg(Voice*v_l)const;
Voice_registers *get_voice_reg(Voice*v_l);
/// search and return. return 0 if not found.
- Voice_group_registers *find_voice_group(Voice* v_l);
+ Voice_group_registers *find_voice_group(Voice* v_l)const;
/// search. Create if necessary
Voice_group_registers *get_voice_group(Voice* v_l);
/// search and return. return 0 if not found
- Voice_group_registers *find_voice_group(const char* id);
+ Voice_group_registers *find_voice_group(const char* id)const;
/// Create if necessary
Voice_group_registers *get_voice_group(const char*);
+
+ Array<Voice_registers *> get_voice_regs(Voice_group_registers *) const;
void regs_process_requests();
- void do_announces();
- void try_request(Request*req);
void typeset_element(Staff_elem *elem_p);
void announce_element(Staff_elem_info);
virtual void do_TYPESET_command(Command*);
Complex_walker(Complex_staff*);
Complex_column *col();
Complex_staff *staff();
+private:
+ void do_change_group( Voice * v, String group_id_str);
+ void do_announces();
+ void try_request(Request*req);
};
#include "real.hh"
#include "string.hh"
+const Real INCH_TO_PT=72.0;
+const Real CM_TO_PT=INCH_TO_PT/2.54;
+const Real MM_TO_PT=CM_TO_PT/10;
+const Real PT_TO_PT =1.0;
+
+#define PT *PT_TO_PT
+#define MM *MM_TO_PT
+#define CM *CM_TO_PT
+#define INCH *INCH_TO_PT
+
Real parse_dimen(String);
-Real convert_dimen(Real, String);
String print_dimen(Real);
-
+Real convert_dimen(Real, String);
#endif
struct Directional_spanner : Spanner{
/// -1 below heads, +1 above heads.
- int dir;
+ int dir_i_;
/// offset of "center" relative to left-column/0-pos of staff
virtual Offset center() const=0;
typedef Interval_t<Moment> MInterval;
-/// data structure which represents rhythmic units
+/** data structure which represents rhythmic units this is a tree. It groupes notes according to rules
+ */
struct Rhythmic_grouping {
Array<Rhythmic_grouping*> children;
MInterval *interval_;
- /****************/
+ /* *************** */
Array<MInterval> intervals();
MInterval interval()const;
void junk();
void copy(Rhythmic_grouping const&);
};
-/**
- this is a tree. It groupes notes according to rules
-
- */
-
#endif
--- /dev/null
+/*
+ headreg.hh -- part of LilyPond
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef HEADREG_HH
+#define HEADREG_HH
+#include "register.hh"
+
+struct Notehead_register : Request_register {
+ Item* note_p_;
+ int dir_i_;
+ /* *************** */
+ Notehead_register(Complex_walker*);
+ virtual bool try_request(Request *req_l) ;
+ virtual void process_request();
+ virtual void do_pre_move_process();
+ void set_dir(int);
+};
+
+
+#endif // HEADREG_HH
struct Commands_at : public IPointerList<Input_command*> {
Time_description tdescription_;
- /****************/
+ /* *************** */
Moment when();
void parse(Staff_commands_at*);
struct Input_cursor : public PCursor<Commands_at*>
{
- /****************/
+ /* *************** */
Input_cursor(PCursor<Commands_at*>);
Moment when()const;
void find_moment(Moment w);
struct Input_commands : public IPointerList<Commands_at*> {
Input_cursor ptr;
- /****************/
+ /* *************** */
void find_moment(Moment);
void add(Input_command c,Assoc<String,Moment> &marks_assoc_r);
void translate_time(Moment dt);
};
-/// ABC for input structures
+/**
+
+ Input_music is anything that can simply be regarded as/converted to
+ a set of voices "cooperating" or independant. It has some basic
+ characteristics that real music has too:
+
+ - it is rhythmic (it has a length, and can be translated horizontally)
+ - a pitch (it can be transposed)
+
+ */
+
+
struct Input_music {
virtual Voice_list convert()const=0;
virtual Moment length()const=0;
virtual Input_music *clone() const = 0;
virtual Simple_music *simple() { return 0; }
};
-/**
-
- Input_music is anything that can simply be regarded as/converted to
- a set of voices "cooperating" or independant. It has some basic
- characteristics that real music has too:
-
- - it is rhythmic (it has a length, and can be translated horizontally)
- - a pitch (it can be transposed)
-
- */
-
/// Simple music consists of one voice
struct Simple_music : Input_music {
Voice voice_;
- /****/
+ /* *** */
virtual Simple_music*simple() { return this; }
void add(Voice_element*);
virtual void set_default_group(String g) { voice_.set_default_group(g); }
/// Complex_music consists of multiple voices
struct Complex_music : Input_music {
IPointerList<Input_music*> elts;
- /****************/
+ /* *************** */
virtual void set_default_group(String g);
void add(Input_music*);
Complex_music();
};
-/// multiple stuff after each other
+
+/**
+ voice like.
+
+ different music forms which start after each other ( concatenated,
+ stacked "horizontally )
+
+ */
+
struct Music_voice : Complex_music {
- /****************/
+ /* *************** */
Moment length()const;
virtual void translate_time(Moment dt);
virtual Voice_list convert()const;
}
virtual void print() const ;
};
-/**
- voice like.
- different music forms which start after each other ( concatenated,
- stacked "horizontally )
-
- */
+/**
+ Multiple musicstuff stacked on top of each other
+ chord like :
-/// Multiple musicstuff stacked on top of each other
+ - different music forms which start at the same time ( stacked "vertically" )
+
+ */
struct Music_general_chord : Complex_music {
- /****************/
+ /* *************** */
virtual Moment length()const;
virtual Voice_list convert()const;
virtual void print() const ;
};
-/**
- chord like :
-
- - different music forms which start at the same time ( stacked "vertically" )
-
- */
struct Multi_voice_chord : Music_general_chord {
void set_default_group(String);
IPointerList<Input_staff*> staffs_;
IPointerList<Input_command*> commands_;
- /****************************************************************/
+ /* *************************************************************** */
Input_score();
Input_score(Input_score const&);
void add(Array<Input_command*> &s);
void print() const;
Score*parse();
};
-/**
-
- */
+
#endif
IPointerList<Input_command*> commands_;
IPointerList<Input_music*> music_;
- /****************/
+ /* *************** */
void add(Input_music*m);
Input_staff(Input_staff const&);
#include "string.hh"
#include "staffelem.hh"
-/// a horizontally fixed size element of the score
+/**
+ a horizontally fixed size element of the score
+
+ Item is the datastructure for printables whose width is known
+ before the spacing is calculated
+
+ NB. This doesn't mean an Item has to initialize the output field before
+ spacing calculation.
+
+*/
+
struct Item : Staff_elem {
/// indirection to the column it is in
PCol * pcol_l_;
- /****************/
+ /* *************** */
virtual Item *item() { return this; }
Item();
void do_print()const;
const char*name()const;
};
-/** Item is the datastructure for printables whose width is known
- before the spacing is calculated
-
- NB. This doesn't mean an Item has to initialize the output field before
- spacing calculation.
-
-*/
#endif
class Key {
Array<int> accidentals;
- /****************/
+ /* *************** */
public:
Array<int> read(Array<Scalar> );
struct Clef;
-///
+/// An item which places accidentals at the start of the line
struct Keyitem : Item {
const char * name() const;
Array<int> pitch;
int c_position;
- /****************/
+ /* *************** */
Keyitem(int cposition);
void add(int pitch, int acc);
Molecule* brew_molecule_p()const;
};
-/**
- An item which places accidentals at the start of the line
- */
#endif // KEYITEM_HH
Notename_tab * defaulttab;
char const* data_ch_c_l_m;
int errorlevel_i_;
- /****************/
+ /* *************** */
int ret_notename(int *p, String text, int octave_mod);
char const* here_ch_c_l();
void set(Notename_tab *n);
+++ /dev/null
-#include "pstaff.hh"
-
-struct Linestaff : PStaff {
-
- int nolines;
-
-/****************/
-
- void brew_molecule_p(Real width);
- Linestaff(int, PScore*);
-};
const Real* fixpos;
Interval width;
- /****************/
+ /* *************** */
Colinfo();
void operator=(Colinfo const&);
Colinfo(Colinfo const&);
};
-/// spacing for one line.
+/** the problem, given by the columns (which include constraints) and
+ intercolumn spacing. The problem is:
+
+ Generate a spacing which
+ \begin{itemize}
+ \item
+ Satisfies spacing constraints (notes can't be printed through each other)
+ \item
+ Looks good, ie tries to conform to an ideal spacing as much as possible.
+ \end{itemize}
+ This is converted by regarding idealspacing as "springs" attached
+ to columns. The equilibrium of one spring is the ideal
+ distance. The columns have a size, this imposes "hard" constraints
+ on the distances. This transforms the problem into a quadratic
+ programming problem with linear constraints.
+
+ The quality is given by the total potential energy in the
+ springs. The lower the energy, the better the configuration.
+*/
class Spacing_problem {
Array<const Idealspacing*> ideals;
Array<Colinfo> cols;
void make_constraints(Mixed_qp& lp) const;
public:
- /// solve the spacing problem
+ /** solve the spacing problem
+ return the column positions, and the energy (last element)
+ */
Array<Real> solve() const;
- /**
- return the column positions, and the energy (last element)
- */
+
/// add a idealspacing to the problem.
- void add_ideal(const Idealspacing *i);
-
/**
+
+
One pair of columns can have no, one or more idealspacings,
since they can be "summed" if the columns to which #i# refers are
not in this problem, the spacing is ignored.
*/
+ void add_ideal(const Idealspacing *i);
/// add a col to the problem
- void add_column(const PCol *, bool fixed=false, Real fixpos=0.0);
- /** columns have to be added left to right. The column contains
+ /** columns have to be added left to right. The column contains
info on it's minimum width.
*/
+ void add_column(const PCol *, bool fixed=false, Real fixpos=0.0);
+
bool check_constraints(Vector v) const;
};
-/** the problem, given by the columns (which include constraints) and
- intercolumn spacing. The problem is:
-
- Generate a spacing which
- \begin{itemize}
- \item
- Satisfies spacing constraints (notes can't be printed through each other)
- \item
- Looks good, ie tries to conform to an ideal spacing as much as possible.
- \end{itemize}
- This is converted by regarding idealspacing as "springs" attached
- to columns. The equilibrium of one spring is the ideal
- distance. The columns have a size, this imposes "hard" constraints
- on the distances. This transforms the problem into a quadratic
- programming problem with linear constraints.
-
- The quality is given by the total potential energy in the
- springs. The lower the energy, the better the configuration.
-*/
#endif
Array<Item*> group;
int c0_position; // move into walker
- /****************/
+ /* *************** */
Local_key_item(int c0position);
void add(Item*);
--- /dev/null
+/*
+ localkeyreg.hh -- part of LilyPond
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef LOCALKEYREG_HH
+#define LOCALKEYREG_HH
+#include "register.hh"
+
+struct Local_key_register : Request_register {
+ Local_key_item* key_item_p_;
+
+ /* *************** */
+
+ virtual bool try_request(Request*);
+ virtual void process_request();
+ virtual void acknowledge_element(Staff_elem_info);
+ virtual void do_pre_move_process();
+ Local_key_register(Complex_walker*);
+};
+
+#endif // LOCALKEYREG_HH
struct Lookup {
Symtables *symtables_;
String texsetting;
- /****************/
+ /* *************** */
void add(String, Symtable*);
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);
- Symbol streepjes(int pos);
+
/**
pos == 3 : 3 lines above staff (extending below note)
pos == -3: below staff
*/
+ Symbol streepjes(int pos);
Symbol meter(Array<Scalar>);
Symbol stem(Real y1_pos, Real y2_pos);
Symbol big_slur(int dy, Real &dx, int dir);
Symbol text(String style, String text, int align = 1);
Symbol script(String idx);
-
+ Symbol hairpin(Real & width, bool decresc);
Lookup();
Lookup(Lookup const &);
Array<Word_info> winfo_array_;
Lyric_staff* lstaff_l_;
- void typeset_item(Item *, int=1);
+ void typeset_item(Item *);
virtual void setup_requests();
- Lyric_column(Score_column*s,Lyric_staff*rs);
+ Lyric_column(Score_column* s,Lyric_staff*rs);
};
#endif // LYRICSTAFF_HH
#include "textitem.hh"
struct Lyric_item : Text_item {
- /****************/
+ /* *************** */
Lyric_item(Lyric_req* lreq_l, int voice_count_i);
virtual void do_pre_processing();
};
/// (lstaff)
struct Lyric_staff : Staff {
- PStaff* line_pstaff_p_;
+ PStaff* pstaff_l_;
Staff_column* create_col(Score_column*);
-
-// virtual Item *get_TYPESET_item(Command*);
- virtual void set_output(PScore *);
-// virtual Local_key_item* get_local_key_item();
+ virtual void set_output(PScore *);
void process_commands(PCursor<Command*> &where);
virtual void walk();
struct Lyric_walker: Staff_walker {
Array<Lyric_item*> litem_l_array_;
- /****************/
+ /* *************** */
virtual void do_TYPESET_command(Command*);
virtual void do_INTERPRET_command(Command*);
+++ /dev/null
-/*
- rhythmstaf.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef MELODICSTAFF_HH
-#define MELODICSTAFF_HH
-
-#include "simplestaff.hh"
-
-/// five line staff, no multiple voices
-struct Melodic_staff : public Simple_staff
-{
-
- /****************/
-
- virtual Rest *get_rest(Rest_req *rq);
- virtual void set_output(PScore *);
-
- virtual Item* get_TYPESET_item(Command*);
- virtual Stem * get_stem(Stem_req *rq);
- virtual Notehead * get_notehead(Note_req *rq, int bot);
- virtual Local_key_item* get_local_key_item();
-};
-
-#endif // MELODICSTAFF_HH
-
-
struct Meter: Item {
const char * name() const;
Array<Scalar> args;
- /****************/
+ /* *************** */
Meter(Array<Scalar> args) ;
Molecule*brew_molecule_p() const;
Offset off;
Symbol sym;
- /****************/
+ /* *************** */
void translate(Offset o) {
off += o;
String TeXstring() const;
};
-/// a group of #Atom#s
+
+/** a group of individually translated symbols. You can add molecules
+ to the top, to the right, etc. */
struct Molecule {
IPointerList<Atom*> ats; // change to List<Atom>?
- /****************/
+ /* *************** */
Molecule() { }
Molecule(Atom a) { add(a) ; }
private:
void operator=(const Molecule&);
};
-/** a group of individually translated symbols. You can add molecules
- to the top, to the right, etc. */
#endif
#define NOTEHEAD_HH
#include "item.hh"
-/// ball at the end of the stem
+/**
+ ball at the end of the stem
+takes care of:
+
+ * help lines
+ * proper placing of dots
+
+ */
+
struct Notehead : Item {
const char * name() const;
const char* defined_ch_c_l_m; //sorry, trying to find error in martien.ly
int balltype;
int x_dir;
- /****************/
+ /* *************** */
void set_rhythmic(Rhythmic_req *);
- Notehead(int staff_size);
+
/**
position of top line (5 linestaff: 8)
*/
-
+ Notehead(int staff_size);
void do_print()const;
static int compare(Notehead*&a, Notehead*&b) ;
Molecule* brew_molecule_p()const;
};
-/**
- takes care of:
-
- * help lines
- * proper placing of dots
-
- */
#endif // NOTEHEAD_HH
#include "string.hh"
#include "moment.hh"
-/// symbols, dimensions and constants
+
+/** symbols, dimensions and constants
+
+ This struct takes care of all kinds of symbols, dimensions and
+ constants. Most of them are related to the point-size of the fonts,
+ so therefore, the lookup table for symbols is also in here.
+
+ see TODO
+ */
struct Paperdef {
Lookup *lookup_p_;
String outfile;
/// ideal = geometric_ ^ log2(duration)
Real geometric_;
- /****************/
+ /* *************** */
void reinit();
Paperdef(Lookup*);
void set(Lookup*);
void print() const;
Real duration_to_dist(Moment);
};
-/** This struct takes care of all kinds of symbols, dimensions and
- constants. Most of them are related to the point-size of the fonts,
- so therefore, the lookup table for symbols is also in here.
- see TODO
- */
#include "item.hh"
/// stuff grouped vertically.
-struct PCol {
+/**
+ This is a class to address items vertically. It contains the data for:
+ \begin{itemize}
+ \item
+ unbroken score
+ \item
+ broken score
+ \item
+ the linespacing problem
+ \end{itemize}
+ */struct PCol {
PointerList<const Item*> its;
PointerList<const Spanner*> stoppers, starters;
/// prebreak is put before end of line.
- PCol *prebreak_p_;
/**
if broken here, then (*this) column is discarded, and prebreak
is put at end of line, owned by Col
*/
+ PCol *prebreak_p_;
/// postbreak at beginning of the new line
PCol *postbreak_p_;
- /** \See{prebreak}
- */
- PCol *daddy_l_;
/** if this column is pre or postbreak, then this field points to
the parent. */
+ PCol *daddy_l_;
/// if lines are broken then this column is in #line#
const Line_of_score *line_l_;
PScore * pscore_l_;
- /****************/
+ /* *************** */
/// which one (left =0)
int rank() const;
PCol(PCol * parent);
/// which col comes first?
- static int compare(const PCol &c1, const PCol &c2);
/**
signed compare on columns.
return < 0 if c1 < c2.
- */
+ */static int compare(const PCol &c1, const PCol &c2);
+
void OK() const;
void set_breakable();
private:
PCol(PCol const&){}
};
-/**
- This is a class to address items vertically. It contains the data for:
- \begin{itemize}
- \item
- unbroken score
- \item
- broken score
- \item
- the linespacing problem
- \end{itemize}
- */
+
#include "compare.hh"
instantiate_compare(PCol &, PCol::compare);
struct Music_voice;
struct Note_req;
struct Notehead;
+struct Notehead_register;
struct Notename_tab;
struct Offset;
struct Output;
struct Score_column;
struct Script_def;
struct Script;
+struct Script_register;
struct Script_req;
struct Simple_music;
struct Slur;
+struct Slur_register;
struct Slur_req;
-class Source;
-class Source_file;
+struct Source;
+struct Source_file;
struct Spacing_req ;
struct Span_req;
struct Spanner;
struct Staff_commands_at ;
struct Staff_elem;
struct Staff_elem_info;
+struct Staff_symbol;
struct Staff_walker;
struct Stem;
struct Stem_req;
struct Text_item ;
struct Text_def;
struct Text_gob;
+struct Text_register;
struct Text_req;
+
struct Time_description;
struct Voice;
struct Voice_element;
#include "pstaff.hh"
/// all stuff which goes onto paper
-struct PScore {
+/** notes, signs, symbols in a score can be grouped in two ways:
+ horizontally (staffwise), and vertically (columns). #PScore#
+ contains the items, the columns and the staffs.
+ */struct PScore {
Paperdef *paper_l_;
/// the columns, ordered left to right
/// broken spanners
IPointerList<Spanner*> broken_spans;
- /****************/
+ /* *************** */
/* CONSTRUCTION */
PScore(Paperdef*);
void add(PStaff *);
- /// add item
- void typeset_item(Item *, PCol *,PStaff*,int=1);
+ /// add an item
+ /**
+ add the item in specified containers. If breakstatus is set
+ properly, add it to the {pre,post}break of the pcol.
+ */
+ void typeset_item(Item *item_p, PCol *pcol_l,PStaff*pstaf_l,int breakstatus=1);
/// add a Spanner
void typeset_spanner(Spanner*, PStaff*);
/// delete unused columns
void clean_cols();
};
-/** notes, signs, symbols in a score can be grouped in two ways:
- horizontally (staffwise), and vertically (columns). #PScore#
- contains the items, the columns and the staffs.
- */
+
#endif
/// items grouped horizontally
struct PStaff {
- Molecule * stafsym_p_;
PScore * pscore_l_;
PointerList<const Spanner*> spans;
PointerList<Item*> its;
- /****************/
- virtual void brew_molecule_p(Real width)=0; // maybe overkill
+ /* *************** */
void add(Item*i);
PStaff(PScore*);
- virtual ~PStaff();
+
private:
PStaff(PStaff const&);
};
Vector lin;
Real const_term;
- ///
- void assert_solution(Vector sol) const;
+
/**
use a KKT method to assert optimality of sol
*/
- /// solve the problem using a projected gradient method
+ void assert_solution(Vector sol) const;
+ /// solve the problem using a projected gradient method
Vector solve(Vector start) const;
+ /** return the number of variables in the problem */
int dim() const{
return lin.dim();
}
- /** return the number of variables in the problem */
- ///
- void add_inequality_cons(Vector c, double r);
+
/**
add a constraint
c.dim() == dim();
*/
- ///
- Ineq_constrained_qp(int novars);
+ void add_inequality_cons(Vector c, double r);
+
/** set up matrices to go with the problem. */
-
- Real eval(Vector v);
+ Ineq_constrained_qp(int novars);
+
/**
evaluate the quadratic function for input #v#
*/
+ Real eval(Vector v);
void eliminate_var(int idx, Real value);
void OK()const;
};
/// Quadratic programming with mixed linear constraints
+/**
+ problem definition of a quadratic optimisation problem with linear
+ inequality and equality constraints
+
+
+ x^T QUAD x /2 + b^T x
+*/
+
+
class Mixed_qp :public Ineq_constrained_qp {
Array<int> eq_cons;
Array<Real> eq_consrhs;
Vector solve(Vector start) const;
void add_fixed_var(int i , Real value);
- ///
- void add_equality_cons(Vector c, double r);
+
/**
add a constraint,
PRE
c.dim()==dim();
*/
-
+ void add_equality_cons(Vector c, double r);
};
-/**
- problem definition of a quadratic optimisation problem with linear
- inequality and equality constraints
-
-
- x^T QUAD x /2 + b^T x
-*/
-
-
#endif
#include "matrix.hh"
+/**
+ This class represents the set of active (binding) constraints
+ which can be active while the QLP algorithm is in a feasible
+ point. The active constraints are numbered.
+ If the constraints are of the form
+
+ A^T*x >= b
+
+ then the binding constraints are those where the >= is equality.
+
+ */
+
class Active_constraints {
friend class Inactive_iter;
Real rhs(int k) const { return opt->consrhs[k]; }
/// drop constraint
- void drop (int k);
/** drop constraint k from the active set. k is the index of the
constraint in #active#
*/
+ void drop (int k);
/// add constraint j
- void add(int j);
/**
add constraint j to the active set j is the index of the
constraint in #inactive#
*/
+ void add(int j);
/// exchange in and out.
void exchange(int in, int out) { add(in); drop (out); }
- ///
+
Vector find_active_optimum(Vector g);
/// get lagrange multipliers.
void OK();
};
-/**
- This class represents the set of active (binding) constraints
- which can be active while the QLP algorithm is in a feasible
- point. The active constraints are numbered.
- If the constraints are of the form
-
- A^T*x >= b
- then the binding constraints are those where the >= is equality.
-
+/**
+ loop through the inactive constraints.
*/
-
-///
class Inactive_iter {
int j;
Active_constraints const* ac;
Real rhs() const { return ac->rhs(constraint_id()); }
bool ok() const { return j < ac->inactive.size(); }
};
-/**
- loop through the inactive constraints.
- */
#define REGISTER_HH
#include "proto.hh"
#include "varray.hh"
+#include "request.hh"
/// data container.
struct Staff_elem_info {
Staff_elem * elem_p_;
Request*req_l_;
const Voice * voice_l_;
- Voice_group_registers * group_regs_l_;
-
+ Voice_group_registers * group_regs_l_;
Request_register * origin_reg_l_;
- /****/
+ /* *** */
Staff_elem_info(Staff_elem*, Request*, Request_register*);
Staff_elem_info();
};
/// Hungarian postfix: reg
+/**
+ a struct which processes requests, and creates the Staff_elems
+ */
struct Request_register {
Complex_walker * walk_l_;
Array<Request*> accepted_req_arr_;
- /****************/
-
+ /* *************** */
+ /**
+ Warning: you can't copy a Request_register
+ */
+ Request_register(Request_register const &);
Request_register(Complex_walker*);
Request_register();
virtual ~Request_register(){}
- /// take note of item/spaanner
+ /** take note of item/spaanner
+ put item in spanner. Adjust local key; etc.
+ */
virtual void acknowledge_element(Staff_elem_info){}
/**
- put item in spanner. Adjust local key; etc.
+ Announce element to walker
+ */
+ void announce_element(Staff_elem_info);
+
+ /**
+ invoke walker method to typeset element
*/
+ void typeset_element(Staff_elem*elem_p);
- ///
- virtual bool try_request(Request *req_l) =0;
/**
try to fit the request in this register
- RETURN
- false: request noted, but not taken.
+ @return
+ false: not noted, not taken.
true: request swallowed. Don't try to put elsewhere
(may be we could use C++ exceptions.. :-)
*/
-
+ virtual bool try_request(Request *req_l) =0;
+
/// make items/spanners with the requests you got
virtual void process_request()=0;
-
+ Paperdef * paper() const;
/// typeset any spanners. Empty accepted_req_arr_
void pre_move_processing();
void post_move_processing();
-
+ virtual void set_dir(int){}
protected:
/// virtual, called by pre_move_process()
virtual void do_pre_move_process(){}
virtual void do_post_move_process(){}
};
-/**
- a struct which processes requests, and creates the Staff_elems
- */
-struct Notehead_register : Request_register {
- Item* note_p_;
- /****************/
- Notehead_register(Complex_walker*);
- virtual bool try_request(Request *req_l) ;
- virtual void process_request();
- virtual void do_pre_move_process();
-};
-
-struct Slur_register : Request_register {
- Array<Slur_req*> requests_arr_;
- Array<Slur *> slur_l_stack_;
- Array<Slur*> end_slur_l_arr_;
-
- /****************/
- ~Slur_register();
- Slur_register(Complex_walker*);
- virtual bool try_request(Request*);
- virtual void process_request();
- virtual void acknowledge_element(Staff_elem_info);
- virtual void do_pre_move_process();
-};
-
-struct Stem_beam_register : Request_register {
- Stem * stem_p_;
- Beam * beam_p_;
- Beam_req * beam_req_l_;
- Stem_req * stem_req_l_;
- Beam_req * start_req_l_;
- bool end_beam_b_;
- Rhythmic_grouping *current_grouping;
- int default_dir_i_;
-
- /****************/
- Stem_beam_register(Complex_walker*);
- ~Stem_beam_register();
- void set_dir(int dir_i_);
- virtual bool try_request(Request*);
- virtual void process_request();
- virtual void acknowledge_element(Staff_elem_info);
- virtual void do_pre_move_process();
- virtual void do_post_move_process();
-};
-
-struct Script_register : Request_register {
- Script * script_p_;
-
- /****************/
- void set_dir(int dir_i_);
- Script_register(Complex_walker*);
- virtual bool try_request(Request*);
- virtual void process_request();
- virtual void acknowledge_element(Staff_elem_info);
- virtual void do_pre_move_process();
-};
-
-struct Text_register : Request_register{
- Text_item * text_p_;
-
- /****************/
- void set_dir(int dir_i_);
- Text_register(Complex_walker*);
- virtual bool try_request(Request*);
- virtual void process_request();
- virtual void do_pre_move_process();
-};
-
-
-struct Local_key_register : Request_register {
- Local_key_item* key_item_p_;
-
- /****************/
-
- virtual bool try_request(Request*);
- virtual void process_request();
- virtual void acknowledge_element(Staff_elem_info);
- virtual void do_pre_move_process();
- Local_key_register(Complex_walker*);
-};
#endif // REGISTER_HH
#include "moment.hh"
/// Hungarian postfix: req
+/**
+ a voice element wants something printed.
+see lilygut page
+ */
+
struct Request {
Voice_element*elt_l_;
char const* defined_ch_c_l_m;
- /****************/
+ /* *************** */
Request();
Request(Request const&);
virtual ~Request(){}
protected:
virtual void do_print()const ;
};
-/**
- a voice element wants something printed.
-see lilygut page
- */
-
#define REQUESTMETHODS(T,accessor) \
virtual T * accessor() { return this;}\
int balltype;
int dots;
Moment plet_factor;
- /****************/
+ /* *************** */
static int compare(const Rhythmic_req &, const Rhythmic_req &);
Moment duration() const;
Rhythmic_req();
Moment next;
Real distance;
Real strength;
- /****************/
+ /* *************** */
Spacing_req();
REQUESTMETHODS(Spacing_req, spacing);
};
struct Text_req : virtual Request {
int dir_i_;
Text_def *tdef_p_;
- /****************/
+ /* *************** */
Text_req(int d, Text_def*);
~Text_req();
Text_req(Text_req const&);
///Put a rest on the staff.
+/**
+Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded.
+*/
+
struct Rest_req : Rhythmic_req {
REQUESTMETHODS(Rest_req,rest);
};
+/// attach a stem to the noteball
/**
-Why a request? It might be a good idea to not typeset the rest, if the paper is too crowded.
-*/
+ Rhythmic_req parent needed to determine if it will fit inside a beam.
+ */
-/// attach a stem to the noteball
struct Stem_req : Rhythmic_req {
int dir_i_;
Stem_req(int s, int dots);
REQUESTMETHODS(Stem_req,stem);
};
-/**
- Rhythmic_req parent needed to determine if it will fit inside a beam.
- */
/// requests to start or stop something.
+/**
+ This type of request typically results in the creation of a #Spanner#
+*/
struct Span_req : Request {
/// should the spanner start or stop, or is it unwanted?
enum {
Span_req();
};
-/**
- This type of request typically results in the creation of a #Spanner#
-*/
///Start / stop a beam at this note.
+
+/** if #nplet# is set, the staff will try to put an
+appropriate number over the beam
+ */
struct Beam_req : Span_req {
int nplet;
- /****************/
+ /* *************** */
REQUESTMETHODS(Beam_req,beam);
Beam_req();
};
-/** if #nplet# is set, the staff will try to put an
-appropriate number over the beam
- */
-
/// a slur
struct Slur_req : Span_req {
REQUESTMETHODS(Slur_req,slur);
///Put a script above or below this ``note''
+/** eg upbow, downbow. Why a request? These symbols may conflict with
+slurs and brackets, so this also a request */
struct Script_req : Request {
int dir_i_;
Script_def *scriptdef_p_;
- /****************/
+ /* *************** */
static int compare(const Script_req &, const Script_req &);
Script_req(int d, Script_def*);
REQUESTMETHODS(Script_req,script);
~Script_req();
Script_req(Script_req const&);
};
-/** eg upbow, downbow. Why a request? These symbols may conflict with
-slurs and brackets, so this also a request */
/// designate this spot with a name.
struct Mark_req : Request {
String mark_str_;
- /****************/
+ /* *************** */
Mark_req(String);
REQUESTMETHODS(Mark_req,mark);
};
struct Staff_command_req : Request {
Input_command * com_p_;
- /****************/
+ /* *************** */
Staff_command_req(Staff_command_req const&);
~Staff_command_req();
Staff_command_req(Input_command*);
};
/// helper in the hierarchy
-struct Dynamic:Subtle_req {
-
-};
/** Each dynamic is bound to one note ( a crescendo spanning multiple
notes is thought to be made of two "dynamics": a start and a stop).
Dynamic changes can occur in a smaller time than the length of its
Dynamic should have been derived from request, but I don't want to
fuss with virtual baseclasses. */
+struct Dynamic:Subtle_req {
+
+};
/// do a crescendo
struct Cresc_req : Span_req, Dynamic {
#define REST_HH
#include "item.hh"
-/// ball at the end of the stem
struct Rest : Item {
int dots;
int balltype;
- /****************/
+ /* *************** */
Rest(int dur,int dots);
const char * name() const;
Molecule* brew_molecule_p()const;
};
-/**
- takes care of:
-
- * help lines
- * proper placing of dots
-
- */
#endif
+++ /dev/null
-/*
- rhythmstaf.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef RHYTHMSTAF_HH
-#define RHYTHMSTAF_HH
-
-#include "simplestaff.hh"
-
-/// all notes on one line
-struct Rhythmic_staff : public Simple_staff
-{
-
- /****************/
-
- virtual Item *get_TYPESET_item(Command*);
- virtual Stem *get_stem(Stem_req *rq);
- virtual Notehead * get_notehead(Note_req *rq, int b);
- virtual void set_output(PScore *);
-};
-
-#endif // RHYTHMSTAF_HH
-
-
#include "moment.hh"
+/**
+
+ When typesetting hasn't started on PScore yet, the columns which
+ contain data have a rhythmical position. Score_column is the type
+ with a rhythmical time attached to it. The calculation of
+ idealspacing is done with data in these columns. (notably: the
+ #durations# field)
+
+ */
+
struct Score_column {
/// indirection to column
/// length of notes/rests in this column
Array<Moment> durations;
- ///
+
bool musical_;
- /****************/
+ /* *************** */
Moment when() { return when_; }
Score_column(Moment when);
static int compare(Score_column & c1, Score_column &c2);
private:
Moment when_;
};
-/**
-
- When typesetting hasn't started on PScore yet, the columns which
- contain data have a rhythmical position. Score_column is the type
- with a rhythmical time attached to it. The calculation of
- idealspacing is done with data in these columns. (notably: the
- #durations# field)
-
- */
instantiate_compare(Score_column&, Score_column::compare);
#include "plist.hh"
#include "moment.hh"
#include "assoc.hh"
+#include "string.hh"
/// the total music def of one movement
struct Score {
int errorlevel_i_;
Assoc<String, Moment> markers_assoc_;
- /****************************************************************/
+
+ /* *************************************************************** */
/// construction
Score(Paperdef*);
// utils:
PCursor<Score_column*> create_cols(Moment);
+
+ /// find a column. The cursor is given to try a little efficiency.
PCursor<Score_column *> find_col(Moment,bool);
+
/// when does the last *musical* element finish?
Moment last() const;
private:
Score(Score const&){}
- ///
- void do_cols();
+
/**
make the pcol_l_ fields of each Score_column point to the correct PCol,
remove any unnecessary Score_column's
*/
+ void do_cols();
/// remove unused cols
void clean_cols();
/// add #Idealspacings# to #pscore_#
void calc_idealspacing();
- /** add the score wide commands (bars, breaks) to each staff so
- they can process (typeset) them if needed */
};
-/**
-
- */
#endif
IPointerList<Line_of_staff*> staffs;
PScore * pscore_l_; // needed to generate staffs
- /****************/
+ /* *************** */
void process() ;
Line_of_score(Array<PCol *> sv, PScore *);
Stem *stem_l_;
Array<Item *> support;
- /****************/
+ /* *************** */
const char * name() const;
Molecule* brew_molecule_p()const;
virtual void do_post_processing();
bool invertsym;
String symidx;
- /****************/
+ /* *************** */
int compare(Script_def const &);
void print() const;
Script_def(String, int, int ,bool);
--- /dev/null
+/*
+ scriptreg.hh -- part of LilyPond
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef SCRIPTREG_HH
+#define SCRIPTREG_HH
+
+#include "register.hh"
+
+
+struct Script_register : Request_register {
+ Script * script_p_;
+ int dir_i_;
+ /* *************** */
+ void set_dir(int dir_i_);
+ Script_register(Complex_walker*);
+ virtual bool try_request(Request*);
+ virtual void process_request();
+ virtual void acknowledge_element(Staff_elem_info);
+ virtual void do_pre_move_process();
+};
+
+#endif // SCRIPTREG_HH
+++ /dev/null
-/*
- simplestaff.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef SIMPLESTAFF_HH
-#define SIMPLESTAFF_HH
-
-#include "key.hh"
-#include "stcol.hh"
-#include "staff.hh"
-#include "staffwalker.hh"
-
-/*
- mega-stupido staffs and cols: they do notes one at each moment.
- */
-
-struct Simple_staff;
-struct Note_info {
- Rhythmic_req *rq;
- Array<Script_req*> scripts;
- Note_info();
- Note_info(Rhythmic_req*);
-};
-
-/// column of Simple_staff: store one request
-struct Simple_column : Staff_column {
-
- Array<Note_info> notes;
- Array<Slur_req *> slurs;
- Stem_req *stem_;
- Moment stem_requester_len;
- Beam_req *beam_;
- Simple_staff* staff_l_;
- Text_req *text_;
-
- /****************/
- Slur_req * find_slur(Voice *);
- void typeset_item(Item *, int=1);
- void typeset_item_directional(Item *, int dir, int=1);
-
- Molecule *create_command_mol(Command *com);
-
- void take_request(Request *rq);
- virtual void setup_requests();
-
- Simple_column(Score_column*s,Simple_staff*rs);
-};
-
-
-/// Simple staff: one voicegroup at a time
-struct Simple_staff : Staff {
- /// indirection to the PStaff.
- PStaff *theline_l_;
-
- /****************/
- Staff_column*create_col(Score_column*);
-
- virtual Item *get_TYPESET_item(Command*);
- virtual Stem *get_stem(Stem_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();
-};
-
-#endif // SIMPLESTAFF_HH
-
-
-
-
+++ /dev/null
-/*
- simplewalker.hh -- part of LilyPond
-
- (c) 1996,97 Han-Wen Nienhuys
-*/
-
-#ifndef SIMPLEWALKER_HH
-#define SIMPLEWALKER_HH
-
-#include "proto.hh"
-#include "grouping.hh"
-
-
-struct Simple_walker: Staff_walker {
- Stem *stem_;
- Array<Notehead *>noteheads;
- Local_key local_key_;
- Key key_;
- Array<int> *oldkey_undo;
- Array<int> typesetkey;
- Beam *beam_;
- Local_key_item *local_key_item_;
- bool wantkey; // urgh
- int processed_bar_priority;
- bool processed_key;
- bool processed_clef;
- Clef clef_;
- Rhythmic_grouping default_grouping;
- Rhythmic_grouping *current_grouping;
- Array<Slur_req*> pending_slur_reqs;
- Array<Slur*> pending_slurs;
-
- /****************/
-
- virtual void do_TYPESET_command(Command*);
- virtual void do_INTERPRET_command(Command*);
- virtual void process_requests();
- virtual void do_post_move();
- ~Simple_walker();
- Simple_walker(Simple_walker const& c);
- void do_note(Note_info);
- Simple_walker(Simple_staff*);
- Simple_column *col();
- Simple_staff *staff();
-
- void do_local_key(Note_req*, Notehead*);
- int find_slur(const Voice*v);
-};
-
-
-#endif // SIMPLEWALKER_HH
-
-
struct Slur : Directional_spanner {
Array<Notehead*> encompass;
- //int dir;
- bool open_left,open_right;
+ bool open_left, open_right;
- /****************/
+ /* *************** */
Offset center() const;
Slur();
void do_post_processing();
--- /dev/null
+/*
+ slurreg.hh -- declare Slur_register
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef SLURREG_HH
+#define SLURREG_HH
+
+#include "register.hh"
+
+struct Slur_register : Request_register {
+ Array<Slur_req*> requests_arr_;
+ Array<Slur *> slur_l_stack_;
+ Array<Slur*> end_slur_l_arr_;
+ int dir_i_;
+ /* *************** */
+ ~Slur_register();
+ Slur_register(Complex_walker*);
+ virtual bool try_request(Request*);
+ virtual void process_request();
+ virtual void acknowledge_element(Staff_elem_info);
+ virtual void do_pre_move_process();
+ virtual void set_dir(int);
+};
+
+#endif // SLURREG_HH
class Source_file
{
public:
- ///
- Source_file( String &filename_str );
/**
RETURN path to opened file.
*/
+ Source_file( String &filename_str );
~Source_file();
char const* ch_c_l();
String error_str( char const* pos_ch_c_l );
#include "staffelem.hh"
/// a symbol which is attached between two columns.
+/** A spanner is a symbol which spans across several columns, so its
+ final appearance can only be calculated after the breaking problem
+ is solved.
+
+ Examples
+
+ - (de)crescendo
+ - slur
+ - beam
+ - bracket
+
+
+ Spanner should know about the items which it should consider:
+ e.g. slurs should be steep enough to "enclose" all those items. This
+ is absolutely necessary for beams, since they have to adjust the
+ length of stems of notes they encompass.
+
+ */
struct Spanner:Staff_elem {
PCol *left, *right;
- /****************/
+ /* *************** */
Spanner();
virtual Interval width()const;
virtual Spanner* spanner() { return this; }
protected:
/// clone a piece of this spanner.
- virtual Spanner *do_break_at( PCol *c1, PCol *c2) const=0;
/**
PRE
c1 >= start, c2 <= stop
*/
+ virtual Spanner *do_break_at( PCol *c1, PCol *c2) const=0;
};
-/** A spanner is a symbol which spans across several columns, so its
- final appearance can only be calculated after the breaking problem
- is solved.
-
- Examples
-
- - (de)crescendo
- - slur
- - beam
- - bracket
-
-
- Spanner should know about the items which it should consider:
- e.g. slurs should be steep enough to "enclose" all those items. This
- is absolutely necessary for beams, since they have to adjust the
- length of stems of notes they encompass.
-
- */
#endif
PScore *pscore_l_;
String define_spot_str_;
- /****************************************************************/
+ /* *************************************************************** */
void add(PointerList<Voice*> &s);
void do_commands(PointerList<Input_command*> score_wide,
Paperdef*paper()const;
/// interpret all requests and add items to #destination#.
- void process();
/**
This routines calls virtual functions from Staff, to delegate the
interpretation of requests to a derived class of Staff */
+ void process();
void setup_staffcols();
/// remove unused cols
void clean_cols() ;
- Staff_column * get_col(Moment,bool);
+ Staff_column *get_col(Moment,bool); // ugh
Staff();
- /****************************************************************
+ /*
VIRTUALS
- ****************************************************************/
+ */
virtual void set_output(PScore * destination)=0;
virtual void walk()=0;
struct Staff_commands_at : public IPointerList<Command*> {
Time_description tdescription_;
- /****************/
+ /* *************** */
bool is_breakable();
Moment when();
#include "offset.hh"
#include "molecule.hh"
+/** Both Spanner and Item are Staff_elem's. Most Staff_elem's depend
+ on other Staff_elem's, eg, Beam needs to know and set direction of
+ Stem. So the Beam has to be calculated *before* Stem. This is
+ accomplished with the dependencies field of struct Staff_elem.
+
+ */
struct Staff_elem {
enum Status {
ORPHAN, // not yet added to pstaff
/// the pstaff it is in
PStaff *pstaff_l_;
- /****************/
+ /* *************** */
Staff_elem(Staff_elem const&);
String TeXstring () const ;
virtual void print() const;
/// member: the symbols
Molecule *output; // should scrap, and use temp var?
- ///
- Offset offset_;
+
/**
This is needed, because #output# may still be
NULL.
*/
+ Offset offset_;
Array<Staff_elem*> dependencies;
};
-/** Both Spanner and Item are Staff_elem's. Most Staff_elem's depend
- on other Staff_elem's, eg, Beam needs to know and set direction of
- Stem. So the Beam has to be calculated *before* Stem. This is
- accomplished with the dependencies field of struct Staff_elem.
-
- */
-
#define NAME_METHOD(c) const char *c::name()const{ return #c; } struct c
#endif // STAFFELEM_HH
Line_of_score * line_of_score_l_;
PStaff *pstaff_l_;
- /****************/
+ /* *************** */
String TeXstring() const;
Line_of_staff(Line_of_score*, PStaff *);
--- /dev/null
+/*
+ staffsym.hh -- declare Staff_symbol
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef STAFFSYM_HH
+#define STAFFSYM_HH
+#include "spanner.hh"
+/**
+ This spanner draws the lines of a pstaff.
+ The bottom line is position 0.
+ */
+class Staff_symbol : public Spanner
+{
+public:
+ /// this many lines.
+ int no_lines_i_;
+
+ const char *name()const;
+ Staff_symbol(int lines);
+ virtual Molecule* brew_molecule_p() const;
+ void set_extent(PCol* p1, PCol* p2);
+ virtual void do_print()const;
+ virtual Spanner *do_break_at( PCol *c1, PCol *c2) const;
+};
+#endif // STAFFSYM_HH
#include "staff.hh"
+/**
+ manage run-time info when walking staffcolumns such as: key,
+ meter, pending beams & slurs
+ */
struct Staff_walker : public PCursor<Staff_column*> {
Staff * staff_l_;
PScore * pscore_l_;
int break_status;
- /****************/
+ /* *************** */
int priority() const; // Command
Moment when() const;
void process_command(Command *);
void operator++(int);
- /****************
+ /* ***************
VIRTUAL
- ****************/
+ *************** */
/// every time ++ is called
virtual void do_pre_move(){}
private:
Staff_walker(Staff_walker const&);
};
-/**
- manage run-time info when walking staffcolumns such as: key,
- meter, pending beams & slurs
- */
#endif // STAFFWALKER_HH
/*
- stcol.hh -- part of LilyPond
+ stcol.hh -- declare Staff_column
(c) 1996,97 Han-Wen Nienhuys
*/
Time_description *tdescription_;
- /****************/
+ /* *************** */
- Staff_column(Score_column*s);
- bool mus() const;
+ Staff_column(Score_column*);
+ bool musical_b() const;
Moment when() const;
void add(Voice_element*ve);
void OK() const;
- /****************************************************************
+ /*
VIRTUAL
- ****************************************************************/
+ */
virtual void setup_requests()=0;
virtual ~Staff_column();
private:
- Staff_column(Staff_column const&){}
+ Staff_column(Staff_column const&);
};
#include "moment.hh"
/// the rule attached to the ball
+/**
+ takes care of:
+
+ \begin{itemize}
+ \item the rule
+ \item the flag
+ \item up/down position.
+ \end{itemize}
+ */
+
struct Stem : Item {
/*
/// rhythmical length
int staff_center;
// extent of the stem (positions)
- Real bot, top;
/**
fractional, since Beam has to adapt them.
*/
+ Real bot, top;
Real stemlen;
/// flagtype? 4 none, 8 8th flag, 0 = beam.
int flag;
///geen gedonder, jij gaat onder
- int dir;
/**
-1 stem points down, +1: stem points up
*/
+ int dir;
Real stem_xoffset;
Array<Notehead*> heads;
- /****************/
+ /* *************** */
Stem(int center); //, Moment duration);
/// ensure that this Stem also encompasses the Notehead #n#
Molecule* brew_molecule_p() const;
};
-/**
- takes care of:
-
- \begin{itemize}
- \item the rule
- \item the flag
- \item up/down position.
- \end{itemize}
- */
-
#endif
--- /dev/null
+/*
+ stembeamreg.hh -- part of LilyPond
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef STEMBEAMREG_HH
+#define STEMBEAMREG_HH
+#include "register.hh"
+
+struct Stem_beam_register : Request_register {
+ Stem * stem_p_;
+ Beam * beam_p_;
+ Beam_req * beam_req_l_;
+ Stem_req * stem_req_l_;
+ Beam_req * start_req_l_;
+ bool end_beam_b_;
+ Rhythmic_grouping *current_grouping;
+ int default_dir_i_;
+
+ /* *************** */
+ Stem_beam_register(Complex_walker*);
+ ~Stem_beam_register();
+ void set_dir(int dir_i_);
+ virtual bool try_request(Request*);
+ virtual void process_request();
+ virtual void acknowledge_element(Staff_elem_info);
+ virtual void do_pre_move_process();
+ virtual void do_post_move_process();
+};
+#endif // STEMBEAMREG_HH
#include "scalar.hh"
/// parameter substitution in TeXstrings
-String
-substitute_args(String source, Array<String> args);
/**
- this structure provides a simple macro mechanism:
+ this function provides a simple macro mechanism:
if source == "tex%bla%", then
- eval({"X","Y"}) == "texXblaY"
+ substitute_args(source, {"X","Y"}) == "texXblaY"
*/
+String
+substitute_args(String source, Array<String> args);
/// parameter substitution in TeXstrings
String
char const* defined_ch_c_l_m;
- /*****************/
+ /* ****************/
virtual ~Text_def() {};
bool compare(const Text_def&);
Text_def();
int dir_i_;
Text_def* tdef_l_;
- /****************/
+ /* ***************/
const char * name() const;
virtual void set_default_pos();
Molecule* brew_molecule_p() const;
--- /dev/null
+/*
+ textreg.hh -- part of LilyPond
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+
+#ifndef TEXTREG_HH
+#define TEXTREG_HH
+#include "register.hh"
+
+struct Text_register : Request_register{
+ Text_item * text_p_;
+ int dir_i_;
+ /* *************** */
+ void set_dir(int dir_i);
+ Text_register(Complex_walker*);
+ virtual bool try_request(Request*);
+ virtual void process_request();
+ virtual void do_pre_move_process();
+};
+
+#endif // TEXTREG_HH
#include "textdef.hh"
/// a spanner which puts texts on top of other spanners.
+/**
+ Use for triplets, eentweetjes, ottava, etc.
+ */
struct Text_spanner : Spanner {
Text_def spec;
- Offset tpos;
+ Offset text_off_;
Directional_spanner*support;
- /****************/
+ /* *************** */
const char * name() const;
virtual void do_pre_processing();
virtual void do_post_processing();
- Molecule* brew_molecule_p()const;
virtual Interval height() const ;
- void do_print() const;
+ virtual Molecule* brew_molecule_p()const;
+ virtual void do_print() const;
virtual Spanner* do_break_at(PCol*,PCol*)const;
Text_spanner();
void set_support(Directional_spanner*);
};
-/**
- Use for triplets, eentweetjes, ottava, etc.
- */
-
#endif // TEXTSPANNER_HH
/// idem
int bars;
- /****************/
+ /* *************** */
void set_cadenza(bool);
void OK() const;
Time_description(Moment, const Time_description*);
#include "string.hh"
/// TeX output
+/**
+ Use this class for writing to a TeX file.
+ It counts braces to prevent nesting errors, and
+ it will add a comment sign before each newline.
+ */
struct Tex_stream {
bool outputting_comment;
ostream *os;
private:
Tex_stream(Tex_stream const&);
};
-/**
- Use this class for writing to a TeX file.
- It counts braces to prevent nesting errors, and
- it will add a comment sign before each newline.
- */
#endif
#include "moment.hh"
/// class for horizontal stuff.
+/**
+
+ Voice is a ordered row of Voice_elements. It is strictly horizontal:
+ you cannot have two rhythmic elements running parallel in a Voice
+
+ */
+
struct Voice {
IPointerList<Voice_element *> elts;
Moment start;
- /****************/
+ /* *************** */
Moment when(const Voice_element*)const;
Moment last() const;
Voice();
void print() const;
void set_default_group(String id);
};
-/**
-
- Voice is a ordered row of Voice_elements. It is strictly horizontal:
- you cannot have two rhythmic elements running parallel in a Voice
-
- */
-
/// one horizontal bit.
+/** Apart from being a container for the requests, Voice_element is nothing
+ */
struct Voice_element {
Moment duration;
char const* defined_ch_c_l_m;
const Voice *voice_l_;
IPointerList<Request*> reqs;
- /****************/
+ /* *************** */
void add(Request*);
Voice_element();
void print ()const;
void set_default_group(String id);
};
-/** Apart from being a container for the requests, Voice_element is nothing
- */
#endif
#define VOICEGROUP_HH
#include "proto.hh"
-#include "register.hh"
-#include "varray.hh"
#include "string.hh"
struct Voice_registers {
- Notehead_register head_reg_;
- Slur_register slur_reg_;
+ Notehead_register *head_reg_;
+ Slur_register *slur_reg_;
Voice *voice_l_;
- /****************/
+ /* *************** */
+ void set_dir(int i);
static bool acceptable_request(Request*);
void pre_move_processing();
void post_move_processing();
- void announce_element(Staff_elem_info info);
+ void acknowledge_element(Staff_elem_info info);
Voice_registers(Complex_walker*,Voice*);
+ ~Voice_registers();
bool try_request(Request*);
void process_requests();
};
struct Voice_group_registers {
String group_id_str_;
- Text_register text_reg_;
- Stem_beam_register stem_beam_reg_;
- Script_register script_reg_;
+ Text_register* text_reg_;
+ Stem_beam_register* stem_beam_reg_;
+ Script_register *script_reg_;
Complex_walker * walk_l_;
int dir_i_;
- /****************/
+ /* *************** */
+ void set_dir(int i);
static bool acceptable_request(Request*);
void pre_move_processing();
void post_move_processing();
- void announce_element(Staff_elem_info info);
+ void acknowledge_element(Staff_elem_info info);
Voice_group_registers(Complex_walker*, String id = "");
+ ~Voice_group_registers();
void process_requests();
bool try_request(Request*);
};
"||" "\finishbar" 0pt 2pt -8pt 8pt
":|" "\repeatbar" -4pt 0pt -8pt 8pt
"|:" "\startrepeat" 0pt 4pt -8pt 8pt
- ":|:" "\repeatbarstartrepeat" 0pt 8pt -8pt 8pt
+ ":|:" "\repeatbarstartrepeat" 0pt 16pt -8pt 8pt
}
"linestaf" "\linestafsym{%}{%}"
"stem" "\stem{%}{%}"
"fill" "\hbox{}"
+ "crescendo" "\crescendosym{%}" 0pt 0pt -3pt 3pt
+ "decrescendo" "\decrescendosym{%}" 0pt 0pt -3pt 3pt
}
"dots" = table {
a b ,c
a b c-*
a b c&
+ { a-. b-. }
$
}
@
}
+
+include "this-is-hopefully-a-nonexisting-file"
+
score {
staff {
lyric music { bla }
geometric 1.4
unitspace 3.0 cm
}
- staff { ritme }
+% staff { ritme }%broken for now
staff { melody }
commands {
meter 4* 4
%%11
% { a4\stemup( f2\stemdown } ) 'd4\stemup
% { 'cis4\stemup-. e4\stemdown }
- { \music { a4 'd4 'cis4-. } \music { f2 e4 } } |
+ { \multivoice \music {\stem{1} a4(\stem{1}) 'd4 'cis4-. } \music { \stem{-1} f2 e4 } } |
%%12
% { 'g^4 d\stemdown } (^ 'f 'e ) 'f 'd^3(^ ) ='c ] |
{ [ 'g^"4" d } 'f 'e 'f 'd^"3"( ) 'c ] |
% { bes2\stemup g4\stemdown } ( ) f4
% { 'c4\stemup e4\stemdown }
% { bes2 g4 } f4 { 'c4 e4 } | % \clef "alto" |
- { \music { bes2 'c4 } \music { g4 f4 e4 } } |
+ { \multivoice
+ \music { \stem{1} bes2 'c4 }
+ \music { \stem{-1} g4(\stem{-1}) f4 e4 }% ugh
+ } |
%%%14
%% [ { a( f } ) g a f ] { 'd4-\upbow e4 `bes4\stemdown } |
{ [ a f } g a f ] { 'd4-\upbow e4 `bes4 } |
%%%21
%% { 'd4\stemup g2\stemdown } (^ ) 'cis4\stemup { 'd4\stemup =f4\stemdown } |
% { 'd4 g2 } 'cis4 { 'd4 f4 } |
- { \music { 'd4 'cis4 'd4 } \music { g2 f4 } } |
+ { \multivoice \music {\stem{1} 'd4(\stem{1} ) 'cis4 'd4 } \music { \stem{-1} g2 f4 } } |
%%%22
%% [ { g( cis } )f g e ] { f4 d4 } |
{ [ g cis } f g e ] { f4 d4 } |
symboltables { table_sixteen }
width 195mm
% unitspace 12mm % this should do, really
- unitspace 8mm % to get lily to use only three lines
- output "scsii-menuetto.out"
- }
-}
-% scsii-menuetto.ly
-%
-% Solo Cello Suites
-% J. S. Bach
-%
-% Suite II part v
-% Menuetto I
-%
-% Copyright (c) 1995,1996,1997 Jan Nieuwenhuizen <jan@digicash.com>
-%
-% The purpose of this file is to demonstrate features of LilyPond.
-% (there is an accompanying LaTeX file, scsii-menuetto.tex)
-%
-
-% \lefttitle{Menuetto}
-% \tempo{Moderato}
-% \metron{4=120}
-%
-% \meter{3/4}
-% \key\F % key is F ( f-major )
-% \clef\alto % use alto clef
-% \duration8 % default duration is 'eight note
-%
-% \verb{\nobarnumbers} % issue MusiXTeX command
-% \barnumbering0
-% \slope{30} % Fool MusiXTeX into 30 / 10 steeper beam
-% \stemlength3 % shorter stemlength
-% % because piece is set very tightly
-%%1 % double comments are included in .tex file
-ii_menuetto = music {
- $
- \octave{}
- \duration{8}
- { a2 f2 d2_"\f" } bes4-. |
-%%2
- { [ bes^"1" e c_"2"_"4" }
-% (^ )
- a bes-. g-. ] a4-.^"4" |
-%%3
-% { d4 `bes4-.\stemup } stemup: 2 voices?
- { d4 `bes4-. } g4-. [ f-. e-. ] |
-%%4
-% { f `a } (^ e ) d cis-. `b-. `a-. ]
-% [ f ( e ) d cis-. `b-. `a-. ]
- { [ f `a } e d cis-. `b-. `a-. ]
-%%5
- { a2 f2 d2 } bes4-. | % @bes4-. |
-%%6
-% { bes( e } ) a
- { [ bes e } a bes-. g-. ]
- 'c4-. | % ='c4-. |
-%%7
- { a4-. f4}
-% { 'd4-.-\upbow f4 `bes4\stemdown }
- { 'd4-.-\upbow f4 `bes4 }
-% { 'e4-.-\downbow g4 `g4\stemdown } |
- { 'e4-.-\downbow g4 `g4 } |
-%%8
-% { 'cis2.-\upbow e2. `a2.\stemdown } :||:
- { 'cis2.-\upbow e2. `a2. } | % :||:
-%%9
-% \clef "violin"
-% { 'e2 a2_f\stemdown }
- { 'e2 a2_"\f" }
- [ 'd( 'e16 )'f16 ] |
-%%10
-% [ { 'e( g } ) 'd 'cis_{ }_{ }_2 'e
- { [ 'e g } 'd 'cis_"2" 'e a( )g ] |
-%%11
-% { a4\stemup( f2\stemdown } ) 'd4\stemup
-% { 'cis4\stemup-. e4\stemdown }
- { \music { a4 'd4 'cis4-. } \music { f2 e4 } } |
-%%12
-% { 'g^4 d\stemdown } (^ 'f 'e ) 'f 'd^3(^ ) ='c ] |
- { [ 'g^"4" d } 'f 'e 'f 'd^"3"( ) 'c ] |
-% %13
-% { bes2\stemup g4\stemdown } ( ) f4
-% { 'c4\stemup e4\stemdown }
-% { bes2 g4 } f4 { 'c4 e4 } | % \clef "alto" |
- { \music { bes2 'c4 } \music { g4 f4 e4 } } |
-%%%14
-%% [ { a( f } ) g a f ] { 'd4-\upbow e4 `bes4\stemdown } |
- { [ a f } g a f ] { 'd4-\upbow e4 `bes4 } |
-%%%15
-%% { 'c4-\downbow f4 `a4\stemdown } [ bes( )a g a ] |
-% { 'c4-\downbow f4 `a4 } [ bes( )a g a ] |
-%%%16
- [ f( e )f a-. g-. bes-. ] |
-%% \tighten % use one line less
-%% \newline % start new line
-%% |
-%%%17
-%% { a2^0^\tr fis2_3 } bes4 |
- { a2^"0" fis2_"3" } bes4 |
-%%%18
-%% [ { 'c( es } ) bes 'c a ] fis4^\tr |
- { [ 'c es } bes 'c a ] fis4 |
-%%%19
-%% { 'd4-\downbow g4 `bes4\stemdown } { 'c4-\upbow g4 c4\stemdown } [ { bes d } a ] |
- { 'd4-\downbow g4 `bes4 } { 'c4-\upbow g4 c4 } { [ bes d } a ] |
-%%%20
-%% [ { 'c( d `g } bes a ) bes g ( ) bes ] |
- { [ 'c d `g } bes a bes g( )bes ] |
-%%%21
-%% { 'd4\stemup g2\stemdown } (^ ) 'cis4\stemup { 'd4\stemup =f4\stemdown } |
-% { 'd4 g2 } 'cis4 { 'd4 f4 } |
- { \music { 'd4 'cis4 'd4 } \music { g2 f4 } } |
-%%%22
-%% [ { g( cis } )f g e ] { f4 d4 } |
- { [ g cis } f g e ] { f4 d4 } |
-%%%23
-%% [ `g g ] { e4.\stemup^\tr `a4.\stemdown } d\stemup-\upbow |
- [ `g g ] { e4. `a4. } d-\upbow |
-%%%24
-%% { d2.^{fine} `a2. `d2.\stemup_{ }_{ }_{3 mins.}} s4 :||
-%% { \textstyle "italic" d2.^"fine" `a2. \textstyle "roman" `d2._"3 mins."} | % :||
- { d2.^"fine" `a2. `d2._"3 mins."} | % :||
-%% \tighten % use one line less
- $
-}
-
-score {
- staff {
- melodic
- music { ii_menuetto }
- commands {
- key $bes$
- clef "alto"
- skip 8:0
- clef "violin"
- skip 5:0
- clef "alto"
- skip 12:0
- }
- }
- commands {
- meter 3*4
- skip 8:0
- bar ":|:"
-% clef "violin"
- skip 5:0
-% \clef "alto"
- skip 12:0
- bar ":||"
- }
- paper {
- symboltables { table_sixteen }
- width 195mm
-% unitspace 12mm % this should do, really
- unitspace 8mm % to get lily to use only three lines
+ unitspace 9mm % to get lily to use only three lines
+ geometric 1.4
output "scsii-menuetto.out"
}
}
dux = music { $
\duration { \last }
- \stem{-1} r8 ['c16 b] ['c8 g] [as 'c16 b] ['c8 'd] |
+ r8-"dux" \stem{-1} ['c16 b] ['c8 g] [as 'c16 b] ['c8 'd] |
[g 'c16 b] ['c8 'd] [f16 g] as4 [g16 f] |
[es 'c b a] [ g f es d] [c8 'es 'd 'c] |
[bes a bes 'c] [fis g a fis] |
r1 r1
\stem{1}
\octave {'}
- r8 [g16 fis] [g8 c] [es g16 f] [g8 a]|
+ r8-"comes" [g16 fis] [g8 c] [es g16 f] [g8 a]|
[d8 g16 fis] [g8 a] [c16 d] es4 [d16 c] |
[`bes8 es16 d] [es8 `g8] [`as f16 es] [f8 `a] |
[`bes8 g16 f] [g8 `b] [c8 d16 es] f4( |
bassdux = music { $
r1 r1 r1 r1 r1 r1
- \stem{1} \octave { }
- r8 [c16 B] [c8 G] [As c16 Bes] [c8 d] |
+ \octave { }
+ r8 [c16 B] [c8 G] [As c16 B] [c8 d] |
[G c16 B] [c8 d] [F16 G] As4 [G16 F] | $
}
meter 4*4
skip 8:0
}
- paper { unitspace 2.5cm
- geometric 1.1
+ paper { %unitspace 2.5cm
+ %geometric 1.4
}
}
\ No newline at end of file
}
\def\musixcalc{
- \interlinedist=\fontdimen5\musicfnt
- \smallspace=.3\interlinedist
+ \interlinedist=\fontdimen5\musicfnt
+ \smallspace=.3\interlinedist
\interstaffrule=\balkhoog
\advance\interstaffrule by-\staffrulethickness
\divide\interstaffrule by 4
\def\beamslope#1#2{{\count0=#2\advance\count0 by#1\musicfnt\char\count0}}
\def\rulesym#1#2{\vrule height #1 width #2}
-
+\def\crescendosym#1{\count0=84\advance\count0 by #1}
+\def\decrescendosym#1{\count0=116\advance\count0 by #1}
\def\settext#1{\textfont #1}
\def\setitalic#1{\italicfont #1}
Real miny;
int no_beams;
- ///////////////
Stem_info(){}
Stem_info(const Stem*);
}
-/****************/
+/* *************** */
Offset
Beam::center()const
assert(status >= POSTCALCED);
Real w=(paper()->note_width() + width().length())/2.0;
- return Offset(w, (left_pos + w* slope)*paper()->interline());
+ return Offset(w, (left_pos + w* slope)*paper()->internote());
}
{
slope = 0;
left_pos = 0.0;
- dir =0;
}
void
int d = i->get_default_dir();
dirs[(d+1)/2] ++;
}
- dir = (dirs[0] > dirs[1]) ? -1 : 1;
+ dir_i_ = (dirs[0] > dirs[1]) ? -1 : 1;
for (iter_top(stems,i); i.ok(); i++) {
- i->dir = dir;
+ i->dir = dir_i_;
}
}
dy = my -y;
}
left_pos += dy;
- left_pos *= dir;
- slope *= dir;
+ left_pos *= dir_i_;
+ slope *= dir_i_;
// URG
Real sl = slope*paper()->internote();
- paper()->lookup_p_->beam(sl, convert_dimen(20,"pt"));
+ paper()->lookup_p_->beam(sl, 20 PT);
slope = sl /paper()->internote();
}
left = (*stems.top()) ->pcol_l_;
right = (*stems.bottom())->pcol_l_;
assert(stems.size()>1);
- if (!dir)
+ if (!dir_i_)
set_default_dir();
}
Real dy=paper()->internote()*2;
Real stemdx = paper()->rule_thickness();
Real sl = slope*paper()->internote();
- paper()->lookup_p_->beam(sl, convert_dimen(20,"pt"));
+ paper()->lookup_p_->beam(sl, 20 PT);
Molecule leftbeams;
Molecule rightbeams;
a.translate(Offset (-w, -w * sl));
for (int j = 0; j < lhalfs; j++) {
Atom b(a);
- b.translate(Offset(0, -dir * dy * (lwholebeams+j)));
+ b.translate(Offset(0, -dir_i_ * dy * (lwholebeams+j)));
leftbeams.add( b );
}
}
int j = 0;
for (; j < rwholebeams; j++) {
Atom b(a);
- b.translate(Offset(0, -dir * dy * j));
+ b.translate(Offset(0, -dir_i_ * dy * j));
rightbeams.add( b );
}
w /= 4;
for (; j < rwholebeams + rhalfs; j++) {
Atom b(a);
- b.translate(Offset(0, -dir * dy * j));
+ b.translate(Offset(0, -dir_i_ * dy * j));
rightbeams.add(b );
}
#include "idealspacing.hh"
-#include "tstream.hh"
#include "score.hh"
#include "pscore.hh"
-#include "staff.hh"
#include "paper.hh"
#include "sccol.hh"
-#include "debug.hh"
+//#include "debug.hh"
#include "dimen.hh"
-/*
+/**
this needs A LOT of rethinking.
generate springs between columns.
for (int n=0; n < i->durations.size(); n++) {
Moment d = i->durations[n];
Real dist = paper_p_->duration_to_dist(d);
+ Real strength = i->durations[0]/i->durations[n];
+ assert(strength <= 1.0);
+
while (j->when() < d + i->when())
j++;
assert( j->when()== d+i->when());
- pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist);
-#if 0
- if (!j->musical_ && (j+1).ok()
- && ) {
- j++;
- pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist);
- }
-#endif
+ pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist, strength);
}
} else if (j.ok()) {
*/
Moment d = j->when() - i->when();
- Real dist = (d) ? paper_p_->duration_to_dist(d) :
- convert_dimen(2,"pt"); // todo
+ Real dist = (d) ? paper_p_->duration_to_dist(d) : 2 PT; // todo
pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist, (d) ? 1.0:1.0);
}
+/*
+ clef.cc -- implement Clef
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>,
+ Mats Bengtsson <matsb@s3.kth.se>
+*/
+
#include "clef.hh"
+#include "debug.hh"
Clef::Clef()
{
- clef_type= "violin";
- c0_pos = -2;
+ set_type("violin");
}
-void
-Clef::read(Array<Scalar>args)
+void
+Clef::set_type(String type_str)
{
- clef_type = args[0];
- if (clef_type == "violin") {
- c0_pos=-2;
- } else if (clef_type == "alto") {
- c0_pos = 4;
- } else if (clef_type == "tenor") {
- c0_pos = 6;
- } else if (clef_type == "bass") {
- c0_pos = 10;
+ clef_type_str_ = type_str;
+ if (clef_type_str_ == "violin") {
+ c0_position_i_= -2;
+ } else if (clef_type_str_ == "alto") {
+ c0_position_i_= 4;
+ } else if (clef_type_str_ == "tenor") {
+ c0_position_i_= 6;
+ } else if (clef_type_str_ == "bass") {
+ c0_position_i_= 10;
} else
- assert(false);
+ error("unknown clef type `"+clef_type_str_+"\'");
}
void
Clef_item::read(Clef k)
{
- read(k.clef_type);
+ read(k.clef_type_str_);
}
Molecule*
t += "_change";
Symbol s = paper()->lookup_p_->clef(t);
Molecule*output = new Molecule(Atom(s));
- output->translate(Offset(0, paper()->interline()/2 * y_off));
+ output->translate(Offset(0, paper()->internote() * y_off));
return output;
}
#include "complexstaff.hh"
#include "sccol.hh"
#include "debug.hh"
-#include "linepstaff.hh"
+
#include "clefitem.hh"
#include "bar.hh"
#include "meter.hh"
Interval
-citemlist_width(const Array<Item*> &its)
+itemlist_width(const Array<Item*> &its)
{
Interval iv ;
iv.set_empty();
assert(i);
staff_l_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_,
- staff_l_->theline_l_,breakst);
+ staff_l_->pstaff_l_,breakst);
if (breakst == BREAK_PRE - BREAK_PRE) {
Array<Item*> to_move(
- staff_l_->pscore_l_->select_items(staff_l_->theline_l_,
+ staff_l_->pscore_l_->select_items(staff_l_->pstaff_l_,
score_column_l_->pcol_l_->prebreak_p_));
- Interval column_wid = citemlist_width(to_move);
+ Interval column_wid = itemlist_width(to_move);
assert(!column_wid.empty());
for (int j=0; j < to_move.size(); j++) {
else if (breakst == 2)
c = c->postbreak_p_;
- Array<Item*> to_move(staff_l_->pscore_l_->select_items(staff_l_->theline_l_,
+ Array<Item*> to_move(staff_l_->pscore_l_->select_items(staff_l_->pstaff_l_,
c));
typeset_item(i, breakst);
- Interval column_wid = citemlist_width(to_move);
+ 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
-Complex_staff::set_output(PScore* ps )
+Complex_staff::set_output(PScore* pscore_l )
{
- theline_l_ = new Linestaff(NO_LINES,ps); // theline_l_ is added to pscore later.
- pscore_l_ = ps;
- pscore_l_->add(theline_l_);
+ pstaff_l_ = new PStaff(pscore_l); // pstaff_l_ is added to pscore later.
+ pscore_l_ = pscore_l;
+ pscore_l_->add(pstaff_l_);
}
#include "complexstaff.hh"
#include "sccol.hh"
#include "complexwalker.hh"
-#include "main.hh"
+#include "score.hh"
+#include "pscore.hh"
+#include "staffsym.hh"
-
-Complex_column::Complex_column(Score_column*s, Complex_staff *rs)
+Complex_column::Complex_column(Score_column*s, Complex_staff *staff_l)
: Staff_column(s)
{
- staff_l_ = rs;
+ staff_l_ = staff_l;
}
Complex_staff::Complex_staff()
{
- theline_l_ = 0;
+ pstaff_l_ = 0;
}
void
Complex_staff::walk()
{
for (Complex_walker sc(this); sc.ok(); sc++) {
- sc.col()->setup_requests();// TODO
+ sc.col()->setup_requests();
sc.process();
}
+ Staff_symbol *span_p = new Staff_symbol(5);
+
+
+ Score_column* col_last
+ =score_l_->find_col(score_l_->last(), false);
+ Score_column* col_first=
+ score_l_->find_col(0, false);
+ col_first->pcol_l_->set_breakable();
+ col_last->pcol_l_->set_breakable();
+
+ span_p->set_extent( col_first->pcol_l_->postbreak_p_,
+ col_last->pcol_l_->prebreak_p_);
+
+ pscore_l_->typeset_spanner(span_p, pstaff_l_);
}
#include "clef.hh"
#include "pscore.hh"
#include "complexstaff.hh"
-#include "sccol.hh"
#include "debug.hh"
#include "keyitem.hh"
#include "clefitem.hh"
#include "voicegroup.hh"
-#include "register.hh"
+#include "localkeyreg.hh"
#include "complexwalker.hh"
#include "misc.hh"
+Rhythmic_grouping
+parse_grouping(Array<Scalar> const &a)
+{
+ Array<int> r;
+ Array<Moment> grouplen_arr;
+ for (int i= 0 ; i < a.size()/2; ) {
+ r.push(a[i++]);
+ grouplen_arr.push(Moment(1,(int) a[i++]));
+ }
+ Moment here =0;
+
+ Array<Rhythmic_grouping*> children;
+ for (int i=0; i < r.size(); i++) {
+
+ Moment last = here;
+ here += grouplen_arr[i] * Rational(r[i]);
+ children.push(
+ new Rhythmic_grouping(MInterval(last, here), r[i] ));
+ }
+ return Rhythmic_grouping(children);
+}
+
void
-Complex_walker::do_INTERPRET_command(Command*com)
+Complex_walker::do_INTERPRET_command(Command*com_l)
{
- Array<Scalar> args(com->args);
+ Array<Scalar> args(com_l->args);
args.del(0);
- if (com->args[0] == "GROUPING") {
+ String com = com_l->args[0];
+
+ if (com == "GROUPING") {
default_grouping = parse_grouping(args);
- }else if (com->args[0] == "NEWMEASURE") {
+ }else if (com == "NEWMEASURE") {
local_key_.reset(key_);
- } else if (com->args[0] == "KEY") {
+ } else if (com == "KEY") {
if (col()->when() > Moment(0)) {
assert(!oldkey_undo);
typesetkey = key_.read(args);
local_key_.reset(key_);
- } else if (com->args[0] == "CLEF") {
- clef_.read(args);
+ } else if (com == "CLEF") {
+ clef_.set_type(args[0]);
} else {
- WARN << " ignoring INTERPRET command: " << com->args[0]<< "\n";
+ WARN << " ignoring INTERPRET command: " << com<< "\n";
}
}
for (int i = 0; i < announce_info_arr_.size(); i++){
Staff_elem_info info = announce_info_arr_[i];
for (iter_top(voice_reg_list_,j); j.ok(); j++) {
- j->announce_element(info);
+ j->acknowledge_element(info);
}
for (iter_top ( group_reg_list_, j); j.ok(); j++) {
- j->announce_element(info);
+ j->acknowledge_element(info);
}
local_key_reg_.acknowledge_element(info);
}
}
Voice_registers *
-Complex_walker::find_voice_reg(Voice*v_l)
+Complex_walker::find_voice_reg(Voice*v_l)const
{
for (iter_top(voice_reg_list_, i); i.ok(); i++) {
if (i->voice_l_ == v_l)
}
Voice_group_registers *
-Complex_walker::find_voice_group(Voice* v_l)
+Complex_walker::find_voice_group(Voice* v_l)const
{
if (!voice_group_map_.elt_query(v_l))
return 0;
}
Voice_group_registers *
-Complex_walker::find_voice_group(const char *id)
+Complex_walker::find_voice_group(const char *id)const
{
for (iter_top(group_reg_list_, i); i.ok(); i++)
if (i->group_id_str_ == id)
}
void
-Complex_walker::do_change_group(const Voice * v, String group_id_str)
+Complex_walker::do_change_group(Voice * v, String group_id_str)
{
voice_group_map_[v] = get_voice_group(group_id_str);
}
} else if (Voice_group_registers::acceptable_request(req)){
Voice_group_registers* reg_l = get_voice_group(voice_l);
b = reg_l->try_request(req);
-#if 0
- if (!b) {
- bool please_b = get_voice_group("")->try_request(req);
- b |= please_b;
- }
-#endif
}
if (!b)
if (!elem_p)
return;
if (elem_p->spanner())
- pscore_l_->typeset_spanner(elem_p->spanner(), staff()->theline_l_);
+ pscore_l_->typeset_spanner(elem_p->spanner(), staff()->pstaff_l_);
else
col()->typeset_item(elem_p->item());
}
Complex_walker::Complex_walker(Complex_staff*s)
- : Staff_walker(s, s->theline_l_->pscore_l_),
+ : Staff_walker(s, s->pstaff_l_->pscore_l_),
local_key_reg_(this)
{
oldkey_undo = 0;
j->post_move_processing();
local_key_reg_.post_move_processing();
}
+
+Array<Voice_registers*>
+Complex_walker::get_voice_regs(Voice_group_registers* group_regs_l) const
+ return l_arr;
+{
+ for (Assoc_iter<Voice*,Voice_group_registers*> i(voice_group_map_); i.ok(); i++) {
+ if (i.val() == group_regs_l)
+ l_arr.push(find_voice_reg(i.key()));
+ }
+}
return convert_dimen(dim.fvalue(), unit);
}
-const Real CM_TO_PT=72/2.54;
Real
convert_dimen(Real quant, String unit)
if (unit == "mm")
return quant*CM_TO_PT/10;
if (unit == "in")
- return quant * 72;
+ return quant * INCH_TO_PT;
error ("unknown length unit: `" + unit+"'");
}
Directional_spanner::Directional_spanner()
{
- dir = 0;
+ dir_i_ = 0;
}
-#include "script.hh"
-#include "request.hh"
-#include "beam.hh"
-#include "stem.hh"
-#include "register.hh"
-#include "grouping.hh"
-#include "complexwalker.hh"
-#include "debug.hh"
-#include "complexstaff.hh"
-#include "textspanner.hh"
-#include "textitem.hh"
-
-Stem_beam_register::Stem_beam_register(Complex_walker*w)
- :Request_register(w)
-{
- do_post_move_process();
- current_grouping = 0;
- beam_p_ = 0;
- set_dir(0);
- start_req_l_ = 0;
-}
-
-bool
-Stem_beam_register::try_request(Request*req_l)
-{
- if ( req_l->beam() ) {
- if (bool(beam_p_ ) == bool(req_l->beam()->spantype == Span_req::START))
- return false;
-
- if (beam_req_l_ && Beam_req::compare(*beam_req_l_ , *req_l->beam()))
- return false;
-
- beam_req_l_ = req_l->beam();
- return true;
- }
-
- if ( req_l->stem() ) {
- if (current_grouping && !current_grouping->child_fit_query(
- walk_l_->col()->tdescription_->whole_in_measure))
- return false;
-
- if (stem_req_l_ && Stem_req::compare(*stem_req_l_, *req_l->stem()))
- return false;
-
- stem_req_l_ = req_l->stem();
- return true;
- }
- return false;
-}
-
-void
-Stem_beam_register::process_request()
-{
- if (beam_req_l_) {
- if (beam_req_l_->spantype == Span_req::STOP) {
- end_beam_b_ = true;
- start_req_l_ = 0;
- } else {
- beam_p_ = new Beam;
- start_req_l_ = beam_req_l_;
-// walk_l_->announce_element(Staff_elem_info(beam_p_, ))
- current_grouping = new Rhythmic_grouping;
- if (beam_req_l_->nplet) {
- Text_spanner* t = new Text_spanner();
- t->set_support(beam_p_);
- t->spec.align_i_ = 0;
- t->spec.text_str_ = beam_req_l_->nplet;
- walk_l_->typeset_element(t);
- }
-
- }
- }
-
- if (stem_req_l_) {
- stem_p_ = new Stem(4);
- if (current_grouping)
- current_grouping->add_child(
- walk_l_->col()->tdescription_->whole_in_measure,
- stem_req_l_->duration());
-
- stem_p_->flag = stem_req_l_->balltype;
-
- if (beam_p_) {
- if (stem_req_l_->balltype<= 4)
- warning( "stem doesn't fit in Beam",
- stem_req_l_->defined_ch_c_l_m);
- else
- beam_p_->add(stem_p_);
- stem_p_->print_flag = false;
- } else {
- stem_p_->print_flag = true;
- }
-
- walk_l_->announce_element(Staff_elem_info(stem_p_,
- stem_req_l_, this));
- }
-}
-
-void
-Stem_beam_register::acknowledge_element(Staff_elem_info info)
-{
- if (!stem_p_)
- return;
-
- if (info.elem_p_->name() == String("Notehead") &&
- stem_req_l_->duration() == info.req_l_->rhythmic()->duration())
-
- stem_p_->add((Notehead*)info.elem_p_);
-}
-
-void
-Stem_beam_register::do_pre_move_process()
-{
- if (stem_p_) {
- if (default_dir_i_)
- stem_p_->dir = default_dir_i_;
-
- walk_l_->typeset_element(stem_p_);
- stem_p_ = 0;
- }
- if (beam_p_ && end_beam_b_) {
- walk_l_->default_grouping.extend(current_grouping->interval());
- beam_p_->set_grouping(walk_l_->default_grouping, *current_grouping);
- walk_l_->typeset_element(beam_p_);
- delete current_grouping;
- current_grouping = 0;
- beam_p_ = 0;
- }
- end_beam_b_ = false;
-}
-void
-Stem_beam_register::do_post_move_process()
-{
- stem_p_ = 0;
- beam_req_l_ = 0;
- stem_req_l_ = 0;
- end_beam_b_ = false;
-}
-
-Stem_beam_register::~Stem_beam_register()
-{
- if (beam_p_)
- warning("unterminated beam", start_req_l_->defined_ch_c_l_m);
-}
-
-void
-Stem_beam_register::set_dir(int i)
-{
- default_dir_i_ = i;
-}
-/****************/
-
-Script_register::Script_register(Complex_walker*w)
- : Request_register(w)
-{
- script_p_ = 0;
-}
-
-bool
-Script_register::try_request(Request *r_l)
-{
- if (!r_l->script())
- return false ;
-
- if (accepted_req_arr_.size()
- && Script_req::compare(
- *accepted_req_arr_[0]->script(), *r_l->script()))
-
- return false;
-
- accepted_req_arr_.push(r_l);
-
- return true;
-}
-void
-Script_register::process_request()
-{
- if (accepted_req_arr_.size() ) {
- script_p_ = new Script(accepted_req_arr_[0]->script(), 10);
- walk_l_->announce_element(
- Staff_elem_info(script_p_, accepted_req_arr_[0], this));
- }
-}
-
-void
-Script_register::acknowledge_element(Staff_elem_info info)
-{
- if (!script_p_)
- return;
- if (info.elem_p_->name() == String("Stem"))
- script_p_->set_stem((Stem*)info.elem_p_);
- else if (info.req_l_->rhythmic())
- script_p_->set_support(info.elem_p_->item());
-}
-
-void
-Script_register::do_pre_move_process()
-{
- if (script_p_){
- walk_l_->typeset_element(script_p_);
- script_p_ = 0;
- }
-}
-/******************/
-
-
-Text_register::Text_register(Complex_walker*w)
- : Request_register(w)
-{
- text_p_ = 0;
-}
-
-bool
-Text_register::try_request(Request*req_l)
-{
- if (!req_l->text())
- return false;
- if (accepted_req_arr_.size() &&
- Text_req::compare(*req_l->text(), *accepted_req_arr_[0]->text()))
-
- return false;
-
- accepted_req_arr_.push(req_l);
- return true;
-}
-
-void
-Text_register::process_request()
-{
-
- if (accepted_req_arr_.size()) {
- text_p_ = new Text_item(accepted_req_arr_[0]->text(), 10);
- walk_l_->announce_element(Staff_elem_info(text_p_,
- accepted_req_arr_[0], this));
- }
-}
-void
-Text_register::do_pre_move_process()
-{
- if (text_p_) {
- walk_l_->typeset_element(text_p_);
- text_p_ = 0;
- }
-}
--- /dev/null
+/*
+ headreg.cc -- part of LilyPond
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+#include "rest.hh"
+#include "notehead.hh"
+#include "headreg.hh"
+#include "paper.hh"
+#include "complexwalker.hh"
+
+
+Notehead_register::Notehead_register(Complex_walker*w_l)
+ :Request_register(w_l)
+{
+ note_p_ = 0;
+ set_dir(0);
+}
+
+bool
+Notehead_register::try_request(Request *req_l)
+{
+ if (req_l->note() || req_l->rest())
+ accepted_req_arr_.push(req_l);
+ else
+ return false;
+
+ return true;
+}
+void
+Notehead_register::set_dir(int d)
+{
+ dir_i_ = d;
+}
+
+void
+Notehead_register::process_request()
+{
+ if (!accepted_req_arr_.size())
+ return;
+
+ Request* req_l = accepted_req_arr_.top();
+ if (req_l->note()) {
+ Notehead*n_p = new Notehead(8); // ugh
+ note_p_ = n_p;
+ n_p->set_rhythmic(req_l->rhythmic());
+ n_p->position = req_l->note()->height() +
+ walk_l_->clef_.c0_position_i_;
+ } else {
+ note_p_ = new Rest ( req_l->rhythmic()->balltype,
+ req_l->rhythmic()->dots);
+ if (req_l->rhythmic()->balltype <= 2)
+ note_p_->translate(
+ Offset(0,
+ 6 * paper()->internote()));
+ }
+ Staff_elem_info itinf(note_p_,req_l,this);
+ announce_element(itinf);
+}
+
+void
+Notehead_register::do_pre_move_process()
+{
+ if (note_p_) {
+ if (dir_i_ && note_p_->name() == String("Rest"))
+ note_p_->translate(Offset(0, 4*dir_i_ * paper()->internote()));
+ typeset_element(note_p_);
+ note_p_ = 0;
+ }
+}
}
}
}
-/****************/
+/* *************** */
void
Input_cursor::find_moment(Moment w)
-/****************/
+/* *************** */
void
Input_commands::find_moment(Moment m)
{
}
#endif
}
-/****************/
+/* *************** */
Moment
Input_cursor::when()const
mtor << "}\n";
}
-/****************/
+/* *************** */
void
Complex_music::add(Input_music*v)
for (iter_top(elts,i); i.ok(); i++)
i->set_default_group(g);
}
-/****************************************************************/
+/* *************************************************************** */
void
Music_voice::print() const
-/****************/
+/* *************** */
void
Music_general_chord::add_elt(Voice_element*v)
return l;
}
-/****************/
+/* *************** */
void
Multi_voice_chord::set_default_group(String g)
}
-/****************/
+/* *************** */
void
Voice_list::translate_time(Moment x)
delete paper_;
paper_ = p;
}
+
Input_score::Input_score(Input_score const&)
{
assert(false);
Input_score::~Input_score()
{
- // TODO!
-//should fix paper/symtabs to allow this deletion.
-// delete paper_;
+ delete paper_;
}
Input_score::Input_score()
#include "inputstaff.hh"
#include "inputcommand.hh"
#include "staffcommands.hh"
-#include "melodicstaff.hh"
-#include "rhythmstaff.hh"
-#include "lyricstaff.hh"
#include "staff.hh"
#include "complexstaff.hh"
#include "lexer.hh"
+#include "lyricstaff.hh"
void
Input_staff::add(Array<Input_command*> &s)
Input_staff::parse(Score*score_l)
{
Staff *p=0;
-
+#if 0
if (type == "simple")
p = new Melodic_staff;
- else if (type == "melodic")
- p = new Complex_staff;
else if (type == "rhythmic")
p = new Rhythmic_staff;
+ else
+#endif
+
+ if (type == "melodic")
+ p = new Complex_staff;
else if (type == "lyric")
p = new Lyric_staff;
else
const int FLAT_TOP_PITCH=2; /* fes,ges,as and bes typeset in lower octave */
const int SHARP_TOP_PITCH=4; /* ais and bis typeset in lower octave */
+
NAME_METHOD(Keyitem);
+
Keyitem::Keyitem(int c)
{
c_position = c;
void
Keyitem::read(const Clef& c)
{
- c_position=(c.c0_pos+70)%7;
+ int octaves =(abs(c.c0_position_i_) / 7) +1 ;
+ c_position=(c.c0_position_i_ + 7*octaves)%7;
}
Keyitem::brew_molecule_p()const
{
Molecule*output = new Molecule;
- Real inter = paper()->interline()/2;
+ Real inter = paper()->internote();
for (int i =0; i < pitch.size(); i++) {
Symbol s= paper()->lookup_p_->accidental(acc[i]);
#include "parser.hh"
#include "debug.hh"
#include "inputscore.hh"
+#include "parseconstruct.hh"
#include "main.hh"
%}
<incl>[ \t]* { /* eat the whitespace */ }
<incl>\"[^"]*\"+ { /* got the include file name */
String s (YYText()+1);
- s = s.left(s.len()-1);
+ s = s.left(s.len()-1);
+ defined_ch_c_l = here_ch_c_l() - String( YYText() ).len() - 1;
new_input(s);
yy_pop_state();
}
+++ /dev/null
-#include "linepstaff.hh"
-#include "molecule.hh"
-#include "symbol.hh"
-#include "lookup.hh"
-#include "dimen.hh"
-#include "paper.hh"
-#include "pscore.hh"
-
-Linestaff::Linestaff(int l, PScore *s)
- : PStaff(s)
-{
- nolines = l;
-}
-
-void
-Linestaff::brew_molecule_p(Real width)
-{
- Atom a = pscore_l_->paper_l_->lookup_p_->linestaff(nolines,width);
- stafsym_p_ = new Molecule(a);
-}
-
-
-
-
-
-
-
const Real COLFUDGE=1e-3;
-//#define COLFUDGE 1e-3
+
bool
Spacing_problem::contains(const PCol *w)
{
}
-/*****************/
+/* **************** */
void
Colinfo::print() const
Molecule*octmol = 0;
int lastoct = -100;
for (int i = 0; i < accs.size(); i++) {
+ // do one octave
if (accs[i].octave != lastoct) {
if (octmol){
- Real dy =lastoct*7*paper()->interline()/2;
+ Real dy =lastoct*7*paper()->internote();
octmol->translate(Offset(0, dy));
output->add(*octmol);
delete octmol;
lastoct = accs[i].octave;
Symbol s =paper()->lookup_p_->accidental(accs[i].acc);
Atom a(s);
- Real dy = (accs[i].name + c0_position) * paper()->interline()/2;
+ Real dy = (accs[i].name + c0_position) * paper()->internote();
a.translate(Offset(0,dy));
octmol->add_right(a);
}
if (octmol){
- Real dy =lastoct*7*paper()->interline()/2;
+ Real dy =lastoct*7*paper()->internote();
octmol->translate(Offset(0, dy));
output->add(*octmol);
delete octmol;
--- /dev/null
+/*
+ localkeyreg.cc -- implement Local_key_register
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "localkeyreg.hh"
+#include "localkeyitem.hh"
+#include "complexwalker.hh"
+
+Local_key_register::Local_key_register(Complex_walker*w)
+ : Request_register(w)
+{
+ key_item_p_ = 0;
+}
+bool
+Local_key_register::try_request(Request*)
+
+{
+ return false;
+}
+
+void
+Local_key_register::process_request()
+{
+}
+void
+Local_key_register::do_pre_move_process()
+{
+ if (key_item_p_) {
+ walk_l_->typeset_element(key_item_p_);
+ key_item_p_ = 0;
+ }
+}
+void
+Local_key_register::acknowledge_element(Staff_elem_info info)
+{
+ if (info.req_l_->melodic()) {
+ Melodic_req * melodic_l_ = info.req_l_->melodic();
+
+ if( melodic_l_->forceacc ||
+ walk_l_->local_key_.oct(melodic_l_->octave).acc(melodic_l_->notename)
+ != melodic_l_->accidental) {
+ Item * support_l_ = info.elem_p_->item();
+
+
+ if (!key_item_p_) {
+ key_item_p_ = new Local_key_item(walk_l_->clef_.c0_position_i_);
+ key_item_p_->c0_position = walk_l_->clef_.c0_position_i_;
+ }
+
+ key_item_p_->add(melodic_l_);
+ key_item_p_->add(support_l_);
+ walk_l_->local_key_.oct(melodic_l_->octave)
+ .set(melodic_l_->notename, melodic_l_->accidental);
+ }
+ }
+}
return s;
}
-/****************/
+/* *************** */
Real
Lookup::internote()
return ret;
}
-
+Symbol
+Lookup::hairpin(Real &wid, bool decresc)
+{
+ int idx = rint(wid / 6 PT);
+ if(!idx) idx ++;
+ wid = idx*6 PT;
+ String idxstr = (decresc)? "decrescendosym" : "crescendosym";
+ Symbol ret=(*symtables_)("param")->lookup(idxstr);
+
+ Array<String> a;
+ a.push(idx);
+ ret.tex = substitute_args(ret.tex, a);
+ ret.dim.x = Interval(0,wid);
+ return ret;
+}
Symbol
Lookup::linestaff(int lines, Real wid)
Lookup::meter(Array<Scalar> a)
{
Symbol s;
- s.dim.x = Interval( convert_dimen(0,"pt"),
- convert_dimen(10,"pt"));
- s.dim.y = Interval(0, convert_dimen(20,"pt") ); // todo
+ s.dim.x = Interval( 0 PT, 10 PT);
+ s.dim.y = Interval(0, 20 PT); // todo
String src = (*symtables_)("param")->lookup("meter").tex;
s.tex = substitute_args(src,a);
return s;
#include "pscore.hh"
#include "main.hh"
-Lyric_column::Lyric_column(Score_column*s, Lyric_staff* lstaff_l)
+Lyric_column::Lyric_column(Score_column* s, Lyric_staff* lstaff_l)
: Staff_column(s)
{
lstaff_l_ = lstaff_l;
}
}
-Interval itemlist_width(const Array<Item*> &its);
-
void
-Lyric_column::typeset_item(Item *i, int breakst)
-{
- assert(i);
-
+Lyric_column::typeset_item(Item *i)
+{
lstaff_l_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_,
- lstaff_l_->line_pstaff_p_,breakst);
-
- if (breakst == BREAK_PRE - BREAK_PRE) {
-
- Array<Item*> to_move(
- lstaff_l_->pscore_l_->select_items(lstaff_l_->line_pstaff_p_,
- score_column_l_->pcol_l_->prebreak_p_));
- Interval column_wid = itemlist_width(to_move);
- assert(!column_wid.empty());
-
- for (int j=0; j < to_move.size(); j++) {
- to_move[j]->translate(Offset(-column_wid.right, 0));
- }
- }
+ lstaff_l_->pstaff_l_);
}
Word_info::Word_info()
#include "command.hh"
#include "lyricstaff.hh"
#include "lyriccolumn.hh"
-#include "linepstaff.hh"
#include "sccol.hh"
#include "lyricwalker.hh"
#include "pscore.hh"
-
-
Lyric_staff::Lyric_staff()
{
- line_pstaff_p_ = 0;
+ pstaff_l_=0;
}
Staff_column*
}
void
-Lyric_staff::set_output(PScore*ps)
+Lyric_staff::set_output(PScore*pscore_l)
{
- line_pstaff_p_ = new Linestaff(0,ps);
- pscore_l_ = ps;
- pscore_l_->add(line_pstaff_p_);
+ pstaff_l_ = new PStaff(pscore_l);
+ pscore_l_ = pscore_l;
+ pscore_l_->add(pstaff_l_);
}
void
Lyric_staff::walk()
{
for (Lyric_walker lcols(this); lcols.ok(); lcols++) {
- lcols.lcol_l()->setup_requests();// TODO
+ lcols.lcol_l()->setup_requests();
lcols.process();
}
}
-//
-// what about
-// #include "flower.hh"
-// #include "lily.hh"
-//
-// or should we first devide lily/src up ?
-// HWN: huh?
-
#include "request.hh"
#include "voice.hh"
#include "pscore.hh"
#include "lyricstaff.hh"
#include "lyricwalker.hh"
-#include "sccol.hh"
+//#include "sccol.hh"
#include "debug.hh"
#include "lyricitem.hh"
void
Lyric_walker::do_INTERPRET_command(Command* )
{
-// WARN << "command for Lyrics found\n";
}
void
Lyric_walker::do_TYPESET_command(Command* )
{
-// WARN << "command for Lyrics found\n";
}
void
}
Lyric_walker::Lyric_walker(Lyric_staff* lstaff_l)
- : Staff_walker(lstaff_l, lstaff_l->line_pstaff_p_->pscore_l_)
+ : Staff_walker(lstaff_l, lstaff_l->pstaff_l_->pscore_l_)
{
reset();
}
+++ /dev/null
-#include "melodicstaff.hh"
-#include "keyitem.hh"
-#include "stem.hh"
-#include "rest.hh"
-#include "notehead.hh"
-#include "paper.hh"
-#include "molecule.hh"
-#include "linepstaff.hh"
-//#include "rhythmstaff.hh"
-#include "sccol.hh"
-#include "localkeyitem.hh"
-#include "request.hh"
-
-const int NO_LINES=5;
-
-
-void
-Melodic_staff::set_output(PScore*ps)
-{
- theline_l_ = new Linestaff(NO_LINES,ps); // theline_l_ is added to pscore later.
- Simple_staff::set_output(ps);
-}
-
-
-Notehead*
-Melodic_staff::get_notehead(Note_req *rq, int bottom)
-{
- Notehead *n =new Notehead((NO_LINES-1)*2);
- n->set_rhythmic(rq->rhythmic());
- n->position = rq->note()->height() + bottom;
- n->defined_ch_c_l_m = rq->defined_ch_c_l_m;
- return n;
-}
-
-Item *
-Melodic_staff::get_TYPESET_item(Command*com)
-{
- if (com->args[0] == "KEY") {
- return new Keyitem(NO_LINES); // urgh. depends on clef.
- } else
- return Simple_staff::get_TYPESET_item(com);
-}
-
-Stem *
-Melodic_staff::get_stem(Stem_req*rq)
-{
- Stem * s = new Stem(NO_LINES-1);
- s->flag = rq->balltype;
- return s;
-}
-
-Rest*
-Melodic_staff::get_rest(Rest_req*rq)
-{
- Rest*r = Simple_staff::get_rest(rq);
- if (rq->balltype <= 2)
- r->translate(Offset(0, NO_LINES * paper()->internote()));
- return r;
-}
-
-Local_key_item*
-Melodic_staff::get_local_key_item()
-{
- return new Local_key_item(-2);
-}
-
return substitute_args(s, a);
}
-/****************/
+/* *************** */
String
Molecule::TeXstring() const
"bar", BAR,
"cadenza", CADENZA,
"clef", CLEF,
- "cm", CM,
+ "cm", CM_T,
"command", COMMAND,
"commands", COMMANDS,
"duration", DURATIONCOMMAND,
"geometric", GEOMETRIC,
"goto", GOTO,
- "in", IN,
+ "in", IN_T,
"key", KEY,
"mark", MARK,
"meter", METER,
- "mm", MM,
+ "mm", MM_T,
"multivoice", MULTIVOICE,
"octave", OCTAVECOMMAND,
"output", OUTPUT,
"partial", PARTIAL,
"paper", PAPER,
"plet", PLET,
- "pt", PT,
+ "pt", PT_T,
"score", SCORE,
"script", SCRIPT,
"skip", SKIP,
/*
could use cleanup
*/
- #include <ctype.h>
+#include <ctype.h>
#include "lexer.hh"
#include "string.hh"
#include "real.hh"
parse_pitchmod(pitch, i, oct, forceacc);
rq->notename =notename[0];
rq->accidental = notename[1];
- rq->octave = oct;
+ rq->octave = oct + notename[2];
rq->forceacc = forceacc;
rq->balltype = dur;
rq->dots = dots;
get_script_req(int d , Script_def*def)
{
Script_req* script_req_p = new Script_req(d, def);
- script_req_p->defined_ch_c_l_m = defined_ch_c_l;
+// script_req_p->defined_ch_c_l_m = req_defined_ch_c_l;
+ // all terminal symbols, rather set directly here:
+ script_req_p->defined_ch_c_l_m = lexer->here_ch_c_l();
return script_req_p;
}
extremal = 0;
defined_ch_c_l_m = 0;
}
+
void
Notehead::set_rhythmic(Rhythmic_req*r_req_l)
{
assert(l < 8 && s <= 2 && s >= -2 && l >=0);
notetab[l * 5 + s +2] = n;
}
-/****************/
+/* *************** */
void
My_flex_lexer::set(Notename_tab *n)
{
Real
Paperdef::rule_thickness()const
{
- return convert_dimen(0.4, "pt");
+ return 0.4 PT;
}
Paperdef::Paperdef(Lookup *l)
{
lookup_p_ = l;
-
- linewidth = convert_dimen(15,"cm"); // in cm for now
+ linewidth = 15 *CM_TO_PT; // in cm for now
whole_width = 8 * note_width();
geometric_ = sqrt(2);
}
Real
Paperdef::standard_height() const
{
- return convert_dimen(20,"pt");
+ return 20 PT;
}
void
}
%token VOICE STAFF SCORE TITLE BAR OUTPUT MULTIVOICE
-%token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS COMMAND
+%token CM_T IN_T PT_T MM_T PAPER WIDTH METER UNITSPACE SKIP COMMANDS COMMAND
%token GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND
%token KEY CLEF TABLE VOICES STEM
%token PARTIAL MUSIC GROUPING CADENZA
%token <string> STRING
%token <i> DOTS INT
-%type <consstr> unit
+%type <real> unit
%type <intvec> pitch_list
%type <c> open_request_parens close_request_parens
%type <id> declaration
;
script_req:
- script_dir mudela_script { $$ = get_script_req($1, $2); }
+ script_dir mudela_script {
+ $$ = get_script_req($1, $2);
+ }
;
mudela_script:
dim:
- real unit { $$ = convert_dimen($1,$2); }
+ real unit { $$ = $1*$2; }
;
-unit: CM { $$ = "cm"; }
- |IN { $$ = "in"; }
- |MM { $$ = "mm"; }
- |PT { $$ = "pt"; }
+unit: CM_T { $$ = 1 CM; }
+ |IN_T { $$ = 1 INCH; }
+ |MM_T { $$ = 1 MM; }
+ |PT_T { $$ = 1 PT; }
;
/*
PScore::get_spacing(PCol*l, PCol*r)
{
assert(l!=r);
- for (iter_top(suz,ic); ic.ok(); ic++) {
- if (ic->left == l && ic->right == r){
- return ic;
- }
- }
-
- Idealspacing*ip =new Idealspacing(l,r);
- suz.bottom().add(ip);
- return ip;
+ Idealspacing*i_p =new Idealspacing(l,r);
+ suz.bottom().add(i_p);
+
+ return i_p;
}
if (!c1 || !c2 )
return;
Idealspacing*s_l=get_spacing(c1,c2);
-
- if (!s_l->hooke){
- s_l->hooke = h;
- s_l->space =d;
- }
+
+
+ s_l->hooke = h;
+ s_l->space =d;
}
void
PScore::typeset_item(Item *i, PCol *c, PStaff *s, int breakstat)
{
assert(c && i && s);
-// assert(!breakstat != 4 || c->breakable() );
+
if (breakstat == 0) {
typeset_item(i, c->prebreak_p_, s);
return;
PScore::process()
{
clean_cols();
- *mlog << "Preprocessing" << endl;
+ *mlog << "Preprocessing ... " <<flush;
preprocess();
- *mlog << "Calculating" << endl;
+ *mlog << "\nCalculating column positions ... " <<flush;
calc_breaking();
- *mlog << "Postprocessing" << endl;
+ *mlog << "\nPostprocessing ..." << endl;
postprocess();
}
#include "pstaff.hh"
#include "molecule.hh"
-PStaff::~PStaff()
-{
- delete stafsym_p_;
-}
-
PStaff::PStaff(PScore*ps)
{
pscore_l_=ps;
- stafsym_p_ = 0;
}
void
-PStaff::add(Item *i )
+PStaff::add(Item *i)
{
its.bottom().add(i);
i->pstaff_l_ = this;
#endif
}
-/****************/
+/* *************** */
/*
eliminate appropriate variables, until we have a Ineq_constrained_qp
return H*g;
}
-/****************************************************************/
+/* *************************************************************** */
int
min_elt_index(Vector v)
}
///the numerical solving
+/** Mordecai Avriel, Nonlinear Programming: analysis and methods (1976)
+ Prentice Hall.
+
+ Section 13.3
+
+ This is a "projected gradient" algorithm. Starting from a point x
+ the next point is found in a direction determined by projecting
+ the gradient onto the active constraints. (well, not really the
+ gradient. The optimal solution obeying the active constraints is
+ tried. This is why H = Q^-1 in initialisation) )
+
+
+ */
Vector
Ineq_constrained_qp::solve(Vector start) const
{
return x;
}
-/** Mordecai Avriel, Nonlinear Programming: analysis and methods (1976)
- Prentice Hall.
-
- Section 13.3
-
- This is a "projected gradient" algorithm. Starting from a point x
- the next point is found in a direction determined by projecting
- the gradient onto the active constraints. (well, not really the
- gradient. The optimal solution obeying the active constraints is
- tried. This is why H = Q^-1 in initialisation) )
-
-
- */
+/*
+ register.cc -- implement Staff_elem_info, Request_register
+
+ Sourcefile of LilyPond musictypesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
#include "voice.hh"
#include "request.hh"
#include "register.hh"
#include "notehead.hh"
#include "complexwalker.hh"
#include "localkeyitem.hh"
+#include "complexstaff.hh"
Staff_elem_info::Staff_elem_info(Staff_elem*s_l, Request*r_l,
Request_register *reg_l)
group_regs_l_ = 0;
origin_reg_l_ = reg_l;
}
+
Staff_elem_info::Staff_elem_info()
{
elem_p_ = 0;
origin_reg_l_ = 0;
req_l_ = 0;
}
-/****************/
+
+/* *************** */
Request_register::Request_register()
{
do_post_move_process();
}
-
-/****************/
-
-Local_key_register::Local_key_register(Complex_walker*w)
- : Request_register(w)
+Request_register::Request_register(Request_register const&)
{
- key_item_p_ = 0;
-}
-bool
-Local_key_register::try_request(Request*)
-
-{
- return false;
+ assert(false);
}
void
-Local_key_register::process_request()
+Request_register::announce_element(Staff_elem_info i)
{
+ walk_l_->announce_element(i);
}
+
void
-Local_key_register::do_pre_move_process()
+Request_register::typeset_element(Staff_elem*p)
{
- if (key_item_p_) {
- walk_l_->typeset_element(key_item_p_);
- key_item_p_ = 0;
- }
+ walk_l_->typeset_element(p);
}
-void
-Local_key_register::acknowledge_element(Staff_elem_info info)
-{
- if (info.req_l_->melodic()) {
- Melodic_req * melodic_l_ = info.req_l_->melodic();
-
- if( melodic_l_->forceacc ||
- walk_l_->local_key_.oct(melodic_l_->octave).acc(melodic_l_->notename)
- != melodic_l_->accidental) {
- Item * support_l_ = info.elem_p_->item();
-
- if (!key_item_p_) {
- key_item_p_ = new Local_key_item(walk_l_->clef_.c0_pos);
- key_item_p_->c0_position = walk_l_->clef_.c0_pos;
- }
-
- key_item_p_->add(melodic_l_);
- key_item_p_->add(support_l_);
- walk_l_->local_key_.oct(melodic_l_->octave)
- .set(melodic_l_->notename, melodic_l_->accidental);
- }
- }
+Paperdef*
+Request_register::paper()const
+{
+ return walk_l_->staff()->paper();
}
dir_i_ = 0;
}
-/****************/
+/* *************** */
void
Barcheck_req::do_print() const
{
#endif
}
-/****************/
+/* *************** */
void
Request::print() const
elt_l_ = 0;
defined_ch_c_l_m = src.defined_ch_c_l_m;
}
-/****************/
+/* *************** */
Spacing_req::Spacing_req()
{
next = 0;
{
Spacing_req::do_print();
}
-/****************/
+/* *************** */
Melodic_req::Melodic_req()
{
notename = 0;
return notename + octave*7;
}
-/****************/
+/* *************** */
int
Rhythmic_req::compare(const Rhythmic_req &r1, const Rhythmic_req &r2)
{
- return r1.duration() - r2.duration();
+ return sign(r1.duration() - r2.duration());
}
Rhythmic_req::Rhythmic_req(int b, int d)
{
Rhythmic_req::duration() const {
return wholes(balltype,dots)*plet_factor;
}
-/****************/
+/* *************** */
Lyric_req::Lyric_req(Text_def* def_p)
:Text_req(0, def_p)
Rhythmic_req::do_print();
Text_req::do_print();
}
-/****************/
+/* *************** */
void
Note_req::do_print() const
{
Melodic_req::do_print();
Rhythmic_req::do_print();
}
-/****************/
+/* *************** */
void
Rest_req::do_print() const
{
Rhythmic_req::do_print();
}
-/****************/
+/* *************** */
Beam_req::Beam_req()
{
nplet = 0;
}
void Beam_req::do_print()const{}
-/****************/
+/* *************** */
void Slur_req::do_print()const{}
-/****************/
+/* *************** */
int
Span_req:: compare(const Span_req &r1, const Span_req &r2)
{
{
spantype = NOSPAN;
}
-/****************/
+/* *************** */
void
Group_feature_req::do_print() const
{
Terminate_voice_req::do_print()const
{
}
-/****************/
+/* *************** */
Script_req::Script_req(int d , Script_def*def)
{
dir_i_ = d;
}
Script_req::Script_req(Script_req const &s)
+ : Request( s )
{
dir_i_ = s.dir_i_;
scriptdef_p_ = new Script_def(*s.scriptdef_p_);
{
delete scriptdef_p_;
}
-/****************/
+/* *************** */
int
Text_req:: compare(const Text_req &r1, const Text_req &r2)
{
-/****************/
+/* *************** */
Mark_req::Mark_req(String s)
{
mtor<< " `" << mark_str_ << "\'\n";
#endif
}
-/****************/
+/* *************** */
Staff_command_req::Staff_command_req(Input_command * p)
{
com_p_ = p;
+++ /dev/null
-#include "molecule.hh"
-#include "score.hh"
-#include "request.hh"
-#include "notehead.hh"
-#include "stem.hh"
-#include "linepstaff.hh"
-#include "rhythmstaff.hh"
-#include "paper.hh"
-#include "sccol.hh"
-#include "rest.hh"
-
-void
-Rhythmic_staff::set_output(PScore*ps)
-{
- theline_l_ = new Linestaff(1,ps);
- Simple_staff::set_output(ps);
-}
-
-Item *
-Rhythmic_staff::get_TYPESET_item(Command *com)
-{
- if (com->args[0] == "KEY" || com->args[0] == "CLEF"||
- com->args[0] == "CURRENTCLEF")
- return 0;
- Item *i = Simple_staff::get_TYPESET_item(com);
- if (!i) return 0;
- i->translate(Offset(0,
- -score_l_->paper_p_->standard_height()/2));
- return i;
-}
-
-Notehead*
-Rhythmic_staff::get_notehead(Note_req *rq, int)
-{
- Notehead *n =new Notehead(1);
- n->set_rhythmic(rq->rhythmic());
- n->position = 0;
- return n;
-}
-
-Stem *
-Rhythmic_staff::get_stem(Stem_req*rq)
-{
- Stem * s = new Stem(0);
- s->flag = rq->balltype;
- return s;
-}
void
Score_column::add_duration(Moment d)
{
+ assert(d);
for (int i = 0; i< durations.size(); i++) {
if (d == durations[i])
return ;
void
Score::process()
{
- *mlog << "\nProcessing music" << endl;
+ *mlog << "\nProcessing music ..." << flush;
assert (paper_p_);
if (last() == Moment(0)) {
warning("Need to have music in a score.", defined_ch_c_l_);
}
+
// distribute commands to disciples
pscore_p_ = new PScore(paper_p_);
for (iter_top(staffs_,i); i.ok(); i++) {
- i->truncate_cols(last());
i->set_output(pscore_p_);
+ i->truncate_cols(last());
i->process();
}
// debugging
OK();
+ *mlog << endl;
pscore_p_->process();
}
}
PCursor<Score_column*>
-Score::find_col(Moment w,bool mus)
-{
- iter_top(cols_,i);
+Score::find_col(Moment w, bool mus)
+{ iter_top( cols_,i);
+
+
for (; i.ok(); i++) {
if (i->when() == w && i->musical_ == mus)
return i;
}
clean_cols(); // can't move clean_cols() farther up.
}
+
Moment
Score::last() const
{
#endif
}
-Score::Score(Paperdef*p)
+Score::Score(Paperdef*paper_p)
{
pscore_p_=0;
- paper_p_ = p; // ?? safe?
+ paper_p_ = paper_p;
errorlevel_i_ = 0;
defined_ch_c_l_ = 0;
}
int
Script_def::compare(Script_def const & c)
{
- return (symidx == c.symidx &&
+ return !(symidx == c.symidx &&
stemdir == c.stemdir&&
staffdir == c.staffdir&&
invertsym == c.invertsym);
--- /dev/null
+/*
+ scriptreg.cc -- implement Script_register
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "scriptreg.hh"
+#include "script.hh"
+#include "request.hh"
+#include "complexwalker.hh"
+
+Script_register::Script_register(Complex_walker*w)
+ : Request_register(w)
+{
+ script_p_ = 0;
+}
+
+bool
+Script_register::try_request(Request *r_l)
+{
+ if (!r_l->script())
+ return false ;
+
+ if (accepted_req_arr_.size()
+ && Script_req::compare(*accepted_req_arr_[0]->script(), *r_l->script()))
+
+ return false;
+
+ accepted_req_arr_.push(r_l);
+
+ return true;
+}
+
+void
+Script_register::process_request()
+{
+ if (accepted_req_arr_.size() ) {
+ script_p_ = new Script(accepted_req_arr_[0]->script(), 10);
+ announce_element(
+ Staff_elem_info(script_p_, accepted_req_arr_[0], this));
+ }
+}
+
+void
+Script_register::acknowledge_element(Staff_elem_info info)
+{
+ if (!script_p_)
+ return;
+ if (info.elem_p_->name() == String("Stem"))
+ script_p_->set_stem((Stem*)info.elem_p_);
+ else if (info.req_l_->rhythmic())
+ script_p_->set_support(info.elem_p_->item());
+}
+
+void
+Script_register::do_pre_move_process()
+{
+ if (script_p_){
+ script_p_->dir = dir_i_;
+ typeset_element(script_p_);
+ script_p_ = 0;
+ }
+}
+
+void
+Script_register::set_dir(int i)
+{
+ dir_i_ = i;
+}
+++ /dev/null
-#include "clefitem.hh"
-#include "request.hh"
-#include "pscore.hh"
-#include "paper.hh"
-#include "simplestaff.hh"
-#include "sccol.hh"
-#include "rest.hh"
-#include "debug.hh"
-#include "bar.hh"
-#include "meter.hh"
-
-Item *
-Simple_staff::get_TYPESET_item(Command *com)
-{
- Item *s=0;
- Array<Scalar> arg( com->args);
- String type =arg[0];
- arg.del(0);
- if (type == "BAR" ) {
- s = new Bar(com->args[1]);
- } else if (type == "METER") {
- s = new Meter(arg);
- } else if (type == "CLEF" || type == "CURRENTCLEF") {
- Clef_item * c = new Clef_item;
- s = c;
- c->change = (type == "CLEF");
- }else{
- WARN << "ignoring TYPESET command for " << type << '\n';
- }
- return s;
-}
-
-
-Interval
-itemlist_width(const Array<Item*> &its)
-{
- Interval iv ;
- iv.set_empty();
-
- for (int j =0; j < its.size(); j++){
- iv.unite (its[j]->width());
-
- }
- return iv;
-}
-
-void
-Simple_column::typeset_item(Item *i, int breakst)
-{
- assert(i);
-
- staff_l_->pscore_l_->typeset_item(i, score_column_l_->pcol_l_,
- staff_l_->theline_l_,breakst);
-
- if (breakst == BREAK_PRE - BREAK_PRE) {
-
- Array<Item*> to_move(
- staff_l_->pscore_l_->select_items(staff_l_->theline_l_,
- score_column_l_->pcol_l_->prebreak_p_));
- Interval column_wid = itemlist_width(to_move);
- assert(!column_wid.empty());
-
- for (int j=0; j < to_move.size(); j++) {
- to_move[j]->translate(Offset(-column_wid.right, 0));
- }
- }
-}
-
-void
-Simple_column::typeset_item_directional(Item *i, int dir, int breakst) // UGH!
-{
- assert(i);
- PCol * c=score_column_l_->pcol_l_;
- if (breakst == 0)
- c = c->prebreak_p_;
- else if (breakst == 2)
- c = c->postbreak_p_;
-
- Array<Item*> to_move(staff_l_->pscore_l_->select_items(staff_l_->theline_l_,
- 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
-Simple_staff::set_output(PScore* ps )
-{
- pscore_l_ = ps;
- pscore_l_->add(theline_l_);
-}
-
-
-Rest*
-Simple_staff::get_rest(Rest_req*rq)
-{
- int b = rq->rhythmic()->balltype;
- int d = rq->rhythmic()->dots;
- return new Rest(b, d);
-}
-
-Local_key_item*
-Simple_staff::get_local_key_item()
-{
- return 0;
-}
-
+++ /dev/null
-#include "request.hh"
-#include "voice.hh"
-#include "staffwalker.hh"
-#include "debug.hh"
-#include "clef.hh"
-#include "staff.hh"
-#include "command.hh"
-#include "simplestaff.hh"
-#include "sccol.hh"
-#include "simplewalker.hh"
-
-
-
-Simple_column::Simple_column(Score_column*s, Simple_staff *rs)
- : Staff_column(s)
-{
- stem_requester_len = 0;
- stem_ = 0;
- staff_l_ = rs;
- beam_ = 0;
- text_=0;
-
-}
-
-Simple_staff::Simple_staff()
-{
- theline_l_ = 0;
-}
-
-
-
-void
-Simple_column::setup_requests()
-{
- for (int i = 0 ; i < v_elts.size(); i ++)
- for (iter_top(v_elts[i]->reqs,j); j.ok(); j++) {
- Request *rq= j;
- if (rq->barcheck()) {
- if (tdescription_->whole_in_measure) {
- warning( "Barcheck failed", rq->defined_ch_c_l_m );
- }
- }
- if (rq->rhythmic()){
- notes.push(rq->rhythmic());
- }
- if (rq->script()) {
- notes.top().scripts.push(rq->script());
- }
- if (rq->stem()) {
- stem_ = rq->stem();
- stem_requester_len = v_elts[i]->duration;
- }
- if (rq->text()) {
- text_ = rq->text();
- }
- if (rq->beam()) {
- beam_ = rq->beam();
- }
- if (rq->slur()) {
- slurs.push(rq->slur());
- }
- }
-}
-
-Staff_column*
-Simple_staff::create_col(Score_column*s)
-{
- return new Simple_column(s,this);
-}
-
-void
-Simple_staff::walk()
-{
- for (Simple_walker sc(this); sc.ok(); sc++) {
- sc.col()->setup_requests();// TODO
- sc.process();
- }
-}
-Note_info::Note_info()
-{
- rq =0;
-}
-Note_info::Note_info(Rhythmic_req*r) {
- rq = r;
-}
+++ /dev/null
-/*
- UGR!! CHAOS RULEZ
- */
-#include "textspanner.hh"
-#include "script.hh"
-#include "request.hh"
-#include "voice.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 "slur.hh"
-#include "localkeyitem.hh"
-#include "textitem.hh"
-#include "misc.hh"
-
-Rhythmic_grouping
-parse_grouping(Array<Scalar> const &a)
-{
- Array<int> r;
- Array<Moment> grouplen_arr;
- for (int i= 0 ; i < a.size()/2; ) {
- r.push(a[i++]);
- grouplen_arr.push(Moment(1,(int) a[i++]));
- }
- Moment here =0;
-
- Array<Rhythmic_grouping*> children;
- for (int i=0; i < r.size(); i++) {
-
- Moment last = here;
- here += grouplen_arr[i] * Rational(r[i]);
- children.push(
- new Rhythmic_grouping(MInterval(last, here), r[i] ));
- }
- return Rhythmic_grouping(children);
-}
-
-
-
-void
-Simple_walker::do_INTERPRET_command(Command*com)
-{
- Array<Scalar> args(com->args);
- args.del(0);
- if (com->args[0] == "GROUPING") {
- default_grouping = parse_grouping(args);
- }else if (com->args[0] == "NEWMEASURE") {
- local_key_.reset(key_);
-
- } else if (com->args[0] == "KEY") {
-
- if (col()->when() > Moment(0)) {
- assert(!oldkey_undo);
- oldkey_undo = new Array<int>( key_.oldkey_undo(args));
- }
-
- typesetkey = key_.read(args);
- local_key_.reset(key_);
- } else if (com->args[0] == "CLEF") {
- clef_.read(args);
- } else {
- WARN << " ignoring INTERPRET command: " << com->args[0]<< '\n';
- }
-}
-
-void
-Simple_walker::do_TYPESET_command(Command*com)
-{
- /* ignore these commands if non-default versions have been
- processed. */
- if (com->args[0] == "CURRENTKEY")
- if (processed_key)
- return;
- else
- com->args[0] = "KEY"; // urgh
-
- if (com->args[0] == "CURRENTCLEF") {
- if (processed_clef)
- return;
- }
- if (com->args[0] == "BAR") {
-
- if (processed_bar_priority > com->priority)
- return;
- else
- processed_bar_priority = com->priority;
- }
-
- Item* i = staff()->get_TYPESET_item(com);
- if (!i)
- return;
-
- if (com->args[0] == "KEY") {
- ((Keyitem*) i)->read(clef_);
- 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"||com->args[0] == "CURRENTCLEF") {
- processed_clef =true;
- Clef_item*c=(Clef_item*)i;
- c->read(clef_);
- c->change = (break_status != BREAK_POST - BREAK_PRE);
- }
- col()->typeset_item_directional(i, 1, break_status);
-}
-
-void
-Simple_walker::do_local_key(Note_req*n,Notehead* head_p)
-{
- if ( local_key_.oct(n->octave).acc(n->notename) != n->accidental) {
- if (!local_key_item_) {
- local_key_item_ = staff()->get_local_key_item();
- local_key_item_->c0_position = clef_.c0_pos;
- }
- local_key_item_->add(head_p);
- local_key_item_->add(n->octave, n->notename, n->accidental);
- local_key_.oct(n->octave).set(n->notename, n->accidental);
- }
-}
-
-void
-Simple_walker::do_note(Note_info n)
-{
- Simple_column*c = col();
- Simple_staff *s = staff();
- Item*rhythmic=0;
- if (n.rq->note()) {
- Note_req * req = n.rq->note() ;
- const Voice *v = req->elt_l_->voice_l_;
-
- Notehead*n = s->get_notehead(req, clef_.c0_pos);
- rhythmic=n;
- if (stem_)
- stem_->add(n);
-
- if (current_grouping) {
- current_grouping->add_child(
- c->tdescription_->whole_in_measure, req->duration());
- }
- noteheads.push(n);
- int sidx =find_slur(v);
- if (sidx >= 0) {
- pending_slurs[sidx]->add(n);
- }
-
- if (wantkey)
- do_local_key(req,n);
- } else if (n.rq->rest()) {
- rhythmic = s->get_rest(n.rq->rest());
- c->typeset_item(rhythmic);
- }
- for (int i= 0; i < n.scripts.size(); i ++) {
- Script * s_p =new Script(n.scripts[i], 10);
- s_p->set_support(rhythmic);
- s_p->set_stem(stem_);
- c->typeset_item(s_p); // UGR
- }
-}
-
-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 (t = " +String(c->when())+")");
- beam_ = new Beam;
- assert(!current_grouping);
- current_grouping = new Rhythmic_grouping;
- }
-
- for (int i=0; i < c->slurs.size(); i++) {
- Slur_req*sl = c->slurs[i];
-
- if (sl->spantype == Span_req::START) {
- if (find_slur(sl->elt_l_->voice_l_)>=0)
- error( "Too many slurs in voice", sl->defined_ch_c_l_m );
- pending_slur_reqs.push(sl);
- pending_slurs.push(new Slur);
- }
- }
-
- if (c->text_) {
- c->typeset_item(new Text_item(c->text_, 10)); // UGR
- }
-
- if (c->stem_) {
- stem_ = s->get_stem(c->stem_->stem());
- }
-
- for (int i = 0; i < c->notes.size(); i ++) {
- do_note(c->notes[i]);
- }
-
- if (beam_) {
- if (!stem_)
- WARN <<"beamed note should have a stem (t = "
- <<String(c->when())<<")\n";
- else
- beam_->add(stem_);
-
-
- }
- if (stem_) {
- c->typeset_item(stem_);
- /* needed, otherwise placement of
- local_key fucks up */
- }
-
- if (c->beam_&& c->beam_->spantype == Span_req::STOP) {
- if (!beam_) {
- error( "No beam to end", c->beam_->defined_ch_c_l_m );
- }
- default_grouping.extend(current_grouping->interval());
- beam_->set_grouping(default_grouping, *current_grouping);
- pscore_l_->typeset_spanner(beam_, s->theline_l_);
-
- if (c->beam_->nplet) {
- Text_spanner* t = new Text_spanner;
- t->set_support(beam_);
- t->spec.align_i_ = 0;
- t->spec.text_str_ = c->beam_->nplet;
- pscore_l_->typeset_spanner(t, s->theline_l_);
- }
-
- beam_ = 0;
- delete current_grouping;
- current_grouping =0;
- }
- for (int i = 0; i < noteheads.size(); i++) {
- c->typeset_item(noteheads[i]);
- }
- noteheads.set_size(0);
-
- if (local_key_item_) {
- c->typeset_item(local_key_item_);
- local_key_item_ = 0;
- }
- if (stem_) {
- stem_ = 0;
- }
- for (int i=0; i < c->slurs.size(); i++) {
- Slur_req *sl = c->slurs[i];
-
- if (sl->spantype == Span_req::STOP) {
- int idx = find_slur(sl->elt_l_->voice_l_);
- if (idx < 0)
- error( "can't find slur end", sl->defined_ch_c_l_m );
-
- pscore_l_->typeset_spanner(pending_slurs[idx],
- s->theline_l_);
- pending_slurs.del(idx);
- pending_slur_reqs.del(idx);
- }
- }
-
-}
-Simple_walker::Simple_walker(Simple_walker const&)
- : Staff_walker(0, 0)
-{
- assert(false);
-}
-
-Simple_walker::~Simple_walker()
-{
- if (pending_slurs.size())
- WARN << "destructing " << pending_slurs.size() << " Pending slurs ";
- if (beam_)
- WARN << "destructing Beam\n";
- if (local_key_item_)
- WARN<<"destructing Local_key_item\n";
- if (stem_)
- WARN<< "destructing Stem\n";
- delete local_key_item_;
- delete stem_;
- delete beam_;
-
-}
-
-Simple_walker::Simple_walker(Simple_staff*s)
- : Staff_walker(s, s->theline_l_->pscore_l_)
-{
- stem_ = 0;
- beam_ =0;
- oldkey_undo = 0;
- current_grouping = 0;
- Local_key_item * i = s->get_local_key_item();
- wantkey =i;
- delete i;
- local_key_item_ = 0;
- do_post_move();
-}
-
-
-
-Simple_staff*
-Simple_walker::staff()
-{
- return (Simple_staff*) staff_l_;
-}
-
-Simple_column*
-Simple_walker::col()
-{
- return (Simple_column*) *(*this);
-}
-
-void
-Simple_walker::do_post_move()
-{
- processed_clef =false;
- processed_key = false;
- processed_bar_priority = 0;
-}
-
-int
-Simple_walker::find_slur(const Voice *v)
-{
- for (int i=0; i < pending_slur_reqs.size(); i++) {
- if (pending_slur_reqs[i]->elt_l_->voice_l_== v)
- return i;
- }
- return -1;
-}
-
-
#include "molecule.hh"
#include "debug.hh"
#include "boxes.hh"
+
NAME_METHOD(Slur);
+
Slur::Slur()
{
- dir = 0;
open_right=open_left=false;
}
/* should consult stems */
Real meanpos = sumpos/Real(encompass.size());
if (meanpos < 5) // todo
- dir = -1;
+ dir_i_ = -1;
else
- dir = 1;
+ dir_i_ = 1;
}
void
void
Slur::do_post_processing()
{
- set_default_dir();
+ if (!dir_i_)
+ set_default_dir();
}
Molecule*
Notehead *rnote_p =encompass.top();
int lpos_i = lnote_p->position;
int rpos_i = rnote_p->position;
- Offset left_off(lnote_p->x_dir, lpos_i + 2*dir);
- Offset right_off(lnote_p->x_dir, rpos_i + 2*dir);
+ Offset left_off(lnote_p->x_dir, lpos_i + 2*dir_i_);
+ Offset right_off(lnote_p->x_dir, rpos_i + 2*dir_i_);
if (!lnote_p->extremal)
- left_off += Offset(0.5, -dir);
+ left_off += Offset(0.5, -dir_i_);
if (!rnote_p->extremal)
- right_off+= Offset(-0.5, -dir);
+ right_off+= Offset(-0.5, -dir_i_);
int dy = int(right_off.y - left_off.y);
w+= (right_off.x - left_off.x) * nw_f ;
Real round_w = w; // slur lookup rounds the slurwidth .
- Symbol sl = paper()->lookup_p_->slur(dy , round_w, dir);
+ Symbol sl = paper()->lookup_p_->slur(dy , round_w, dir_i_);
Real error = w-round_w;
--- /dev/null
+/*
+ slurreg.cc -- implement Slur_register
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "complexwalker.hh"
+#include "slurreg.hh"
+#include "slur.hh"
+#include "debug.hh"
+void
+Slur_register::set_dir(int i)
+{
+ dir_i_ = i;
+}
+
+Slur_register::Slur_register(Complex_walker* w)
+ : Request_register(w)
+{
+ set_dir(0);
+}
+
+bool
+Slur_register::try_request(Request *req_l)
+{
+ if(!req_l->slur())
+ return false;
+
+ accepted_req_arr_.push(req_l);
+ return true;
+}
+
+void
+Slur_register::acknowledge_element(Staff_elem_info info)
+{
+ if (info.elem_p_->name() == String("Notehead")) {
+ Notehead *head_p =(Notehead*) info.elem_p_ ;// ugh
+ for (int i = 0; i < slur_l_stack_.size(); i++)
+ slur_l_stack_[i]->add(head_p );
+ for (int i = 0; i < end_slur_l_arr_.size(); i++)
+ end_slur_l_arr_[i]->add(head_p);
+ }
+}
+/*
+ abracadabra
+ */
+void
+Slur_register::process_request()
+{
+ Array<Slur*> start_slur_l_arr_;
+ for (int i=0; i< accepted_req_arr_.size(); i++) {
+ Slur_req* slur_req_l = accepted_req_arr_[i]->slur();
+ // end slur: move the slur to other array
+ if (slur_req_l->spantype == Span_req::STOP) {
+ if (slur_l_stack_.empty())
+ warning("can't find slur to end",
+ slur_req_l->defined_ch_c_l_m);
+ else {
+ end_slur_l_arr_.push(slur_l_stack_.pop());
+ requests_arr_.pop();
+ }
+ } else if (slur_req_l->spantype == Span_req::START) {
+ // push a new slur onto stack.
+ //(use temp. array to wait for all slur STOPs)
+ Slur * s_p =new Slur;
+ requests_arr_.push(slur_req_l);
+ start_slur_l_arr_.push(s_p);
+ announce_element(Staff_elem_info(s_p, slur_req_l, this));
+ }
+ }
+ for (int i=0; i < start_slur_l_arr_.size(); i++)
+ slur_l_stack_.push(start_slur_l_arr_[i]);
+}
+
+void
+Slur_register::do_pre_move_process()
+{
+ for (int i = 0; i < end_slur_l_arr_.size(); i++) {
+ if (dir_i_)
+ end_slur_l_arr_[i]->dir_i_ = dir_i_;
+ typeset_element(end_slur_l_arr_[i]);
+ }
+ end_slur_l_arr_.set_size(0);
+}
+
+Slur_register::~Slur_register()
+{
+ for (int i=0; i < requests_arr_.size(); i++) {
+ warning("unterminated slur", requests_arr_[i]->defined_ch_c_l_m);
+ }
+}
#include "string.hh"
#include "proto.hh"
#include "plist.hh"
+#include "lexer.hh"
+#include "debug.hh"
+#include "parseconstruct.hh"
#include "main.hh" // find_file
#include "sourcefile.hh"
void
Source_file::map()
{
+ if ( fildes_i_m == -1 )
+ return;
+
data_caddr_m = (caddr_t)mmap( (void*)0, size_off_m, PROT_READ, MAP_SHARED, fildes_i_m, 0 );
- if ( (int)data_caddr_m == -1 ) {
- cerr << "lilypond: can't map: " << name_str_m << ": " << strerror( errno ) << endl;
- assert( 0 );
- }
+ if ( (int)data_caddr_m == -1 )
+ warning( String( "can't map: " ) + name_str_m + String( ": " ) + strerror( errno ), defined_ch_c_l ); //lexer->here_ch_c_l() );
}
String
void
Source_file::open()
{
- name_str_m = find_file( name_str_m );
+ String name_str = find_file( name_str_m );
+ if ( name_str != "" )
+ name_str_m = name_str;
+
fildes_i_m = ::open( name_str_m, O_RDONLY );
-
+
if ( fildes_i_m == -1 ) {
- cerr << "lilypond: can't open: " << name_str_m << ": " << strerror( errno ) << endl;
- assert( 0 );
+ warning( String( "can't open: " ) + name_str_m + String( ": " ) + strerror( errno ), defined_ch_c_l ); // lexer->here_ch_c_l() );
+ return;
}
struct stat file_stat;
#include "pcol.hh"
NAME_METHOD(Spanner);
+
void
Spanner::do_print()const
{
Staff_column *
Staff::get_col(Moment w, bool mus)
{
- Score_column* sccol_l = score_l_->find_col(w,mus);
-
- iter_top(cols,i);
+ iter_top(cols,i);
for (; i.ok(); i++) {
-
- if (*i->score_column_l_ > *sccol_l) // too far
+ if (i->when() == w) {
+ if (i->musical_b() == mus) {
+ assert( score_l_->find_col(w,mus).ptr() == i->score_column_l_);
+ return i;
+ }
+ else if (!mus)
+ break;
+ } else if (i->when() > w)
break;
- if (sccol_l == i->score_column_l_)
- return i;
}
-
/* post: *sc > *->score_column_l_ || !i.ok() */
+
+ Score_column* sccol_l = score_l_->find_col(w,mus);
Staff_column* newst = create_col(sccol_l);
if (!i.ok()) {
if (mus) {
i.insert(newst);
+
return newst;
}
Staff::setup_staffcols()
{
for (iter_top(voices,i); i.ok(); i++) {
+
Moment now = i->start;
for (iter_top(i->elts,j); j.ok(); j++) {
-
- Staff_column *s_l=get_col(now,true);
+
+ Staff_column *s_l= get_col(now, true);
+ assert(now == s_l->when());
s_l->add(j);
now += j->duration;
}
-
}
+ OK();
set_time_descriptions();
}
+
+
void
Staff::set_time_descriptions()
{
i++;
for (; i.ok(); j++,i++) {
if ( j->when() == i->when())
- assert(!j->mus() && i->mus());
+ assert(!j->musical_b() && i->musical_b());
else
assert(j->when () < i->when() );
}
Line_of_staff::TeXstring() const
{
String s("%line_of_staff\n");
+
s+=make_vbox(height());
// the staff itself: eg lines, accolades
s += "\\hbox{";
{
- ((PStaff*)pstaff_l_)->
- brew_molecule_p(line_of_score_l_->pscore_l_->paper_l_->linewidth);
-
- s+=pstaff_l_->stafsym_p_->TeXstring();
iter_top(line_of_score_l_->cols,cc);
Real lastpos=cc->hpos;
PCol *linestop = sc->cols.bottom();
for (iter_top(pstaff_l_->spans,i); i.ok(); i++) {
-
PCol *brokenstart = &max(*linestart, *i->left);
PCol *brokenstop = &min(*linestop, *i->right);
if ( *brokenstart < *brokenstop) {
Interval
Line_of_staff::height() const
{
- Interval y = pstaff_l_->stafsym_p_->extent().y;
+ Interval y(0,0);
+
iter_top(line_of_score_l_->cols,cc);
// all items in the current line & staff.
void
Line_of_staff::process()
{
+#if 0
if (!pstaff_l_->stafsym_p_)
pstaff_l_->brew_molecule_p(line_of_score_l_->pscore_l_->
paper_l_->linewidth);
+#endif
}
--- /dev/null
+/*
+ staffsym.cc -- implement Staff_symbol
+
+ source file of the LilyPond music typesetter
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+#include "staffsym.hh"
+#include "lookup.hh"
+#include "paper.hh"
+#include "debug.hh"
+
+NAME_METHOD(Staff_symbol);
+
+Staff_symbol::Staff_symbol(int l)
+{
+ no_lines_i_ = l;
+}
+
+void
+Staff_symbol::do_print()const
+{
+ mtor << "lines: " << no_lines_i_;
+}
+
+Molecule*
+Staff_symbol::brew_molecule_p() const
+{
+ Atom a = paper()->lookup_p_->linestaff(no_lines_i_, width().length());
+ return new Molecule(a);
+}
+
+Spanner*
+Staff_symbol::do_break_at(PCol*p1, PCol*p2)const
+{
+ Staff_symbol *span_p=new Staff_symbol(*this);
+ return span_p;
+}
+
+void
+Staff_symbol::set_extent(PCol*p1, PCol*p2)
+{
+ assert(p1&&p2);
+ left = p1;
+ right = p2;
+}
#include "staffwalker.hh"
#include "stcol.hh"
#include "sccol.hh"
+#include "debug.hh"
Staff_walker::~Staff_walker() {}
Staff_walker::Staff_walker(Staff_walker const &s)
{
break_status = BREAK_END - BREAK_PRE;
- if (ptr()->mus()) {
+ if (ptr()->musical_b()) {
process_requests();
} else if (ptr()->staff_commands_p_)
for (iter_top(*ptr()->staff_commands_p_,i); i.ok(); i++) {
Staff_walker::operator++(int i)
{
do_pre_move();
+ if (ptr()->musical_b() && ptr()->tdescription_
+ && !ptr()->tdescription_->whole_in_measure) {
+ *mlog << "[" << ptr()->tdescription_->bars<<"]"<< flush;
+ }
PCursor<Staff_column*>::operator++(i);
+
do_post_move();
}
}
bool
-Staff_column::mus() const
+Staff_column::musical_b() const
{
return score_column_l_->musical_;
}
v_elts.push(ve);
}
-Staff_column::Staff_column(Score_column *s_l)
+Staff_column::Staff_column(Score_column * cur)
+
{
tdescription_ =0;
- score_column_l_ = s_l;
+ score_column_l_=cur;
staff_commands_p_ = 0;
}
--- /dev/null
+/*
+ stembeamreg.cc -- part of LilyPond
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "stembeamreg.hh"
+#include "beam.hh"
+#include "stem.hh"
+#include "grouping.hh"
+#include "textspanner.hh"
+#include "complexwalker.hh"
+#include "complexstaff.hh"
+#include "debug.hh"
+
+Stem_beam_register::Stem_beam_register(Complex_walker*w)
+ :Request_register(w)
+{
+ do_post_move_process();
+ current_grouping = 0;
+ beam_p_ = 0;
+ set_dir(0);
+ start_req_l_ = 0;
+}
+
+bool
+Stem_beam_register::try_request(Request*req_l)
+{
+ if ( req_l->beam() ) {
+ if (bool(beam_p_ ) == bool(req_l->beam()->spantype == Span_req::START))
+ return false;
+
+ if (beam_req_l_ && Beam_req::compare(*beam_req_l_ , *req_l->beam()))
+ return false;
+
+ beam_req_l_ = req_l->beam();
+ return true;
+ }
+
+ if ( req_l->stem() ) {
+ if (current_grouping && !current_grouping->child_fit_query(
+ walk_l_->col()->tdescription_->whole_in_measure))
+ return false;
+
+ if (stem_req_l_ && Stem_req::compare(*stem_req_l_, *req_l->stem()))
+ return false;
+
+ stem_req_l_ = req_l->stem();
+ return true;
+ }
+ return false;
+}
+
+void
+Stem_beam_register::process_request()
+{
+ if (beam_req_l_) {
+ if (beam_req_l_->spantype == Span_req::STOP) {
+ end_beam_b_ = true;
+ start_req_l_ = 0;
+ } else {
+ beam_p_ = new Beam;
+ start_req_l_ = beam_req_l_;
+
+ current_grouping = new Rhythmic_grouping;
+ if (beam_req_l_->nplet) {
+ Text_spanner* t = new Text_spanner();
+ t->set_support(beam_p_);
+ t->spec.align_i_ = 0;
+ t->spec.text_str_ = beam_req_l_->nplet;
+ typeset_element(t);
+ }
+
+ }
+ }
+
+ if (stem_req_l_) {
+ stem_p_ = new Stem(4);
+ if (current_grouping)
+ current_grouping->add_child(
+ walk_l_->col()->tdescription_->whole_in_measure,
+ stem_req_l_->duration());
+
+ stem_p_->flag = stem_req_l_->balltype;
+
+ if (beam_p_) {
+ if (stem_req_l_->balltype<= 4)
+ warning( "stem doesn't fit in Beam",
+ stem_req_l_->defined_ch_c_l_m);
+ else
+ beam_p_->add(stem_p_);
+ stem_p_->print_flag = false;
+ } else {
+ stem_p_->print_flag = true;
+ }
+
+ announce_element(Staff_elem_info(stem_p_,
+ stem_req_l_, this));
+ }
+}
+
+void
+Stem_beam_register::acknowledge_element(Staff_elem_info info)
+{
+ if (!stem_p_)
+ return;
+
+ if (info.elem_p_->name() == String("Notehead") &&
+ stem_req_l_->duration() == info.req_l_->rhythmic()->duration())
+
+ stem_p_->add((Notehead*)info.elem_p_);
+}
+
+void
+Stem_beam_register::do_pre_move_process()
+{
+ if (stem_p_) {
+ if (default_dir_i_)
+ stem_p_->dir = default_dir_i_;
+
+ typeset_element(stem_p_);
+ stem_p_ = 0;
+ }
+ if (beam_p_ && end_beam_b_) {
+ walk_l_->default_grouping.extend(current_grouping->interval());
+ beam_p_->set_grouping(walk_l_->default_grouping, *current_grouping);
+ typeset_element(beam_p_);
+ delete current_grouping;
+ current_grouping = 0;
+ beam_p_ = 0;
+ }
+ end_beam_b_ = false;
+}
+void
+Stem_beam_register::do_post_move_process()
+{
+ stem_p_ = 0;
+ beam_req_l_ = 0;
+ stem_req_l_ = 0;
+ end_beam_b_ = false;
+}
+
+Stem_beam_register::~Stem_beam_register()
+{
+ if (beam_p_)
+ warning("unterminated beam", start_req_l_->defined_ch_c_l_m);
+}
+
+void
+Stem_beam_register::set_dir(int i)
+{
+ default_dir_i_ = i;
+}
args.push(widx);
bs.tex = substitute_args(bs.tex,args);
int w = 2 << widx;
- Real width = convert_dimen(w,"pt");
+ Real width = w PT;
bs.dim.x = Interval(0,width);
bs.dim.y = Interval(0,width*slope);
return bs;
slope_index(Real &s)
{
if (abs(s) > 0.5) {
- WARN << "beam steeper than 0.5\n";
+ WARN << "beam steeper than 0.5 (" << s << ")\n";
s = sign(s) * 0.5;
}
{
int sidx = slope_index(slope);
if (!slope)
- return rule_symbol(convert_dimen(2,"pt"), width);
- if (width < convert_dimen(2,"pt")) {
- WARN<<"Beam too narrow.\n";
- width = convert_dimen(2,"pt");
+ return rule_symbol(2 PT, width);
+ if (width < 2 PT) {
+ WARN<<"Beam too narrow. (" << print_dimen(width) <<")\n";
+ width = 2 PT;
}
- Real elemwidth = convert_dimen(64,"pt");
+ Real elemwidth = 64 PT;
int widx = 5;
Molecule m;
Symbol
Lookup::half_slur_middlepart(Real &dx, int dir)
{
- if (dx >= convert_dimen(400,"pt")) // todo
- error ("halfslur too large");
- int widx = int(floor(dx / 4.0));
+ if (dx >= 400 PT) {// todo
+ WARN<<"halfslur too large" <<print_dimen(dx)<< "shrinking (ugh)\n";
+ dx = 400 PT;
+ }
+ int widx = int(floor(dx / 4.0));
dx = widx * 4.0;
if (widx) widx --;
else {
Symbol s;
- s.dim.y = Interval(min(0,0), max(0,0));
+ s.dim.y = Interval(min(0,0), max(0,0)); // todo
s.dim.x = Interval(0,dx);
String f = String("\\hslurchar");
Symbol
Lookup::half_slur(int dy, Real &dx, int dir, int xpart)
{
+ Real orig_dx = dx;
if (!xpart)
return half_slur_middlepart(dx, dir);
int widx;
- if (dx >= convert_dimen(96,"pt")) {
- WARN << "Slur half too wide.";
- dx = convert_dimen(96,"pt");
+ if (dx >= 96 PT) {
+ WARN << "Slur half too wide." << print_dimen(orig_dx) << " shrinking (ugh)\n";
+ dx = 96 PT;
}
-
+
widx = int(rint(dx/12.0));
dx = widx*12.0;
if (widx)
widx --;
else {
- WARN << "slur too narrow\n";
+ WARN << "slur too narrow " << print_dimen(orig_dx)<<"\n";
}
Symbol s;
Symbol
Lookup::slur (int dy , Real &dx, int dir)
-{ // ugh. assuming pt here.
- assert(dx >=0);
+{
+ assert(dx >=0 && abs(dir) <= 1);
int y_sign = sign(dy);
bool large = dy > 16;
if (y_sign) {
- large |= dx>= convert_dimen(4*16, "pt");
+ large |= dx>= 4*16 PT;
} else
- large |= dx>= convert_dimen(4*54, "pt");
+ large |= dx>= 4*54 PT;
if (large) {
return big_slur(dy, dx, dir);
}
-
+ Real orig_dx = dx;
int widx = int(floor(dx/4.0)); // slurs better too small..
dx = 4.0 * widx;
if (widx)
widx --;
else {
- WARN << "slur too narrow\n";
+ WARN << "slur too narrow: " << print_dimen(orig_dx) << "\n";
}
int hidx = dy;
if (hidx <0)
hidx = -hidx;
hidx --;
- if (hidx > 16)
- error("slur to steep");
-
+ if (hidx > 16) {
+ WARN<<"slur to steep: " << dy << " shrinking (ugh)\n";
+ }
Symbol s;
s.dim.x = Interval(0,dx);
if (dir < 0)
idx += 128;
} else {
- if (dx >= convert_dimen(4*54, "pt"))
- error("slur too wide");
+ if (dx >= 4*54 PT) {
+ WARN << "slur too wide: " << print_dimen(dx) <<
+ " shrinking (ugh)\n";
+ dx = 4*54 PT;
+ }
idx = widx;
if (dir < 0)
idx += 54;
Symbol
Lookup::big_slur(int dy , Real &dx, int dir)
{
- assert(dx >= convert_dimen(24,"pt"));
+ assert(dx >= 24 PT);
Real slur_extra =abs(dy) /2.0 + 2;
int l_dy = int(Real (dy)/2 + slur_extra*dir);
int r_dy = dy - l_dy;
--- /dev/null
+/*
+ textreg.cc -- implement Text_register
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#include "textreg.hh"
+#include "textitem.hh"
+
+Text_register::Text_register(Complex_walker*w)
+ : Request_register(w)
+{
+ text_p_ = 0;
+ set_dir(0);
+}
+
+bool
+Text_register::try_request(Request*req_l)
+{
+ if (!req_l->text())
+ return false;
+ if (accepted_req_arr_.size() &&
+ Text_req::compare(*req_l->text(), *accepted_req_arr_[0]->text()))
+
+ return false;
+
+ accepted_req_arr_.push(req_l);
+ return true;
+}
+
+void
+Text_register::process_request()
+{
+
+ if (accepted_req_arr_.size()) {
+ text_p_ = new Text_item(accepted_req_arr_[0]->text(), 10);
+ announce_element(Staff_elem_info(text_p_, accepted_req_arr_[0], this));
+ }
+}
+void
+Text_register::do_pre_move_process()
+{
+ if (text_p_) {
+ text_p_->dir_i_ = dir_i_;
+ typeset_element(text_p_);
+ text_p_ = 0;
+ }
+}
+void
+Text_register::set_dir(int i)
+{
+ dir_i_ = i;
+}
#include "textspanner.hh"
#include "textdef.hh"
#include "debug.hh"
+#include "paper.hh"
NAME_METHOD(Text_spanner);
{
switch(spec.align_i_) {
case 0:
- tpos = support->center();
+ text_off_ = support->center() +
+ Offset(0,support->dir_i_ * paper()->internote() * 4); // todo
break;
default:
assert(false);
break;
- }
-
-
+ }
}
+
Molecule*
Text_spanner::brew_molecule_p() const
{
Atom tsym (spec.create_atom(paper()));
- tsym.translate(tpos);
+ tsym.translate(text_off_);
Molecule*output = new Molecule;
output->add( tsym );
}
-/****************************************************************/
+/* *************************************************************** */
l += i->duration;
return l;
}
-/****************************************************************/
+/* *************************************************************** */
void
Voice_element::print() const
{
#include "request.hh"
-#include "complexwalker.hh"
-#include "complexstaff.hh"
#include "voicegroup.hh"
#include "register.hh"
+#include "textreg.hh"
+#include "stembeamreg.hh"
+#include "scriptreg.hh"
+#include "complexwalker.hh"
+
static int temp_id_count;
Voice_group_registers::Voice_group_registers(Complex_walker*w_l, String id)
- : text_reg_(w_l),
- stem_beam_reg_(w_l),
- script_reg_(w_l)
{
walk_l_ = w_l;
+ text_reg_=new Text_register(w_l);
+ stem_beam_reg_= new Stem_beam_register(w_l);
+ script_reg_ = new Script_register(w_l);
if (id=="")
id = __FUNCTION__ + String(temp_id_count++);
group_id_str_ = id;
dir_i_ = 0;
}
+Voice_group_registers::~Voice_group_registers()
+{
+ delete text_reg_;
+ delete stem_beam_reg_;
+ delete script_reg_;
+}
void
Voice_group_registers::pre_move_processing()
{
- stem_beam_reg_.pre_move_processing();
- script_reg_.pre_move_processing();
- text_reg_.pre_move_processing();
+ stem_beam_reg_->pre_move_processing();
+ script_reg_->pre_move_processing();
+ text_reg_->pre_move_processing();
}
void
Voice_group_registers::post_move_processing()
{
- stem_beam_reg_.post_move_processing();
- text_reg_.post_move_processing();
- script_reg_.post_move_processing();
+ stem_beam_reg_->post_move_processing();
+ text_reg_->post_move_processing();
+ script_reg_->post_move_processing();
}
bool
Voice_group_registers::try_request(Request*r_l)
{
if (r_l->groupfeature()) {
- dir_i_ = r_l->groupfeature()->stemdir_i_;
+ set_dir(r_l->groupfeature()->stemdir_i_);
return true;
}
- bool b = stem_beam_reg_.try_request(r_l);
+ bool b = stem_beam_reg_->try_request(r_l);
if (!b)
- b|= script_reg_.try_request(r_l);
+ b|= script_reg_->try_request(r_l);
if (!b)
- b|= text_reg_.try_request(r_l);
+ b|= text_reg_->try_request(r_l);
return b;
}
void
-Voice_group_registers::announce_element(Staff_elem_info i)
+Voice_group_registers::acknowledge_element(Staff_elem_info i)
{
if (i.group_regs_l_!= this)
return;
- stem_beam_reg_.acknowledge_element(i);
- script_reg_.acknowledge_element(i);
- text_reg_.acknowledge_element(i);
+ stem_beam_reg_->acknowledge_element(i);
+ script_reg_->acknowledge_element(i);
+ text_reg_->acknowledge_element(i);
}
-
void
-Voice_group_registers::process_requests()
+Voice_group_registers::set_dir(int i)
{
- stem_beam_reg_.process_request();
- if (dir_i_)
- stem_beam_reg_.set_dir (dir_i_);
+ stem_beam_reg_->set_dir(i);
+ script_reg_->set_dir(i);
+ text_reg_->set_dir(i);
- script_reg_.process_request();
- text_reg_.process_request();
+ Array<Voice_registers*> vr_arr (walk_l_->get_voice_regs(this));
+ for (int j=0; j<vr_arr.size(); j++) {
+ if (vr_arr[j])
+ vr_arr[j]->set_dir(i);
+}
+}
+void
+Voice_group_registers::process_requests()
+{
+ stem_beam_reg_->process_request();
+ script_reg_->process_request();
+ text_reg_->process_request();
}
-#include "rest.hh"
-#include "notehead.hh"
-#include "paper.hh"
-#include "debug.hh"
-#include "slur.hh"
#include "request.hh"
-#include "complexwalker.hh"
-#include "complexstaff.hh"
#include "voicegroup.hh"
#include "register.hh"
+#include "slurreg.hh"
+#include "headreg.hh"
Voice_registers::Voice_registers(Complex_walker*c_l, Voice *v_p)
- : head_reg_(c_l), slur_reg_(c_l)
{
voice_l_ = v_p;
+ head_reg_ = new Notehead_register(c_l);
+ slur_reg_ = new Slur_register(c_l);
+}
+Voice_registers::~Voice_registers()
+{
+ delete head_reg_;
+ delete slur_reg_;
}
-
bool
Voice_registers::try_request(Request * r_l)
{
- bool b = head_reg_.try_request(r_l);
+ bool b = head_reg_->try_request(r_l);
if (!b)
- b = slur_reg_.try_request(r_l);
+ b = slur_reg_->try_request(r_l);
return b;
}
void
-Voice_registers::announce_element(Staff_elem_info i)
+Voice_registers::acknowledge_element(Staff_elem_info i)
{
if (i.voice_l_ != voice_l_)
return;
- if (i.origin_reg_l_ != &slur_reg_)
- slur_reg_.acknowledge_element(i);
+ if (i.origin_reg_l_ != slur_reg_)
+ slur_reg_->acknowledge_element(i);
}
void
Voice_registers::pre_move_processing()
{
- head_reg_.pre_move_processing();
- slur_reg_.pre_move_processing();
+ head_reg_->pre_move_processing();
+ slur_reg_->pre_move_processing();
}
void
Voice_registers::post_move_processing()
{
- head_reg_.post_move_processing();
- slur_reg_.post_move_processing();
+ head_reg_->post_move_processing();
+ slur_reg_->post_move_processing();
}
void
Voice_registers::process_requests()
{
- head_reg_.process_request();
- slur_reg_.process_request();
+ head_reg_->process_request();
+ slur_reg_->process_request();
}
bool
return (r->rest() || r->note() || r->slur());
}
-/****************/
-
-Notehead_register::Notehead_register(Complex_walker*w_l)
- :Request_register(w_l)
-{
- note_p_ = 0;
-}
-
-bool
-Notehead_register::try_request(Request *req_l)
-{
- if (req_l->note() || req_l->rest())
- accepted_req_arr_.push(req_l);
- else
- return false;
-
- return true;
-}
-
-void
-Notehead_register::process_request()
-{
- if (!accepted_req_arr_.size())
- return;
-
- Request* req_l = accepted_req_arr_.top();
- if (req_l->note()) {
- Notehead*n_p = new Notehead(8); // ugh
- note_p_ = n_p;
- n_p->set_rhythmic(req_l->rhythmic());
- n_p->position = req_l->note()->height() + -2;
- } else {
- note_p_ = new Rest ( req_l->rhythmic()->balltype,
- req_l->rhythmic()->dots);
- if (req_l->rhythmic()->balltype <= 2)
- note_p_->translate(
- Offset(0,
- 6 * walk_l_->staff()->paper()->internote()));
- }
- Staff_elem_info itinf(note_p_,req_l,this);
- walk_l_->announce_element(itinf);
-}
-
-void
-Notehead_register::do_pre_move_process()
-{
- if (note_p_) {
- walk_l_->typeset_element(note_p_);
- note_p_ = 0;
- }
-}
-
-/****************/
-
-Slur_register::Slur_register(Complex_walker* w)
- : Request_register(w)
-{
-}
-
-bool
-Slur_register::try_request(Request *req_l)
-{
- if(!req_l->slur())
- return false;
-
- accepted_req_arr_.push(req_l);
- return true;
-}
void
-Slur_register::acknowledge_element(Staff_elem_info info)
-{
- if (info.elem_p_->name() == String("Notehead")) {
- Notehead *head_p =(Notehead*) info.elem_p_ ;// ugh
- for (int i = 0; i < slur_l_stack_.size(); i++)
- slur_l_stack_[i]->add(head_p );
- for (int i = 0; i < end_slur_l_arr_.size(); i++)
- end_slur_l_arr_[i]->add(head_p);
- }
-}
-/*
- abracadabra
- */
-void
-Slur_register::process_request()
-{
- Array<Slur*> start_slur_l_arr_;
- for (int i=0; i< accepted_req_arr_.size(); i++) {
- Slur_req* slur_req_l = accepted_req_arr_[i]->slur();
- // end slur: move the slur to other array
- if (slur_req_l->spantype == Span_req::STOP) {
- if (slur_l_stack_.empty())
- warning("can't find slur to end",
- slur_req_l->defined_ch_c_l_m);
- else {
- end_slur_l_arr_.push(slur_l_stack_.pop());
- requests_arr_.pop();
- }
- } else if (slur_req_l->spantype == Span_req::START) {
- // push a new slur onto stack.
- //(use temp. array to wait for all slur STOPs)
- Slur * s_p =new Slur;
- requests_arr_.push(slur_req_l);
- start_slur_l_arr_.push(s_p);
- walk_l_->announce_element(Staff_elem_info(s_p, slur_req_l, this));
- }
- }
- for (int i=0; i < start_slur_l_arr_.size(); i++)
- slur_l_stack_.push(start_slur_l_arr_[i]);
-}
-
-void
-Slur_register::do_pre_move_process()
-{
- for (int i = 0; i < end_slur_l_arr_.size(); i++)
- walk_l_->typeset_element(end_slur_l_arr_[i]);
- end_slur_l_arr_.set_size(0);
-}
-
-Slur_register::~Slur_register()
+Voice_registers::set_dir(int i)
{
- for (int i=0; i < requests_arr_.size(); i++) {
- warning("unterminated slur", requests_arr_[i]->defined_ch_c_l_m);
- }
+ head_reg_->set_dir(i);
+ slur_reg_->set_dir(i);
}
#include "pscore.hh"
#include "debug.hh"
-/* el stupido. This should be done more accurately:
+/** el stupido. This should be done more accurately:
It would be nice to have a Dynamic Programming type of algorithm
similar to TeX's
*/
-
Array<Col_hpositions>
Word_wrap::solve()
{
curcol ++;
break_idx_i++;
}
- mtor << "Adding cols~, next breakpoint " << break_idx_i << '\n';
+
+ *mlog << "[" <<break_idx_i<<"]"<<flush;
breaking.push(minimum);
}