]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 0.0.68pre.jcn1: Re: patsen?
authorJan Nieuwenhuizen <janneke@gnu.org>
Fri, 27 Jun 1997 10:27:29 +0000 (12:27 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Fri, 27 Jun 1997 10:27:29 +0000 (12:27 +0200)
pl 67.jcn3
- rests under beam [c8 r c]

pl 67.jcn2
- first attempt at rest collisions
- rests.ly

pl 67.jcn1
- beam stem length: beams.ly
- bf: mingw configure
- re: conflily

30 files changed:
.version
ANNOUNCE
NEWS
TODO
bin/Makefile
bin/conflily [new file with mode: 0644]
configure.in
init/table_sixteen.ini
input/beams.ly [new file with mode: 0644]
input/rests.ly [new file with mode: 0644]
lily/.version
lily/beam.cc
lily/include/beam.hh
lily/include/lookup.hh
lily/include/paper-def.hh
lily/include/rest-collision-reg.hh
lily/include/rest-collision.hh
lily/include/rest-column.hh
lily/lookup.cc
lily/note-column-reg.cc
lily/paper-def.cc
lily/rest-collision-reg.cc
lily/rest-collision.cc
lily/rest-column.cc
lily/stem.cc
mi2mu/include/mi2mu.hh
mi2mu/include/midi-track.hh
mi2mu/include/midi-voice.hh
mi2mu/include/track-column.hh
mi2mu/midi-track.cc

index f39dbaa0d93f88a125d75afaa6b23f145f57a55a..4bbb128a6d26eab1b9e8e24bce709247605df819 100644 (file)
--- a/.version
+++ b/.version
@@ -4,4 +4,4 @@ TOPLEVEL_PATCH_LEVEL = 68
 # use to send patches, always empty for released version:
 # include separator: ".postfix", "-pl" makes rpm barf
 
-TOPLEVEL_MY_PATCH_LEVEL = pre
+TOPLEVEL_MY_PATCH_LEVEL =pre.jcn1
index 003b4845c9a1c593be0c63347174307c2df7fd0d..db7636e52b6b0179fec50dd2295996e009781ea3 100644 (file)
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -24,7 +24,12 @@ least) Janneke!
 
        HW
 
-[misschien wat monieks invoegen?]
+       That's a nice thought, Wendy.  I've got a few too, to spread
+the credits a bit (Again, no particular order) Michelle, Illushka, 
+Ruth, Eva, Fro/ydis, Monique, Noor, Sascha, Monique, Ilse, Monique, 
+Eva, Roos, Judith, and, of course, Wendy!
+
+       JCN
 
 **************************
 
diff --git a/NEWS b/NEWS
index fe3edf293f0cdc2d8c9454ebae436a0e692c4682..7f2e5345818b0e3cf73a7d625d16aced99fd0b87 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,15 @@
+pl 67.jcn3
+       - rests under beam [c8 r c]
+
+pl 67.jcn2
+       - first attempt at rest collisions
+       - rests.ly
+
+pl 67.jcn1
+       - beam stem length: beams.ly
+       - bf: mingw configure
+       - re: conflily
+
 pl 68
        - doco: other-packages.pod, lots of lilyliterature.pod
        - last duration mode now is default.
@@ -28,6 +40,10 @@ pl 68
 
 ******
 june 3
+
+pl 67.wl1
+       - damped beamslope after wanske
+
 pl 67
        - sketch of Music classes
        - General_script_def as baseclass for Text_def and Script_def
diff --git a/TODO b/TODO
index f7a191fe75190bbf0888d9aa1ce5da489b12c9dc..f39f9c84911499d3f58d4da4711dfedcc6c7cb30 100644 (file)
--- a/TODO
+++ b/TODO
@@ -140,6 +140,8 @@ BUGS
 
        * lilypond - -> crash
 
+       * scales.ly
+
        * standchen triool beam up/down
        
        * (where are the) gcc compile warnings on linux
index ad9f6bb05b5b70613b469ca9ff7cba22df0bf468..cf07dbbc41ca72fed15a464fbf4866570f97a4f6 100644 (file)
@@ -8,7 +8,8 @@ include $(depth)/make/Include.make
 
 SCRIPTS = clearlily cpgento genheader make_patch \
        lily.efence\
-       make_version make_website release convert-mudela show-latest
+       make_version make_website release convert-mudela show-latest \
+       conflily
 EXTRA_DISTFILES = $(SCRIPTS)
 #
 
diff --git a/bin/conflily b/bin/conflily
new file mode 100644 (file)
index 0000000..a7e86b1
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/bash
+# conflily
+# ugh: must be executed from lilypond-x.x.x (bin/conflily)
+
+root=$HOME
+lelie=music/lily
+
+if [ ! -e $root/lelie ]
+then
+       echo ln -s $root/$lelie/current $root/lelie
+       ln -s $root/$lelie/current $root/lelie
+fi
+
+rm $root/$lelie/current >& /dev/null
+current=`basename \`pwd\``
+echo ln -s $root/$lelie/$current $root/$lelie/current
+ln -s $root/$lelie/$current $root/$lelie/current
+
+ln -sf $root/lelie/lily/out/lilypond bin/lilypond
+ln -sf $root/lelie/mi2mu/out/mi2mu bin/mi2mu
+
+if [ "x$LILYINCLUDE" = "x" ]
+then
+       export LILYINCLUDE=$root/lelie/init
+fi
+
+configure --prefix=$HOME --enable-debugging --enable-printing --enable-checking
+
index dbaf1cd095151361a7b3ac8651c373fab6add44d..9cffeaeae8900160ae1e5fe29eb230ee47666e58 100644 (file)
@@ -107,7 +107,7 @@ AC_ARG_ENABLE(profiling,
 AC_ARG_ENABLE(mingw32,
     [  mingw-prefix=DIR        set the mingw32 directory (standalone windows32 exes)],
     [MINGWPREFIX=$enableval],
-    [MINGWPREFIX=$enableval])
+    [MINGWPREFIX=no])
     
 AC_ARG_ENABLE(tex-prefix,
     [  tex-prefix=DIR          set the tex-directory to find TeX subdirectories. (default: PREFIX)],
index b331826f55928916b0dea0d10dadcc47a5f9f0da..7f1ced6c03a6cb6d96877017b507ddbdc22bbf86 100644 (file)
@@ -97,7 +97,7 @@ table_sixteen=
 
      "bars" = \table {
        "empty" "\emptybar"
-       "|"     "\maatstreep"           0.0\pt  0.4\pt  -8.0\pt 8.0\pt
+       "|"     "\maatstreep"           0.0\pt  0.64\pt -8.0\pt 8.0\pt
        "||"    "\doublebar"            0.0\pt  4.0\pt  -8.0\pt 8.0\pt
        "|."    "\finishbar"            -4.0\pt 0.0\pt  -8.0\pt 8.0\pt
        ":|"    "\repeatbar"            -4.0\pt 0.0\pt  -8.0\pt 8.0\pt
diff --git a/input/beams.ly b/input/beams.ly
new file mode 100644 (file)
index 0000000..24753a1
--- /dev/null
@@ -0,0 +1,69 @@
+%{MudelaHeader
+
+ filename: beams.ly
+ title: 
+ description: 
+ composer(s): heu
+ entered-by: jcn
+ copyright: GPL
+
+ Tested Features: beams and beamflags
+EndMudelaHeader
+%}
+
+\score{
+       \staff{ \inputregister{melodicregs}
+               \melodic{ \octave c'; 
+                       \meter 8/4;
+                       \duration8;
+                       \stem 1; [c c'' a' f']
+                       \duration16;
+                       \stem 1; [c c'' a' f']
+                       \duration32;
+                       \stem 1; [c c'' a' f']
+                       \duration64;
+                       \stem 1; [c c'' a' f']
+                       \duration128;
+                       \stem 1; [c c'' a' f']
+
+                       \duration 8;
+                       \stem 1; ['g 'g 'g 'g]
+                       \duration 16;
+                       \stem 1; ['g 'g 'g 'g]
+                       \duration 32;
+                       \stem 1; ['g 'g 'g 'g]
+                       \duration 64;
+                       \stem 1; ['g 'g 'g 'g]
+                       \duration 128;
+                       \stem 1; ['g 'g 'g 'g]
+               }
+       }
+       \staff{ \inputregister{melodicregs}
+               \melodic{ \octave c'; 
+                       \meter 8/4;
+                       \duration8;
+                       \stem -1; [a' 'a c e]
+                       \duration16;
+                       \stem -1; [a' 'a c e]
+                       \duration32;
+                       \stem -1; [a' 'a c e]
+                       \duration64;
+                       \stem -1; [a' 'a c e]
+                       \duration128;
+                       \stem -1; [a' 'a c e]
+
+                       \octave c;
+                       \duration 8;
+                       \stem -1; [d'' d'' d'' d'']
+                       \duration 16;
+                       \stem -1; [d'' d'' d'' d'']
+                       \duration 32;
+                       \stem -1; [d'' d'' d'' d'']
+                       \duration 64;
+                       \stem -1; [d'' d'' d'' d'']
+                       \duration 128;
+                       \stem -1; [d'' d'' d'' d'']
+               }
+       }
+       \paper{}
+}
diff --git a/input/rests.ly b/input/rests.ly
new file mode 100644 (file)
index 0000000..a8a7a0b
--- /dev/null
@@ -0,0 +1,42 @@
+%{MudelaHeader
+
+ filename: rests.ly
+ title: 
+ description: 
+ composer(s): heu
+ entered-by: jcn
+ copyright: GPL
+
+ Tested Features: rest collisions
+EndMudelaHeader
+%}
+
+\score{
+       \staff{ \inputregister{melodicregs}
+               \melodic{ 
+                       \meter 4/4;
+                       \octave c'; 
+                       < \multivoice 
+                               { \stem 1;  g' f' e' d' c' b a g f e d c }
+                               { \stem -1; r  r  r  r  r  r r r r r r r }
+                       >
+                       < \multivoice 
+                               { \stem 1;  r r r r r r r r  r  r  r  r }
+                               { \stem -1; c d e f g a b c' d' e' f' g' }
+                       >
+                       r8
+                       < \multivoice r8 r8 >
+                       < \multivoice r8 r8 r8 >
+                       < \multivoice r8 r8 r8 r8 >
+                       < \multivoice r r >
+                       < \multivoice r r r >
+                       \stem 1;
+                       [c''8 r8 c''8 c''8]
+                       [c8 r8 c8 c8]
+                       \stem -1;
+                       [c8 r8 c8 c8]
+                       [c''8 r8 c''8 c''8]
+               }
+       }
+       \paper{}
+}
index 779974957f9061a58992188e3d7caa8018cda294..f8c8298f3aa56b00a74a52f37e09e15c6af299b8 100644 (file)
@@ -4,4 +4,4 @@ PATCH_LEVEL = 68
 # use to send patches, always empty for released version:
 # include separator: ".postfix", "-pl" makes rpm barf
 
-MY_PATCH_LEVEL = pre
+MY_PATCH_LEVEL =pre.jcn1
index cf2eb652a846f9924cbeec122519387198890f9a..d0b0079692411028520408b3e82ba771d4979f9e 100644 (file)
 
 struct Stem_info {
     Real x;
-    Real idealy;
-    Real miny;
-    int no_beams;
+    int dir_i_;
+    Real idealy_f_;
+    Real miny_f_;
+    int beams_i_;
 
-    
     Stem_info(){}
     Stem_info(Stem const *);
 };
@@ -45,17 +45,52 @@ struct Stem_info {
 Stem_info::Stem_info(Stem const *s)
 {
     x = s->hpos_f();
-    int dir = s->dir_i_;
-    idealy  = dir * s->stem_end_f();
-    miny = dir * s->stem_start_f() + 2;        // ugh
-    assert(miny <= idealy);
+    dir_i_ = s->dir_i_;
+    beams_i_ = intlog2( s->flag_i_ ) - 2;
+
+    /*
+     [todo] 
+         * get algorithm
+        * runtime
+
+     Breitkopf + H\"artel:
+         miny_f_ = interline + #beams * interbeam
+        ideal8 = 2 * interline + interbeam
+        ideal16,32,64,128 = 1.5 * interline + #beams * interbeam
+
+     * B\"arenreiter:
+         miny_f_ = interline + #beams * interbeam
+        ideal8,16 = 2 interline + #beams * interbeam
+        ideal32,64,128 = 1.5 interline + #beams * interbeam
+         
+     */
+
+    Real notehead_y = s->paper()->interline_f();
+    // huh? why do i need the / 2
+//    Real interbeam_f = s->paper()->interbeam_f();
+    Real interbeam_f = s->paper()->interbeam_f() / 2;
+    Real interline_f = s->paper()->interline_f();
+           
+    /* well eh, huh?
+    idealy_f_  = dir_i_ * s->stem_start_f() + beams_i_ * interbeam_f; 
+    if ( beams_i_ < 3 )
+       idealy_f_ += 2 * interline_f;
+    else
+       idealy_f_ += 1.5 * interline_f;
+    */
+
+    idealy_f_  = dir_i_ * s->stem_end_f();
+
+    miny_f_ = dir_i_ * s->stem_start_f() + notehead_y + beams_i_ * interbeam_f;
+
+    idealy_f_ =  miny_f_ >? idealy_f_;
+//    assert(miny_f_ <= idealy_f_);
 }
 
 
 /* *************** */
 
 
-
 Offset
 Beam::center()const
 {
@@ -133,14 +168,14 @@ Beam::solve_slope()
     Least_squares l;
     for (int i=0; i < sinfo.size(); i++) {
        sinfo[i].x -= leftx;
-       l.input.push(Offset(sinfo[i].x, sinfo[i].idealy));
+       l.input.push(Offset(sinfo[i].x, sinfo[i].idealy_f_));
     }
 
     l.minimise(slope, left_pos);
     Real dy = 0.0;
     for (int i=0; i < sinfo.size(); i++) {
        Real y = sinfo[i].x * slope + left_pos;
-       Real my = sinfo[i].miny;
+       Real my = sinfo[i].miny_f_;
 
        if (my - y > dy)
            dy = my -y; 
@@ -235,7 +270,8 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const
 {
     assert( !next || next->hpos_f() > here->hpos_f()  );
     assert( !prev || prev->hpos_f() < here->hpos_f()  );
-    Real dy=paper()->internote_f()*2;
+//    Real dy=paper()->internote_f()*2;
+    Real dy = paper()->interbeam_f();
     Real stemdx = paper()->rule_thickness();
     Real sl = slope*paper()->internote_f();
     paper()->lookup_l()->beam(sl, 20 PT);
@@ -293,9 +329,15 @@ Beam::stem_beams(Stem *here, Stem *next, Stem *prev)const
 Molecule*
 Beam::brew_molecule_p() const 
 {
-    Molecule *out=0;
-    Real inter=paper()->internote_f();
-    out = new Molecule;
+    /*
+      [todo]
+      the y of the (start) of the beam should be quantisized,
+      so that no stafflines appear just in between two beam-flags
+     */
+    Molecule *mol_p = new Molecule;
+    // huh? inter-what
+//    Real inter_f = paper()->interbeam_f();
+    Real inter_f = paper()->internote_f();
     Real x0 = stems[0]->hpos_f();
     for (int j=0; j <stems.size(); j++) {
        Stem *i = stems[j];
@@ -304,11 +346,11 @@ Beam::brew_molecule_p() const
 
        Molecule sb = stem_beams(i, next, prev);
        Real  x = i->hpos_f()-x0;
-       sb.translate(Offset(x, (x * slope  + left_pos)* inter));
-       out->add(sb);
+       sb.translate(Offset(x, (x * slope  + left_pos)* inter_f));
+       mol_p->add(sb);
     }
-    out->translate_x(x0 - left_col_l_->hpos);
-    return out;
+    mol_p->translate_x(x0 - left_col_l_->hpos);
+    return mol_p;
 }
 
 IMPLEMENT_STATIC_NAME(Beam);
index 01726c57df993a134e6318a96987c9e5744d5cd0..9a729a5da9dec9d0c16fce6de7e06d0ad9d8cc05 100644 (file)
@@ -27,7 +27,6 @@ public:
     NAME_MEMBERS();
     Beam();
     void add(Stem*);
-    
 
     void set_grouping(Rhythmic_grouping def, Rhythmic_grouping current);
     void set_stemlens();
index 0a0921efce7b6eef39a24345ae059512b01c1146..b41306315fdd9bb12b0f6cb6bb7b38b28d894b9f 100644 (file)
@@ -21,6 +21,7 @@ struct Lookup {
     void add(String, Symtable*);
     void print()const;
     Real internote_f()const;
+    Real interbeam_f()const;
 
     Symbol linestaff(int n, Real w)const;
     Symbol fill(Box b)const;
index 2ce328406b9f4bda4972b0b203fcd6475c6733b2..21423cf5bc5171a0dc58588f150d0dfde3bc5f8a 100644 (file)
@@ -49,6 +49,8 @@ public:
     void set(Lookup*);
     ~Paper_def();
     Paper_def(Paper_def const&);
+    /// The distance between beams
+    Real interbeam_f()const;
     /**
       The distance between lines
      */
index b324fe245faaac9d3a5fc8ba22c99f11a715d66a..ecde3d6f96122e9a2e5d91ffff8d33f81bff09af 100644 (file)
@@ -18,6 +18,7 @@ class Rest_collision_register : public Request_register {
     Array< Collision *> collision_l_arr_;
 protected:
     virtual void acknowledge_element(Score_elem_info);
+    virtual void do_print() const;
     virtual void do_pre_move_processing();
 public:
     Rest_collision_register();
index 8482d66882d15900bd1f6490bb6e4dd27920d33f..1d698f859d093c499fbf5d471c030aff82643e35 100644 (file)
@@ -17,11 +17,14 @@ class Rest_collision : public Item {
     Link_array<Rest_column> rest_l_arr_;
     Link_array<Note_column> ncol_l_arr_;
 public:
+    void add(Note_column*);
     void add(Rest_column*);
     void add(Collision*);
     NAME_MEMBERS();
 protected:
     virtual void do_post_processing();
+    virtual void do_pre_processing();
+    virtual void do_print() const;
     virtual void do_substitute_dependency(Score_elem*,Score_elem*);
 };
 #endif // REST_COLLISION_HH
index 4e54241d019a5d842087913ec5dd1ad6aa4a5910..8c9e4b80f5ba39f6818b14d9c928a94a5f361130 100644 (file)
@@ -20,11 +20,14 @@ class Rest_column : public Script_column {
     Link_array<Note_head> head_l_arr_;
 public:
     int dir_i_;
+    Stem* stem_l_;
     void add(Note_head *);
+    void add(Stem *);
     NAME_MEMBERS();
     void translate_y(Real dy);
     Rest_column();
 protected:
+    virtual void do_print() const;
     virtual void do_substitute_dependency(Score_elem*, Score_elem*);
 };
 
index dae5ad37b5117dd7cb23d99932f80a4851277bf5..c38322fdf089d4495f7af2f905ed31a605c60542 100644 (file)
@@ -72,6 +72,23 @@ Lookup::internote_f() const
     return ball(4).dim.y.length()/2;
 }
 
+Real
+Lookup::interbeam_f() const
+{
+    /* 
+      [todo]
+         * runtime
+
+      "french" style: interbeam = intenote;
+      "german" style: interbeam = 2/3 * interline
+
+      as lily's style is currently german, we'll hardcode german style
+     */
+     // it seems that "interline" means _between_ lines
+//   return  ball(4).dim.y.length() * 2 / 3; 
+     return  ball(4).dim.y.length() * 2 / 3 + 0.4;  //ugh
+}
+
 Symbol
 Lookup::ball(int j) const
 {
index 4dbf16f8877fa2cc6ea9f7222a631611438de335..44142ac9a703dd88d88f20894193267e802f39d3 100644 (file)
@@ -73,8 +73,12 @@ Note_column_register::do_pre_move_processing()
     for (int i=0; i < script_l_arr_.size(); i++)
        col_l->add(script_l_arr_[i]);
     
-    if (ncol_p_&&stem_l_)
-       ncol_p_->add(stem_l_);
+    if (stem_l_) {
+       if (ncol_p_)
+           ncol_p_->add(stem_l_);
+       if (restcol_p_)
+           restcol_p_->add(stem_l_);
+    }
     if (restcol_p_) {
        if (! restcol_p_ -> dir_i_)
            restcol_p_->dir_i_ = dir_i_;
index 3691fabfd5ccc5fbdbff39ebf79a35b7ba63116d..18158eba08a107f77503c937c27e76306b4ccdb8 100644 (file)
@@ -66,6 +66,11 @@ Paper_def::interline_f() const
     return lookup_p_->ball(4).dim.y.length();
 }
 
+Real
+Paper_def::interbeam_f() const
+{
+    return lookup_p_->interbeam_f();
+}
 Real
 Paper_def::internote_f() const
 {
index 81b27a417a795a4273cf81338bc189913c261613..259e33c94937a7eff81e819c6a1b2f76bc5e23a4 100644 (file)
@@ -6,12 +6,22 @@
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 
+#include "debug.hh"
 #include "rest-collision.hh"
 #include "rest-collision-reg.hh"
 #include "collision.hh"
 #include "rest-column.hh"
 #include "note-column.hh"
 
+IMPLEMENT_STATIC_NAME(Rest_collision_register);
+IMPLEMENT_IS_TYPE_B1(Rest_collision_register, Request_register);
+ADD_THIS_REGISTER(Rest_collision_register);
+
+Rest_collision_register::Rest_collision_register()
+{
+    rest_collision_p_ =0;
+}
+
 void
 Rest_collision_register::acknowledge_element(Score_elem_info i)
 {
@@ -19,7 +29,13 @@ Rest_collision_register::acknowledge_element(Score_elem_info i)
     if (nC == Collision::static_name()) {
        collision_l_arr_.push((Collision*)i.elem_l_->item());
     } 
-    else if (nC == Rest_column ::static_name()) {
+    else if (nC == Note_column::static_name()) {
+       // what should i do, what should _register do?
+       if (!rest_collision_p_)
+           rest_collision_p_ = new Rest_collision;
+       rest_collision_p_->add((Note_column*)i.elem_l_->item());
+    }
+    else if (nC == Rest_column::static_name()) {
        if (!rest_collision_p_)
            rest_collision_p_ = new Rest_collision;
        rest_collision_p_->add((Rest_column*)i.elem_l_->item());
@@ -35,11 +51,12 @@ Rest_collision_register::do_pre_move_processing()
     }
 }
 
-Rest_collision_register::Rest_collision_register()
+void
+Rest_collision_register::do_print() const
 {
-    rest_collision_p_ =0;
+#ifndef NPRINT
+    mtor << "collisions: " << collision_l_arr_.size();
+    if ( rest_collision_p_ )
+       rest_collision_p_->print();
+#endif
 }
-
-IMPLEMENT_STATIC_NAME(Rest_collision_register);
-IMPLEMENT_IS_TYPE_B1(Rest_collision_register, Request_register);
-ADD_THIS_REGISTER(Rest_collision_register);
index 368d47d574c580fe11e736c73473c2f9932ac0b5..7d219dc95c01a9ad28be815e9f3a5a007749e308 100644 (file)
@@ -6,16 +6,32 @@
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 
+#include "debug.hh"
 #include "rest-collision.hh"
 #include "rest-column.hh"
+#include "note-column.hh"
+#include "stem.hh"
+#include "note-head.hh"
 #include "collision.hh"
+#include "paper-def.hh"
+
+IMPLEMENT_STATIC_NAME(Rest_collision);
+IMPLEMENT_IS_TYPE_B1(Rest_collision,Item);
+
+void
+Rest_collision::add(Note_column *nc_l)
+{
+    add_dependency(nc_l);
+    ncol_l_arr_.push(nc_l);
+}
 
 void
 Rest_collision::add(Rest_column *rc_l)
 {
-    rest_l_arr_.push(rc_l);
     add_dependency(rc_l);
+    rest_l_arr_.push(rc_l);
 }
+
 void
 Rest_collision::add(Collision * c_l)
 {
@@ -24,40 +40,108 @@ Rest_collision::add(Collision * c_l)
        ncol_l_arr_.push(c_l->clash_l_arr_[i]);
 }
 
-
 void
 Rest_collision::do_post_processing()
 {
-#if 0
-        bool rest_b_a[4];
-       rest_b_a[j] = (col_l_a[j]) ? col_l_a[j]->rest_b_ : false;       
-    do {
-       int i1 = idx(d, false);
-       int i2 = idx(d,true);
-       if (!intersection(y_extent[i1] , 
-                         y_extent[i2]).empty_b()) {
-           if (rest_b_a[i1]) {
-               y_off[i1] = -y_extent[i1][-d] + y_extent[1][d] + d*4; // ugh
-               y_extent[i1] += y_off[i1];
-           }
-       }
-    } while ((d *= -1) != 1);
-
-    do {
-       int i1 = idx(d, false);
-       int i2 = idx(-d,false);
-       
-       if (d*(y_extent[i1][-d] - y_extent[i2][d] )< 0&& rest_b_a[i1]) {
-           y_off[i1] = -y_extent[i1][-d] + y_extent[i2][d] +d* 4; // ugh
-           y_extent[i1] += y_off[i1];
+    /*
+      handle rest under beam (do_post: beams are calculated now)
+
+      [todo]
+      i-d like to have access to the beam itself, 
+      iso only the (half-initialised?) stem
+
+      what about combination of collisions and rest under beam
+     */
+
+    // no rests to collide
+    if (!rest_l_arr_.size())
+       return;
+    // can this happen?
+    Stem* stem_l = rest_l_arr_[0]->stem_l_;
+    if (!stem_l)
+       return;
+    // no beam
+    if (!(stem_l->beams_left_i_ || stem_l->beams_right_i_))
+       return;
+
+    Real inter_f = paper()->internote_f();
+    int dir_i = rest_l_arr_[0]->dir_i_;
+    int midpos = 4;
+#if 1
+    // ugh
+    int stem_length_i = 7 - 2;
+    // ugh, Stem::stem_start vs Stem::stem_end
+    int pos = (stem_l->stem_end_f() - midpos) - dir_i * stem_length_i;
+#else // nogo: stem_start not set for rests?
+    int pos = (stem_l->stem_start_f() - midpos) + dir_i * 2;
+#endif
+    Real dy = pos * inter_f;
+    rest_l_arr_[0]->translate_y(dy);   
+}
+
+void
+Rest_collision::do_pre_processing()
+{
+    /* 
+      handle rest-rest and rest-note collisions
+
+      [todo]
+      decide not to print rest if too crowded?
+     */
+
+    // no rests to collide
+    if (!rest_l_arr_.size())
+       return;
+
+    // no partners to collide with
+    if (rest_l_arr_.size() + ncol_l_arr_.size() < 2 )
+       return;
+
+    Real inter_f = paper()->internote_f();
+
+    // meisjes met meisjes
+    if (!ncol_l_arr_.size()) {
+       Real dy = rest_l_arr_.size() > 2 ? 6 * inter_f : 4 * inter_f;
+       rest_l_arr_[0]->translate_y(dy);        
+       // top is last element...
+       rest_l_arr_.top()->translate_y(-dy);    
+    }
+    // meisjes met jongetjes
+    else {
+#if 0 // breendet: rests go always under
+       // geen gemug, trug op je rug
+       int dir_i = -1;
+       rest_l_arr_[0]->translate_y(dir_i * 3 * inter_f);       
+#else
+       // int dir_i = - ncol_l_arr_[0]->dir_i_;
+       int dir_i = rest_l_arr_[0]->dir_i_;
+       // hope it's 4: if it works->doco
+       int midpos = 4;
+       // minimum move
+       int minpos = 4;
+       // quart rest height
+       int size_i = 6;
+       int sep_i = 3 + size_i / 2;
+       for (int i = 0; i < ncol_l_arr_.size(); i++) {
+           // how to know whether to sort?
+           ncol_l_arr_[i]->sort();
+           for ( int j = 0; j < ncol_l_arr_[i]->head_l_arr_.size(); j++ )
+               minpos = minpos >? dir_i * ( ncol_l_arr_[i]->head_l_arr_[j]->position_i_ - midpos ) + sep_i;
        }
-    } while ((d *= -1) != 1);
-    
+       Real dy = dir_i * minpos * inter_f;
+       rest_l_arr_[0]->translate_y(dy);        
 #endif
+    }
 }
-IMPLEMENT_STATIC_NAME(Rest_collision);
-IMPLEMENT_IS_TYPE_B1(Rest_collision,Item);
 
+void
+Rest_collision::do_print() const
+{
+#ifndef NPRINT
+    mtor << "rests: " << rest_l_arr_.size() << ", ";
+    mtor << "cols: " << ncol_l_arr_.size();
+#endif
+}
 
 void
 Rest_collision::do_substitute_dependency(Score_elem*o,Score_elem*n)
index 39cd296b85143ae15655a03b8aa9841bcf13ce87..df4bd988463399016876042003a0eb2b9f8cdbd8 100644 (file)
@@ -6,10 +6,20 @@
   (c) 1997 Han-Wen Nienhuys <hanwen@stack.nl>
 */
 
+#include "debug.hh"
 #include "rest-column.hh"
 #include "note-head.hh"
 #include "rest-column.hh"
+#include "stem.hh"
 
+IMPLEMENT_STATIC_NAME(Rest_column);
+IMPLEMENT_IS_TYPE_B1(Rest_column,Item);
+
+Rest_column::Rest_column()
+{
+    dir_i_ = 0;
+}
+    
 void
 Rest_column::add(Note_head *n_l)
 {
@@ -18,20 +28,19 @@ Rest_column::add(Note_head *n_l)
 }
 
 void
-Rest_column::translate_y(Real dy_f)
+Rest_column::add(Stem*stem_l)
 {
-    for (int i=0; i < head_l_arr_.size(); i++)
-       head_l_arr_[i]->translate_y(dy_f);
+    stem_l_ = stem_l;
+//    add_support(stem_l);
 }
 
-IMPLEMENT_STATIC_NAME(Rest_column);
-IMPLEMENT_IS_TYPE_B1(Rest_column,Item);
-
-Rest_column::Rest_column()
+void
+Rest_column::do_print() const
 {
-    dir_i_ = 0;
+#ifndef NPRINT
+    mtor << "heads: " << head_l_arr_.size();
+#endif
 }
-    
 
 void
 Rest_column::do_substitute_dependency(Score_elem*o,Score_elem*n)
@@ -42,3 +51,10 @@ Rest_column::do_substitute_dependency(Score_elem*o,Score_elem*n)
                                (n)? (Note_head*)n->item() : 0);
     }
 }
+
+void
+Rest_column::translate_y(Real dy_f)
+{
+    for (int i=0; i < head_l_arr_.size(); i++)
+       head_l_arr_[i]->translate_y(dy_f);
+}
index d41d96f9c3c28c772c3687731cef4b2258033813..00b7423a2b014356f2a833a9b9c3fa2bd2bd641c 100644 (file)
@@ -59,7 +59,6 @@ Stem::do_print() const
 {
 #ifndef NPRINT
     mtor << "flag "<< flag_i_ << " print_flag_b_ " << print_flag_b_;
-
 #endif
 }
 
index a7e877f301d41e097257bbfc334ecfd71d804910..493b2c76cd4b610c9a9bf22da4e5da07815d80c6 100644 (file)
 #undef mtor
 #endif
 
-#define MVOICE_LIST
+// arrays are 20% faster, but we have no Pointer_array yet
+#define MVOICE_LIST  // does this work?
+#define MEVENT_LIST
+#define TCOL_LIST
 
 #include "string.hh"
 #include "string-convert.hh"
index 61022327c36d9ffb6e5c8f92d3c5938884a7a96d..c25d65831b4308e3e9364c1bb573ed19cbc80a71 100644 (file)
@@ -49,13 +49,11 @@ private:
        void output_mudela_rest_remain( Lily_stream& lily_stream_r, Moment mom );
 
 #ifdef TCOL_LIST
-#warning using track_column list
        Pointer_list<Track_column*> tcol_p_list_;
 #else
        Array<Track_column*> tcol_p_array_;
 #endif
 #ifdef MVOICE_LIST
-#warning using midi_voice list
        Pointer_list<Midi_voice*> midi_voice_p_list_;
 #else
        Array<Midi_voice*> midi_voice_p_array_;
index 8360af08e4a940e513e6c4415de72dfc97ad3575..cc3e023152f93f8f9af33e83bba892eb86ea1207 100644 (file)
@@ -22,7 +22,6 @@ private:
        Moment end_mom_;
        Moment begin_mom_;
 #ifdef MEVENT_LIST
-#error using list
        Pointer_list<Midi_event*> midi_event_p_list_;
 #else
        Array<Midi_event*> midi_event_p_array_;
index 6c0630883b39ac4ad032ebe5889c9fffd35a26b3..4d5f647a618a6dbe397c32c9913087da254037de 100644 (file)
@@ -16,7 +16,6 @@ public:
 
 //private:
 #ifdef MEVENT_LIST
-#error using list
        Pointer_list<Midi_event*> midi_event_p_list_;
 #else
        Array<Midi_event*> midi_event_p_array_;
index 8d1c7833e41d0700a17f577e35baaad1a644e44c..10cd36d291dafce3e0e3c0f053152e4aa762ace6 100644 (file)
@@ -14,7 +14,6 @@ Midi_track::Midi_track( int number_i, String copyright_str, String track_name_st
        midi_time_p_ = new Midi_time( 4, 2, 24, 8 );
        midi_tempo_p_ = new Midi_tempo( 1000000 );
 #ifdef TCOL_LIST
-#error doing list!
        tcol_p_list_.bottom().add( new Track_column( Moment( 0 ) ) );
 #else
        tcol_p_array_.push( new Track_column( Moment( 0 ) ) );
@@ -141,14 +140,12 @@ Midi_track::next_begin_mom( Moment now_mom )
        Moment begin_mom = Midi_track::end_mom();
 #ifdef MVOICE_LIST
        for ( PCursor<Midi_voice*> i( midi_voice_p_list_.top() ); i.ok(); i++ )
-//             if ( i->begin_mom() >= now_mom )// well, which one ? 
                if ( i->begin_mom() > now_mom )
                        begin_mom = begin_mom <? i->begin_mom();
 #else
        for ( int i = 0; i < midi_voice_p_array_.size(); i++ )
-               if ( midi_voice_p_array_[ i ]->begin_mom() >= now_mom ) // well, which one ?
                if ( midi_voice_p_array_[ i ]->begin_mom() > now_mom )
-//                     begin_mom = begin_mom <? midi_voice_p_array_[ i ]->begin_mom();
+                       begin_mom = begin_mom <? midi_voice_p_array_[ i ]->begin_mom();
 #endif
        return begin_mom;
 }
@@ -163,7 +160,6 @@ Midi_track::next_end_mom( Moment now_mom )
                        end_mom = end_mom <? i->end_mom();
 #else
        for ( int i = 0; i < midi_voice_p_array_.size(); i++ ) 
-//             if ( midi_voice_p_array_[ i ]->end_mom() >= now_mom )
                if ( midi_voice_p_array_[ i ]->end_mom() > now_mom )
                        end_mom = end_mom <? midi_voice_p_array_[ i ]->end_mom();
 #endif
@@ -444,7 +440,6 @@ void
 Midi_track::remove_end_at( Link_list<Midi_voice*>& open_voices_r, Moment mom )
 {
        for ( PCursor<Midi_voice*> i( open_voices_r.top() ); i.ok(); i++ )
-//             if ( i->end_mom() == mom ) { }
                if ( i->end_mom() <= mom ) {
                        tor( DEBUG_ver ) << "open_voices (" << open_voices_r.size() << "): -1\n";
                        i.remove_p();