]> git.donarmstrong.com Git - lilypond.git/commitdiff
patch::: 1.4.8.jcn3
authorJan Nieuwenhuizen <janneke@gnu.org>
Wed, 14 Nov 2001 08:11:12 +0000 (09:11 +0100)
committerJan Nieuwenhuizen <janneke@gnu.org>
Wed, 14 Nov 2001 08:11:12 +0000 (09:11 +0100)
1.4.8.jcn3
---
Generated by janneke@gnu.org,
From = lilypond-1.4.8.jcn2, To = lilypond-1.4.8.jcn3

usage

    cd lilypond-source-dir; patch -E -p1 < lilypond-1.4.8.jcn3.diff

Patches do not contain automatically generated files
or (urg) empty directories,
i.e., you should rerun autoconf, configure

22 files changed:
CHANGES
VERSION
midi2ly/duration-convert.cc
midi2ly/duration-iter.cc [deleted file]
midi2ly/duration.cc
midi2ly/include/duration-iter.hh [deleted file]
midi2ly/include/lilypond-column.hh
midi2ly/include/lilypond-item.hh
midi2ly/include/lilypond-score.hh
midi2ly/include/lilypond-staff.hh
midi2ly/include/lilypond-stream.hh
midi2ly/include/lilypond-voice.hh
midi2ly/include/midi-score-parser.hh
midi2ly/include/midi2ly-global.hh
midi2ly/lilypond-column.cc
midi2ly/lilypond-item.cc
midi2ly/lilypond-score.cc
midi2ly/lilypond-staff.cc
midi2ly/lilypond-voice.cc
midi2ly/main.cc
midi2ly/midi-track-parser.cc
midi2ly/midi2ly-version.cc

diff --git a/CHANGES b/CHANGES
index 44deb112dfb5e5319c261da31dcd02ff2eeb36d7..0d336259300d9c6e96b1a64ead4b8904f0db8493 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,4 +1,14 @@
---- ../lilypond-1.4.8.jcn1/CHANGES     Mon Oct  1 13:45:09 2001
+--- ../lilypond-1.4.8.jcn2/CHANGES     Mon Nov 12 15:35:25 2001
+++ b/CHANGES   Wed Nov 14 09:11:12 2001
+@@ -1,5 +1,7 @@
+-1.4.8.jcn2
+1.4.8.jcn3
+ ==========
+
+* Dropped-in fixed c++ midi2ly from 1.5.
+ * Backported lilypond-login.sh fixes.
+ --- ../lilypond-1.4.8.jcn1/CHANGES    Mon Oct  1 13:45:09 2001
 ++ b/CHANGES   Mon Nov 12 15:35:25 2001
 @@ -1,7 +1,11 @@
 -1.4.8.jcn1
diff --git a/VERSION b/VERSION
index 1cfdb6d9b5b0049658c3cc2aeb70cf8ad4de924b..ca27b24fd31d6a5675764f746ce301f2e05dfe93 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond
 MAJOR_VERSION=1
 MINOR_VERSION=4
 PATCH_LEVEL=8
-MY_PATCH_LEVEL=jcn2
+MY_PATCH_LEVEL=jcn3
 
 # use the above to send patches: MY_PATCH_LEVEL is always empty for a
 # released version.
index b915c87727df15a8e50787d09c77175af7dd2a9d..356e8d42a4835e0f18a99d3ead9cbe96b259e43c 100644 (file)
@@ -8,7 +8,6 @@
 */
 #include <assert.h>
 #include "duration-convert.hh"
-#include "duration-iter.hh"
 #include "warn.hh"
 
 // statics Duration_convert
@@ -39,8 +38,11 @@ Duration_convert::dur2_str (Duration dur)
      }
   str += to_str ('.', dur.dots_i_);
   if (dur.plet_b ())
-    str += String ("*") + to_str (dur.plet_.iso_i_)
-      + String ("/") + to_str (dur.plet_.type_i_);
+    {
+      str += String ("*") + to_str (dur.plet_.iso_i_);
+      if (dur.plet_.type_i_ != 1)
+       str += String ("/") + to_str (dur.plet_.type_i_);
+    }
   return str;
 }
 
@@ -110,49 +112,58 @@ Duration_convert::mom2_dur (Rational mom)
   return mom2standardised_dur (mom);
 }
 
+
 Duration
 Duration_convert::mom2standardised_dur (Rational mom)
 {
-  //   if (!dur_array_s.length_i ())
-  if (!dur_array_s.size ())
-    set_array ();
-  assert (dur_array_s.size ());
-  for (int i = 0; i < dur_array_s.size () - 1; i++) 
+  Duration dur;
+
+  if (mom == Rational (0))
+    return dur;
+
+  int d = no_smaller_than_i_s ? no_smaller_than_i_s : 7;
+  int i = type2_i (d);
+  int n = (mom / Rational (1, i));
+  
+  int tuplet = 1;
+  if (!no_tuplets_b_s)
     {
-      Rational lower_mom = dur2_mom (dur_array_s[ i ]);
-      if (mom <= lower_mom) 
+      // ugh: 8
+      int m = n;
+      int tup = 1;
+      while (tup < 8 && 
+            mom != Rational (m, i * tup))
        {
-         // all arbitrary, but 3/4 will get rid of the noise...
-         // kinda ok
-         if (i || (mom / lower_mom > Rational (3, 4)))
-           return dur_array_s[ i ];
-         else 
-           {
-             Duration d;
-             d.durlog_i_ = -100;
-             return d;
-           }
+         tup += 2;
+         m = (mom / Rational (1, i * tup));
        }
-      Rational upper_mom = dur2_mom (dur_array_s[ i + 1 ]);
-      if ((mom < upper_mom)
-         && ((mom - lower_mom) / lower_mom
-             < (upper_mom - mom) / upper_mom))
-       return dur_array_s[ i ];
-    }
-  return dur_array_s[ dur_array_s.size () - 1 ];
-}
-
-void
-Duration_convert::set_array ()
-{
-  dur_array_s.clear ();
 
-  Duration_iterator i;
-  while (i.ok ())
-    dur_array_s.push (i.forward_dur ());
+      if (tuplet < 8)
+       {
+         n = m;
+         tuplet = tup;
+       }
+    }
+      
+  if (!n)
+    return dur;
+  
+  if (mom - Rational (n, i)
+      > Rational (1, i * 2 * tuplet))
+    n++;
+  
+  while (!(n & 1))
+    {
+      n >>= 1;
+      d--;
+    }
+  
+  dur.durlog_i_ = d;
+  dur.plet_.iso_i_ = n;
+  dur.plet_.type_i_ = tuplet;
+  return dur;
 }
 
-
 Rational
 Duration_convert::plet_factor_mom (Duration dur)
 {
diff --git a/midi2ly/duration-iter.cc b/midi2ly/duration-iter.cc
deleted file mode 100644 (file)
index 12c2fa8..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-  duration-convert.cc -- implement Duration_convert
-
-  source file of the LilyPond music typesetter
-
-  (c)  1997--2001 Han-Wen Nienhuys <hanwen@cs.uu.nl>
-          Jan Nieuwenhuizen <janneke@gnu.org>
-*/
-#include <assert.h>
-#include "duration-convert.hh"
-#include "warn.hh"
-#include "duration-iter.hh"
-
-Duration_iterator::Duration_iterator ()
-{
-  cursor_dur_.durlog_i_ = 7;
-  if (Duration_convert::no_smaller_than_i_s)
-    cursor_dur_.durlog_i_ = Duration_convert::no_smaller_than_i_s;
-}
-
-Duration 
-Duration_iterator::operator ++(int)
-{
-  return forward_dur ();
-}
-
-Duration
-Duration_iterator::dur ()
-{
-  return cursor_dur_;
-}
-
-Duration
-Duration_iterator::forward_dur ()
-{
-  /* should do smart table? guessing: 
-     duration wholes
-     16        0.0625
-     32..      0.0703
-     8:2/3     0.0833
-     16.       0.0938
-     8 0.1250
-     16..      0.1406
-     4:2/3     0.1667
-     8.        0.1875
-               
-     */
-  assert (ok ());
-
-  Duration dur = this->dur ();
-
-  if (!cursor_dur_.dots_i_ && !cursor_dur_.plet_b ()) 
-    {
-      cursor_dur_.durlog_i_ += 1;
-      cursor_dur_.dots_i_ = 2;
-    }
-  else if (cursor_dur_.dots_i_ == 2) 
-    {
-      assert (!cursor_dur_.plet_b ());
-      cursor_dur_.dots_i_ = 0;
-      cursor_dur_.durlog_i_ -=2;
-      cursor_dur_.set_plet (2, 3);
-    }
-  else if (cursor_dur_.plet_b () 
-          && (cursor_dur_.plet_.iso_i_ == 2)
-          && (cursor_dur_.plet_.type_i_ == 3)) 
-    {
-      assert (!cursor_dur_.dots_i_);
-      cursor_dur_.set_plet (1, 1);
-      cursor_dur_.durlog_i_ += 1;
-      cursor_dur_.dots_i_ = 1;
-    }
-  else if (cursor_dur_.dots_i_ == 1) 
-    {
-      assert (!cursor_dur_.plet_b ());
-      cursor_dur_.dots_i_ = 0;
-      cursor_dur_.durlog_i_ -= 1;
-    }
-               
-  if (Duration_convert::no_tuplets_b_s
-      && cursor_dur_.plet_b () && ok ())
-    forward_dur ();
-  if (Duration_convert::no_double_dots_b_s 
-      && (cursor_dur_.dots_i_ == 2) && ok ())
-    forward_dur ();
-  if (Duration_convert::no_smaller_than_i_s
-      && (cursor_dur_.durlog_i_ > Duration_convert::no_smaller_than_i_s) && ok ())
-    forward_dur ();
-  if (Duration_convert::no_smaller_than_i_s
-      && cursor_dur_.dots_i_
-      && (cursor_dur_.durlog_i_ >= Duration_convert::no_smaller_than_i_s)
-      && ok ())
-    forward_dur ();
-  if (Duration_convert::no_smaller_than_i_s
-      && (cursor_dur_.dots_i_ == 2)
-      && (cursor_dur_.durlog_i_ >= Duration_convert::no_smaller_than_i_s / 2)
-      && ok ())
-    forward_dur ();
-
-  return dur;
-}
-
-bool
-Duration_iterator::ok ()
-{
-  return cursor_dur_.length_mom () <= Rational (4);
-}
index 5289273358ad4d5feafaaa756cd1898c63cf10e7..391537af3ad1fdf8813cb0289993a2103c5d854d 100644 (file)
@@ -19,7 +19,6 @@
 #include "rational.hh"
 #include "duration.hh"
 #include "duration-convert.hh"
-#include "duration-iter.hh"
 
 // statics Duration
 int Duration::division_1_i_s = 384 * 4;
@@ -44,8 +43,8 @@ Duration::duration_type_b (int t)
 void
 Duration::compress (Rational m)
 {
-  plet_.iso_i_ *= m.num_i ();
-  plet_.type_i_ *= m.den_i (); 
+  plet_.iso_i_ *= m.num ();
+  plet_.type_i_ *= m.den (); 
 }
 
 Rational
diff --git a/midi2ly/include/duration-iter.hh b/midi2ly/include/duration-iter.hh
deleted file mode 100644 (file)
index d3320c3..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*   
-  duration-iter.hh -- declare Duration_iterator
-  
-  source file of the GNU LilyPond music typesetter
-  
-  (c) 1998--2001 Han-Wen Nienhuys <hanwen@cs.ruu.nl>
-  
- */
-
-#ifndef DURATION_ITER_HH
-#define DURATION_ITER_HH
-
-/// (iter_dur)
-struct Duration_iterator {
-  
-  /// start at shortest: 128:2/3
-  Duration_iterator ();
-
-  /// return forward_dur ();
-  Duration operator ++(int); 
-
-  /// return current dur
-  Duration dur ();
-
-  /// return dur (), step to next
-  Duration forward_dur ();
-
-  /// durations left?
-  bool ok ();
-
-private:
-
-  Duration cursor_dur_;
-};
-
-
-
-#endif /* DURATION_ITER_HH */
-
index 15a9097e9d028b557ff6e66bd4dc1258a7efd983..b7422c2c6760a331959fd6d6ca7345e5d7e72aac 100644 (file)
@@ -1,7 +1,7 @@
 //
 // lilypond-column.hh -- declare Lilypond_column
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #ifndef LILYPOND_COLUMN_HH
 #define LILYPOND_COLUMN_HH
index 039280c91e9447e499c1a94a9507e8b9ef27b9c6..5855725d2abe39d9862b3bba94187a2d8084b05b 100644 (file)
@@ -1,7 +1,7 @@
 //
 // lilypond-item.hh -- declare lilypond_item
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #ifndef LILYPOND_ITEM_HH
 #define LILYPOND_ITEM_HH
index 9076384ac53b563d5c8346b09a3c97a3bfe0174b..d8996e82f0dbede903cbca21085b3d4953c81f14 100644 (file)
@@ -1,7 +1,7 @@
 //
 // lilypond-score.hh -- declare Lilypond_score
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #ifndef LILYPOND_SCORE_HH
 #define LILYPOND_SCORE_HH
index ceba267b4b26514d6a6e7625565cc475670f05d2..d9e4580c29e512a3f39115485068f9b68fa8c1fe 100644 (file)
@@ -1,7 +1,7 @@
 //
 // lilypond-staff.hh -- declare lilypond_staff
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #ifndef LILYPOND_STAFF_HH
 #define LILYPOND_STAFF_HH
index 29c1c8cf3a26f552db0b5355874dba3c0737638f..2e6429907f95e480f034e39506d14f1876dd66f5 100644 (file)
@@ -1,7 +1,7 @@
 //
 //  lilypond-stream.hh -- part of LilyPond
 //
-//  copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+//  (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 // should i be named Lilypond_stream?
 
index b64882f6fbe0a727e3c8a4ebf563fc3de2bbf9bf..dff2528881ad4561725f7bcb75bb323985ec5154 100644 (file)
@@ -1,12 +1,14 @@
 //
 // lilypond-voice.hh -- declare Lilypond_voice
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #ifndef LILYPOND_VOICE_HH
 #define LILYPOND_VOICE_HH
 
 #include "midi2ly-proto.hh"
+//#include "flower-proto.hh"
+#include "parray.hh"
 #include "cons.hh"
 
 /// (lilypond_voice)
@@ -14,15 +16,14 @@ class Lilypond_voice
 {
 public:
   Lilypond_voice (Lilypond_staff* lilypond_staff_l);
-  void add_item (Lilypond_item* lilypond_item_l);
+  void add_items (Link_array<Lilypond_item>& items);
   void output (Lilypond_stream& lilypond_stream_r);
   String get_clef () const;
-  Lilypond_item * last_item_l_;
-  Lilypond_note * last_note_l_;
+
 private:
   Lilypond_staff* lilypond_staff_l_;
-  Cons_list<Lilypond_item> lilypond_item_l_list_;
-
+  Link_array < Cons_list<Lilypond_item> > threads_;
+  Rational mom_;
 };
 
 #endif // LILYPOND_VOICE_HH
index 2fca257ec326845f493a6a8f5ebe868e80a12be7..25d6758883fc24335d49649d52e57e26f7c009ad 100644 (file)
@@ -1,5 +1,5 @@
 /*
-  midi-score-parser.hh -- declare 
+  midi-score-parser.hh -- declare Midi_score_parser
 
   source file of the GNU LilyPond music typesetter
 
index 4e5c54922b43e4c612f367e16503815ba2f3fb99..2b068909219696246cca92170bc34f767a4fa847 100644 (file)
@@ -1,7 +1,7 @@
 //
 // midi2ly-global.hh -- declare global stuff for midi2ly
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #ifndef MIDI2LY_GLOBAL_HH
 #define MIDI2LY_GLOBAL_HH
index 136f10a06d29cc5846c96f2858268f6b5b837d3a..3fde791a6614aadae14cbdecc5366bbefeed087a 100644 (file)
@@ -1,7 +1,7 @@
 //
 // lilypond-column.cc -- implement Lilypond_column
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #include "lilypond-column.hh"
 
index 977f44e70e1065ad4181632c99f5e4f4030fa8ab..93bf3fd9060333b6a69b572370b8766e797f7b75 100644 (file)
@@ -1,7 +1,7 @@
 //
 // lilypond-item.cc -- implement Lilypond_item
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #include <string.h>
 #include <assert.h>
@@ -255,14 +255,17 @@ Lilypond_note::str ()
   String str;
 
   //ugh
-  if (dur.plet_b ())
-    str += String ("\\times ")
-      + String_convert::i2dec_str (dur.plet_.iso_i_, 0, 0)
-      + "/"
-      + String_convert::i2dec_str (dur.plet_.type_i_, 0, 0)
-      + " { ";
+  if (dur.plet_b () && dur.plet_.type_i_ != 1)
+    {
+       {
+         str += String ("\\times ")
+           + String_convert::i2dec_str (dur.plet_.iso_i_, 0, 0)
+           + "/"
+           + String_convert::i2dec_str (dur.plet_.type_i_, 0, 0)
+           + " { ";
+       }
+    }
   
-
   str += name_str;
 
   Duration tmp = dur;
@@ -270,8 +273,13 @@ Lilypond_note::str ()
   str += Duration_convert::dur2_str (tmp);
 
   if (dur.plet_b ())
-    str += String (" }");
-
+    {
+      if (dur.plet_.type_i_ != 1)
+       str += String (" }");
+    else
+      str += String ("*") + to_str (dur.plet_.iso_i_);
+    }
+  
   /* 
      note of zero duration is nonsense, 
      but let's output anyway for convenient debugging
@@ -303,16 +311,29 @@ Lilypond_skip::duration_mom ()
 String
 Lilypond_skip::str ()
 {
-  if (!mom_)
-    return String ("");
-
-  Duration dur = duration ();
-  if (dur.durlog_i_<-10)
-    return "";
-
-  String str = "\\skip ";
-  str += Duration_convert::dur2_str (dur);
+  String str;
+  Rational m = mom_;
+  if ((int)m >= 1)
+    {
+      int n = m;
+      str += "\\skip 1";
+      if (n > 1)
+       {
+         str += "*";
+         str += to_str (n);
+       }
+      str += " ";
+      m -= n;
+    }
 
+  if (m > Rational (0))
+    {
+      
+      Duration dur = Duration_convert::mom2_dur (m);
+      str += "\\skip ";
+      str += Duration_convert::dur2_str (dur);
+      str += " ";
+    }
   return str;
 }
 
index d0b05bb02b03e56bb60484195181befdf56f5976..363a0e7bf7dface10d0241dbfc9e1b8dc3ec4768 100644 (file)
@@ -1,7 +1,7 @@
 //
 // lilypond-score.cc -- implement Lilypond_score
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #include <assert.h>
 #include "rational.hh"
@@ -192,7 +192,7 @@ Lilypond_score::quantify_columns ()
   int current_bar_i = 0;
   Rational bar_mom = lilypond_time_signature_l_->bar_mom ();
   
-  int n = 5 >? Duration_convert::no_smaller_than_i_s;
+  int n = 7 >? Duration_convert::no_smaller_than_i_s;
   n = Duration_convert::type2_i (n);
   Rational s = Rational (1, n);
   for (int i = 0; i < column_l_array_.size (); i++)
index 0e79b7f4e25d2087bdb0474f328d0f9bd4decd9c..481bc38417ad01214d452a7aa8083fd78c9c9c42 100644 (file)
@@ -1,7 +1,7 @@
 //
 // lilypond-staff.cc -- implement Lilypond_staff
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #include <assert.h>
 #include <ctype.h>
@@ -55,109 +55,40 @@ Lilypond_staff::eat_voice (Cons_list<Lilypond_item>& items)
   Lilypond_voice* voice_p = new Lilypond_voice (this);
   lilypond_voice_p_list_.append (new Killing_cons<Lilypond_voice> (voice_p, 0));
 
-  //    Rational mom = items.top ()->at_mom ();
   Rational mom = 0;
 
-  for (Cons<Lilypond_item>** pp = &items.head_; *pp;)
+  Link_array<Lilypond_item> now_items;
+  for (Cons<Lilypond_item>** i = &items.head_; *i;)
     {
-      Cons<Lilypond_item>* i = *pp;
-      if (i->car_->at_mom () > mom)
-       {
-         if (no_rests_b_g && voice_p->last_note_l_)
-           {
-             voice_p->last_note_l_->end_column_l_ = i->car_->lilypond_column_l_;
-           }
-         else
-           {
-             /* uh, what about quantisation?  This should probably
-                use  mom2standardised_dur ()
-                arg, urg: skip should get duration from start/end columns!
-               */
-
-             Rational r = i->car_->at_mom () - mom;
-             // ugh, need score
-             Lilypond_column* start = lilypond_score_l_g->find_column_l (mom);
-             voice_p->add_item (new Lilypond_skip (start, r));
-           }
-
-         mom = i->car_->at_mom ();
-         continue;             // unnecessary
-       }
+      while (*i && (*i)->car_->at_mom () < mom)
+       i = &(*i)->next_;
       
+      Lilypond_note* last_note = 0;
       Link_array<Lilypond_item> now_items;
-      for (Cons<Lilypond_item> *cp = i; cp && cp->car_->at_mom () == mom; cp = cp->next_)
-       now_items.push (i->car_);
-
-#if 0
-      /*
-        Why don't we use <note>, if voice has:
-
-         <note> <key-change>
-
-        we'd get last_item == key_change -> last_note == 0;
-       */
-      Lilypond_note * last_note = dynamic_cast<Lilypond_note*> (voice_p->last_item_l_);
-#else
-      /*
-        Not sure, is this better?
-       */
-      Lilypond_note * last_note = voice_p->last_note_l_;
-#endif
-
-      Link_array<Lilypond_item> candidates; 
-
-      for (int i=0; last_note && i < now_items.size (); i++)
-       {
-         Lilypond_note * now_note = dynamic_cast<Lilypond_note*> (now_items[i]);
-         if (now_note && last_note->channel_i_ != now_note->channel_i_)
-           candidates.push (now_note);
-       }
-
-      if (candidates.size())
-       {
-         now_items = candidates;
-       }
-
-      Lilypond_item * which = 0;
-      if (now_items.size () > 1)
+      if (*i)
+       mom = (*i)->car_->at_mom ();
+      while (*i && (*i)->car_->at_mom () == mom)
        {
-         int mindiff = 100000; // ugh
-         for (int i=0; last_note && i < now_items.size (); i++)
-           {
-             Lilypond_note *nt = dynamic_cast<Lilypond_note*> (now_items[i]);
-             if (!nt)
-               continue;
-             int diff = abs (last_note->pitch_i_ - nt->pitch_i_ );
-             if(diff < mindiff)
-               {
-                 mindiff =  diff;
-                 which = now_items [i];
-               }
-           }
-
-         if (which && mindiff > 18)            // more than 1.5 octaves apart.  Don't put in same voice.
-           {
-             which =0;
-           }
-       }
-      else if (now_items.size () == 1)
-       which = now_items[0];
-      
-      if (which)
-       {
-         while ((*pp)->car_ != which)
-           pp = &(*pp)->next_;
-      
-         mom += (*pp)->car_->duration_mom ();
-         Cons<Lilypond_item>* c = items.remove_cons (pp);
-         voice_p->add_item (c->car_);
+         Lilypond_note* note = dynamic_cast<Lilypond_note*> ((*i)->car_);
+         if (note && last_note
+             /* ugh, should sort out (whether to) channel before */
+             && (note->channel_i_ != last_note->channel_i_
+                 || (note->duration_mom ()
+                     != last_note->duration_mom ())))
+           break;
+         Cons<Lilypond_item>* c = items.remove_cons (i);
+         now_items.push (c->car_);
+         if (note)
+           last_note = note;
          delete c;
        }
-      else 
-       {
-         pp = &(*pp)->next_;
-         continue;
-       }
+      
+      if (now_items.size ())
+       mom = now_items.top ()->at_mom ();
+      if (last_note)
+       mom += last_note->duration_mom ();
+
+      voice_p->add_items (now_items);
     }
 }
 
@@ -199,17 +130,18 @@ Lilypond_staff::output (Lilypond_stream& lilypond_stream_r)
       
       lilypond_stream_r << voicename << " = \\notes ";
 
-      trackbody += "\\"  + voicename + "\n";
-
+      trackbody += "\\context Voice = " + voicename + " \\"  + voicename + "\n";
       lilypond_stream_r << '\n';
       i->car_->output (lilypond_stream_r);
       c++;      
+      lilypond_stream_r << '\n';
     }
 
+  lilypond_stream_r << '\n';
   lilypond_stream_r << _ ("% MIDI copyright:") << copyright_str_ << '\n';
   lilypond_stream_r << _ ("% MIDI instrument:") << instrument_str_ << '\n';
   lilypond_stream_r << id_str () << " = ";
-  lilypond_stream_r << "<\n " << trackbody << " >\n";
+  lilypond_stream_r << "<\n" << trackbody << ">\n";
 
   lilypond_stream_r << " % " << name_str () << '\n';
 }
@@ -231,99 +163,12 @@ Lilypond_staff::output_lilypond_begin_bar (Lilypond_stream& lilypond_stream_r, R
 }
 
 
-#if 0 // not used for now
-void
-Lilypond_staff::output_lilypond_rest (Lilypond_stream& lilypond_stream_r, Rational begin_mom, Rational end_mom)
-{
-  Rational bar_mom = lilypond_time_signature_l_->bar_mom ();
-  Rational now_mom = begin_mom;
-
-  int begin_bar_i = (int) (now_mom / bar_mom) + 1;
-  int end_bar_i = (int) (end_mom / bar_mom) + 1;
-
-  if (end_bar_i == begin_bar_i)
-    {
-      output_lilypond_rest_remain (lilypond_stream_r, end_mom - begin_mom);
-      return;
-    }
-
-  // multiple bars involved
-  int bar_i = (int) (now_mom / bar_mom) + 1;
-
-  //fill current bar
-  Rational begin_bar_mom = Rational (begin_bar_i - 1) * bar_mom;
-  if (now_mom > begin_bar_mom)
-    {
-      int next_bar_i = (int) (now_mom / bar_mom) + 2;
-      Rational next_bar_mom = Rational (next_bar_i - 1) * bar_mom;
-      assert (next_bar_mom <= end_mom);
-
-      Rational remain_mom = next_bar_mom - now_mom;
-      if (remain_mom > Rational (0))
-       {
-         output_lilypond_rest_remain (lilypond_stream_r, remain_mom);
-         now_mom += remain_mom;
-       }
-
-      bar_i = check_end_bar_i (now_mom, bar_i);
-    }
-
-  // fill whole bars
-  int count_i = end_bar_i - bar_i;
-  for (int i = 0; i < count_i; i++)
-    {
-      int begin_bar_i = check_begin_bar_i (now_mom, bar_i);
-      if (begin_bar_i)
-       output_lilypond_begin_bar (lilypond_stream_r, now_mom, begin_bar_i);
-      lilypond_stream_r << "r1 ";
-      //       *lilypond_stream_r.os_p_ << flush;
-      if (begin_bar_i)
-       LOGOUT (NORMAL_ver) << begin_bar_i << flush;
-      bar_i = check_end_bar_i (now_mom, bar_i);
-      now_mom += bar_mom;
-    }
-
-  // use "int i" here, and gcc 2.7.2 hits internal compiler error
-  int ii = check_begin_bar_i (now_mom, bar_i);
-  if (ii)
-    output_lilypond_begin_bar (lilypond_stream_r, now_mom, ii);
-
-  //    bar_i = check_end_bar_i (now_mom, bar_i);
-
-  Rational remain_mom = end_mom - Rational (end_bar_i - 1) * bar_mom;
-  if (remain_mom > Rational (0))
-    {
-      output_lilypond_rest_remain (lilypond_stream_r, remain_mom);
-      now_mom += remain_mom;
-    }
-  assert (now_mom == end_mom);
-}
-
-void
-Lilypond_staff::output_lilypond_rest_remain (Lilypond_stream& lilypond_stream_r, Rational mom)
-{
-  if (Duration_convert::no_quantify_b_s)
-    {
-      Duration dur = Duration_convert::mom2_dur (mom);
-      lilypond_stream_r << "r" << dur.str () << " ";
-      //       assert (mom == dur.mom ());
-      assert (mom == dur.length ());
-      return;
-    }
-
-  Duration dur = Duration_convert::mom2standardised_dur (mom);
-  if (dur.type_i_>-10)
-    lilypond_stream_r << "r" << dur.str () << " ";
-}
-#endif
-
-
 void
 Lilypond_staff::process ()
 {
   /*
-     group items into voices
-     */
+    group items into voices
+  */
 
   assert (lilypond_score_l_g);
   lilypond_key_l_ = lilypond_score_l_g->lilypond_key_l_;
index d7676b26341796d31b52b2f7b17a340b74db2235..a19eec037865c9169e51cd8a9d571d8a5e16faf9 100644 (file)
@@ -1,7 +1,7 @@
 //
 // lilypond-voice.cc -- implement Lilypond_voice
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #include "string-convert.hh"
 #include "midi2ly-global.hh"
@@ -17,19 +17,40 @@ extern Lilypond_score* lilypond_score_l_g;
 Lilypond_voice::Lilypond_voice (Lilypond_staff* lilypond_staff_l)
 {
   lilypond_staff_l_ = lilypond_staff_l;
-  last_item_l_ =0;
-  last_note_l_ =0;
+  threads_.push (new Cons_list<Lilypond_item>);
+  mom_ = 0;
 }
-
+  
 void
-Lilypond_voice::add_item (Lilypond_item* lilypond_item_l)
+Lilypond_voice::add_items (Link_array<Lilypond_item>& items)
 {
-  last_item_l_  = lilypond_item_l;
-  if (Lilypond_note* n = dynamic_cast<Lilypond_note*> (lilypond_item_l))
+  int thread = 0;
+  for (int i = 0; i < items.size (); i++)
     {
-      last_note_l_  = n;
+      Lilypond_item* item = items[i];
+
+      int to_thread;
+      if (Lilypond_note* n = dynamic_cast<Lilypond_note*> (item))
+       to_thread = thread++;
+      else
+       to_thread = 0;
+      
+      if (to_thread >= threads_.size ())
+       threads_.push (new Cons_list<Lilypond_item>);
+      
+      if (to_thread == 0 && item->at_mom () > mom_)
+       {
+         /* urg: skip should use refer to end-colum, not separate moment */
+         Rational r = item->at_mom () - mom_;
+         Lilypond_column* start = lilypond_score_l_g->find_column_l (mom_);
+         threads_[to_thread]->append (new Cons<Lilypond_item> (new Lilypond_skip (start, r), 0));
+         mom_ = item->at_mom ();
+       }
+
+      threads_[to_thread]->append (new Cons<Lilypond_item> (item, 0));
+      if (to_thread == 0)
+       mom_ += item->duration_mom ();
     }
-  lilypond_item_l_list_.append (new Cons<Lilypond_item> (lilypond_item_l, 0));
 }
 
 /**
@@ -40,7 +61,7 @@ Lilypond_voice::get_clef () const
 {
   Lilypond_note * n =0;
 
-  for (Cons<Lilypond_item> *cp = lilypond_item_l_list_.head_; !n && cp; cp = cp->next_)
+  for (Cons<Lilypond_item> *cp = threads_[0]->head_; !n && cp; cp = cp->next_)
     {
       n = dynamic_cast<Lilypond_note*> (cp->car_);
     }
@@ -64,7 +85,7 @@ void
 Lilypond_voice::output (Lilypond_stream& lilypond_stream_r)
 {
   lilypond_stream_r << "{ ";
-  if (lilypond_item_l_list_.size_i () > FAIRLY_LONG_VOICE_i)
+  if (threads_[0]->size_i () > FAIRLY_LONG_VOICE_i)
     lilypond_stream_r << '\n';
 
 
@@ -73,7 +94,10 @@ Lilypond_voice::output (Lilypond_stream& lilypond_stream_r)
   int current_bar_i = 0;
   Rational bar_mom = lilypond_staff_l_->lilypond_time_signature_l_->bar_mom ();
 
-  for (Cons<Lilypond_item>* i = lilypond_item_l_list_.head_; i; i = i->next_)
+  Link_array <Cons<Lilypond_item> > heads;
+  for (int i = 1; i < threads_.size (); i++)
+    heads.push (threads_[i]->head_);
+  for (Cons<Lilypond_item>* i = threads_[0]->head_; i; i = i->next_)
     {
       Rational at_mom = i->car_->lilypond_column_l_->at_mom ();
       int bar_i = (int) (at_mom / bar_mom) + 1;
@@ -91,12 +115,34 @@ Lilypond_voice::output (Lilypond_stream& lilypond_stream_r)
          current_bar_i = bar_i;
        }
 
-      lilypond_stream_r << *i->car_;
+      if (dynamic_cast<Lilypond_note*> (i->car_)
+         && heads.size ()
+         && heads[0]
+         && heads[0]->car_->at_mom () == at_mom)
+       {
+         lilypond_stream_r << '<';
+      
+         lilypond_stream_r << *i->car_;
+
+         for (int h = 0;
+              h < heads.size ()
+                && heads[h]
+                && heads[h]->car_->at_mom () == at_mom;
+              h++)
+           {
+             lilypond_stream_r << *heads[h]->car_;
+             heads[h] = heads[h]->next_;
+           }
+         lilypond_stream_r << '>';
+       }
+      else
+       lilypond_stream_r << *i->car_;
+      
       if (Lilypond_key* k = dynamic_cast<Lilypond_key*> (i->car_))
        lilypond_staff_l_->lilypond_key_l_ = lilypond_score_l_g->lilypond_key_l_ = k;
     }
 
-  if (lilypond_item_l_list_.size_i () > FAIRLY_LONG_VOICE_i)
+  if (threads_[0]->size_i () > FAIRLY_LONG_VOICE_i)
     lilypond_stream_r << '\n';
 
   lilypond_stream_r << "} ";
index cce169c639694d8183678de694bbea6ad94530e6..a1a066553936ee43ae27ff6a942f0b53d809dcfa 100644 (file)
@@ -1,7 +1,7 @@
 //
 // main.cc -- implement  main () entry point
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #include <stdlib.h>
 #include <iostream.h>
@@ -121,7 +121,7 @@ usage()
   cout << '\n';
   cout << Long_option_init::table_str (long_option_init_a) << endl;
 
-  cout << _f ("Report bugs to %s", "bug-lilypond@gnu.org") << endl;
+  cout << _f ("Report bugs to %s", "bug-gnu-music@gnu.org") << endl;
 }
 
 void
index 3b62ffc106ba0a3e5d5467a9c398dc297d4f47d6..b8d786bed24308aee507cf66657c2a0f6f701e20 100644 (file)
@@ -308,10 +308,6 @@ Midi_track_parser::parse_event (Lilypond_column* col_l)
              int minor_i = (int)(bool)next_byte ();
              Lilypond_key* p = new Lilypond_key (accidentals_i, minor_i);
              item_p = p;
-#if 0
-             info_l_->score_l_->lilypond_key_l_ = p;
-             lilypond_staff_p_->lilypond_key_l_ = p;
-#endif
            }
          // SSME               [\0x7f][\x03]
          else if ((byte == 0x7f) && (next == 0x03))
index 08cb1637233ae1f73111917a84bdc5476953787b..73efc5a42ba421f02bf51a0ea29d571a896738a7 100644 (file)
@@ -1,7 +1,7 @@
 //
 // version.cc -- implement inexpensive versioning
 //
-// copyright 1997 Jan Nieuwenhuizen <janneke@gnu.org>
+// (c) 1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
 
 #include <stdio.h>
 #include "config.h"