-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
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.
#define CONS_HH
+#include <assert.h>
+
template<class T>
class Cons
{
return knip;
}
+template<class T> int cons_list_size_i (Cons<T> *l)
+{
+ int i=0;
+ while (l)
+ {
+ l = l->next_;
+ i++;
+ }
+ return i;
+}
+
+
+
+
+
+template<class T>
+Cons<T> * last_cons (Cons<T> * head)
+{
+ while (head->next_)
+ {
+ head = head->next_;
+ }
+ return head;
+}
+
/**
Invariants:
{
public:
Cons<T> * head_;
- Cons<T> ** tail_;
- Cons_list () { init_list (); }
- void init_list () {head_ =0; tail_ = &head_; }
+ Cons<T> ** nil_pointer_address_;
+ Cons_list ()
+ {
+ init ();
+ }
+ void init ()
+ {
+ head_ =0;
+ nil_pointer_address_ = &head_;
+ }
void append (Cons<T> *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
*/
Cons<T> *remove_cons (Cons<T> **pp)
{
- if (&(*pp)->next_ == tail_)
- tail_ = pp;
+ if (&(*pp)->next_ == nil_pointer_address_)
+ nil_pointer_address_ = pp;
return ::remove_cons (pp);
}
delete head_;
head_ =0;
}
- ~Cons_list () { junk (); }
+ ~Cons_list ()
+ {
+ junk ();
+ }
+ int size_i ()
+ {
+ return cons_list_size_i (head_);
+ }
};
void
clone_killing_cons_list (Cons_list<T>&, Cons<T> *src);
-template<class T> int cons_list_size_i (Cons<T> *l)
-{
- int i=0;
- while (l)
- {
- l = l->next_;
- i++;
- }
- return i;
-}
-
-
-
-
#endif /* CONS_HH */
public:
VIRTUAL_COPY_CONS(Score_element);
Drul_array<Array<Column_rod> > minimal_dists_arr_drul_;
-
+ Drul_array<Array<Column_spring> > spring_arr_drul_;
void preprocess ();
/// set a minimum distance
void add_rod (Paper_column * to, Real distance);
void print () const;
};
+
struct Rod
{
Drul_array <Item*> item_l_drul_;
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 */
--- /dev/null
+/*
+ spacing-spanner.hh -- declare Spacing_spanner
+
+ source file of the GNU LilyPond music typesetter
+
+ (c) 1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+
+ */
+
+#ifndef SPACING_SPANNER_HH
+#define SPACING_SPANNER_HH
+
+class Spacing_spanner : public Spanner
+{
+ Link_array<Paper_column> cols_;
+
+ Spacing_spanner ();
+protected:
+ virtual void do_space_processing ();
+};
+
+#endif /* SPACING_SPANNER_HH */
+
Music_list::Music_list (Music_list const &s)
: Cons_list<Music> (s)
{
- init_list ();
+ Cons_list<Music>::init ();
clone_killing_cons_list (*this, s.head_);
}
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();
+}
#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"
Moment at_mom_;
Byte running_byte_;
- Link_list<Mudela_note*> open_note_l_list_;
+ Cons_list<Mudela_note> open_note_l_list_;
Mudela_staff* mudela_staff_p_;
Midi_parser_info* track_info_p_;
};
#include "proto.hh"
#include "mi2mu-proto.hh"
#include "moment.hh"
-#include "plist.hh"
+#include "cons.hh"
/// (mudela_column)
class Mudela_column
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*> mudela_item_l_list_;
+ Cons_list<Mudela_item> mudela_item_l_list_;
Moment at_mom_;
Mudela_score* mudela_score_l_;
};
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
#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*> mudela_staff_p_list_;
- // wants Pointer_array!
-// Pointer_list<Mudela_column*> mudela_column_p_list_;
- Link_array<Mudela_column> column_l_array_;
+ Cons_list<Mudela_staff> mudela_staff_p_list_;
+ Link_array<Mudela_column> 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
#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<Mudela_item*>& items);
- String id_str();
- String name_str();
+ void eat_voice (Cons_list<Mudela_item>& items);
+ String id_str ();
+ String name_str ();
void output (Mudela_stream& mudela_stream_r);
- void process();
+ void process ();
String copyright_str_;
String instrument_str_;
private:
void output_mudela_begin_bar (Mudela_stream& mudela_stream_r, Moment now_mom, int bar_i);
- Pointer_list<Mudela_voice*> mudela_voice_p_list_;
- Pointer_list<Mudela_item*> mudela_item_p_list_;
+ Cons_list<Mudela_voice> mudela_voice_p_list_;
+ Cons_list<Mudela_item> mudela_item_p_list_;
};
#endif // MUDELA_STAFF_HH
#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*> mudela_item_l_list_;
+ Mudela_staff* mudela_staff_l_;
+ Cons_list<Mudela_item> mudela_item_l_list_;
};
#endif // MUDELA_VOICE_HH
assert (col_l);
- for (PCursor<Mudela_note*> i (open_note_l_list_.top ()); i.ok (); )
+ for (Cons<Mudela_note>** pp = &open_note_l_list_.head_; *pp;)
{
- if ((i->pitch_i_ == pitch_i) && (i->channel_i_ == channel_i))
+ Cons<Mudela_note>* 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));
{
// find
assert (col_l);
- for (PCursor<Mudela_note*> i (open_note_l_list_.top ()); i.ok (); )
+ for (Cons<Mudela_note>* 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*
{
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<Mudela_note> (p, 0));
}
else
{
note_end (col_l, channel_i, pitch_i, dyn_i);
}
}
+
// POLYPHONIC_AFTERTOUCH [\xa0-\xaf]
else if ((byte >= 0xa0) && (byte <= 0xaf))
{
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> (mudela_item_l, 0));
}
Moment
#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);
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;
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> (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;
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);
}
assert (0);
return 0;
-#endif
}
Mudela_column*
{
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];
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<Mudela_staff*> i (mudela_staff_p_list_); i.ok(); i++)
+ for (Cons<Mudela_staff>* 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<Mudela_staff*> i (mudela_staff_p_list_); i.ok(); i++)
+ for (Cons<Mudela_staff>* 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<Mudela_column*> 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<Mudela_staff*> i (mudela_staff_p_list_); i.ok(); i++)
+ for (Cons<Mudela_staff>* 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<Mudela_column*> 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;
#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)
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> (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<Mudela_item*>& items)
+Mudela_staff::eat_voice (Cons_list<Mudela_item>& 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<Mudela_voice> (voice_p, 0));
- // Moment mom = items.top()->at_mom();
+ // Moment mom = items.top ()->at_mom ();
Moment mom = 0;
- for (PCursor<Mudela_item*> i (items); i.ok();)
+ for (Cons<Mudela_item>** 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<Mudela_item>* 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<Mudela_item>* 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))
}
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_));
}
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<Mudela_voice*> i (mudela_voice_p_list_); i.ok(); i++)
+ for (Cons<Mudela_voice>* 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';
}
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;
//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;
// 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;
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
mudela_time_signature_l_ = mudela_score_l_g->mudela_time_signature_l_;
mudela_tempo_l_ = mudela_score_l_g->mudela_tempo_l_;
- Link_list<Mudela_item*> items;
- for (PCursor<Mudela_item*> i (mudela_item_p_list_); i.ok(); i++)
- items.bottom().add (*i);
+ Cons_list<Mudela_item> items;
+ for (Cons<Mudela_item>* i = mudela_item_p_list_.head_; i; i = i->next_)
+ items.append (new Cons<Mudela_item> (i->car_, 0));
- while (items.size())
+ while (items.size_i ())
eat_voice (items);
}
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> (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<Mudela_item*> i (mudela_item_l_list_); i.ok(); i++)
+ for (Cons<Mudela_item>* 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';
}
+++ /dev/null
-//
-// 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 <janneke@gnu.org>
-
-#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);