From: Han-Wen Nienhuys Date: Wed, 14 Apr 1999 11:58:33 +0000 (+0200) Subject: patch::: 1.1.39.hwn1 X-Git-Tag: release/1.1.40~2 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=cfb5287829e4c8df689ef42e4367c44e51298dcd;p=lilypond.git patch::: 1.1.39.hwn1 pl 39.hwn1 - consified mi2mu --- Generated by hanwen@cs.uu.nl using package-diff 0.62, >From = lilypond-1.1.39, To = lilypond-1.1.39.hwn1 usage cd lilypond-source-dir; patch -E -p1 < lilypond-1.1.39.hwn1.diff Patches do not contain automatically generated files or (urg) empty directories, i.e., you should rerun autoconf, configure and possibly make outdirs. --state 1.1.39 1.1.39.hwn1 ++state --- diff --git a/NEWS b/NEWS index 9759d8c368..d561e5e3ae 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,13 @@ -pl 39.jcn1 +--- ../lilypond-1.1.39/NEWS Tue Apr 13 21:32:36 1999 +++ b/NEWS Tue Apr 13 22:43:46 1999 +@@ -1,3 +1,7 @@ +pl 39.hwn1 + - consified mi2mu + + + pl 39 + - \property textstyle -> textStyle + pl 39.jcn1 - Musical_pitch::str (): use names from notename table pl 39 diff --git a/VERSION b/VERSION index 76ebe35e32..c6610d636a 100644 --- a/VERSION +++ b/VERSION @@ -2,7 +2,7 @@ PACKAGE_NAME=LilyPond MAJOR_VERSION=1 MINOR_VERSION=1 PATCH_LEVEL=39 -MY_PATCH_LEVEL=jcn1 +MY_PATCH_LEVEL=hwn1 # use the above to send patches: MY_PATCH_LEVEL is always empty for a # released version. diff --git a/flower/include/cons.hh b/flower/include/cons.hh index 6e62c4c865..8fd58acb7f 100644 --- a/flower/include/cons.hh +++ b/flower/include/cons.hh @@ -11,6 +11,8 @@ #define CONS_HH +#include + template class Cons { @@ -55,6 +57,31 @@ Cons *remove_cons (Cons **pp) return knip; } +template int cons_list_size_i (Cons *l) +{ + int i=0; + while (l) + { + l = l->next_; + i++; + } + return i; +} + + + + + +template +Cons * last_cons (Cons * head) +{ + while (head->next_) + { + head = head->next_; + } + return head; +} + /** Invariants: @@ -69,15 +96,22 @@ class Cons_list { public: Cons * head_; - Cons ** tail_; - Cons_list () { init_list (); } - void init_list () {head_ =0; tail_ = &head_; } + Cons ** nil_pointer_address_; + Cons_list () + { + init (); + } + void init () + { + head_ =0; + nil_pointer_address_ = &head_; + } void append (Cons *c) { assert (!c->next_); - *tail_ = c; - while (*tail_) - tail_ = &(*tail_)->next_; + *nil_pointer_address_ = c; + while (*nil_pointer_address_) + nil_pointer_address_ = &(*nil_pointer_address_)->next_; } /** PRE: *pp should either be the head_ pointer, or the next_ pointer @@ -85,8 +119,8 @@ public: */ Cons *remove_cons (Cons **pp) { - if (&(*pp)->next_ == tail_) - tail_ = pp; + if (&(*pp)->next_ == nil_pointer_address_) + nil_pointer_address_ = pp; return ::remove_cons (pp); } @@ -95,7 +129,14 @@ public: delete head_; head_ =0; } - ~Cons_list () { junk (); } + ~Cons_list () + { + junk (); + } + int size_i () + { + return cons_list_size_i (head_); + } }; @@ -105,19 +146,5 @@ template void clone_killing_cons_list (Cons_list&, Cons *src); -template int cons_list_size_i (Cons *l) -{ - int i=0; - while (l) - { - l = l->next_; - i++; - } - return i; -} - - - - #endif /* CONS_HH */ diff --git a/lily/include/p-col.hh b/lily/include/p-col.hh index 82be4547bc..1211309e1c 100644 --- a/lily/include/p-col.hh +++ b/lily/include/p-col.hh @@ -31,7 +31,7 @@ class Paper_column : public Axis_group_item { public: VIRTUAL_COPY_CONS(Score_element); Drul_array > minimal_dists_arr_drul_; - + Drul_array > spring_arr_drul_; void preprocess (); /// set a minimum distance void add_rod (Paper_column * to, Real distance); diff --git a/lily/include/rod.hh b/lily/include/rod.hh index 2d8b9b4e53..fbde969355 100644 --- a/lily/include/rod.hh +++ b/lily/include/rod.hh @@ -22,6 +22,7 @@ struct Column_rod { void print () const; }; + struct Rod { Drul_array item_l_drul_; @@ -31,6 +32,18 @@ struct Rod Rod (); }; +struct Column_spring { + Paper_column *other_l_; + Real distance_f_; + Real strength_f_; + + Column_spring (); + static int compare (const Column_spring &r1, const Column_spring &r2); + void print () const; +}; +struct Spring{ + +}; #endif /* ROD_HH */ diff --git a/lily/include/spacing-spanner.hh b/lily/include/spacing-spanner.hh new file mode 100644 index 0000000000..fbf332b2c7 --- /dev/null +++ b/lily/include/spacing-spanner.hh @@ -0,0 +1,23 @@ +/* + spacing-spanner.hh -- declare Spacing_spanner + + source file of the GNU LilyPond music typesetter + + (c) 1999 Han-Wen Nienhuys + + */ + +#ifndef SPACING_SPANNER_HH +#define SPACING_SPANNER_HH + +class Spacing_spanner : public Spanner +{ + Link_array cols_; + + Spacing_spanner (); +protected: + virtual void do_space_processing (); +}; + +#endif /* SPACING_SPANNER_HH */ + diff --git a/lily/music-list.cc b/lily/music-list.cc index 01ccd5be0f..656798d3ca 100644 --- a/lily/music-list.cc +++ b/lily/music-list.cc @@ -92,7 +92,7 @@ Music_list::do_relative_octave (Musical_pitch last, bool ret_first) Music_list::Music_list (Music_list const &s) : Cons_list (s) { - init_list (); + Cons_list::init (); clone_killing_cons_list (*this, s.head_); } diff --git a/lily/rod.cc b/lily/rod.cc index 8f3cdc9260..008707bbc1 100644 --- a/lily/rod.cc +++ b/lily/rod.cc @@ -47,3 +47,24 @@ Rod::add_to_cols () item_l_drul_[LEFT]->column_l ()->add_rod (item_l_drul_[RIGHT]->column_l (), distance_f_); } + +void +Column_spring::print () const +{ +#ifndef NDEBUG + DOUT << "Column_spring { rank = " + << other_l_->rank_i () << ", dist = " << distance_f_ << "}\n"; +#endif +} + +Column_spring::Column_spring () +{ + distance_f_ = 0; + other_l_ = 0; +} + +int +Column_spring::compare (const Column_spring &r1, const Column_spring &r2) +{ + return r1.other_l_->rank_i() - r2.other_l_->rank_i(); +} diff --git a/mi2mu/include/midi-track-parser.hh b/mi2mu/include/midi-track-parser.hh index 3679ef6007..d873e198df 100644 --- a/mi2mu/include/midi-track-parser.hh +++ b/mi2mu/include/midi-track-parser.hh @@ -11,7 +11,7 @@ #define MIDI_TRACK_PARSER_HH #include "proto.hh" -#include "plist.hh" +#include "cons.hh" #include "moment.hh" #include "mi2mu-proto.hh" #include "midi-parser.hh" @@ -36,7 +36,7 @@ private: Moment at_mom_; Byte running_byte_; - Link_list open_note_l_list_; + Cons_list open_note_l_list_; Mudela_staff* mudela_staff_p_; Midi_parser_info* track_info_p_; }; diff --git a/mi2mu/include/mudela-column.hh b/mi2mu/include/mudela-column.hh index b1ab97c24b..a09cebb469 100644 --- a/mi2mu/include/mudela-column.hh +++ b/mi2mu/include/mudela-column.hh @@ -9,7 +9,7 @@ #include "proto.hh" #include "mi2mu-proto.hh" #include "moment.hh" -#include "plist.hh" +#include "cons.hh" /// (mudela_column) class Mudela_column @@ -18,9 +18,9 @@ public: Mudela_column (Mudela_score* mudela_score_l, Moment mom); void add_item (Mudela_item* mudela_item_l); - Moment at_mom(); + Moment at_mom (); - Link_list mudela_item_l_list_; + Cons_list mudela_item_l_list_; Moment at_mom_; Mudela_score* mudela_score_l_; }; diff --git a/mi2mu/include/mudela-item.hh b/mi2mu/include/mudela-item.hh index 6dce94333d..e1b52b7368 100644 --- a/mi2mu/include/mudela-item.hh +++ b/mi2mu/include/mudela-item.hh @@ -21,109 +21,109 @@ class Mudela_item { public: - Mudela_item (Mudela_column* mudela_column_l); - virtual ~Mudela_item (); + Mudela_item (Mudela_column* mudela_column_l); + virtual ~Mudela_item (); - virtual Moment at_mom(); - virtual Moment duration_mom(); - void output (Mudela_stream& mudela_stream_r); - virtual String str() = 0; + virtual Moment at_mom (); + virtual Moment duration_mom (); + void output (Mudela_stream& mudela_stream_r); + virtual String str () = 0; - Mudela_column* mudela_column_l_; + Mudela_column* mudela_column_l_; }; class Mudela_key : public Mudela_item { public: - Mudela_key (int accidentals_i, int minor_i); + Mudela_key (int accidentals_i, int minor_i); - String notename_str (int pitch_i); - virtual String str(); + String notename_str (int pitch_i); + virtual String str (); -//private: - int accidentals_i_; - int minor_i_; + //private: + int accidentals_i_; + int minor_i_; }; class Mudela_time_signature : public Mudela_item { public: - Mudela_time_signature (int num_i, int den_i, int division_4_i, int count_32_i); + Mudela_time_signature (int num_i, int den_i, int division_4_i, int count_32_i); - Duration i2_dur (int time_i, int division_1_i); - int clocks_1_i(); - int den_i(); - int num_i(); - virtual String str(); - Moment bar_mom(); + Duration i2_dur (int time_i, int division_1_i); + int clocks_1_i (); + int den_i (); + int num_i (); + virtual String str (); + Moment bar_mom (); private: - Real sync_f_; - Duration sync_dur_; - int clocks_1_i_; - int num_i_; - int den_i_; + Real sync_f_; + Duration sync_dur_; + int clocks_1_i_; + int num_i_; + int den_i_; }; class Mudela_note : public Mudela_item { public: - Mudela_note (Mudela_column* mudela_column_l, int channel_i, int pitch_i, int dyn_i); + Mudela_note (Mudela_column* mudela_column_l, int channel_i, int pitch_i, int dyn_i); - Duration duration(); - virtual Moment duration_mom(); - virtual String str(); + Duration duration (); + virtual Moment duration_mom (); + virtual String str (); -// int const c0_pitch_i_c_ = 60; // huh? - static int const c0_pitch_i_c_ = 48; + // int const c0_pitch_i_c_ = 60; // huh? + static int const c0_pitch_i_c_ = 48; - static bool const simple_plet_b_s = false; - int channel_i_; - int pitch_i_; - Mudela_column* end_column_l_; + static bool const simple_plet_b_s = false; + int channel_i_; + int pitch_i_; + Mudela_column* end_column_l_; }; class Mudela_skip : public Mudela_item { public: - Mudela_skip (Mudela_column* mudela_column_l, Moment skip_mom); + Mudela_skip (Mudela_column* mudela_column_l, Moment skip_mom); - Duration duration(); - virtual Moment duration_mom(); - virtual String str(); + Duration duration (); + virtual Moment duration_mom (); + virtual String str (); private: - Moment mom_; + Moment mom_; }; class Mudela_tempo : public Mudela_item { public: - Mudela_tempo (int useconds_per_4_i); + Mudela_tempo (int useconds_per_4_i); - int get_tempo_i (Moment moment); - virtual String str(); - int useconds_per_4_i(); + int get_tempo_i (Moment moment); + virtual String str (); + int useconds_per_4_i (); private: - int useconds_per_4_i_; - Moment seconds_per_1_mom_; + int useconds_per_4_i_; + Moment seconds_per_1_mom_; }; class Mudela_text : public Mudela_item { public: - enum Type { - TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, - MARKER, CUE_POINT - }; - Mudela_text (Mudela_text::Type type, String str); - virtual String str(); - -//private: - Type type_; - String text_str_; + enum Type { + TEXT = 1, COPYRIGHT, TRACK_NAME, INSTRUMENT_NAME, LYRIC, + MARKER, CUE_POINT + }; + Mudela_text (Mudela_text::Type type, String str); + virtual String str (); + + //private: + Type type_; + String text_str_; }; #endif // MUDELA_ITEM_HH diff --git a/mi2mu/include/mudela-score.hh b/mi2mu/include/mudela-score.hh index 4d0992b35c..8e75d028cc 100644 --- a/mi2mu/include/mudela-score.hh +++ b/mi2mu/include/mudela-score.hh @@ -8,45 +8,43 @@ #include "mi2mu-proto.hh" #include "proto.hh" -#include "plist.hh" +#include "cons.hh" #include "parray.hh" /// (mudela_score) class Mudela_score { public: - Mudela_score (int format_i, int tracks_i, int tempo_i); - ~Mudela_score(); + Mudela_score (int format_i, int tracks_i, int tempo_i); + ~Mudela_score (); - void add_item (Mudela_item* mudela_item_p); - void add_staff (Mudela_staff* mudela_staff_p); + void add_item (Mudela_item* mudela_item_p); + void add_staff (Mudela_staff* mudela_staff_p); - Mudela_column* find_column_l (Moment mom); - Mudela_column* get_column_l (Moment mom); + Mudela_column* find_column_l (Moment mom); + Mudela_column* get_column_l (Moment mom); - void output (String filename_str); - void process(); - - // ugh - Mudela_key* mudela_key_l_; - Mudela_time_signature* mudela_time_signature_l_; - Mudela_tempo* mudela_tempo_l_; + void output (String filename_str); + void process (); + // ugh + Mudela_key* mudela_key_l_; + Mudela_time_signature* mudela_time_signature_l_; + Mudela_tempo* mudela_tempo_l_; + Mudela_staff * last_staff_l_; private: - void filter_tempo(); - void quantify_columns(); - void quantify_durations(); - void settle_columns(); + void filter_tempo (); + void quantify_columns (); + void quantify_durations (); + void settle_columns (); - Pointer_list mudela_staff_p_list_; - // wants Pointer_array! -// Pointer_list mudela_column_p_list_; - Link_array column_l_array_; + Cons_list mudela_staff_p_list_; + Link_array column_l_array_; -// ugh, ugh, ugh + // ugh, ugh, ugh public: - int format_i_; - int tracks_i_; - int tempo_i_; + int format_i_; + int tracks_i_; + int tempo_i_; }; #endif // MUDELA_SCORE_HH diff --git a/mi2mu/include/mudela-staff.hh b/mi2mu/include/mudela-staff.hh index 4b4fd75c60..8c0afa044a 100644 --- a/mi2mu/include/mudela-staff.hh +++ b/mi2mu/include/mudela-staff.hh @@ -8,20 +8,21 @@ #include "mi2mu-proto.hh" #include "proto.hh" -#include "plist.hh" +#include "cons.hh" #include "string.hh" /// (mudela_staff) -class Mudela_staff { +class Mudela_staff +{ public: Mudela_staff (int number_i, String copyright_str, String track_name_str, String instrument_str); void add_item (Mudela_item* mudela_item_p); - void eat_voice (Link_list& items); - String id_str(); - String name_str(); + void eat_voice (Cons_list& items); + String id_str (); + String name_str (); void output (Mudela_stream& mudela_stream_r); - void process(); + void process (); String copyright_str_; String instrument_str_; @@ -34,8 +35,8 @@ public: private: void output_mudela_begin_bar (Mudela_stream& mudela_stream_r, Moment now_mom, int bar_i); - Pointer_list mudela_voice_p_list_; - Pointer_list mudela_item_p_list_; + Cons_list mudela_voice_p_list_; + Cons_list mudela_item_p_list_; }; #endif // MUDELA_STAFF_HH diff --git a/mi2mu/include/mudela-voice.hh b/mi2mu/include/mudela-voice.hh index 28b4efcdb9..db196da9e6 100644 --- a/mi2mu/include/mudela-voice.hh +++ b/mi2mu/include/mudela-voice.hh @@ -7,22 +7,19 @@ #define MUDELA_VOICE_HH #include "mi2mu-proto.hh" -#include "plist.hh" +#include "cons.hh" /// (mudela_voice) -class Mudela_voice { +class Mudela_voice +{ public: - Mudela_voice (Mudela_staff* mudela_staff_l); - - void add_item (Mudela_item* mudela_item_l); - Moment begin_mom(); - Moment end_mom(); - - void output (Mudela_stream& mudela_stream_r); + Mudela_voice (Mudela_staff* mudela_staff_l); + void add_item (Mudela_item* mudela_item_l); + void output (Mudela_stream& mudela_stream_r); private: - Mudela_staff* mudela_staff_l_; - Link_list mudela_item_l_list_; + Mudela_staff* mudela_staff_l_; + Cons_list mudela_item_l_list_; }; #endif // MUDELA_VOICE_HH diff --git a/mi2mu/midi-track-parser.cc b/mi2mu/midi-track-parser.cc index ff7d4453d4..661d6a8bcb 100644 --- a/mi2mu/midi-track-parser.cc +++ b/mi2mu/midi-track-parser.cc @@ -53,19 +53,17 @@ Midi_track_parser::note_end (Mudela_column* col_l, int channel_i, int pitch_i, i assert (col_l); - for (PCursor i (open_note_l_list_.top ()); i.ok (); ) + for (Cons** pp = &open_note_l_list_.head_; *pp;) { - if ((i->pitch_i_ == pitch_i) && (i->channel_i_ == channel_i)) + Cons* i = *pp; + if ((i->car_->pitch_i_ == pitch_i) && (i->car_->channel_i_ == channel_i)) { - i->end_column_l_ = col_l; - // LOGOUT(DEBUG_ver) << "Note: " << pitch_i; - // LOGOUT(DEBUG_ver) << "; " << i->mudela_column_l_->at_mom_; - // LOGOUT(DEBUG_ver) << ", " << i->end_column_l_->at_mom_ << '\n'; - i.remove_p(); + i->car_->end_column_l_ = col_l; + delete open_note_l_list_.remove_cons (pp); return; } else - i++; + pp = &i->next_; } warning (_f ("junking note-end event: channel = %d, pitch = %d", channel_i, pitch_i)); @@ -76,11 +74,12 @@ Midi_track_parser::note_end_all (Mudela_column* col_l) { // find assert (col_l); - for (PCursor i (open_note_l_list_.top ()); i.ok (); ) + for (Cons* i = open_note_l_list_.head_; i; i = i->next_) { - i->end_column_l_ = col_l; - i.remove_p (); + i->car_->end_column_l_ = col_l; } + // UGH UGH. MEMORY LEAK. + open_note_l_list_.init (); } Mudela_staff* @@ -169,13 +168,14 @@ Midi_track_parser::parse_event (Mudela_column* col_l) { Mudela_note* p = new Mudela_note (col_l, channel_i, pitch_i, dyn_i); item_p = p; - open_note_l_list_.bottom ().add (p); + open_note_l_list_.append (new Cons (p, 0)); } else { note_end (col_l, channel_i, pitch_i, dyn_i); } } + // POLYPHONIC_AFTERTOUCH [\xa0-\xaf] else if ((byte >= 0xa0) && (byte <= 0xaf)) { diff --git a/mi2mu/mudela-column.cc b/mi2mu/mudela-column.cc index 5a00e88310..833b351f81 100644 --- a/mi2mu/mudela-column.cc +++ b/mi2mu/mudela-column.cc @@ -14,7 +14,7 @@ Mudela_column::Mudela_column (Mudela_score* mudela_score_l, Moment mom) void Mudela_column::add_item (Mudela_item* mudela_item_l) { - mudela_item_l_list_.bottom().add (mudela_item_l); + mudela_item_l_list_.append (new Cons (mudela_item_l, 0)); } Moment diff --git a/mi2mu/mudela-score.cc b/mi2mu/mudela-score.cc index 4380edfcb2..6916d80df7 100644 --- a/mi2mu/mudela-score.cc +++ b/mi2mu/mudela-score.cc @@ -14,9 +14,7 @@ #include "mudela-staff.hh" #include "mudela-stream.hh" -// ugh, cygnus' b19 gcc -#include "list.tcc" -#include "cursor.tcc" +#include "killing-cons.tcc" //static Mudela_key key_c (0, 0); static Mudela_time_signature time_sig_4 (4, 2, 24, 8); @@ -25,6 +23,7 @@ static Mudela_tempo tempo_60 (1000000); Mudela_score::Mudela_score (int format_i, int tracks_i, int tempo_i) { + last_staff_l_ =0; format_i_ = format_i; tracks_i_ = tracks_i; tempo_i_ = tempo_i; @@ -35,32 +34,26 @@ Mudela_score::Mudela_score (int format_i, int tracks_i, int tempo_i) mudela_tempo_l_ = &tempo_60; } -Mudela_score::~Mudela_score() +Mudela_score::~Mudela_score () { } void Mudela_score::add_item (Mudela_item* mudela_item_p) { - mudela_staff_p_list_.bottom()->add_item (mudela_item_p); + last_staff_l_->add_item (mudela_item_p); } void Mudela_score::add_staff (Mudela_staff* mudela_staff_p) { - mudela_staff_p_list_.bottom().add (mudela_staff_p); + mudela_staff_p_list_.append (new Killing_cons (mudela_staff_p, 0)); + last_staff_l_ = mudela_staff_p; } Mudela_column* Mudela_score::find_column_l (Moment mom) { -#if 0 - // should do binary search - for (int i = 0; i < column_l_array_.size (); i++ ) - if ( column_l_array_[i]->at_mom () == mom ) - return column_l_array_[i]; - return 0; -#else int upper_i = max (0, column_l_array_.size () - 1); int lower_i = 0; int i = 0; //upper_i; @@ -73,7 +66,7 @@ Mudela_score::find_column_l (Moment mom) upper_i = i; else lower_i = i; - if ((upper_i == lower_i) || (i == column_l_array_.size () - 1)) + if ( (upper_i == lower_i) || (i == column_l_array_.size () - 1)) { // we don't do inserts assert (0); @@ -85,7 +78,6 @@ Mudela_score::find_column_l (Moment mom) } assert (0); return 0; -#endif } Mudela_column* @@ -93,7 +85,7 @@ Mudela_score::get_column_l (Moment mom) { int i; Mudela_column *c=0; - for (i=column_l_array_.size() - 1; !c && i >=0; i--) + for (i=column_l_array_.size () - 1; !c && i >=0; i--) { if (column_l_array_ [i]->at_mom () == mom ) c = column_l_array_[i]; @@ -110,162 +102,152 @@ Mudela_score::get_column_l (Moment mom) return c; } - void Mudela_score::output (String filename_str) { - LOGOUT(NORMAL_ver) << _f ("Lily output to %s...", filename_str) << endl; - + LOGOUT (NORMAL_ver) << _f ("Lily output to %s...", filename_str) << endl; + // ugh, ugly midi type 1 fix - if ( (mudela_staff_p_list_.size() == 1) && !mudela_staff_p_list_.top()->number_i_) - mudela_staff_p_list_.top()->number_i_ = 1; - + if ( (mudela_staff_p_list_.size_i () == 1) + && !mudela_staff_p_list_.head_->car_->number_i_) + mudela_staff_p_list_.head_->car_->number_i_ = 1; + int track_i = 0; Mudela_stream mudela_stream (filename_str); - for (PCursor i (mudela_staff_p_list_); i.ok(); i++) + for (Cons* i = mudela_staff_p_list_.head_; i; i = i->next_) { - LOGOUT(NORMAL_ver) << _ ("track ") << track_i++ << ": " << flush; - i->output (mudela_stream); + LOGOUT (NORMAL_ver) << _ ("track ") << track_i++ << ": " << flush; + i->car_->output (mudela_stream); mudela_stream << '\n'; - LOGOUT(NORMAL_ver) << endl; + LOGOUT (NORMAL_ver) << endl; } - + mudela_stream << "\\score{\n"; - if (mudela_staff_p_list_.size() > 1) + if (mudela_staff_p_list_.size_i () > 1) mudela_stream << "< \n"; - for (PCursor i (mudela_staff_p_list_); i.ok(); i++) + for (Cons* i = mudela_staff_p_list_.head_; i; i = i->next_) { - if ( (mudela_staff_p_list_.size() != 1) - && (i == mudela_staff_p_list_.top())) - continue; - mudela_stream << "\\type Staff = \"" << i->id_str() << "\" "; - mudela_stream << String ("\\" + i->id_str ()) << "\n"; + if ( (mudela_staff_p_list_.size_i () != 1) + && (i->car_ == mudela_staff_p_list_.head_->car_)) + continue; + mudela_stream << "\\type Staff = \"" << i->car_->id_str () << "\" "; + mudela_stream << String ("\\" + i->car_->id_str ()) << "\n"; } - if (mudela_staff_p_list_.size() > 1) + if (mudela_staff_p_list_.size_i () > 1) mudela_stream << ">\n"; - - + mudela_stream << "\\paper{}\n"; - + +#if 0 mudela_stream << "\\midi{\n"; + // let's not use silly 0 track - mudela_staff_p_list_.bottom()->mudela_tempo_l_->output (mudela_stream); + last_cons (mudela_staff_p_list_.head_)->car_->mudela_tempo_l_->output (mudela_stream); mudela_stream << "}\n"; - +#endif + mudela_stream << "}\n"; } - + void -Mudela_score::process() +Mudela_score::process () { - LOGOUT(NORMAL_ver) << '\n' << _ ("Processing...") << endl; - - LOGOUT(DEBUG_ver) << "columns\n"; - // for (PCursor i (mudela_column_p_list_); i.ok(); i++) - // LOGOUT(DEBUG_ver) << "At: " << i->at_mom() << '\n'; - - settle_columns(); - filter_tempo(); - quantify_columns(); - quantify_durations(); - - LOGOUT(NORMAL_ver) << '\n' << _ ("Creating voices...") << endl; + LOGOUT (NORMAL_ver) << '\n' << _ ("Processing...") << endl; + + LOGOUT (DEBUG_ver) << "columns\n"; + + settle_columns (); + filter_tempo (); + quantify_columns (); + quantify_durations (); + + LOGOUT (NORMAL_ver) << '\n' << _ ("Creating voices...") << endl; int track_i = 0; - for (PCursor i (mudela_staff_p_list_); i.ok(); i++) + for (Cons* i = mudela_staff_p_list_.head_; i; i = i->next_) { - LOGOUT(NORMAL_ver) << _ ("track ") << track_i++ << ": " << flush; - i->process(); - LOGOUT(NORMAL_ver) << endl; + LOGOUT (NORMAL_ver) << _ ("track ") << track_i++ << ": " << flush; + i->car_->process (); + LOGOUT (NORMAL_ver) << endl; } } - + void -Mudela_score::filter_tempo() +Mudela_score::filter_tempo () { - LOGOUT(NORMAL_ver) << '\n' << _ ("NOT Filtering tempo...") << endl; + LOGOUT (NORMAL_ver) << '\n' << _ ("NOT Filtering tempo...") << endl; } - + void -Mudela_score::quantify_columns() +Mudela_score::quantify_columns () { // ugh - if (Duration_convert::no_quantify_b_s) + if (Duration_convert::no_quantify_b_s) { - LOGOUT(NORMAL_ver) << '\n' << _("NOT Quantifying columns...") << endl; + LOGOUT (NORMAL_ver) << '\n' << _ ("NOT Quantifying columns...") << endl; return; } - - LOGOUT(NORMAL_ver) << '\n' << _("Quantifying columns...") << endl; - + + LOGOUT (NORMAL_ver) << '\n' << _ ("Quantifying columns...") << endl; + int current_bar_i = 0; - Moment bar_mom = mudela_time_signature_l_->bar_mom(); - + Moment bar_mom = mudela_time_signature_l_->bar_mom (); + int n = 5 >? Duration_convert::no_smaller_than_i_s; n = Duration_convert::type2_i (n); Moment s = Moment (1, n); - Moment sh = Moment (1, 2 * n); - for (int i = 0; i < column_l_array_.size(); i++) + for (int i = 0; i < column_l_array_.size (); i++) { column_l_array_ [i]->at_mom_ = - s * Moment( (int) ( (column_l_array_ [i]->at_mom()) / s)); - + s * Moment ( (int) ( (column_l_array_ [i]->at_mom ()) / s)); + int bar_i = (int) (column_l_array_ [i]->at_mom () / bar_mom) + 1; if (bar_i > current_bar_i) - { - LOGOUT (NORMAL_ver) << "[" << bar_i << "]" << flush; - current_bar_i = bar_i; - } + + { + LOGOUT (NORMAL_ver) << "[" << bar_i << "]" << flush; + current_bar_i = bar_i; + } } - LOGOUT(NORMAL_ver) << endl; + LOGOUT (NORMAL_ver) << endl; } - + void -Mudela_score::quantify_durations() +Mudela_score::quantify_durations () { - // LOGOUT(NORMAL_ver) << '\n' << "Quantifying durations..." << endl; + } - + void -Mudela_score::settle_columns() +Mudela_score::settle_columns () { - // LOGOUT(NORMAL_ver) << '\n' << "NOT Settling columns..." << endl; - // return; - LOGOUT(NORMAL_ver) << '\n' << _("Settling columns...") << endl; - -#if 0 - assert (!column_l_array_.size()); - int n = mudela_column_p_list_.size(); - // huh? - // column_l_array_.set_size (n); - for (PCursor i (mudela_column_p_list_); i.ok(); i++) - column_l_array_.push (*i); -#endif - - int n = column_l_array_.size(); - + LOGOUT (NORMAL_ver) << '\n' << _ ("Settling columns...") << endl; + + int n = column_l_array_.size (); + int start_i = 0; int end_i = 0; Moment start_mom = 0; + Duration smallest_dur; smallest_dur.durlog_i_ = 6; Moment const noise_mom = Duration_convert::dur2_mom (smallest_dur) / Moment (2); - for (int i = 0; i < n; i++) + for (int i = 0; i < n; i++) { - if (!start_i) + if (!start_i) { start_i = end_i = i; - start_mom = column_l_array_ [i]->at_mom(); + start_mom = column_l_array_ [i]->at_mom (); continue; } // find all columns within noise's distance - while ( (i < n) - && (column_l_array_ [i]->at_mom() - start_mom < noise_mom)) + while ( (i < n) + && (column_l_array_ [i]->at_mom () - start_mom < noise_mom)) end_i = ++i; // bluntly set all to time of first in group - for (int j = start_i; j < end_i; j++) + for (int j = start_i; j < end_i; j++) column_l_array_ [j]->at_mom_ = start_mom; start_i = end_i = 0; diff --git a/mi2mu/mudela-staff.cc b/mi2mu/mudela-staff.cc index 3c92577895..d6088e1bec 100644 --- a/mi2mu/mudela-staff.cc +++ b/mi2mu/mudela-staff.cc @@ -17,6 +17,8 @@ #include "mudela-voice.hh" #include "mudela-score.hh" +#include "killing-cons.tcc" + extern Mudela_score* mudela_score_l_g; Mudela_staff::Mudela_staff (int number_i, String copyright_str, String track_name_str, String instrument_str) @@ -33,51 +35,53 @@ Mudela_staff::Mudela_staff (int number_i, String copyright_str, String track_nam void Mudela_staff::add_item (Mudela_item* mudela_item_p) { - mudela_item_p_list_.bottom().add (mudela_item_p); - if (mudela_item_p->mudela_column_l_) + mudela_item_p_list_.append (new Killing_cons (mudela_item_p, 0)); + if (mudela_item_p->mudela_column_l_) mudela_item_p->mudela_column_l_->add_item (mudela_item_p); } void -Mudela_staff::eat_voice (Link_list& items) +Mudela_staff::eat_voice (Cons_list& items) { Mudela_voice* voice_p = new Mudela_voice (this); - mudela_voice_p_list_.bottom().add (voice_p); + mudela_voice_p_list_.append (new Killing_cons (voice_p, 0)); - // Moment mom = items.top()->at_mom(); + // Moment mom = items.top ()->at_mom (); Moment mom = 0; - for (PCursor i (items); i.ok();) + for (Cons** pp = &items.head_; *pp;) { - LOGOUT(DEBUG_ver) << "At: " << i->at_mom ().str () << "; "; - LOGOUT(DEBUG_ver) << "dur: " << i->duration_mom ().str () << "; "; - LOGOUT(DEBUG_ver) << "mom: " << mom.str () << " -> "; - if (i->at_mom() > mom) + Cons* i = *pp; + LOGOUT (DEBUG_ver) << "At: " << i->car_->at_mom ().str () << "; "; + LOGOUT (DEBUG_ver) << "dur: " << i->car_->duration_mom ().str () << "; "; + LOGOUT (DEBUG_ver) << "mom: " << mom.str () << " -> "; + if (i->car_->at_mom () > mom) { - Moment dur = i->at_mom() - mom; + Moment dur = i->car_->at_mom () - mom; // ugh, need score Mudela_column* start = mudela_score_l_g->find_column_l (mom); voice_p->add_item (new Mudela_skip (start, dur)); - mom = i->at_mom(); + mom = i->car_->at_mom (); } - if (i->at_mom() == mom) + if (i->car_->at_mom () == mom) { - mom = i->at_mom() + i->duration_mom(); - voice_p->add_item (i.remove_p()); - // ugh + mom = i->car_->at_mom () + i->car_->duration_mom (); + Cons* c = items.remove_cons (pp); + voice_p->add_item (c->car_); + delete c; } - else if (i.ok()) - i++; - LOGOUT(DEBUG_ver) << "mom: " << mom.str () << '\n'; + else if (*pp) + pp = &i->next_; + LOGOUT (DEBUG_ver) << "mom: " << mom.str () << '\n'; } } String -Mudela_staff::id_str() +Mudela_staff::id_str () { String id (name_str ()); char *cp = id.ch_l (); - char *end = cp + id.length_i(); + char *end = cp + id.length_i (); for (;cp < end; cp++) { if (!isalpha (*cp)) @@ -89,9 +93,9 @@ Mudela_staff::id_str() } String -Mudela_staff::name_str() +Mudela_staff::name_str () { - if (name_str_.length_i()) + if (name_str_.length_i ()) return name_str_; return String ("track") + to_str (char ('A' - 1 + number_i_)); } @@ -101,40 +105,40 @@ Mudela_staff::name_str() void Mudela_staff::output (Mudela_stream& mudela_stream_r) { - mudela_stream_r << id_str() << " = \\notes"; - mudela_stream_r << (mudela_voice_p_list_.size() > 1 ? "<" : "{"); + mudela_stream_r << id_str () << " = \\notes"; + mudela_stream_r << (mudela_voice_p_list_.size_i () > 1 ? "<" : "{"); mudela_stream_r << '\n'; mudela_stream_r << _ ("% midi copyright:") << copyright_str_ << '\n'; mudela_stream_r << _ ("% instrument:") << instrument_str_ << '\n'; // don't use last duration mode // mudela_stream_r << "\\duration 4;\n"; - if (mudela_voice_p_list_.size() == 1) - mudela_voice_p_list_.top()->output (mudela_stream_r); + if (mudela_voice_p_list_.size_i () == 1) + mudela_voice_p_list_.head_->car_->output (mudela_stream_r); else - for (PCursor i (mudela_voice_p_list_); i.ok(); i++) + for (Cons* i = mudela_voice_p_list_.head_; i; i = i->next_) { mudela_stream_r << "{ "; - i->output (mudela_stream_r); + i->car_->output (mudela_stream_r); mudela_stream_r << "} "; } - mudela_stream_r << (mudela_voice_p_list_.size() > 1 ? "\n>" : "\n}"); - mudela_stream_r << " % " << name_str() << '\n'; + mudela_stream_r << (mudela_voice_p_list_.size_i () > 1 ? "\n>" : "\n}"); + mudela_stream_r << " % " << name_str () << '\n'; } void Mudela_staff::output_mudela_begin_bar (Mudela_stream& mudela_stream_r, Moment now_mom, int bar_i) { - Moment bar_mom = mudela_time_signature_l_->bar_mom(); + Moment bar_mom = mudela_time_signature_l_->bar_mom (); Moment into_bar_mom = now_mom - Moment (bar_i - 1) * bar_mom; - if (bar_i > 1) + if (bar_i > 1) { - if (!into_bar_mom) + if (!into_bar_mom) mudela_stream_r << "|\n"; } mudela_stream_r << "% " << String_convert::i2dec_str (bar_i, 0, ' '); - if (into_bar_mom) + if (into_bar_mom) mudela_stream_r << ":" << Duration_convert::dur2_str (Duration_convert::mom2_dur (into_bar_mom)); mudela_stream_r << '\n'; } @@ -144,13 +148,13 @@ Mudela_staff::output_mudela_begin_bar (Mudela_stream& mudela_stream_r, Moment no void Mudela_staff::output_mudela_rest (Mudela_stream& mudela_stream_r, Moment begin_mom, Moment end_mom) { - Moment bar_mom = mudela_time_signature_l_->bar_mom(); + Moment bar_mom = mudela_time_signature_l_->bar_mom (); Moment 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) + if (end_bar_i == begin_bar_i) { output_mudela_rest_remain (mudela_stream_r, end_mom - begin_mom); return; @@ -161,14 +165,14 @@ Mudela_staff::output_mudela_rest (Mudela_stream& mudela_stream_r, Moment begin_m //fill current bar Moment begin_bar_mom = Moment (begin_bar_i - 1) * bar_mom; - if (now_mom > begin_bar_mom) + if (now_mom > begin_bar_mom) { int next_bar_i = (int) (now_mom / bar_mom) + 2; Moment next_bar_mom = Moment (next_bar_i - 1) * bar_mom; assert (next_bar_mom <= end_mom); Moment remain_mom = next_bar_mom - now_mom; - if (remain_mom > Moment (0)) + if (remain_mom > Moment (0)) { output_mudela_rest_remain (mudela_stream_r, remain_mom); now_mom += remain_mom; @@ -179,28 +183,28 @@ Mudela_staff::output_mudela_rest (Mudela_stream& mudela_stream_r, Moment begin_m // fill whole bars int count_i = end_bar_i - bar_i; - for (int i = 0; i < count_i; 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) + if (begin_bar_i) output_mudela_begin_bar (mudela_stream_r, now_mom, begin_bar_i); mudela_stream_r << "r1 "; // *mudela_stream_r.os_p_ << flush; - if (begin_bar_i) - LOGOUT(NORMAL_ver) << begin_bar_i << 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) + if (ii) output_mudela_begin_bar (mudela_stream_r, now_mom, ii); // bar_i = check_end_bar_i (now_mom, bar_i); Moment remain_mom = end_mom - Moment (end_bar_i - 1) * bar_mom; - if (remain_mom > Moment (0)) + if (remain_mom > Moment (0)) { output_mudela_rest_remain (mudela_stream_r, remain_mom); now_mom += remain_mom; @@ -211,24 +215,24 @@ Mudela_staff::output_mudela_rest (Mudela_stream& mudela_stream_r, Moment begin_m void Mudela_staff::output_mudela_rest_remain (Mudela_stream& mudela_stream_r, Moment mom) { - if (Duration_convert::no_quantify_b_s) + if (Duration_convert::no_quantify_b_s) { Duration dur = Duration_convert::mom2_dur (mom); - mudela_stream_r << "r" << dur.str() << " "; - // assert (mom == dur.mom()); - assert (mom == dur.length()); + mudela_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) - mudela_stream_r << "r" << dur.str() << " "; + if (dur.type_i_>-10) + mudela_stream_r << "r" << dur.str () << " "; } #endif void -Mudela_staff::process() +Mudela_staff::process () { /* group items into voices @@ -239,10 +243,10 @@ Mudela_staff::process() mudela_time_signature_l_ = mudela_score_l_g->mudela_time_signature_l_; mudela_tempo_l_ = mudela_score_l_g->mudela_tempo_l_; - Link_list items; - for (PCursor i (mudela_item_p_list_); i.ok(); i++) - items.bottom().add (*i); + Cons_list items; + for (Cons* i = mudela_item_p_list_.head_; i; i = i->next_) + items.append (new Cons (i->car_, 0)); - while (items.size()) + while (items.size_i ()) eat_voice (items); } diff --git a/mi2mu/mudela-voice.cc b/mi2mu/mudela-voice.cc index 6f92d03f22..1052b3149d 100644 --- a/mi2mu/mudela-voice.cc +++ b/mi2mu/mudela-voice.cc @@ -19,59 +19,46 @@ Mudela_voice::Mudela_voice (Mudela_staff* mudela_staff_l) void Mudela_voice::add_item (Mudela_item* mudela_item_l) { - mudela_item_l_list_.bottom().add (mudela_item_l); + mudela_item_l_list_.append (new Cons (mudela_item_l, 0)); } -Moment -Mudela_voice::begin_mom() -{ - return mudela_item_l_list_.size() ? - mudela_item_l_list_.top()->at_mom() : Moment (0); -} - -Moment -Mudela_voice::end_mom() -{ - return mudela_item_l_list_.size() ? - mudela_item_l_list_.bottom()->at_mom() : Moment (0); -} static int const FAIRLY_LONG_VOICE_i = 6; void Mudela_voice::output (Mudela_stream& mudela_stream_r) { - if (!mudela_item_l_list_.size()) + if (!mudela_item_l_list_.size_i ()) return; - if (mudela_item_l_list_.size() > FAIRLY_LONG_VOICE_i) + if (mudela_item_l_list_.size_i () > FAIRLY_LONG_VOICE_i) mudela_stream_r << '\n'; int current_bar_i = 0; - Moment bar_mom = mudela_staff_l_->mudela_time_signature_l_->bar_mom(); + Moment bar_mom = mudela_staff_l_->mudela_time_signature_l_->bar_mom (); - for (PCursor i (mudela_item_l_list_); i.ok(); i++) + for (Cons* i = mudela_item_l_list_.head_; i; i = i->next_) { - Moment at_mom = i->mudela_column_l_->at_mom(); + Moment at_mom = i->car_->mudela_column_l_->at_mom (); int bar_i = (int) (at_mom / bar_mom) + 1; - if (bar_i > current_bar_i) + if (bar_i > current_bar_i) { - if (current_bar_i) + if (current_bar_i) { - if (at_mom == Moment (bar_i - 1) * bar_mom) + if (at_mom == Moment (bar_i - 1) * bar_mom) mudela_stream_r << "|"; mudela_stream_r << "\n% "; mudela_stream_r << String_convert::i2dec_str (bar_i, 0, ' '); mudela_stream_r << '\n'; } - LOGOUT(NORMAL_ver) << "[" << bar_i << "]" << flush; + LOGOUT (NORMAL_ver) << "[" << bar_i << "]" << flush; current_bar_i = bar_i; } - mudela_stream_r << **i; + mudela_stream_r << *i->car_; } - if (mudela_item_l_list_.size() > FAIRLY_LONG_VOICE_i) + if (mudela_item_l_list_.size_i () > FAIRLY_LONG_VOICE_i) mudela_stream_r << '\n'; } diff --git a/mi2mu/template9.cc b/mi2mu/template9.cc deleted file mode 100644 index 7d99a4b920..0000000000 --- a/mi2mu/template9.cc +++ /dev/null @@ -1,32 +0,0 @@ -// -// template.cc -- implementemplate -// ugh: must have unique name for Cygnus' gcc: -// liblily.a(template.o): In function `GLOBAL_$I$template.cc': -// template.cc:28: multiple definition of `global constructors keyed to template.cc' -// -// copyright 1997 Jan Nieuwenhuizen - -#include "proto.hh" -#include "list.hh" -#include "list.tcc" -#include "cursor.tcc" - -class istream; -class ostream; - -#include "mudela-item.hh" -#include "mudela-column.hh" -#include "mudela-staff.hh" -#include "mudela-voice.hh" -#include "mudela-staff.hh" -#include "mudela-score.hh" -#include "pcursor.hh" -#include "plist.hh" -#include "pcursor.tcc" -#include "plist.tcc" - -POINTERLIST_INSTANTIATE(Mudela_item); -POINTERLIST_INSTANTIATE(Mudela_staff); -POINTERLIST_INSTANTIATE(Mudela_voice); -POINTERLIST_INSTANTIATE(Mudela_column); -POINTERLIST_INSTANTIATE(Mudela_score);