From: fred Date: Sun, 24 Mar 2002 19:34:05 +0000 (+0000) Subject: lilypond-0.0.38 X-Git-Tag: release/1.5.59~5257 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=2ac67a65a22d3f622edb1ab09f3581a9b7f90a95;p=lilypond.git lilypond-0.0.38 --- diff --git a/init/symbol.ini b/init/symbol.ini index 7de1e0f521..82029a9e1b 100644 --- a/init/symbol.ini +++ b/init/symbol.ini @@ -1,7 +1,7 @@ include "dutch.ini" # do not include init/ path -include "script.ini" -include "table_sixteen.ini" +include "script.ini" +include "table_sixteen.ini" # not needed if doing MIDI diff --git a/input/midi.ly b/input/midi.ly index 38e5073778..9e45033808 100644 --- a/input/midi.ly +++ b/input/midi.ly @@ -4,7 +4,7 @@ melodie = music { $\clef\violin c c | g g | a a | g2 - f f | e e | d d8.( e16 | )c2 | % :| + f f | e e | d d8. e16 | c2 | % :| $ } @@ -33,6 +33,7 @@ score { commands { meter { 2 * 4} } + paper{} midi { tempo 4:120 } diff --git a/src/beam.cc b/src/beam.cc index f554d424bc..64f3e3cf77 100644 --- a/src/beam.cc +++ b/src/beam.cc @@ -9,11 +9,11 @@ #include "leastsquares.hh" #include "pcol.hh" #include "stem.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "lookup.hh" #include "grouping.hh" -NAME_METHOD(Beam); + struct Stem_info { Real x; @@ -58,7 +58,7 @@ void Beam::add(Stem*s) { stems.bottom().add(s); - s->add_depedency(this); + s->add_dependency(this); s->print_flag = false; } diff --git a/src/local-key-item.cc b/src/local-key-item.cc new file mode 100644 index 0000000000..425982120c --- /dev/null +++ b/src/local-key-item.cc @@ -0,0 +1,93 @@ +#include "local-key-item.hh" +#include "molecule.hh" +#include "scalar.hh" +#include "lookup.hh" +#include "paper-def.hh" +#include "musicalrequest.hh" +#include "notehead.hh" +#include "misc.hh" + + + +Local_key_item::Local_key_item(int i) +{ + c0_position = i; +} + +void +Local_key_item::add(Item*head_l) +{ + support_items_.push(head_l); + add_dependency(head_l); +} + +void +Local_key_item::add(Melodic_req*m_l) +{ + add(m_l->octave_i_, m_l->notename_i_, m_l->accidental_i_); +} +void +Local_key_item::add (int o, int p , int a) +{ + Local_acc l; + l.octave = o; + l.name = p; + l.acc = a; + accs.push(l); +} + +void +Local_key_item::do_pre_processing() +{ + accs.sort(Local_acc::compare); +} + +Molecule* +Local_key_item::brew_molecule_p()const +{ + Molecule* output = new Molecule; + 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()->internote(); + octmol->translate(Offset(0, dy)); + output->add(*octmol); + delete octmol; + } + octmol= new Molecule; + } + lastoct = accs[i].octave; + Symbol s =paper()->lookup_p_->accidental(accs[i].acc); + Atom a(s); + 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()->internote(); + octmol->translate(Offset(0, dy)); + output->add(*octmol); + delete octmol; + } + + Interval head_width=itemlist_width(support_items_); + output->translate(Offset(-output->extent().x.right + head_width.left ,0)); + + return output; +} + +int +Local_acc::compare(Local_acc&a, Local_acc&b) +{ + if (a.octave - b.octave) + return a.octave - b.octave; + if (a.name - b.name) + return a.name - b.name; + + assert(false); +}; diff --git a/src/script.cc b/src/script.cc index a98a8a9926..2a31133c33 100644 --- a/src/script.cc +++ b/src/script.cc @@ -1,24 +1,24 @@ #include "musicalrequest.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "script.hh" #include "stem.hh" #include "molecule.hh" #include "lookup.hh" -NAME_METHOD(Script); + void Script::set_stem(Stem*st_l) { stem_l_ = st_l; - add_depedency(st_l); + add_dependency(st_l); } void Script::set_support(Item*i) { support.push(i); - add_depedency(i); + add_dependency(i); } Script::Script(Script_req* rq, int staflen) diff --git a/src/slur.cc b/src/slur.cc index 386b178a20..ba77a6948e 100644 --- a/src/slur.cc +++ b/src/slur.cc @@ -6,14 +6,14 @@ #include "slur.hh" #include "scalar.hh" #include "lookup.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "notehead.hh" #include "pcol.hh" #include "molecule.hh" #include "debug.hh" #include "boxes.hh" -NAME_METHOD(Slur); + Slur::Slur() { @@ -37,7 +37,7 @@ void Slur::add(Notehead*n) { encompass.push(n); - add_depedency(n); + add_dependency(n); } void diff --git a/src/staff-elem.cc b/src/staff-elem.cc new file mode 100644 index 0000000000..b24172fa63 --- /dev/null +++ b/src/staff-elem.cc @@ -0,0 +1,200 @@ +#include "pscore.hh" +#include "symbol.hh" +#include "pstaff.hh" +#include "molecule.hh" +#include "staff-elem.hh" +#include "debug.hh" + +String +Staff_elem::TeXstring() const +{ + Molecule m(*output); + m.translate(offset_); // ugh? + return m.TeXstring(); +} + +Staff_elem::Staff_elem(Staff_elem const&s) + : dependants(s.dependants), + dependencies(s.dependencies) +{ + status = s.status; + assert(!s.output); + output = 0; + pstaff_l_ = s.pstaff_l_; + offset_ = Offset(0,0); +} +/** + TODO: + If deleted, then remove dependants depency! + */ +Staff_elem::~Staff_elem() +{ + delete output; +} + +void +Staff_elem::translate(Offset O) +{ + offset_ += O; +} +Interval +Staff_elem::width() const +{ + Interval r; + + if (!output){ + Molecule*m = brew_molecule_p(); + r = m->extent().x; + delete m; + } else + r = output->extent().x; + + if (!r.empty()) // float exception on DEC Alpha + r+=offset_.x; + + return r; +} +Interval +Staff_elem::height() const +{ + Interval r; + + if (!output){ + Molecule*m = brew_molecule_p(); + r = m->extent().y; + delete m; + } else + r = output->extent().y; + + if (!r.empty()) + r+=offset_.y; + + + return r; +} + +void +Staff_elem::print()const +{ +#ifndef NPRINT + mtor << name() << "{\n"; + do_print(); + if (output) + output->print(); + + mtor << "}\n"; +#endif +} + + + +Staff_elem::Staff_elem() +{ + pstaff_l_=0; + offset_ = Offset(0,0); + output = 0; + status = ORPHAN; +} + + +Paper_def* +Staff_elem::paper() const +{ + assert(pstaff_l_); + return pstaff_l_->pscore_l_->paper_l_; +} + +void +Staff_elem::add_processing() +{ + if (status >= VIRGIN) + return; + status = VIRGIN; + do_add_processing(); +} + +void +Staff_elem::pre_processing() +{ + 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(); + + + do_pre_processing(); + status = PRECALCED; +} +void +Staff_elem::post_processing() +{ + 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(); + do_post_processing(); + status=POSTCALCED; +} + +void +Staff_elem::molecule_processing() +{ + 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(); + + output= brew_molecule_p(); +} + +void +Staff_elem::do_post_processing() +{ +} + +void +Staff_elem::do_pre_processing() +{ +} + +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_dependency(Staff_elem * p) +{ + for (int i=0; i < dependencies.size(); i ++) + if (dependencies[i] == p) + return; + + dependencies.push(p); + p->dependants.push(p); +} diff --git a/src/stem.cc b/src/stem.cc index e9a4f943bf..74ea4b57fc 100644 --- a/src/stem.cc +++ b/src/stem.cc @@ -1,7 +1,7 @@ #include "stem.hh" #include "dimen.hh" #include "debug.hh" -#include "paperdef.hh" +#include "paper-def.hh" #include "notehead.hh" #include "lookup.hh" #include "molecule.hh" @@ -9,7 +9,7 @@ #include "misc.hh" const int STEMLEN=7; -NAME_METHOD(Stem); + Stem::Stem(int c) //, Moment len) { @@ -40,7 +40,7 @@ Stem::set_stemend(Real se) // todo: margins if (! ((dir > 0 && se >= maxnote) || (se <= minnote && dir <0)) ) - WARN << "Weird stem size; check for narrow beams.\n"; + warning("Weird stem size; check for narrow beams",0); top = (dir < 0) ? maxnote : se; bot = (dir < 0) ? se : minnote; @@ -55,12 +55,12 @@ Stem::add(Notehead *n) if (n->balltype == 1) return; int p = n->position; - if ( p < minnote) + if (p < minnote) minnote = p; - if ( p> maxnote) + if (p > maxnote) maxnote = p; heads.push(n); - n->add_depedency(this); + n->add_dependency(this); } @@ -104,7 +104,11 @@ Stem::set_default_stemlen() void Stem::set_default_extents() { - assert(minnote<=maxnote); + if (minnote > maxnote) { + warning("Empty stem. Ugh!", 0); + minnote = -10; + maxnote = 20; + } if (!stemlen) set_default_stemlen(); @@ -119,6 +123,8 @@ Stem::set_default_extents() void Stem::set_noteheads() { + if(!heads.size()) + return; heads.sort(Notehead::compare); heads[0]->extremal = -1; heads.top()->extremal = 1; @@ -151,7 +157,7 @@ Stem::width()const { if (!print_flag || abs(flag) <= 4) return Interval(0,0); // TODO! - Paperdef*p= paper(); + Paper_def*p= paper(); Interval r(p->lookup_p_->flag(flag).dim.x); r+= stem_xoffset; return r; @@ -163,7 +169,7 @@ Stem::brew_molecule_p()const return out; assert(bot!=top); - Paperdef *p =paper(); + Paper_def *p =paper(); Real dy = p->internote(); Symbol ss =p->lookup_p_->stem(bot*dy,top*dy); diff --git a/src/textspanner.cc b/src/textspanner.cc index 8cd1b8ac3f..8a648232f6 100644 --- a/src/textspanner.cc +++ b/src/textspanner.cc @@ -1,17 +1,17 @@ #include "molecule.hh" #include "boxes.hh" #include "textspanner.hh" -#include "textdef.hh" +#include "text-def.hh" #include "debug.hh" -#include "paperdef.hh" +#include "paper-def.hh" + -NAME_METHOD(Text_spanner); void Text_spanner::set_support(Directional_spanner*d) { support = d; - add_depedency(d); + add_dependency(d); } Text_spanner::Text_spanner()