From: Jan Nieuwenhuizen Date: Wed, 14 Nov 2001 08:11:12 +0000 (+0100) Subject: patch::: 1.4.8.jcn3 X-Git-Tag: release/1.4.9~1 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=f0eeafa0e8281bf5e01b1277bd10e4f8ccce3150;p=lilypond.git patch::: 1.4.8.jcn3 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 --- diff --git a/CHANGES b/CHANGES index 44deb112df..0d33625930 100644 --- 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 1cfdb6d9b5..ca27b24fd3 100644 --- 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. diff --git a/midi2ly/duration-convert.cc b/midi2ly/duration-convert.cc index b915c87727..356e8d42a4 100644 --- a/midi2ly/duration-convert.cc +++ b/midi2ly/duration-convert.cc @@ -8,7 +8,6 @@ */ #include #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 index 12c2fa832b..0000000000 --- a/midi2ly/duration-iter.cc +++ /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 - Jan Nieuwenhuizen -*/ -#include -#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); -} diff --git a/midi2ly/duration.cc b/midi2ly/duration.cc index 5289273358..391537af3a 100644 --- a/midi2ly/duration.cc +++ b/midi2ly/duration.cc @@ -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 index d3320c3317..0000000000 --- a/midi2ly/include/duration-iter.hh +++ /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 - - */ - -#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 */ - diff --git a/midi2ly/include/lilypond-column.hh b/midi2ly/include/lilypond-column.hh index 15a9097e9d..b7422c2c67 100644 --- a/midi2ly/include/lilypond-column.hh +++ b/midi2ly/include/lilypond-column.hh @@ -1,7 +1,7 @@ // // lilypond-column.hh -- declare Lilypond_column // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #ifndef LILYPOND_COLUMN_HH #define LILYPOND_COLUMN_HH diff --git a/midi2ly/include/lilypond-item.hh b/midi2ly/include/lilypond-item.hh index 039280c91e..5855725d2a 100644 --- a/midi2ly/include/lilypond-item.hh +++ b/midi2ly/include/lilypond-item.hh @@ -1,7 +1,7 @@ // // lilypond-item.hh -- declare lilypond_item // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #ifndef LILYPOND_ITEM_HH #define LILYPOND_ITEM_HH diff --git a/midi2ly/include/lilypond-score.hh b/midi2ly/include/lilypond-score.hh index 9076384ac5..d8996e82f0 100644 --- a/midi2ly/include/lilypond-score.hh +++ b/midi2ly/include/lilypond-score.hh @@ -1,7 +1,7 @@ // // lilypond-score.hh -- declare Lilypond_score // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #ifndef LILYPOND_SCORE_HH #define LILYPOND_SCORE_HH diff --git a/midi2ly/include/lilypond-staff.hh b/midi2ly/include/lilypond-staff.hh index ceba267b4b..d9e4580c29 100644 --- a/midi2ly/include/lilypond-staff.hh +++ b/midi2ly/include/lilypond-staff.hh @@ -1,7 +1,7 @@ // // lilypond-staff.hh -- declare lilypond_staff // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #ifndef LILYPOND_STAFF_HH #define LILYPOND_STAFF_HH diff --git a/midi2ly/include/lilypond-stream.hh b/midi2ly/include/lilypond-stream.hh index 29c1c8cf3a..2e6429907f 100644 --- a/midi2ly/include/lilypond-stream.hh +++ b/midi2ly/include/lilypond-stream.hh @@ -1,7 +1,7 @@ // // lilypond-stream.hh -- part of LilyPond // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen // should i be named Lilypond_stream? diff --git a/midi2ly/include/lilypond-voice.hh b/midi2ly/include/lilypond-voice.hh index b64882f6fb..dff2528881 100644 --- a/midi2ly/include/lilypond-voice.hh +++ b/midi2ly/include/lilypond-voice.hh @@ -1,12 +1,14 @@ // // lilypond-voice.hh -- declare Lilypond_voice // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #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& 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_l_list_; - + Link_array < Cons_list > threads_; + Rational mom_; }; #endif // LILYPOND_VOICE_HH diff --git a/midi2ly/include/midi-score-parser.hh b/midi2ly/include/midi-score-parser.hh index 2fca257ec3..25d6758883 100644 --- a/midi2ly/include/midi-score-parser.hh +++ b/midi2ly/include/midi-score-parser.hh @@ -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 diff --git a/midi2ly/include/midi2ly-global.hh b/midi2ly/include/midi2ly-global.hh index 4e5c54922b..2b06890921 100644 --- a/midi2ly/include/midi2ly-global.hh +++ b/midi2ly/include/midi2ly-global.hh @@ -1,7 +1,7 @@ // // midi2ly-global.hh -- declare global stuff for midi2ly // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #ifndef MIDI2LY_GLOBAL_HH #define MIDI2LY_GLOBAL_HH diff --git a/midi2ly/lilypond-column.cc b/midi2ly/lilypond-column.cc index 136f10a06d..3fde791a66 100644 --- a/midi2ly/lilypond-column.cc +++ b/midi2ly/lilypond-column.cc @@ -1,7 +1,7 @@ // // lilypond-column.cc -- implement Lilypond_column // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #include "lilypond-column.hh" diff --git a/midi2ly/lilypond-item.cc b/midi2ly/lilypond-item.cc index 977f44e70e..93bf3fd906 100644 --- a/midi2ly/lilypond-item.cc +++ b/midi2ly/lilypond-item.cc @@ -1,7 +1,7 @@ // // lilypond-item.cc -- implement Lilypond_item // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #include #include @@ -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; } diff --git a/midi2ly/lilypond-score.cc b/midi2ly/lilypond-score.cc index d0b05bb02b..363a0e7bf7 100644 --- a/midi2ly/lilypond-score.cc +++ b/midi2ly/lilypond-score.cc @@ -1,7 +1,7 @@ // // lilypond-score.cc -- implement Lilypond_score // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #include #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++) diff --git a/midi2ly/lilypond-staff.cc b/midi2ly/lilypond-staff.cc index 0e79b7f4e2..481bc38417 100644 --- a/midi2ly/lilypond-staff.cc +++ b/midi2ly/lilypond-staff.cc @@ -1,7 +1,7 @@ // // lilypond-staff.cc -- implement Lilypond_staff // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #include #include @@ -55,109 +55,40 @@ Lilypond_staff::eat_voice (Cons_list& items) Lilypond_voice* voice_p = new Lilypond_voice (this); lilypond_voice_p_list_.append (new Killing_cons (voice_p, 0)); - // Rational mom = items.top ()->at_mom (); Rational mom = 0; - for (Cons** pp = &items.head_; *pp;) + Link_array now_items; + for (Cons** i = &items.head_; *i;) { - Cons* 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 now_items; - for (Cons *cp = i; cp && cp->car_->at_mom () == mom; cp = cp->next_) - now_items.push (i->car_); - -#if 0 - /* - Why don't we use , if voice has: - - - - we'd get last_item == key_change -> last_note == 0; - */ - Lilypond_note * last_note = dynamic_cast (voice_p->last_item_l_); -#else - /* - Not sure, is this better? - */ - Lilypond_note * last_note = voice_p->last_note_l_; -#endif - - Link_array candidates; - - for (int i=0; last_note && i < now_items.size (); i++) - { - Lilypond_note * now_note = dynamic_cast (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 (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* c = items.remove_cons (pp); - voice_p->add_item (c->car_); + Lilypond_note* note = dynamic_cast ((*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* 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_; diff --git a/midi2ly/lilypond-voice.cc b/midi2ly/lilypond-voice.cc index d7676b2634..a19eec0378 100644 --- a/midi2ly/lilypond-voice.cc +++ b/midi2ly/lilypond-voice.cc @@ -1,7 +1,7 @@ // // lilypond-voice.cc -- implement Lilypond_voice // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #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); + mom_ = 0; } - + void -Lilypond_voice::add_item (Lilypond_item* lilypond_item_l) +Lilypond_voice::add_items (Link_array& items) { - last_item_l_ = lilypond_item_l; - if (Lilypond_note* n = dynamic_cast (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 (item)) + to_thread = thread++; + else + to_thread = 0; + + if (to_thread >= threads_.size ()) + threads_.push (new Cons_list); + + 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 (new Lilypond_skip (start, r), 0)); + mom_ = item->at_mom (); + } + + threads_[to_thread]->append (new Cons (item, 0)); + if (to_thread == 0) + mom_ += item->duration_mom (); } - lilypond_item_l_list_.append (new Cons (lilypond_item_l, 0)); } /** @@ -40,7 +61,7 @@ Lilypond_voice::get_clef () const { Lilypond_note * n =0; - for (Cons *cp = lilypond_item_l_list_.head_; !n && cp; cp = cp->next_) + for (Cons *cp = threads_[0]->head_; !n && cp; cp = cp->next_) { n = dynamic_cast (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* i = lilypond_item_l_list_.head_; i; i = i->next_) + Link_array > heads; + for (int i = 1; i < threads_.size (); i++) + heads.push (threads_[i]->head_); + for (Cons* 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 (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 (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 << "} "; diff --git a/midi2ly/main.cc b/midi2ly/main.cc index cce169c639..a1a0665539 100644 --- a/midi2ly/main.cc +++ b/midi2ly/main.cc @@ -1,7 +1,7 @@ // // main.cc -- implement main () entry point // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #include #include @@ -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 diff --git a/midi2ly/midi-track-parser.cc b/midi2ly/midi-track-parser.cc index 3b62ffc106..b8d786bed2 100644 --- a/midi2ly/midi-track-parser.cc +++ b/midi2ly/midi-track-parser.cc @@ -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)) diff --git a/midi2ly/midi2ly-version.cc b/midi2ly/midi2ly-version.cc index 08cb163723..73efc5a42b 100644 --- a/midi2ly/midi2ly-version.cc +++ b/midi2ly/midi2ly-version.cc @@ -1,7 +1,7 @@ // // version.cc -- implement inexpensive versioning // -// copyright 1997 Jan Nieuwenhuizen +// (c) 1997--2001 Jan Nieuwenhuizen #include #include "config.h"