#class name silence?
yyFlexLexer 1
-PCol 1
-Score 1
+PCol 0
Score_column 1
Ineq_constrained_qp 1
Spacing_problem 1
Colinfo 1
Mixed_qp 1
PScore 1
-Parser 1
+Parser 0
Lexer 1
parse_duration 1
parse_pitch 1
Col_configuration 1
-Command 1
-Score_commands 1
Note_req 1
Rhythmic_req 1
Rest_req 1
delete_identifiers 1
+Command 0
+Staff_commands 0
Staff 0
+Score 0
Voice 0
Voice_element 0
-Request 1
+Request 0
Input_cursor 1
\ No newline at end of file
DOCFILES=commands CodingStyle algorithms Makefile breaking\
- slurfont pointers
+ slurfont pointers design
dist:
ln $(DOCFILES) $(DDIR)/Documentation/
\ No newline at end of file
--- /dev/null
+LilyPond is a "5-pass" system:
+
+1. Parsing:
+
+No difficult algorithms. Associated datastructures have prefix Input
+(eg Input_score, Input_command)
+
+2. Processing:
+
+Requests are processed and granted. In this step data-structures for
+3. are created and filled with data: PScore, PCol, PStaff
+
+3. Calculation:
+
+This step uses structures which have names starting with 'P'.
+linebreaks and horizontal positions of PCols are determined. Line_of_*
+generated.
+
+4. Postprocesing:
+
+Some items and all spanners need computation after the PCol positions
+are determined.
+
+5. Output
+
const.hh glob.hh molecule.hh boxes.hh pscore.hh item.hh tex.hh\
request.hh voice.hh command.hh staff.hh linestaff.hh \
tstream.hh rhythmstaff.hh\
- parseconstruct.hh debug.hh globvars.hh keyword.hh\
+ parseconstruct.hh debug.hh globvars.hh keyword.hh\
misc.hh score.hh notename.hh lexer.hh symtable.hh\
symbol.hh main.hh dimen.hh paper.hh lookup.hh\
sccol.hh stcol.hh staffcommands.hh melodicstaff.hh\
swalker.hh bar.hh meter.hh accidental.hh\
key.hh keyitem.hh localkeyitem.hh simplewalker.hh\
clef.hh clefitem.hh slur.hh inputcommands.hh\
- getcommand.hh inputmusic.hh
+ getcommand.hh inputmusic.hh \
+ inputscore.hh inputstaff.hh identparent.hh\
+ inputcommand.hh
-mycc= qlp.cc qlpsolve.cc \
+mycc= qlp.cc qlpsolve.cc leastsquares.cc\
+ inputcommands.cc inputmusic.cc inputcursor.cc\
+ inputscore.cc inputstaff.cc\
break.cc linespace.cc molecule.cc staffline.cc\
pscore.cc tex.cc item.cc pcol.cc staff.cc \
rhythmstaff.cc score.cc note.cc main.cc misc.cc\
keyword.cc linestaff.cc table.cc command.cc\
warn.cc debug.cc symtable.cc boxes.cc\
pstaff.cc tstream.cc\
- calcideal.cc scores.cc identifier.cc \
+ calcideal.cc scores.cc \
dimen.cc paper.cc lookup.cc staffcommands.cc\
sccol.cc stcol.cc getcommands.cc simplestaff.cc\
melodicstaff.cc simpleprint.cc stem.cc\
- spanner.cc notehead.cc leastsquares.cc beam.cc\
- texbeam.cc rest.cc swalker.cc scoreline.cc\
+ spanner.cc notehead.cc \
+ rest.cc swalker.cc scoreline.cc\
simplewalker.cc bar.cc meter.cc accidental.cc\
- key.cc keyitem.cc localkeyitem.cc\
- clef.cc clefitem.cc texslur.cc slur.cc\
- inputcommands.cc inputmusic.cc\
- inputcursor.cc\
+ keyitem.cc localkeyitem.cc\
+ clefitem.cc texbeam.cc texslur.cc clef.cc key.cc slur.cc beam.cc\
+ idealspacing.cc inputcommand.cc\
template1.cc template2.cc template3.cc template4.cc\
version.cc
# version info
MAJVER=0
MINVER=0
-PATCHLEVEL=13
+PATCHLEVEL=14
VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
# directories
-MAJVER=1
-MINVER=0
-PATCHLEVEL=13
+include Variables.make
-PACKAGENAME=flower
-VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
-DNAME=$(PACKAGENAME)-$(VERSION)
-DEFINES=-DNDEBUG -O2
-#DEFINES=-g
-CXXFLAGS+=$(DEFINES) -Wall -W -pedantic
-
-include Sources.make
-
-obs=$(cc:.cc=.o)
-staticlib=libflower.a
-
-$(staticlib): $(obs)
+$(staticlib): $(obs) fversion.hh
$(AR) cr libflower.a $(obs)
include depend
realclean: clean
rm -f depend
-DFILES=$(hh) $(cc) $(inl) $(templatecc) Makefile Sources.make TODO README
-DDIR=$(DNAME)
+fversion.hh: Variables.make make_version
+ make_version $(MAJVER) $(MINVER) $(PATCHLEVEL) "$(CXX) `$(CXXVER)`" > $@
+
dist:
-mkdir $(DDIR)
--- /dev/null
+MAJVER=1
+MINVER=0
+PATCHLEVEL=14
+
+PACKAGENAME=flower
+VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
+DNAME=$(PACKAGENAME)-$(VERSION)
+DEFINES=-DNDEBUG -O2
+#DEFINES=-g
+CXXFLAGS+=$(DEFINES) -Wall -W -pedantic
+CXXVER=$(CXX) --version
+include Sources.make
+
+obs=$(cc:.cc=.o)
+staticlib=libflower.a
+
+DFILES=$(hh) $(cc) $(inl) $(templatecc) Makefile Variables.make make_version\
+ Sources.make TODO README
+DDIR=$(DNAME)
#include "vray.hh"
#include <assert.h>
-template<class K,class V>
+template<class K, class V>
struct Assoc_ent_ {
bool free;
K key;
assert(elt_query(key));
return arr[find(key)].val;
}
-
};
/** mindblowingly stupid Associative array implementation
*/
void del();
/// access the list this came from
- const List<T>& list() const ;
+ List<T>& list() const ;
Link<T>* pointer();
private:
}
template<class T>
-inline const List<T>&
+inline List<T>&
Cursor<T>::list() const
{
return list_;
template<class T> struct Handle ;
-struct Assoc_ent_ ;
-struct Assoc ;
-struct Assoc_iter ;
struct Choleski_decomposition ;
struct Interval ;
struct long_option_init ;
--- /dev/null
+#!/bin/sh
+
+echo '#ifndef FVERSION_HH'
+echo '#define FVERSION_HH'
+
+echo '#define FMAJORVERSION ' $1
+echo '#define FMINORVERSION ' $2
+echo '#define FPATCHLEVEL ' $3
+echo '#define FVERSIONSTR "'$1.$2.$3'"'
+echo '#define FCOMPILER "'$4'"'
+echo '#endif'
/// pl. which deletes pointers given to it.
template<class T>
struct IPointerList : public PointerList<T> {
- IPointerList(IPointerList&) { set_empty(); }
+ IPointerList(const IPointerList&) { set_empty(); }
IPointerList() { }
protected:
virtual void remove( Cursor<void*> me ) { remove (PCursor<T>(me)); }
#ifndef CLEF_HH
#define CLEF_HH
-#include "string.hh"
+#include "scalar.hh"
#include "vray.hh"
struct Clef {
String clef_type;
Clef();
- void read(svec<String> args);
+ void read(svec<Scalar> args);
};
#endif // CLEF_HH
#include "glob.hh"
#include "vray.hh"
-#include "string.hh"
+#include "scalar.hh"
enum Commandcode {
NOP,
Real when;
/// analogous to argv[]
- svec<String> args;
+ svec<Scalar> args;
///
int priority;
-Command*get_clef_interpret_command(String w);
-Command *get_bar_command(Real);
-Command* get_meterchange_command( int,int);
+/*
+ getcommand.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef GETCOMMAND_HH
+#define GETCOMMAND_HH
+#include "proto.hh"
+
+
Command* get_meter_command( Real,int,int);
-Command* get_skip_command( int,Real);
-Command* get_key_interpret_command(svec<String>);
-Command *get_reset_command();
-Command*get_partial_command(Real u);
+
+
+
+#endif // GETCOMMAND_HH
#ifndef IDENTIFIER_HH
#define IDENTIFIER_HH
-#include "proto.hh"
-#include "string.hh"
-
-struct Identifier
-{
- void *data;
- String name;
-
- Identifier(String n) ;
- virtual ~Identifier();
- virtual Staff * staff() { assert(false); }
- virtual Voice_list * voices() { assert(false); }
-};
-
-struct Staff_id : Identifier {
- Staff_id(String s, Staff*st):Identifier(s) { data = st; }
- virtual Staff* staff() { return (Staff*) data; }
- ~Staff_id();
-};
-
-struct Voices_id : Identifier {
- Voices_id(String s, Voice_list*st):Identifier(s) { data = st; }
- virtual Voice_list * voices() { return (Voice_list*)data; }
- ~Voices_id();
-};
+#include "identparent.hh"
+#include "inputstaff.hh"
+#include "inputmusic.hh"
+
+#define make_id_class(Idclass, Class, accessor) \
+struct Idclass : Identifier {\
+ Idclass(String s, Class*st):Identifier(s) { data = st; }\
+ virtual Class* accessor() { return (Class*) data; }\
+ ~Idclass() { delete accessor(); }\
+}\
+
+
+make_id_class(Staff_id, Input_staff, staff);
+make_id_class(M_chord_id, Music_general_chord, mchord);
+make_id_class(M_voice_id, Music_voice, mvoice);
+
#endif // IDENTIFIER_HH
--- /dev/null
+/*
+ identparent.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef IDENTPARENT_HH
+#define IDENTPARENT_HH
+
+#include "proto.hh"
+#include "string.hh"
+
+struct Identifier
+{
+ void *data;
+ String name;
+
+ Identifier(String n) : name(n) { }
+ virtual ~Identifier() {}
+ virtual Input_staff * staff() { assert(false); }
+ virtual Voice_list * voices() { assert(false); }
+ virtual Horizontal_music*hmusic() { assert(false); }
+ virtual Vertical_music*vmusic() { assert(false); }
+ virtual Music_voice *mvoice() { assert(false); }
+ virtual Music_general_chord *mchord() { assert(false); }
+};
+#endif // IDENTPARENT_HH
+
+
+
--- /dev/null
+/*
+ inputcommand.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef INPUTCOMMAND_HH
+#define INPUTCOMMAND_HH
+#include "proto.hh"
+#include "scalar.hh"
+#include "vray.hh"
+
+
+struct Input_command {
+ Real when;
+
+ /// analogous to argv[]
+ svec<Scalar> args;
+ void print()const;
+ Input_command();
+ Input_command(Real);
+ operator Command();
+};
+
+Input_command* get_meterchange_command( int,int);
+Input_command* get_key_interpret_command(svec<String>);
+Input_command* get_clef_interpret_command(String w);
+Input_command *get_reset_command();
+Input_command *get_partial_command(Real u);
+Input_command* get_skip_command( int,Real);
+
+void
+interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat,
+ Real& whole_per_measure);
+
+Input_command *get_bar_command(Real );
+#endif // INPUTCOMMAND_HH
+
#include "plist.hh"
#include "real.hh"
-struct Input_cursor : public PCursor<Command*>
+
+struct Input_cursor : public PCursor<Input_command*>
{
/// current measure info
Real whole_per_measure;
int bars;
- Input_cursor(PCursor<Command*>);
+ Input_cursor(PCursor<Input_command*>);
/// hmm. not safe. Should rethink cursor.
void operator++(int);
/** warning: no optor -- () defined.. */
void reset();
Real when()const;
- void add(Command*);
+ void add(Input_command*);
void setpartial(Real);
- void addbot(Command*);
+ void addbot(Input_command*);
void sync();
void print()const;
void last_command_here();
};
/// the list of commands in Score
-struct Input_commands : public IPointerList<Command*> {
+struct Input_commands : public IPointerList<Input_command*> {
Input_cursor ptr;
/****************/
Input_commands();
Input_commands(Input_commands const&);
- void add(Command*);
+ void add(Input_command);
void reset();
void print()const;
Staff_commands *parse() const;
void
-interpret_meter(Command *c, int &beats_per_meas, int& one_beat,
+interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat,
Real& whole_per_measure);
#endif // INPUTCOMMANDS_HH
virtual Voice_list convert()=0;
virtual Real length()=0;
virtual void translate_time(Real dt)=0;
+ virtual Vertical_music *clone() const = 0;
+ virtual ~Vertical_music() {}
+ virtual void print() const =0;
};
struct Horizontal_music {
virtual Voice_list convert()=0;
virtual Real length()=0;
virtual void translate_time(Real dt)=0;
-};
-
-struct Horizontal_simple : Horizontal_music {
- Voice * voice_;
-
- /****************/
-
- Horizontal_simple();
- void set(Voice*);
- virtual Real length();
- virtual Voice_list convert();
- virtual void translate_time(Real dt);
-
+ virtual Horizontal_music *clone() const = 0;
+ virtual ~Horizontal_music() {}
+ virtual void print() const =0;
};
struct Vertical_simple : Vertical_music {
- Voice * voice_;
+ Voice * voice_; // should be a real member
/****************/
+ Vertical_simple(Vertical_simple const&);
Vertical_simple();
+ ~Vertical_simple();
void add(Voice_element*);
virtual Vertical_simple*simple() { return this; }
virtual Real length();
virtual Voice_list convert();
virtual void translate_time(Real dt);
+ virtual Vertical_music *clone() const {
+ return new Vertical_simple(*this);
+ }
+ virtual void print() const ;
};
struct Music_voice : Horizontal_music {
- PointerList<Vertical_music*> voice_ ;
+ IPointerList<Vertical_music*> voice_ ;
/****************/
-
+ Music_voice() {}
+ Music_voice(Music_voice const&);
Real length();
void add(Vertical_music*);
void add(Voice_element*);
virtual Voice_list convert();
virtual void translate_time(Real dt);
+ virtual Horizontal_music *clone() const {
+ return new Music_voice(*this);
+ }
+ void concatenate(Music_voice*);
+ virtual void print() const ;
};
struct Music_general_chord : Vertical_music {
- PointerList<Horizontal_music*> chord_;
+ IPointerList<Horizontal_music*> chord_;
/****************/
+ Music_general_chord() {}
+ Music_general_chord(Music_general_chord const&s);
void add(Horizontal_music*);
virtual Real length();
virtual Voice_list convert();
virtual void translate_time(Real dt);
+ virtual Vertical_music *clone() const {
+ return new Music_general_chord(*this);
+ }
+ void concatenate(Music_general_chord*);
+ virtual void print() const ;
};
--- /dev/null
+#ifndef ISCORE_HH
+#define ISCORE_HH
+#include "vray.hh"
+#include "proto.hh"
+#include "plist.hh"
+
+
+/// the total music def of one movement
+struct Input_score {
+ /// paper_, staffs_ and commands_ form the problem definition.
+ Paperdef *paper_;
+ IPointerList<Input_staff*> staffs_;
+ IPointerList<Input_command*> commands_;
+
+ /****************************************************************/
+ Input_score();
+ Input_score(Input_score&);
+ void add(svec<Input_command*> &s);
+ void add(Input_staff*);
+ ~Input_score();
+ /// construction
+ void set(Paperdef*);
+ void print() const;
+ Score*parse();
+};
+/**
+
+ */
+#endif
--- /dev/null
+/*
+ inputstaff.hh -- part of LilyPond
+
+ (c) 1996 Han-Wen Nienhuys
+*/
+
+#ifndef INPUTSTAFF_HH
+#define INPUTSTAFF_HH
+
+#include "string.hh"
+#include "plist.hh"
+#include "vray.hh"
+#include "proto.hh"
+
+struct Input_staff {
+ String type;
+ IPointerList<Input_command*> commands_;
+ IPointerList<Horizontal_music*> music_;
+
+ /****************/
+
+ void add(Horizontal_music*m);
+ Input_staff(Input_staff&);
+ Input_staff(String);
+ void add(svec<Input_command*> &s);
+ Staff* parse(PointerList<Input_command*>);
+ void print() const;
+
+};
+
+
+#endif // INPUTSTAFF_HH
+
#define KEY_HH
#include "vray.hh"
-#include "string.hh"
+#include "scalar.hh"
class Key {
svec<int> accidentals;
/****************/
public:
- svec<int> read(svec<String> );
- svec<int> oldkey_undo(svec<String>);
+ svec<int> read(svec<Scalar> );
+ svec<int> oldkey_undo(svec<Scalar>);
Key();
void set(int i, int acc);
#include "symbol.hh"
#include "fproto.hh"
+#include "scalar.hh"
+
struct Lookup {
Symtables *symtables_;
pos == -3: below staff
*/
- Symbol meter(svec<String>);
+ Symbol meter(svec<Scalar>);
Symbol stem(Real y1_pos, Real y2_pos);
Symbol rule_symbol(Real height, Real width);
Symbol accidental(int);
void debug_init();
void set_debug(bool);
void do_scores();
-void add_score(Score * s);
+void add_score(Input_score * s);
void set_default_output(String s);
const char *get_version();
virtual Rest *get_rest(Rest_req *rq);
virtual void set_output(PScore *);
- virtual Melodic_staff*clone()const;
+
virtual Item* get_TYPESET_item(Command*);
virtual Stem * get_stem(Stem_req *rq);
virtual Notehead * get_notehead(Note_req *rq, int bot);
#include "vray.hh"
struct Meter: Item {
- svec<String> args;
+ svec<Scalar> args;
- Meter(svec<String> args) ;
+ Meter(svec<Scalar> args) ;
void preprocess();
};
#endif // METER_HH
PScore * pscore_;
/****************/
-
+ /// which one (left =0)
+ int rank() const;
/// does this column have items, does it have spacings attached?
bool used() const;
struct Vertical_simple ;
struct Music_voice;
struct Music_general_chord;
-
+struct Input_score;
+struct Input_staff;
+struct Input_command;
#endif // PROTO_HH
virtual Stem *get_stem(Stem_req *rq);
virtual Notehead * get_notehead(Note_req *rq, int b);
virtual void set_output(PScore *);
- virtual Rhythmic_staff*clone()const;
};
#endif // RHYTHMSTAF_HH
static int compare(Score_column & c1, Score_column &c2) {
return sgn(c1.when - c2.when);
}
+ void add_duration(Real );
+ void preprocess();
void set_breakable() {
pcol_->set_breakable();
}
/// paper_, staffs_ and commands_ form the problem definition.
Paperdef *paper_;
IPointerList<Staff*> staffs_;
-
- svec<Command*> input_commands_;
/// "runtime" fields for setting up spacing
IPointerList<Score_column*> cols_;
PScore *pscore_;
/****************************************************************/
- void add(svec<Command*> &s);
-
+
/// construction
- void add_staff(Staff *st);
- void set(Paperdef*);
- Score();
+ Score(Paperdef*);
~Score();
void add(Staff*);
Score *score_;
PScore *pscore_;
- svec<Command*> input_commands_;
-
/****************************************************************/
- void add(svec<Command*> &s);
void add(PointerList<Voice*> &s);
- void process_input_commands(svec<Command*> &s, Real l);
-
+ void process_commands(Real l);
+
Staff(const Staff&src);
void add_voice(Voice *v);
void add_staff_column(Staff_column *sp);
Staff_column * get_col(Real,bool);
Staff();
- /**
- Should construct with Score as arg, but this isn't known during parsing.
- */
+
/****************************************************************
VIRTUALS
****************************************************************/
- virtual Staff*clone()const=0;
+
virtual void set_output(PScore * destination)=0;
virtual void walk()=0;
virtual Staff_column * create_col(Score_column * )=0;
bool mus() const;
Real when() const;
void add(Voice_element*ve);
+
/****************************************************************
VIRTUAL
****************************************************************/
#include "string.hh"
#include "boxes.hh"
+#include "scalar.hh"
/// parameter substitution in TeXstrings
String
eval({"X","Y"}) == "texXblaY"
*/
+/// parameter substitution in TeXstrings
+String
+substitute_args(String source, svec<Scalar> args);
+
/// #h# is in points
String vstrut(Real h);
%
% bare bones version. (written down from memory :-)
-melodie = $ \octave {c}
+melodie = music {$ \octave {c}
%%% theme
c c g g a a g2 f f e e d d c2
g g f f e e d d g g f f e e d d
%%% var 1
c r8 c8 ( ) g r8 g8 ( ) a r8 a8 ( ) g r4
f r8 f8 ( ) e4 r8 e8 ( ) d4 r8 d8 ( ) c4 r4
-$
+$}
-begeleiding = $
+begeleiding = $\music {
\octave {`c}
%%% theme
`c c e c f c e c d `b c `a `f `g `c2
%%%% var 1
r8 e8() c r8 e8() c r8 f8()c r8 e8()c
r8 d8()`b r8 c8()`a r8 `a8()`f r8 `e8()`c
-$
+}$
-bstaf = melodicstaff {
- voices { begeleiding }
+bstaf = staff {
+ melodic
+ music { begeleiding }
commands {
clef bass
}
}
-vstaf = melodicstaff {
- voices { melodie }
+vstaf = staff {
+ melodic
+ music { melodie }
}
staff { vstaf }
staff { bstaf }
paper {
-% unitspace 2.5cm
+ unitspace 2.5cm
}
commands {
meter 2 4
-ritme = rhythmstaff {
- $
+ritme = staff {rhythmic
+ music {$
c8 c2 c2
%[c8( )'a8 c8 c8]
c2 c2
[fis16 'dis16( fis16 'dis16 ][fis16) 'dis16 fis16 'dis16]
- c2 r32 r32 r16 r8 r4 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 $
+ c2 r32 r32 r16 r8 r4 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 c2 $}
}
melody=
-melodicstaff {
- $
+staff { melodic
+ music{$
c8
r1
'cis2.. r8
r4 r8 r16 r32 r32
\duration {4} \chord {
- \voice { c () `bes c}
- \voice {'fis ()'gisis fis }
- \voice { d () d dis }
- \voice { a () bes eis }
- \voice { fis () g gis }
+ \music { c () `bes c}
+ \music { 'fis ()'gisis fis }
+ \music { d () d dis }
+ \music { a () bes eis }
+ \music { fis () g gis }
}
c4
a8 b8 'c8 'd8 ''c8 ```c8 c4 c4 c4 c4
\duration{ 16 } `b `a `g `f \duration{ 4}
c `b `a `g `f `e `d `c ``b ``a ``g ``f ``e ``d ``c
- $
+ $}
-
-commands {
+ commands {
+ skip 0:0.125
skip 2:0
key $ fis cis gis $
skip 2:0
staff { melody }
% staff { melody }
commands {
- partial 0.125 skip 0:0.125
-
meter 4 4
+ partial 0.125 skip 0:0.125
skip 2:0
meter 2 4
skip 19:0
% pavane pour une Infante d\'efunte
%
-% M. Ravel
+% Maurice Ravel
%
% (Ravel has been dead for over 50 years. This does not have copyright)
%
-horn = melodicstaff {
- $
+horn =
+staff {melodic
+ music{ $
\octave { 'c }
\duration { 8}
cis4 d4()[d cis d e]
\octave { c }
a4 gis2.
- a4 b4()[b a b cis] fis4 e4 cis2
+ a4 b4()[b a b 'cis] fis4 e4 cis2
e4 fis4 () [fis e fis gis] cis4 `b4()`b8 r8 r4
r4 r4 'cis4 'd4 () ['d 'cis 'd 'e]
- a4 gis2. a4 b4()[b a b cis]
+ a4 gis2. a4 b4()[b a b 'cis]
fis4 e4 cis2 e4 fis4()[fis e fis gis]
cis4 `b4()`b8 r8 r4 r1
r2 r4 r4
r4 fis2 fis4 fis2()[fis e a fis]
fis4 e4 d4 e4 `b2() [`b `a d cis]
`b [`fis `a `b] cis4 `b4 `fis2 r2
- $
- commands {
+ $}
+ commands {
key $fis cis $
}
}
score {
- staff { horn }
- paper { unitspace 2.2 cm
- geometric 1.5
+ staff {
+ horn
+ }
+ paper {
+ unitspace 1.5 cm
+ geometric 1.4
}
commands { meter 4 4
skip 18:0
#include "stem.hh"
#include "paper.hh"
#include "lookup.hh"
+#include "scalar.hh"
struct Stem_info {
void
Score::connect(PCol* c1, PCol *c2, Real d, Real h)
{
- if (c2->used() && c1->used()) {
- do_connect(c1,c2,d,h);
- do_connect(c1->postbreak, c2,d,h);
- do_connect(c1, c2->prebreak,d,h);
- do_connect(c1->postbreak, c2->prebreak,d,h);
- }
+ do_connect(c1,c2,d,h);
+ do_connect(c1->postbreak, c2,d,h);
+ do_connect(c1, c2->prebreak,d,h);
+ do_connect(c1->postbreak, c2->prebreak,d,h);
}
/* this needs A LOT of rethinking.
void
Score::calc_idealspacing()
{
+#if 1
PCursor<Score_column*> i(cols_);
for (; i.ok(); i++) {
-
+ assert(i->used());
PCursor<Score_column*> j (i+1);
if (i->musical) {
for (int n=0; n < i->durations.sz(); n++) {
Real d = i->durations[n];
Real dist = paper_->duration_to_dist(d);
- while (d + i->when > j->when)
+ while (j->when < d + i->when)
j++;
+
+ assert(j->when == d+i->when);
- if (j->used())
- connect(i->pcol_, j->pcol_, dist);
- if (!j->musical && (j+1)->used && (j+1)->when == j->when) {
+ connect(i->pcol_, j->pcol_, dist);
+ if (!j->musical && (j+1).ok()
+ && (j+1)->when == j->when) {
j++;
connect(i->pcol_, j->pcol_, dist);
}
}
- } else if (i->used()) {
-
+ } else if (j.ok()) {
+
/* attach i to the next column in use. This exists, since
the last col is breakable, and therefore in use
*/
- for (;j.ok(); j++) {
- if (j->used()) {
- Real d = j->when - i->when;
- Real dist = (d) ? paper_->duration_to_dist(d) :
- convert_dimen(2,"pt");
+
+ Real d = j->when - i->when;
+ Real dist = (d) ? paper_->duration_to_dist(d) :
+ convert_dimen(2,"pt");
+
+ connect(i->pcol_, j->pcol_, dist, (d) ? 1.0:1.0);
+ }
+ // !j.ok() might hold if we're at the last col.
+
+ }
+#else
+ PCursor<Score_column*> sc(cols_);
- connect(i->pcol_, j->pcol_, dist, (d) ? 1.0:1.0);
- break;
- }
+ for (; sc.ok(); sc++) {
+ if (sc->musical)
+ for (int i=0; i < sc->durations.sz(); i++) {
+ Real d = sc->durations[i];
+ Real dist = paper_->duration_to_dist(d);
+ PCol * c2 = find_col(sc->when + d,true)->pcol_;
+ connect(sc->pcol_, c2, dist);
+ c2 = find_col(sc->when + d,false)->pcol_;
+ connect(sc->pcol_, c2, dist);
}
- // !j.ok() might hold if we're at the last col.
+ else if (sc->used()) { // ignore empty columns
+ PCol * c2 = find_col(sc->when,true)->pcol_;
+ connect(sc->pcol_, c2, 0.0);
}
- }
+#endif
}
}
void
-Clef::read(svec<String> args)
+Clef::read(svec<Scalar>args)
{
clef_type = args[0];
if (clef_type == "violin") {
#include "string.hh"
+#include "inputcommand.hh"
#include "parseconstruct.hh"
#include "command.hh"
Command*
-get_partial_command(Real u)
-{
- Command*c = new Command;
- c->code = INTERPRET;
- c->args.add("PARTIAL");
- c->args.add(u);
- return c;
-}
-
-Command*
-get_reset_command()
-{
- Command*c = new Command;
- c->code = INTERPRET;
- c->args.add("RESET");
- return c;
-}
-
-Command*
-get_key_interpret_command(svec<String> which)
+get_key_interpret_command(svec<Scalar> which)
{
Command*c = new Command;
c->code = INTERPRET;
}
Command*
-get_clef_interpret_command(String w)
-{
- Command*c = new Command;
- c->code = INTERPRET;
- c->args.add("CLEF");
- c->args.add(w);
- c->priority = 190;
- return c;
-}
-
-Command*
-get_key_typeset_command(svec<String> which)
+get_key_typeset_command(svec<Scalar>which)
{
Command*c = new Command;
c->code = TYPESET;
return c;
}
-Command *
-get_meterchange_command(int n, int m)
-{
- Command*c = new Command;
-
- c->code = INTERPRET;
- c->args.add( "METER");
- c->args.add( n );
- c->args.add( m );
- c->priority = 170; // more than bar
- return c;
-}
-
Command *
get_meter_command(Real w, int n, int m)
{
c->priority = 40;
return c;
}
-
+#if 0
Command*
get_bar_command(Real w)
{
}
-Command *
-get_skip_command(int n, Real m)
-{
- Command*c = new Command;
-
- c->code = INTERPRET;
- c->args.add( "SKIP");
- c->args.add( n );
- c->args.add( m );
- c->priority = 0;
- return c;
-}
-
-
+#endif
--- /dev/null
+#include "pcol.hh"
+#include "pscore.hh"
+#include "pstaff.hh"
+#include "debug.hh"
+
+void
+Idealspacing::print() const
+{
+#ifndef NPRINT
+ mtor << "idealspacing {" ;
+ mtor << "distance "<<space<< " strength " << hooke ;
+ mtor << "left " << left->rank() << " right " << right->rank() << "}\n";
+#endif
+}
+
+Idealspacing::Idealspacing(const PCol * l,const PCol * r)
+{
+ space = 0.0;
+ hooke = 0.0;
+ left = l;
+ right = r;
+}
+
+void
+Idealspacing::OK() const
+{
+#ifndef NDEBUG
+ assert(hooke >= 0 && left && right);
+#endif
+}
+++ /dev/null
-#include <assert.h>
-#include "identifier.hh"
-#include "staff.hh"
-#include "lexer.hh"
-#include "inputmusic.hh"
-
-
-Identifier::Identifier(String n)
- :name (n)
-{
- data = 0;
-}
-
-
-Identifier::~Identifier()
-{
-}
-
-Staff_id::~Staff_id()
-{
- delete staff();
-}
-
-Voices_id::~Voices_id()
-{
- voices()->junk();
- delete voices();
-}
--- /dev/null
+#include "inputcommand.hh"
+#include "debug.hh"
+#include "command.hh"
+
+Input_command::Input_command()
+{
+ when = -1;
+}
+
+Input_command::Input_command(Real w)
+{
+ when =w;
+}
+
+Input_command::operator Command()
+{
+ Command c(when);
+ if (!args.sz())
+ return c;
+
+ c.code = INTERPRET;
+ String s = args[0];
+
+ int p;
+ if (s == "KEY")
+ p = 200;
+ else if (s=="CLEF")
+ p = 190;
+ else if (s == "METER")
+ p = 180;
+ else if (s == "BAR")
+ p = 170;
+
+ c.priority = p;
+ c.args = args;
+
+ return c;
+}
+
+
+Input_command*
+get_partial_command(Real u)
+{
+ Input_command*c = new Input_command;
+ c->args.add("PARTIAL");
+ c->args.add(u);
+ return c;
+}
+
+Input_command*
+get_key_interpret_command(svec<String>a )
+{
+ Input_command*c = new Input_command;
+ c->args.add("KEY");
+ for (int i=0; i < a.sz(); i ++)
+ c->args.add(a[i]);
+
+ return c;
+}
+
+Input_command*
+get_reset_command()
+{
+ Input_command*c = new Input_command;
+ c->args.add("RESET");
+ return c;
+}
+
+Input_command *
+get_meterchange_command(int n, int m)
+{
+ Input_command*c = new Input_command;
+
+ c->args.add( "METER");
+ c->args.add( n );
+ c->args.add( m );
+
+ return c;
+}
+
+Input_command *
+get_bar_command(Real w)
+{
+ Input_command*c = new Input_command;
+ c->when = w;
+ c->args.add( "BAR");
+ c->args.add( "|");
+
+ return c;
+}
+
+Input_command *
+get_skip_command(int n, Real m)
+{
+ Input_command*c = new Input_command;
+
+ c->args.add( "SKIP");
+ c->args.add( n );
+ c->args.add( m );
+
+ return c;
+}
+
+
+void
+Input_command::print()const
+{
+ mtor << "{ at " << when;
+ if (args.sz()) {
+ mtor<< " args: ";
+ for (int i = 0; i<args.sz(); i++)
+ mtor << "`"<<args[i] <<"',";
+ }
+ mtor << "}\n";
+}
+
+Input_command*
+get_clef_interpret_command(String w)
+{
+ Input_command*c = new Input_command;
+ c->args.add("CLEF");
+ c->args.add(w);
+ return c;
+}
*/
#include "inputcommands.hh"
+#include "inputcommand.hh"
#include "debug.hh"
#include "staffcommands.hh"
#include "getcommand.hh"
Input_commands::Input_commands(Input_commands const&src)
: ptr(src.ptr)
{
- IPointerList<Command*> &me(*this);
- const IPointerList<Command*> &that(src);
+ IPointerList<Input_command*> &me(*this);
+ const IPointerList<Input_command*> &that(src);
PL_copy(me, that);
}
Input_commands::Input_commands()
: ptr (bottom())
{
- Command c(0.0);
- bottom().add(new Command(c));
+ Input_command c(0.0);
+ bottom().add(new Input_command(c));
ptr = bottom();
}
if (ptr.when() >= last)
reset_=true;
- PCursor<Command*> i(*this);
+ PCursor<Input_command*> i(*this);
while (i.ok() && i ->when < last)
i++;
ptr.addbot(get_bar_command(bar_when));
find_moment(w); // tail-recursion. todo
} else {
- ptr.addbot(new Command(w));
+ ptr.addbot(new Input_command(w));
}
} else if (ptr.when() != w) {
- ptr.insert(new Command(w));
+ ptr.insert(new Input_command(w));
ptr--;
}
}
void
-Input_commands::add(Command *c)
+Input_commands::add(Input_command c)
{
- assert(c->code==INTERPRET);
- if (c->args[0] == "PARTIAL") {
- Real p = c->args[1].fvalue();
+ if (c.args[0] == "PARTIAL") {
+ Real p = c.args[1].fvalue();
ptr.setpartial(p);
- } else if (c->args[0] == "METER") {
+ } else if (c.args[0] == "METER") {
int beats_per_meas, one_beat;
Real r;
- interpret_meter(c, beats_per_meas, one_beat, r);
- Command *ch = get_meterchange_command(beats_per_meas, one_beat);
+ interpret_meter(&c, beats_per_meas, one_beat, r);
+ Input_command *ch = get_meterchange_command(beats_per_meas, one_beat);
ch->when = ptr.when();
ptr.add(ch);
-
- delete c;
-
- } else if (c->args[0] == "KEY" || c->args[0] == "CLEF") {
- c->when = ptr.when();
- ptr.add(c);
- } else if (c->args[0] == "SKIP") {
- int bars = c->args[1].value() ;
- Real wholes= c->args[2].fvalue();
+
+ } else if (c.args[0] == "KEY" || c.args[0] == "CLEF") {
+ Input_command *ic = new Input_command(c);
+ ic->when = ptr.when();
+ ptr.add(ic);
+ } else if (c.args[0] == "SKIP") {
+ int bars = c.args[1].value() ;
+ Real wholes= c.args[2].fvalue();
while (bars > 0 || wholes > 0.0) {
do_skip(bars, wholes);
}
- delete c;
- } else if (c->args[0] == "RESET") {
- delete c;
-
+ } else if (c.args[0] == "RESET") {
reset();
}
nc->process_add(c);
}
- for (PCursor<Command*> cc(*this); cc.ok(); cc++) {
- if (cc->code != NOP)
+ for (PCursor<Input_command*> cc(*this); cc.ok(); cc++) {
+ if (cc->args.sz() && cc->args[0] !="")
nc->process_add(**cc);
}
*/
#include "inputcommands.hh"
+#include "inputcommand.hh"
#include "debug.hh"
#include "staffcommands.hh"
#include "getcommand.hh"
#include "command.hh"
void
-interpret_meter(Command *c, int &beats_per_meas, int& one_beat,
+interpret_meter(Input_command *c, int &beats_per_meas, int& one_beat,
Real& whole_per_measure)
{
beats_per_meas = c->args[1].value();
last=0;
}
-Input_cursor :: Input_cursor(PCursor<Command*>c)
- :PCursor<Command*>(c)
+Input_cursor :: Input_cursor(PCursor<Input_command*>c)
+ :PCursor<Input_command*>(c)
{
reset();
}
Input_cursor::operator++(int)
{
last = when();
- (*(PCursor<Command*> *) this) ++;
+ (*(PCursor<Input_command*> *) this) ++;
if (ok()) {
sync();
- if (ptr()->code == INTERPRET && ptr()->args[0] == "METER") {
+ if (ptr()->args[0] == "METER") {
int i,j;
interpret_meter(ptr(), i, j, whole_per_measure);
}
}
void
-Input_cursor::addbot(Command*c)
+Input_cursor::addbot(Input_command*c)
{
assert(!ok());
add(c);
void
-Input_cursor::add(Command*c)
+Input_cursor::add(Input_command*c)
{
- PCursor<Command*> ::add(c);
+ PCursor<Input_command*> ::add(c);
(*this)++;
}
Input_cursor::last_command_here()
{
assert(ok());
- PCursor<Command*> next = (*this)+1;
+ PCursor<Input_command*> next = (*this)+1;
while (next.ok() && next->when == when()){
*this = next;
next = *this +1;
+#include "debug.hh"
#include "inputmusic.hh"
#include "voice.hh"
{
voice_ = new Voice;
}
-
+Vertical_simple::Vertical_simple(Vertical_simple const&s)
+{
+ voice_ = new Voice(*s.voice_);
+}
void
Vertical_simple::add(Voice_element*v)
{
{
voice_->start += t;
}
+
Voice_list
Vertical_simple::convert()
{
Voice_list l;
- l.bottom().add(voice_);
+ l.bottom().add(new Voice(*voice_));
return l;
}
-
+Vertical_simple::~Vertical_simple()
+{
+ delete voice_;
+}
+
+void
+Vertical_simple::print() const
+{
+ mtor << "Vertical_simple {";
+ voice_->print();
+ mtor << "}\n";
+}
+
/****************/
+void
+Music_voice::print() const
+{
+ mtor << "Music_voice {";
+ for (PCursor<Vertical_music*> i(voice_); i.ok(); i++)
+ i->print();
+ mtor << "}\n";
+}
+
+void
+Music_voice::concatenate(Music_voice*h)
+{
+ for (PCursor<Vertical_music*> i(h->voice_); i.ok(); i++)
+ add(i->clone());
+}
+
+
+Music_voice::Music_voice(Music_voice const&s)
+{
+ for (PCursor<Vertical_music*> i(s.voice_); i.ok(); i++)
+ add(i->clone());
+}
void
Music_voice::add(Voice_element*v)
void
Music_voice::add(Vertical_music*v)
{
- // v->translate_time(length());
voice_.bottom().add(v);
}
Real here = 0.0;
for (PCursor<Vertical_music*> i(voice_); i.ok(); i++) {
- Real len = i->length(); // has to be stored, since translate_time doesn't work on copies of the contents of i.
+ Real len = i->length();
Voice_list k(i->convert());
k.translate_time(here);
l.concatenate(k);
/****************/
+void
+Music_general_chord::print() const
+{
+ mtor << "Music_general_chord {";
+ for (PCursor<Horizontal_music*> i(chord_); i.ok(); i++)
+ i->print();
+ mtor << "}\n";
+}
+
+void
+Music_general_chord::concatenate(Music_general_chord*v)
+{
+ for (PCursor<Horizontal_music*> i(v->chord_); i.ok(); i++)
+ add(i->clone());
+}
void
Music_general_chord::translate_time(Real t)
return l;
}
+
+Music_general_chord::Music_general_chord(
+ Music_general_chord const & s)
+{
+ for (PCursor<Horizontal_music*> i(s.chord_); i.ok(); i++) {
+ add(i->clone());
+ }
+}
+
/****************/
void
--- /dev/null
+#include "debug.hh"
+#include "inputcommand.hh"
+#include "inputscore.hh"
+#include "inputstaff.hh"
+#include "score.hh"
+#include "paper.hh"
+
+void
+Input_score::add(svec<Input_command*> &s)
+{
+ commands_.bottom().add(get_reset_command());
+ for (int i=0; i < s.sz(); i++)
+ commands_.bottom().add(s[i]);
+}
+
+void
+Input_score::add(Input_staff*s)
+{
+ staffs_.bottom().add(s);
+}
+
+void
+Input_score::set(Paperdef*p)
+{
+ delete paper_;
+ paper_ = p;
+}
+
+Score*
+Input_score::parse()
+{
+ Paperdef* p=new Paperdef(*paper_);
+ Score *s = new Score(p);
+
+ for (PCursor<Input_staff*> i(staffs_); i.ok(); i++) {
+ Staff* staf=i->parse(commands_);
+ s->add(staf);
+ }
+ return s;
+}
+
+Input_score::~Input_score()
+{
+ // should fix paper/symtabs to allow this deletion.
+// delete paper_;
+}
+
+Input_score::Input_score()
+{
+ paper_=new Paperdef;
+}
+
+void
+Input_score::print()const
+{
+ mtor << "Input_score {\n";
+ for (PCursor<Input_staff*> i(staffs_); i.ok(); i++) {
+ i->print();
+ }
+ mtor << "}\n";
+}
--- /dev/null
+#include "getcommand.hh"
+#include "debug.hh"
+#include "inputmusic.hh"
+#include "inputstaff.hh"
+#include "inputcommands.hh"
+#include "inputcommand.hh"
+#include "staffcommands.hh"
+#include "melodicstaff.hh"
+#include "rhythmstaff.hh"
+#include "staff.hh"
+
+void
+Input_staff::add(svec<Input_command*> &s)
+{
+ commands_.bottom().add(get_reset_command());
+ for (int i=0; i < s.sz(); i++)
+ commands_.bottom().add(s[i]);
+ s.set_size(0);
+}
+
+Input_staff::Input_staff(String s)
+{
+ type= s;
+}
+
+void
+Input_staff::add(Horizontal_music*m)
+{
+ music_.bottom().add(m);
+}
+
+Staff*
+Input_staff::parse(PointerList<Input_command*> score_wide)
+{
+ Staff *p=0;
+
+ if (type == "melodic")
+ p = new Melodic_staff;
+ else if (type == "rhythmic")
+ p = new Rhythmic_staff;
+
+ for (PCursor<Horizontal_music*> i(music_); i.ok(); i++) {
+ Voice_list vl = i->convert();
+ p->add(vl);
+ }
+
+ Input_commands commands;
+ for (PCursor<Input_command*> i(score_wide); i.ok(); i++)
+ commands.add(**i);
+ for (PCursor<Input_command*> i(commands_); i.ok(); i++)
+ commands.add(**i);
+
+ p->staff_commands_ = commands.parse();
+
+ return p;
+}
+
+Input_staff::Input_staff(Input_staff&s)
+{
+ for (PCursor<Input_command*> i(s.commands_); i.ok(); i++)
+ commands_.bottom().add(new Input_command(**i));
+ for (PCursor<Horizontal_music*> i(s.music_); i.ok(); i++)
+ add(i);
+
+ type = s.type;
+}
+
+void
+Input_staff::print() const
+{
+#ifndef NPRINT
+ mtor << "Input_staff {\n";
+ for (PCursor<Input_command*> i(commands_); i.ok(); i++)
+ i->print();
+ for (PCursor<Horizontal_music*> i(music_); i.ok(); i++)
+ i->print();
+ mtor << "}\n";
+#endif
+}
}
svec<int>
-Key::read(svec<String> s)
+Key::read(svec<Scalar> s)
{
svec<int> newkey;
for (int j = 0; j < 7; j++)
- accidentals[j] = 0;
+ accidentals[j] = 0;
for (int i=0; i < s.sz(); i++) {
int large, small;
}
svec<int>
-Key::oldkey_undo(svec<String> s)
+Key::oldkey_undo(svec<Scalar>s)
{
svec<int> oldkey;
svec<int> newkey;
%%
\$ {
- BEGIN(notes); return '$';
+ BEGIN(notes);
}
<notes>{NOTECOMMAND} {
String c = YYText() +1;
+
int l = lookup_keyword(c);
- if (l == -1) {
- String e("unknown NOTECOMMAND: \\");
- e += c;
- yyerror(e);
+ if (l != -1)
+ return l;
+ Identifier * id = lookup_identifier(c);
+ if (id) {
+ yylval.id = id;
+ return IDENTIFIER;
}
- return l;
+ String *sp = new String( c);
+ mtor << "new id: " << *sp;
+ yylval.string=sp;
+ return NEWIDENTIFIER;
}
<notes>{RESTNAME} {
}
<notes>\$ {
- BEGIN(INITIAL); return '$';
+ BEGIN(INITIAL);
}
<notes>[{}] {
return YYText()[0];
yyterminate();
}
{WORD} {
- int l = lookup_keyword(YYText());
+ String c = YYText();
+ int l = lookup_keyword(c);
if (l != -1)
return l;
- Identifier * id = lookup_identifier(YYText());
+ Identifier * id = lookup_identifier(c);
if (id) {
yylval.id = id;
return IDENTIFIER;
}
- String *sp = new String( YYText());
+ String *sp = new String( c);
mtor << "new id: " << *sp;
yylval.string=sp;
return NEWIDENTIFIER;
int r = col_id(id->right);
mtor << "between " << l <<","<<r<<":" ;
+ id->print();
#endif
}
#include "localkeyitem.hh"
#include "molecule.hh"
+#include "scalar.hh"
#include "lookup.hh"
#include "paper.hh"
#include "symtable.hh"
#include "dimen.hh"
#include "tex.hh"
+#include "scalar.hh"
Real
Lookup::internote()
Symbol
-Lookup::meter(svec<String> a)
+Lookup::meter(svec<Scalar> a)
{
Symbol s;
s.dim.x = Interval( convert_dimen(0,"pt"),
{
Rest*r = Simple_staff::get_rest(rq);
if (rq->balltype <= 2)
- r->translate(Offset(0, NO_LINES * paper()->internote()));
+ r->translate(Offset(0, (NO_LINES-1) * paper()->internote()));
return r;
}
-Melodic_staff*
-Melodic_staff::clone()const
-{
- return new Melodic_staff(*this);
-}
-
-Local_key_item* Melodic_staff::get_local_key_item()
+Local_key_item*
+Melodic_staff::get_local_key_item()
{
return new Local_key_item(-2);
}
-#include "string.hh"
+#include "scalar.hh"
#include "molecule.hh"
#include "meter.hh"
#include "paper.hh"
#include "lookup.hh"
-
-Meter::Meter(svec<String> a)
+Meter::Meter(svec<Scalar>a)
:args(a)
{
}
#include "lexer.hh"
#include "paper.hh"
-#include "staff.hh"
-#include "score.hh"
+#include "inputstaff.hh"
+#include "inputscore.hh"
+#include "inputmusic.hh"
#include "main.hh"
#include "keyword.hh"
-#include "getcommand.hh"
+#include "inputcommand.hh"
#include "debug.hh"
#include "parseconstruct.hh"
#include "dimen.hh"
#include "identifier.hh"
-#include "inputmusic.hh"
+
#ifndef NDEBUG
#define YYDEBUG 1
%union {
Real real;
- Command *command;
+ Input_command *command;
Identifier *id;
Voice *voice;
Voice_element *el;
- Staff *staff;
String *string;
- Score *score;
const char *consstr;
Paperdef *paper;
Request* request;
char c;
svec<String> * strvec;
- svec<Command*> *commandvec;
+ svec<Input_command*> *commandvec;
Voice_list *voicelist;
+ Input_staff *staff;
+ Input_score *score;
}
-%token VOICE STAFF SCORE TITLE RHYTHMSTAFF BAR NOTENAME OUTPUT
+%token VOICE STAFF SCORE TITLE BAR NOTENAME OUTPUT
%token CM IN PT MM PAPER WIDTH METER UNITSPACE SKIP COMMANDS
-%token MELODICSTAFF GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND
+%token GEOMETRIC START_T DURATIONCOMMAND OCTAVECOMMAND
%token KEY CLEF VIOLIN BASS MULTI TABLE CHORD VOICES
-%token PARTIAL
+%token PARTIAL RHYTHMIC MELODIC MUSIC
%token <id> IDENTIFIER
%token <string> NEWIDENTIFIER
%type <el> voice_elt full_element
%type <command> score_command staff_command skipcommand
%type <score> score_block score_body
-%type <staff> staff_block rhythmstaff_block rhythmstaff_body
-%type <staff> melodicstaff_block melodicstaff_body staffdecl
+%type <staff> staff_block staff_init staff_body
%type <i> int
%type <commandvec> score_commands_block score_commands_body
%type <commandvec> staff_commands_block staff_commands_body
%type <chord> music_chord music_chord_body
%type <horizontal> horizontal_music
%type <mvoice> music_voice_body music_voice
-%type <voicelist> voices
+
%%
| mudela score_block {
add_score($2);
}
- | mudela add_declaration { }
+ | mudela add_declaration { }
;
/*
DECLARATIONS
$$ = new Staff_id(*$1, $3);
delete $1; // this sux
}
- | NEWIDENTIFIER '=' voices {
- $$ = new Voices_id(*$1, $3);
+ | NEWIDENTIFIER '=' music_voice {
+ $$ = new M_voice_id(*$1, $3);
+ delete $1;
+ }
+ | NEWIDENTIFIER '=' music_chord {
+ $$ = new M_chord_id(*$1, $3);
delete $1;
}
;
score_block: SCORE '{' score_body '}' { $$ = $3; }
;
-score_body: { $$ = new Score; }
+score_body: { $$ = new Input_score; }
| score_body staff_block { $$->add($2); }
| score_body score_commands_block {
$$->add(*$2);
COMMANDS '{' score_commands_body '}' { $$ =$3;}
;
-score_commands_body: { $$ = new svec<Command*>; }
+score_commands_body: { $$ = new svec<Input_command*>; }
| score_commands_body score_command {
$$->add($2);
}
;
staff_commands_body:
- /* empty */ { $$ = new svec<Command*>; }
+ /* empty */ { $$ = new svec<Input_command*>; }
| staff_commands_body staff_command {
$$->add($2);
}
staff_command:
skipcommand
- | KEY '$' pitch_list '$' {/*UGH*/
- $$ = get_key_interpret_command(*$3);
- delete $3;
+ | KEY pitch_list {/*UGH*/
+ $$ = get_key_interpret_command(*$2);
+ delete $2;
}
| CLEF clef_id {
$$ = get_clef_interpret_command(*$2);
STAFFs
*/
staff_block:
- staffdecl
- | rhythmstaff_block
- | melodicstaff_block
+ STAFF '{' staff_body '}' { $$ = $3; }
;
-staffdecl: STAFF '{' IDENTIFIER '}' { $$ = $3->staff()->clone(); }
- ;
-rhythmstaff_block:
- RHYTHMSTAFF '{' rhythmstaff_body '}' { $$ = $3; }
- ;
-rhythmstaff_body:
- /* empty */ { $$ = get_new_rhythmstaff(); }
- | rhythmstaff_body voices { $$->add(*$2);
- delete $2;
+staff_init:
+ IDENTIFIER { $$ = new Input_staff(*$1->staff()); }
+ | RHYTHMIC {
+ $$ = new Input_staff("rhythmic");
}
- | rhythmstaff_body staff_commands_block {
- $$->add(*$2);
- delete $2;
+ | MELODIC {
+ $$ = new Input_staff( "melodic");
}
;
-melodicstaff_block:
- MELODICSTAFF '{' melodicstaff_body '}' { $$ = $3; }
- ;
-
-melodicstaff_body:
- /* empty */ { $$ = get_new_melodicstaff(); }
- | melodicstaff_body voices {
- $$->add(*$2);
- delete $2;
- }
- | melodicstaff_body staff_commands_block {
- $$->input_commands_.add(get_reset_command());
+staff_body:
+ staff_init
+ | staff_body horizontal_music {
+ $$->add($2);
+ }
+ | staff_body staff_commands_block {
$$->add(*$2);
delete $2;
- }
- ;
-
-voices:
- '$' music_voice_body '$' {
- $$ = new Voice_list($2->convert());
- }
- | VOICES '{' IDENTIFIER '}' {
- $$ = new Voice_list(*$3->voices());
}
;
-
+/*
+ MUSIC
+*/
horizontal_music:
music_voice { $$ = $1; }
;
music_chord { $$ = $1; }
;
-music_voice: VOICE '{' music_voice_body '}' { $$ = $3; }
+music_voice: MUSIC '{' music_voice_body '}' { $$ = $3; }
;
music_voice_body: {
$$ = new Music_voice;
}
+ | music_voice_body IDENTIFIER {
+ $$->concatenate($2->mvoice());
+ }
| music_voice_body full_element {
$$->add($2);
}
music_chord_body: {
$$ = new Music_general_chord;
}
+ | music_voice_body IDENTIFIER {
+ $$->concatenate($2->mchord());
+ }
| music_chord_body horizontal_music {
$$ -> add($2);
}
#include "pstaff.hh"
#include "debug.hh"
-void
-Idealspacing::print() const
-{
-#ifndef NPRINT
- mtor << "idealspacing {" ;
- mtor << "distance "<<space<< " strength " << hooke << "}\n";
-#endif
-}
-
-Idealspacing::Idealspacing(const PCol * l,const PCol * r)
-{
- space = 0.0;
- hooke = 0.0;
- left = l;
- right = r;
-}
-
-void
-Idealspacing::OK() const
-{
-#ifndef NDEBUG
- assert(hooke >= 0 && left && right);
-#endif
-}
-
-/****************************************************************/
-
Interval
PCol::width() const
{
w.unite(Interval(0,0));
return w;
}
+int
+PCol::rank() const
+{
+ if(!pscore_)
+ return -1;
+ PCursor<PCol*> me=pscore_->find_col(this);
+ if (!me.ok())
+ return -1;
+ PCursor<PCol*> bot(pscore_->cols.top());
+ return me - bot;
+}
void
PCol::print() const
{
#ifndef NPRINT
mtor << "PCol {";
- if (pscore_) { // ugh
- PCursor<PCol*> me=pscore_->find_col(this);
- PCursor<PCol*> bot(pscore_->cols.top());
- if (me.ok()) {
- mtor << "rank: " << me - bot << '\n';
- }
- }
+
+ if (rank() >= 0)
+ mtor << "rank: " << rank() << '\n';
+
mtor << "# symbols: " << its.size() ;
if (breakable()){
mtor << "\npre,post: ";
void
PScore::preprocess()
{
-#if 0
- for (PCursor<Item*> ic(its); ic.ok(); ic++){
- ic->preprocess();
- }
-#endif
}
void
PCursor<PCol *>
PScore::find_col(const PCol *c)const
{
- PCursor<PCol*> cc(cols);
- for (; cc.ok(); cc++)
- if (cc.ptr() == c || cc->prebreak == c || cc->postbreak == c)
- return cc;
- return cc;
+ PCol*what = (PCol*)c;
+ if (what->daddy )
+ what = what -> daddy;
+
+ return cols.find(what);
}
void
return new Rhythmic_staff;
}
-
-
-Rhythmic_staff*
-Rhythmic_staff::clone() const
-{
- return new Rhythmic_staff(*this);
-}
mtor << "}\n";
#endif
}
+
+int
+Real_compare(Real &a , Real& b)
+{
+ return sgn(a-b);
+}
+
+void
+Score_column::preprocess()
+{
+ durations.sort(Real_compare);
+}
+void
+Score_column::add_duration(Real d)
+{
+ for (int i = 0; i< durations.sz(); i++) {
+ if (d == durations[i])
+ return ;
+ }
+ durations.add(d);
+}
-#include "staffcommands.hh"
#include "tstream.hh"
-#include "getcommand.hh"
-#include "inputcommands.hh"
#include "score.hh"
#include "sccol.hh"
#include "pscore.hh"
#include "debug.hh"
#include "paper.hh"
+
void
Score::process()
{
paper_ = new Paperdef;
/// distribute commands to disciples
- distribute_commands();
-
pscore_ = new PScore(paper_);
- for (PCursor<Staff*> sc(staffs_); sc.ok(); sc++) {
- sc->set_output(pscore_);
- sc->process();
+ for (PCursor<Staff*> i(staffs_); i.ok(); i++) {
+ i->process_commands(last());
+ i->set_output(pscore_);
+ i->process();
}
// do this after processing, staffs first have to generate PCols.
do_pcols();
+ // ugh. Would want to clean the columns before anything else.
+ clean_cols();
calc_idealspacing();
- clean_cols(); // ugh. Would want to clean the columns before anything else.
-
+ // debugging
+ print ();
OK();
pscore_->preprocess();
void
Score::clean_cols()
{
- for (PCursor<Staff * > sc(staffs_); sc.ok(); sc++)
- sc->clean_cols();
+ for (PCursor<Staff * > i(staffs_); i.ok(); i++)
+ i->clean_cols();
for (PCursor<Score_column*> c(cols_); c.ok(); ) {
if (!c->pcol_->used()) {
- mtor << "removing : ";
- c->print();
c.del();
- } else
+ } else {
+ c->preprocess();
c++;
+ }
}
pscore_->clean_cols();
return scc;
}
-void
-Score::distribute_commands()
-{
- for (PCursor<Staff*> sc(staffs_); sc.ok(); sc++) {
- sc->process_input_commands(input_commands_, last());
- }
-}
-void
-Score::add(Staff*s)
-{
- s->score_ = this;
- staffs_.bottom().add(s);
-}
-
-
void
Score::do_pcols()
{
- PCursor<Score_column*> sc(cols_);
- for (; sc.ok(); sc++) {
- pscore_->add(sc->pcol_);
+ PCursor<Score_column*> i(cols_);
+ for (; i.ok(); i++) {
+ pscore_->add(i->pcol_);
}
}
Real
Score::OK() const
{
#ifndef NDEBUG
- for (PCursor<Staff*> sc(staffs_); sc.ok(); sc++) {
- sc->OK();
- assert(sc->score_ == this);
+ for (PCursor<Staff*> i(staffs_); i.ok(); i++) {
+ i->OK();
+ assert(i->score_ == this);
}
staffs_.OK();
cols_.OK();
{
#ifndef NPRINT
mtor << "score {\n";
- for (PCursor<Staff*> sc(staffs_); sc.ok(); sc++) {
- sc->print();
+ for (PCursor<Staff*> i(staffs_); i.ok(); i++) {
+ i->print();
}
- for (PCursor<Score_column*> sc(cols_); sc.ok(); sc++) {
- sc->print();
+ for (PCursor<Score_column*> i(cols_); i.ok(); i++) {
+ i->print();
}
+ if (pscore_)
+ pscore_->print();
+
mtor << "}\n";
#endif
}
-Score::Score()
+Score::Score(Paperdef*p)
{
pscore_=0;
- paper_ = 0;
+ paper_ = p;
}
Score::~Score()
{
delete pscore_;
- for (int i=0; i<input_commands_.sz(); i++)
- delete input_commands_[i];
- delete paper_;
-}
-void
-Score::set(Paperdef*p)
-{
- delete paper_;
- paper_ = p;
}
void
}
+
void
-Score::add(svec<Command*> &s)
+Score::add(Staff*s)
{
- input_commands_.add(get_reset_command());
- input_commands_.concat(s);
+ s->score_ = this;
+ staffs_.bottom().add(s);
}
#include "main.hh"
+#include "inputscore.hh"
#include "score.hh"
#include "string.hh"
-static svec<Score*> sv;
+static svec<Input_score*> sv;
static String outfn="lelie.uit";
// todo: check we don't overwrite default output.
-
void
do_scores()
{
- for (int i=0; i < sv.sz(); i++) {
- sv[i]->process();
- sv[i]->output(outfn);
+ for (int i=0; i < sv.sz(); i++) {
+ Score * s = sv[i]->parse();
delete sv[i];
- sv[i] =0;
+
+ s->process();
+ s->output(outfn);
+ delete s;
+
}
}
void
-add_score(Score * s)
+add_score(Input_score * s)
{
sv.add(s);
}
Simple_staff::get_TYPESET_item(Command *com)
{
Item *s=0;
- svec<String> arg( com->args);
+ svec<Scalar> arg( com->args);
String type =arg[0];
arg.del(0);
if (type == "BAR" ) {
if (com->args[0] == "BAR") {
local_key_.reset(key_);
} else if (com->args[0] == "KEY") {
- svec<String> s(com->args);
+ svec<Scalar>s(com->args);
s.del(0);
if (com->when) {
assert(!oldkey_undo);
typesetkey = key_.read(s);
local_key_.reset(key_);
} else if (com->args[0] == "CLEF") {
- svec<String> s(com->args);
+ svec<Scalar>s(com->args);
s.del(0);
clef_.read(s);
} else {
#include "slur.hh"
+#include "scalar.hh"
#include "lookup.hh"
#include "paper.hh"
#include "notehead.hh"
#include "score.hh"
#include "voice.hh"
#include "swalker.hh"
-#include "getcommand.hh"
#include "stcol.hh"
#include "sccol.hh"
-#include "inputcommands.hh"
#include "staffcommands.hh"
#include "debug.hh"
-Staff::Staff(Staff const&src)
-{
- PL_copy(voices,src.voices);
- staff_commands_ = src.staff_commands_;
- assert(!cols.size()); // cols is a runtime field.
- input_commands_ = src.input_commands_;
-
- score_ = src.score_;
- pscore_ = src.pscore_;
-}
-
-void
-Staff::add(svec<Command*> &s)
-{
- input_commands_.add(get_reset_command());
- input_commands_.concat(s);
-}
void
Staff::add(PointerList<Voice*> &l)
{
for (PCursor<Voice*> i(l); i.ok(); i++)
voices.bottom().add(i);
}
+
void
-Staff::process_input_commands(svec<Command*> &s, Real l)
+Staff::process_commands(Real l)
{
- Input_commands commands;
- for (int i = 0 ; i< s.sz(); i++)
- commands.add(new Command(*s[i]));
- for (int i = 0 ; i< input_commands_.sz(); i++)
- commands.add(input_commands_[i]);
- commands.truncate(l);
- commands.print();
-
- staff_commands_ = commands.parse();
- staff_commands_->clean(l);
- commands.print();
- print();
+ if (staff_commands_)
+ staff_commands_->clean(l);
}
Paperdef*
if (sc == i->score_column)
return i;
}
+
/* post: *sc > *->score_column || !i.ok() */
Staff_column* newst = create_col(sc);
}
-void
-Staff::add_voice(Voice *v)
-{
- voices.bottom().add(v);
-}
/*
put all stuff grouped vertically in the Staff_cols
void
Staff::setup_staffcols()
{
- for (PCursor<Voice*> vc(voices); vc.ok(); vc++) {
- Real now = vc->start;
- for (PCursor<Voice_element *> ve(vc->elts); ve.ok(); ve++) {
+ for (PCursor<Voice*> i(voices); i.ok(); i++) {
+ Real now = i->start;
+ for (PCursor<Voice_element *> ve(i->elts); ve.ok(); ve++) {
Staff_column *sc=get_col(now,true);
sc->add(ve);
Staff::last() const
{
Real l = 0.0;
- for (PCursor<Voice*> vc(voices); vc.ok(); vc++) {
- l = MAX(l, vc->last());
+ for (PCursor<Voice*> i(voices); i.ok(); i++) {
+ l = MAX(l, i->last());
}
return l;
}
{
#ifndef NPRINT
mtor << "Staff {\n";
- for (PCursor<Voice*> vc(voices); vc.ok(); vc++) {
- vc->print();
+ for (PCursor<Voice*> i(voices); i.ok(); i++) {
+ i->print();
}
if (staff_commands_)
staff_commands_->print();
- for (int i =0; i <input_commands_.sz(); i++)
- input_commands_[i]->print();
mtor <<"}\n";
#endif
}
{
Real d= ve->duration;
if (d){
- score_column->durations.add(d);
+ score_column->add_duration(d);
}
v_elts.add(ve);
Staff_column::Staff_column(Score_column*s) {
score_column = s;
}
+
set_stemend((dir< 0) ? maxnote-stemlen: minnote +stemlen);
if (dir > 0){
stem_xoffset = paper()->note_width();
- }
+ } else
+ stem_xoffset = 0;
}
void
void
Stem::preprocess()
{
-
+ set_default_extents(); // needed for the flags.
}
#include "glob.hh"
#include "debug.hh"
#include "string.hh"
-#include "identifier.hh"
+#include "inputstaff.hh"
+#include "identparent.hh"
#include "keyword.hh"
#include "associter.hh"
#include "parser.hh"
"geometric", GEOMETRIC,
"in", IN,
"key", KEY,
- "melodicstaff", MELODICSTAFF,
+ "melodic", MELODIC,
"meter", METER,
"mm", MM,
"octave", OCTAVECOMMAND,
"partial", PARTIAL,
"paper", PAPER,
"pt", PT,
- "rhythmstaff", RHYTHMSTAFF,
+ "rhythmic", RHYTHMIC,
"score", SCORE,
"skip", SKIP,
"staff", STAFF,
"violin", VIOLIN,
"voice", VOICE,
"voices", VOICES,
- "width", WIDTH,
+ "width", WIDTH,
+ "music", MUSIC,
0,0
-} ;
+};
int
#include "command.hh"
+#include "inputscore.hh"
+#include "inputstaff.hh"
+#include "inputmusic.hh"
+#include "inputcommand.hh"
#include "molecule.hh"
#include "plist.cc"
substitute_arg(retval, "");
return retval;
}
+String
+substitute_args(String source, svec<Scalar> args)
+{
+ svec<String> sv;
+ for (int i = 0 ; i < args.sz(); i++)
+ sv.add(args[i]);
+
+ return substitute_args(source, sv);
+}
*/
- #include <math.h>
+#include <math.h>
#include "symbol.hh"
#include "molecule.hh"
#include "tex.hh"
#include "symtable.hh"
#include "dimen.hh"
+#include "debug.hh"
#include "lookup.hh"
Symbol
static int
slope_index(Real &s)
{
- assert(ABS(s) < 0.45);
+ if (ABS(s) > 0.5) {
+ WARN << "beam steeper than 0.5";
+ s = sgn(s) * 0.5;
+ }
+
int i = int(rint(s * 20.0));
s = i/20.0;
+#include <math.h>
+
#include "lookup.hh"
#include "molecule.hh"
-#include <math.h>
#include "dimen.hh"
#include "debug.hh"
error ("halfslur too large");
int widx = int(floor(dx / 4.0));
dx = widx * 4.0;
- widx --;
+ if (widx) widx --;
+ else {
+ WARN << "slur too narrow\n";
+ }
Symbol s;
int widx;
- if (dx >= convert_dimen(96,"pt"))
+ if (dx >= convert_dimen(96,"pt")) {
+ WARN << "Slur half too wide.";
dx = convert_dimen(96,"pt");
+ }
widx = int(rint(dx/12.0));
dx = widx*12.0;
- widx --;
-
+ if (widx)
+ widx --;
+ else {
+ WARN << "slur too narrow\n";
+ }
+
Symbol s;
s.dim.x = Interval(0,dx);
s.dim.y = Interval(MIN(0,dy), MAX(0,dy));
int widx = int(floor(dx/4.0)); // slurs better too small..
dx = 4.0 * widx;
- widx--;
+ if (widx)
+ widx --;
+ else {
+ WARN << "slur too narrow\n";
+ }
+
int hidx = dy;
if (hidx <0)
hidx = -hidx;