My_flex_lexer 1
yyFlexLexer 1
-PCol 0
-Score_column 0
+PCol 1
+Score_column 1
Ineq_constrained_qp 1
-Spacing_problem 0
-Colinfo 0
+Spacing_problem 1
+Colinfo 1
Mixed_qp 1
PScore 1
Idealspacing 1
parse_duration 1
parse_pitchmod 1
Col_configuration 1
-Request 0
-Note_req 0
-Rhythmic_req 0
+Request 1
+Note_req 1
+Rhythmic_req 1
Rest_req 1
delete_identifiers 1
Command 1
Staff_commands 1
Stem 1
-Staff 0
+Staff 1
Score 1
-Voice 0
-Voice_element 0
+Voice 1
+Voice_element 1
Input_cursor 1
-Commands_at 0
-Input_command 0
-Time_description 0
+Commands_at 1
+Input_command 1
+Time_description 1
Melodic_req 1
+Stem_req 1
+Group_change_req 1
+Script_req 1
+Colinfo 1
+Word_wrap 1
+Text_req 1
+Script_def 1
+Text_def 1
+Paperdef 1
=back
+=head1 Request_register
+
+In the previous section the idea of Request has been explained, but
+this only solves one half of the problem. The other half is
+deciding which requests should be honored, which should merged with
+other requests, and which should be ignored. Consider this (pseudo)input
+
+ { % chord
+ \music { [c() c] }
+ \music { [e() e] }
+ }
+
+Both the c and e are part of a chord (they are in the same
+Voice_group), so they should share the beams, and the two [ ] pairs
+should be merged. The slurs OTOH are specific for each voice, so they
+should not be shared.
+
+The judge in this "allocation" problem is Staff (actually, it's child
+C<Complex_staff>). It uses the C<Request_register> to do most of the
+work class. For each request C<Complex_staff> queries so-called
+C<Request_register>s if they want to accept a request eg, the
+C<Notehead_register> will accept C<Note_req>s, and turn down
+C<Slur_req>s. If C<Complex_staff> cannot find a register wants the
+request, it is junked (with a warning message).
+
+After all requests have been either assigned, or junked, the Register
+will process the requests (which usually means creating an C<Item> or
+C<Spanner>). If a C<Request_register> creates something, it tells
+C<Complex_staff>. If all requests have been processed, then each
+Register is notified of any created Staff_element.
+
+=head2 example:
+
+ c4
+
+produces:
+
+ note_request (duration 1/4)
+ stem_request (duration 1/4)
+
+note_request will be taken by a C<Notehead_register>, stem_request
+will be taken by a C<Stem_beam_register>. C<Notehead_register> creates
+a C<Notehead>, C<Stem_beam_register> creates a C<Stem>. Both announce
+this to the Staff. Staff will tell C<Stem_beam_register> about the
+C<Notehead>, which will add the C<Notehead> to the C<Stem> it just
+created.
+
+To decide on merging, C<Complex_staff> has grouped several
+registers. There are a few groups:
+
+=item *
+Staff wide, contains
+ Local_key_register
+
+=item *
+Voice group, contains
+ Stem_beam_register
+ Script_register
+ Text_register
+
+=item *
+Voice, contains
+ Slur_register
+ Notehead_register
+
+
+=item 1
+
+
=head1 COMMANDS
+pl 28
+
+Internal
+ - idealspacing slightly better for multivoice.
+Doc
+ - Request_register
+Bugfix
+ - Script.cc : float exception
+ - Request::Request(Request) copying of definition pointer
+ - cleaned dependencies for broken spanners
+ - stupid typo in Staff_elem::post_processing()
+ - init of hpos in PCol::PCol
+ - Word_wrap::solve() bug
+
pl 27
- preliminary WIN32 support (JN)
Features
# sourcefiles to be shipped. Also for dependencies
hdr= bar.hh beam.hh boxes.hh break.hh clef.hh clefitem.hh\
- command.hh complexwalker.hh complexstaff.hh\
+ colhpos.hh command.hh complexwalker.hh complexstaff.hh\
const.hh debug.hh dimen.hh directionalspanner.hh\
getcommand.hh glob.hh grouping.hh idealspacing.hh\
identifier.hh identparent.hh inputcommand.hh inputcommands.hh\
voicegroup.hh
mycc=bar.cc beam.cc boxes.cc break.cc calcideal.cc clef.cc\
- clefitem.cc command.cc complexstaff.cc complexwalker.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\
* make spanner for staffsym
- * Lyric_req: Text_req, Rhythmic_req
-
* Lookup::tex_glissando, Lookup::tex_bracket,
Lookup::tex_cresc, Lookup::tex_decresc (use texbeam.cc as an
example.)
* beam generation.
- * Request_register
* all errors
# version info
MAJVER=0
MINVER=0
-PATCHLEVEL=27
+PATCHLEVEL=28
VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL)
CXXVER=`$(CXX) --version`
PREFIX=${PREFIX:-.}
echo using PREFIX=$PREFIX
-NEEDFLOWERVER=1.0.2
+NEEDFLOWERVER=1.0.24
flowertar=flower-$NEEDFLOWERVER
here=`pwd`
cd ..
-DISTFILES=Makefile
+DISTFILES=Makefile dummy.dep
-default:
-dist:
+dummy.dep:
+ touch dummy.dep
+
+
+dist: $(DISTFILES)
ln $(DISTFILES) $(DDIR)/$(SUBDIR)
clean:
MAJVER=1
MINVER=0
-PATCHLEVEL=23
+PATCHLEVEL=24
PACKAGENAME=flower
#PROFILEFLAG=-pg
Vector::operator String() const
{
String s("vector [");
-#ifndef NDEBUG
+#ifndef NPRINT
for (int i=0; i < dim(); i++) {
s += String(dat[i], "%6f") + ' ';
}
#include "vector.hh"
-
+Vector::Vector(Array<Real> d)
+ : dat(d)
+{
+
+}
Vector::Vector(const Vector&n)
- :dat(n.dat)
+ : dat(n.dat)
{
}
void OK() const { dat.OK();}
int dim() const { return dat.size(); }
Vector() { }
+ Vector(Array<Real> d );
Vector(const Vector&n);
Vector(int n) {
dat.set_size(n);
(c) 1997 $USERNAME <$MAILADRESS>
*/
+HERE
+
+if [ $1 != `basename .hh` ]
+then
+cat <<EOF
#ifndef $def
#define $def
#endif // $def
-
-HERE
+EOF
+fi
#define BREAK_HH
#include "varray.hh"
#include "proto.hh"
-typedef Array<PCol*> Line_of_cols;
-
-struct Col_configuration {
- Line_of_cols cols;
- Array<Real> config;
- Real energy;
-
- /****************/
- void OK()const;
- void setsol(Array<Real>);
- Col_configuration() ;
- void add( PCol*c);
- void print() const;
-};
+#include "colhpos.hh"
struct Break_algorithm {
PScore &pscore_;
/****************/
Break_algorithm(PScore&);
+
/// check if the spacing/breaking problem is well-stated
void problem_OK()const;
+
/// search all pcols which are breakable.
- Array<PCol *> find_breaks() const;
+ Line_of_cols find_breaks() const;
/// helper: solve for the columns in #curline#.
- Array<Real> solve_line(Line_of_cols) const;
+ Col_hpositions solve_line(Line_of_cols) const;
-
/// does curline fit on the paper?
bool feasible(Line_of_cols)const;
- virtual Array<Col_configuration> solve()=0;
+ virtual Array<Col_hpositions> solve()=0;
};
/// wordwrap type algorithm: move to next line if current is optimal.
struct Word_wrap : Break_algorithm {
- virtual Array<Col_configuration> solve();
+ virtual Array<Col_hpositions> solve();
Word_wrap(PScore&);
};
#endif // BREAK_HH
--- /dev/null
+/*
+ colhpos.hh -- part of LilyPond
+
+ (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
+*/
+
+#ifndef COLHPOS_HH
+#define COLHPOS_HH
+#include "varray.hh"
+#include "proto.hh"
+
+typedef Array<PCol*> Line_of_cols;
+
+struct Col_hpositions {
+ Line_of_cols cols;
+ Array<Real> config;
+ Real energy;
+
+ /****************/
+ void OK()const;
+
+ Col_hpositions();
+ void add( PCol*c);
+ void print() const;
+};
+
+
+#endif // COLHPOS_HH
+
/// the total music def of one movement
struct Input_score {
/// defined where?
- String define_spot_str_;
+ const char* defined_ch_c_l_;
int errorlevel_i_;
/// paper_, staffs_ and commands_ form the problem definition.
struct Input_staff {
/// defined where?
- String define_spot_str_;
+ const char * defined_ch_c_l_;
String type;
IPointerList<Input_command*> commands_;
IPointerList<Input_music*> music_;
struct Least_squares {
Array<Offset> input;
void minimise(Real &coef, Real &offset);
+ void OK() const;
};
/// check if problem is too tight
bool check_feasible() const;
+
/// does #this# contain the column #w#?
bool contains(const PCol *w);
Input_score* current_iscore_l();
String find_file(String);
const char *get_version();
-extern Source* source_l;
+extern Source* source_global_l;
#endif
struct Chord;
struct Clef;
struct Clef_item;
-struct Col_configuration;
+struct Col_hpositions;
struct Colinfo;
struct Command;
struct Commands_at ;
struct Slur_req;
class Source;
class Source_file;
+struct Spacing_req ;
struct Span_req;
struct Spanner;
+struct Blank_req;
struct Staff;
struct Staff_column;
struct Staff_command_req;
#ifndef PSCORE_HH
#define PSCORE_HH
-#include "break.hh"
+#include "colhpos.hh"
#include "varray.hh"
#include "pcol.hh"
#include "pstaff.hh"
PScore(Paperdef*);
/// add a line to the broken stuff. Positions given in #config#
- void set_breaking(Array<Col_configuration>);
+ void set_breaking(Array<Col_hpositions>);
void add(PStaff *);
virtual Moment duration() const { return 0; }
- /* accessors for children */
+ /* accessors for children
+ maybe checkout RTTI
+ */
virtual Barcheck_req *barcheck() { return 0; }
virtual Note_req *note() {return 0;}
virtual Script_req *script() {return 0;}
virtual Terminate_voice_req *terminate() {return 0;}
virtual Group_change_req * groupchange() { return 0;}
virtual Group_feature_req * groupfeature() { return 0; }
+ virtual Spacing_req * spacing() { return 0; }
+ virtual Blank_req * blank() { return 0; }
protected:
virtual void do_print()const ;
};
REQUESTMETHODS(Rhythmic_req, rhythmic);
};
+struct Spacing_req :virtual Request {
+ Moment next;
+ Real distance;
+ Real strength;
+ /****************/
+ REQUESTMETHODS(Spacing_req, spacing);
+};
+
+struct Blank_req : Spacing_req, Rhythmic_req {
+ REQUESTMETHODS(Spacing_req, spacing);
+
+};
///Put a text above or below (?) this staff.
struct Text_req : virtual Request {
};
-struct Spacing_req {
- Moment next;
- Real distance;
-};
-
struct Glissando_req : Span_req {
};
IPointerList<Score_column*> cols_;
PScore *pscore_p_;
- String define_spot_str_;
+ const char *defined_ch_c_l_;
int errorlevel_i_;
Assoc<String, Moment> markers_assoc_;
bool in_b( char const* pos_ch_c_l );
int line_i( char const* pos_ch_c_l );
String name_str();
+ String file_line_no_str(const char *ch_c_l );
private:
void close();
enum Status {
ORPHAN, // not yet added to pstaff
VIRGIN, // added to pstaff
+ PRECALCING,
PRECALCED, // calcs before spacing done
+ POSTCALCING,
POSTCALCED, // after spacing calcs done
OUTPUT, // molecule has been output
} status;
- bool calc_children;
- Array<Staff_elem*> dependencies;
/// the pstaff it is in
PStaff *pstaff_l_;
virtual const char *name() const; // to find out derived classes.
virtual Spanner* spanner() { return 0; }
virtual Item * item() { return 0; }
+ void add_depedency(Staff_elem* );
+ void substitute_dependency(Staff_elem* old, Staff_elem * newdep);
protected:
/// do printing of derived info.
/// do calculations after determining horizontal spacing
virtual void do_post_processing();
+ Array<Staff_elem*> dependants;
+
private:
/// member: the symbols
Molecule *output; // should scrap, and use temp var?
This is needed, because #output# may still be
NULL.
*/
+ 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
cadenza.ly scales.ly standchen.ly twinkle.ly\
wohltemperirt.ly error.ly\
martien.ly mlalt.ly mlvio1.ly mlvio2.ly mlcello.ly\
- standchen.tex pavane.tex scsii-menuetto.tex martien.tex
+ standchen.tex pavane.tex scsii-menuetto.tex scsii-menuetto.ly\
+ martien.tex
dist:
--- /dev/null
+% 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
+ output "scsii-menuetto.out"
+ }
+}
key $bes es as$
}
}
+ staff { basstaf }
commands {
meter 4*4
skip 8:0
idealy = max(dir*s->top, dir*s->bot);
miny = max(dir*s->minnote, dir*s-> maxnote);
assert(miny <= idealy);
- no_beams = s->flag;
+
}
/****************/
Beam::center()const
{
assert(status >= POSTCALCED);
- if (calc_children){ // URGGGG!!!
- Beam*me_p = (Beam*)this;
- me_p->do_post_processing();
- }
Real w=(paper()->note_width() + width().length())/2.0;
return Offset(w, (left_pos + w* slope)*paper()->interline());
Beam::add(Stem*s)
{
stems.bottom().add(s);
- s->dependencies.push(this);
+ s->add_depedency(this);
s->print_flag = false;
}
Spanner *
Beam::do_break_at( PCol *, PCol *) const
{
- return new Beam(*this);
+ Beam *beam_p= new Beam(*this);
+
+ return beam_p;
}
void
/*
- do calculations for breaking problem
-
+ do calculations for breaking problem
*/
#include "break.hh"
#include "paper.hh"
/*
return all breakable columns
*/
-Array<PCol *>
+Line_of_cols
Break_algorithm::find_breaks() const
{
- Array<PCol *> retval;
+ Line_of_cols retval;
for (iter_top(pscore_.cols,c); c.ok(); c++)
if (c->breakable())
retval.push(c);
-
+ assert(retval.last() == pscore_.cols.bottom().ptr());
return retval;
}
// construct an appropriate Spacing_problem and solve it.
-Array<Real>
+Col_hpositions
Break_algorithm::solve_line(Line_of_cols curline) const
{
Spacing_problem sp;
sp.add_ideal(i);
}
Array<Real> the_sol=sp.solve();
- return the_sol;
+ Col_hpositions col_hpos;
+ col_hpos.cols = curline;
+ col_hpos.energy = the_sol.last();
+ the_sol.pop();
+ col_hpos.config = the_sol;
+ col_hpos.OK();
+ return col_hpos;
}
Break_algorithm::Break_algorithm(PScore&s)
assert(end->breakable());
#endif
}
-
-/****************/
-
-Col_configuration::Col_configuration()
-{
- energy = INFTY;
-}
-
-void
-Col_configuration::add( PCol*c)
-{
- cols.push(c);
-}
-
-void
-Col_configuration::setsol(Array<Real> sol)
-{
- config = sol;
- energy = config.last();
- config.pop();
-}
-
-void
-Col_configuration::print() const
-{
-#ifndef NPRINT
- mtor << "energy : " << energy << '\n';
- mtor << "line of " << config.size() << " cols\n";
-#endif
-}
-void
-Col_configuration::OK()const
-{
-#ifndef NDEBUG
- assert(config.size() == cols.size());
-#endif
-}
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+1)->when() == j->when()) {
+ && ) {
j++;
pscore_p_->connect(i->pcol_l_, j->pcol_l_, dist);
}
+#endif
}
} else if (j.ok()) {
--- /dev/null
+#include "colhpos.hh"
+#include "real.hh"
+#include "debug.hh"
+#include "const.hh"
+#include "vector.hh"
+
+Col_hpositions::Col_hpositions()
+{
+ energy = INFTY;
+}
+
+void
+Col_hpositions::add( PCol*c)
+{
+ cols.push(c);
+}
+
+void
+Col_hpositions::print() const
+{
+#ifndef NPRINT
+ mtor << "energy : " << energy << '\n';
+ mtor << "line of " << config.size() << " cols\n";
+ Vector v(config);
+ mtor << v;
+#endif
+}
+
+void
+Col_hpositions::OK()const
+{
+#ifndef NDEBUG
+ assert(config.size() == cols.size());
+#endif
+}
}
if (!b)
- WARN<< "junking request: " <<req->name() <<"\n";
+ warning("junking request: " + String(req->name()),
+ req->defined_ch_c_l_m);
}
void
{
Paperdef* paper_p=new Paperdef(*paper_);
Score *s_p = new Score(paper_p);
- s_p->define_spot_str_ = define_spot_str_;
+ s_p->defined_ch_c_l_= defined_ch_c_l_;
s_p->errorlevel_i_ = errorlevel_i_;
Array<Staff*> parsed_staffs;
for (iter_top(staffs_,i); i.ok(); i++) {
Input_score::Input_score()
{
+ defined_ch_c_l_=0;
paper_= 0;
errorlevel_i_ = 0;
}
Input_staff::Input_staff(String s)
{
type= s;
+ defined_ch_c_l_ = 0;
}
void
error("Unknown staff-type `" + type +"\'");
p->score_l_ = score_l;
- p->define_spot_str_ = define_spot_str_;
+ p->define_spot_str_ = ""; // todo
for (iter_top(music_,i); i.ok(); i++) {
Voice_list vl = i->convert();
Input_staff::Input_staff(Input_staff const&s)
{
+
for (iter_top(s.commands_,i); i.ok(); i++)
commands_.bottom().add(new Input_command(**i));
for (iter_top(s.music_,i); i.ok(); i++)
add(i->clone());
- define_spot_str_ = s.define_spot_str_;
+ defined_ch_c_l_ = s.defined_ch_c_l_;
type = s.type;
}
#include "leastsquares.hh"
+void
+Least_squares::OK() const
+{
+ assert( input.size() > 1 );
+ Real dx = 0.0;
+ for (int i=1; i < input.size(); i++)
+ dx += abs (input[i-1].x - input[i].x);
+ assert(dx);
+}
void
Least_squares::minimise(Real &coef, Real &offset)
{
+ OK();
Real sx = 0.0;
Real sy = 0.0;
Real sqx =0.0;
}
else {
Source_file* sourcefile_p = new Source_file( pf );
- source_l->add( sourcefile_p );
+ source_global_l->add( sourcefile_p );
sourcefile_l_ = sourcefile_p;
is = sourcefile_l_->istream_l();
}
Local_key_item::add(Item*head_l)
{
group.push(head_l);
- dependencies.push(head_l);
+ add_depedency(head_l);
}
void
Local_key_item::add(Melodic_req*m_l)
Lookup::dots(int j)
{
if (j>3)
- error("max 3 dots");
+ error("max 3 dots"); // todo
return (*symtables_)("dots")->lookup(j);
}
#include "source.hh"
Source source;
-Source* source_l = &source;
+Source* source_global_l = &source;
extern void parse_file(String,String);
#endif
Array<Request*> pre_reqs, post_reqs;
-sstack<String> define_spots;
+sstack<const char *> define_spots;
Paperdef*default_paper();
char const* defined_ch_c_l;
char const* req_defined_ch_c_l;
SCORE
*/
score_block: SCORE
- { define_spots.push(lexer->spot()); }
+ { define_spots.push(lexer->here_ch_c_l()); }
'{' score_body '}' {
$$ = $4;
- $$->define_spot_str_ = define_spots.pop();
+ $$->defined_ch_c_l_ = define_spots.pop();
if (!$$->paper_)
$$->paper_ = default_paper();
STAFFs
*/
staff_block:
- STAFF { define_spots.push(lexer->spot()); }
+ STAFF { define_spots.push(lexer->here_ch_c_l()); }
/*cont*/ '{' staff_body '}' {
$$ = $4;
- $$->define_spot_str_ = define_spots.pop();
+ $$-> defined_ch_c_l_ = define_spots.pop();
}
;
prebreak_p_=0;
postbreak_p_=0;
line_l_=0;
-
+ hpos = -1.0;
pscore_l_ = 0;
}
#include "pscore.hh"
#include "tstream.hh"
#include "item.hh"
-
+#include "break.hh"
Idealspacing*
PScore::get_spacing(PCol*l, PCol*r)
}
void
-PScore::set_breaking(Array<Col_configuration> breaking)
+PScore::set_breaking(Array<Col_hpositions> breaking)
{
for (int j=0; j < breaking.size(); j++) {
Array<PCol*> &curline(breaking[j].cols);
elt_l_ = 0;
defined_ch_c_l_m = 0;
}
-Request::Request(Request const&)
+Request::Request(Request const&src)
{
elt_l_ = 0;
- defined_ch_c_l_m = 0;
+ defined_ch_c_l_m = src.defined_ch_c_l_m;
+}
+/****************/
+Spacing_req::Spacing_req()
+{
+ next = 0;
+ distance = 0;
+ strength = 0;
+}
+void
+Spacing_req::do_print()const
+{
+ mtor << "next " << next << "dist " << distance << "strength\n";
+}
+void
+Blank_req::do_print()const
+{
+ Spacing_req::do_print();
}
/****************/
Melodic_req::Melodic_req()
#include "staff.hh"
#include "debug.hh"
#include "paper.hh"
-
+#include "main.hh"
+#include "source.hh"
+#include "sourcefile.hh"
void
Score::process()
assert (paper_p_);
if (last() == Moment(0)) {
- error("Need to have music in a score.");
+ warning("Need to have music in a score.", defined_ch_c_l_);
}
// distribute commands to disciples
pscore_p_ = new PScore(paper_p_);
pscore_p_=0;
paper_p_ = p; // ?? safe?
errorlevel_i_ = 0;
+ defined_ch_c_l_ = 0;
}
Score::~Score()
*mlog << "output to " << paper_p_->outfile << "...\n";
Tex_stream the_output(paper_p_->outfile);
- the_output << "% outputting Score, defined at: " << define_spot_str_ << "\n";
+
+ the_output << "% outputting Score, defined at: " <<
+ source_global_l->
+ sourcefile_l (defined_ch_c_l_)->file_line_no_str(defined_ch_c_l_) << "\n";
pscore_p_->output(the_output);
}
Script::set_stem(Stem*st_l)
{
stem_l_ = st_l;
- dependencies.push(st_l);
+ add_depedency(st_l);
}
void
Script::set_support(Item*i)
{
support.push(i);
- dependencies.push(i);
+ add_depedency(i);
}
Script::Script(Script_req* rq, int staflen)
Interval v= support_height();
y = v[dir] -dy[-dir] + 2*dir*inter_f;
} else {
- Real y = (d > 0) ? staffsize + 2: -2; // ug
+ y = (d > 0) ? staffsize + 2: -2; // ug
y *=inter_f;
Interval v= support_height();
y = y <? v.min();
}
}
+
if (stem_l_) {
Interval v= stem_l_->height();
+/*
+
+ TODO:
+ think about crossing stems.
+ */
#include "slur.hh"
#include "scalar.hh"
#include "lookup.hh"
Slur::add(Notehead*n)
{
encompass.push(n);
- dependencies.push(n);
+ add_depedency(n);
}
void
size_off_m = 0;
}
}
+String
+Source_file::file_line_no_str(const char *cch_c_l )
+{
+ return name_str() + ": "
+ + String( line_i( cch_c_l ) );
+}
{
mtor << " (unknown) ";
}
+
Spanner*
Spanner::broken_at(PCol*c1, PCol *c2)const
{
- Spanner *me_p = (Spanner*)this;
Spanner *span_p = do_break_at(c1,c2);
- me_p->calc_children = true;
- me_p->dependencies.push(span_p);
-
- span_p->calc_children = false; // should handle in ctor
-
+ for (int i=0; i < dependants.size(); i++) {
+ dependants[i]->substitute_dependency((Staff_elem*)this, span_p);
+ }
+
span_p->left = c1;
span_p->right = c2;
String
Staff_elem::TeXstring() const
{
- assert(!calc_children);
Molecule m(*output);
m.translate(offset_); // ugh?
return m.TeXstring();
}
Staff_elem::Staff_elem(Staff_elem const&s)
- : dependencies(s.dependencies)
+ : dependants(s.dependants),
+ dependencies(s.dependencies)
{
status = s.status;
assert(!s.output);
output = 0;
pstaff_l_ = s.pstaff_l_;
- calc_children = false;
offset_ = Offset(0,0);
}
{
delete output;
}
+
void
Staff_elem::translate(Offset O)
{
Staff_elem::Staff_elem()
{
- calc_children = false;
pstaff_l_=0;
offset_ = Offset(0,0);
output = 0;
{
if (status >= VIRGIN)
return;
-
- do_add_processing();
status = VIRGIN;
+ do_add_processing();
}
void
{
if (status >= PRECALCED )
return;
+ assert(status != PRECALCING); // cyclic dependency
+ status = PRECALCING;
+
for (int i=0; i < dependencies.size(); i++)
if (dependencies[i])
dependencies[i]->pre_processing();
- if (!calc_children)
- do_pre_processing();
+
+
+ do_pre_processing();
status = PRECALCED;
}
void
Staff_elem::post_processing()
{
- if (status > POSTCALCED)
+ if (status >= POSTCALCED)
return;
+ assert(status != POSTCALCING);// cyclic dependency
+ status=POSTCALCING;
+
for (int i=0; i < dependencies.size(); i++)
if (dependencies[i])
dependencies[i]->post_processing();
- if (!calc_children)
- do_post_processing();
+ do_post_processing();
status=POSTCALCED;
}
{
if (status >= OUTPUT)
return;
+ status = OUTPUT; // do it only once.
for (int i=0; i < dependencies.size(); i++)
if (dependencies[i])
dependencies[i]->molecule_processing();
- if (!calc_children)
- output= brew_molecule_p();
- status = OUTPUT;
+
+ output= brew_molecule_p();
}
void
Staff_elem::do_add_processing()
{
}
+
+void
+Staff_elem::substitute_dependency(Staff_elem * old, Staff_elem * newdep)
+{
+ bool hebbes_b=false;
+ for (int i=0; i < dependencies.size(); i++) {
+ if (dependencies[i] == old){
+ dependencies[i] = newdep;
+ hebbes_b = true;
+ } else if (dependencies[i] == newdep) {
+ hebbes_b = true;
+ }
+ }
+ if (!hebbes_b)
+ dependencies.push(newdep);
+}
+
+void
+Staff_elem::add_depedency(Staff_elem * p)
+{
+ for (int i=0; i < dependencies.size(); i ++)
+ if (dependencies[i] == p)
+ return;
+
+ dependencies.push(p);
+ p->dependants.push(p);
+}
if ( p> maxnote)
maxnote = p;
heads.push(n);
- n->dependencies.push(this);
+ n->add_depedency(this);
}
Real mean = (minnote+maxnote)/2;
return (mean > staff_center) ? -1: 1;
}
+
void
Stem::set_default_dir()
{
dir = get_default_dir();
}
+
void
Stem::set_default_stemlen()
{
Text_spanner::set_support(Directional_spanner*d)
{
support = d;
- dependencies.push(d);
-}
+ add_depedency(d);
+}
+
Text_spanner::Text_spanner()
{
support = 0;
#include "timedescription.hh"
#include "debug.hh"
+
String
Time_description::str()const
{
} else { // default 4/4
whole_per_measure = 1;
whole_in_measure =0;
- one_beat = 0.25;
+ one_beat = Moment(1,4);
when = 0.0;
bars = 0;
cadenza_b_ = false;
message( String message_str, char const* context_ch_c_l )
{
String str = "lilypond: ";
- Source_file* sourcefile_l = source_l->sourcefile_l( context_ch_c_l );
+ Source_file* sourcefile_l = source_global_l->sourcefile_l( context_ch_c_l );
if ( sourcefile_l ) {
- str += sourcefile_l->name_str() + ": ";
- str += String( sourcefile_l->line_i( context_ch_c_l ) ) + ": ";
+ str += sourcefile_l->file_line_no_str(context_ch_c_l);
}
str += message_str;
if ( sourcefile_l ) {
*/
-Array<Col_configuration>
+Array<Col_hpositions>
Word_wrap::solve()
{
problem_OK();
iter_top(pscore_.cols,curcol);
- Array<Col_configuration> breaking;
- Array<PCol *> breakpoints(find_breaks());
+ Array<Col_hpositions> breaking;
+ Line_of_cols breakpoints(find_breaks());
assert(breakpoints.size()>=2);
- for (int i=0 ; i < breakpoints.size() -1; ) {
- Col_configuration minimum;
- Col_configuration current;
+
+ int break_idx_i=0;
+ while ( break_idx_i < breakpoints.size() -1) {
+ Col_hpositions minimum;
+ Col_hpositions current;
// do another line
- PCol *post = breakpoints[i]->postbreak_p_;
+ PCol *post = breakpoints[break_idx_i]->postbreak_p_;
current.add( post);
curcol++; // skip the breakable.
- i++;
+ break_idx_i++;
- while (i < breakpoints.size()) {
+ while (break_idx_i < breakpoints.size()) {
// add another measure.
- while (breakpoints[i] != curcol.ptr()){
-
+ while (breakpoints[break_idx_i] != curcol.ptr()){
current.add(curcol);
curcol++;
}
- current.add(breakpoints[i]->prebreak_p_ );
+ current.add(breakpoints[break_idx_i]->prebreak_p_ );
+
+ // try to solve
if (!feasible(current.cols)) {
if (!minimum.cols.size())
error("sorry, this measure is too long");
- break;
+ current.energy = INFTY; // make sure we go back
+ } else {
+ current = solve_line(current.cols);
+ current.print();
}
- current.setsol(solve_line(current.cols));
- current.print();
-
+
+ // update minimum, or backup.
if (current.energy < minimum.energy) {
minimum = current;
} else { // we're one col too far.
- i--;
- while (curcol.ptr() != breakpoints[i])
+ break_idx_i--;
+ while (curcol.ptr() != breakpoints[break_idx_i])
curcol --;
-
- break;
+ break; // do the next line.
}
-
- current.cols.last()=breakpoints[i];
+
+
+ // add nobreak version of breakable column
+ current.cols.last()=breakpoints[break_idx_i];
curcol ++;
- i++;
+ break_idx_i++;
}
- mtor << "Adding cols~, next breakpoint " << i << '\n';
+ mtor << "Adding cols~, next breakpoint " << break_idx_i << '\n';
breaking.push(minimum);
}