X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mi2mu%2Fmudela-score.cc;h=b7e234b97de91e9074f8aa6501fde1d16edad9a6;hb=fd67592c6acb9b8e9ac10135d688b3f4938ac0b1;hp=5b951dac39e8478efceec89703c960b7f8f7c7a3;hpb=2862b1027f316a2f0444fa92e441ee28acf7a463;p=lilypond.git diff --git a/mi2mu/mudela-score.cc b/mi2mu/mudela-score.cc index 5b951dac39..b7e234b97d 100644 --- a/mi2mu/mudela-score.cc +++ b/mi2mu/mudela-score.cc @@ -1,7 +1,7 @@ // // mudela-score.cc -- implement Mudela_score // -// copyright 1997 Jan Nieuwenhuizen +// copyright 1997 Jan Nieuwenhuizen #include #include "moment.hh" @@ -14,8 +14,12 @@ #include "mudela-staff.hh" #include "mudela-stream.hh" +// ugh, cygnus' b19 gcc +#include "list.tcc" +#include "cursor.tcc" + //static Mudela_key key_c (0, 0); -static Mudela_meter meter_4 (4, 2, 24, 8); +static Mudela_time_signature time_sig_4 (4, 2, 24, 8); // useconds per 4: 250000 === 60 4 per minute static Mudela_tempo tempo_60 (1000000); @@ -27,7 +31,7 @@ Mudela_score::Mudela_score (int format_i, int tracks_i, int tempo_i) column_l_array_.push (new Mudela_column (this, Moment (0))); // mudela_key_l_ = &key_c; mudela_key_l_ = 0; - mudela_meter_l_ = &meter_4; + mudela_time_signature_l_ = &time_sig_4; mudela_tempo_l_ = &tempo_60; } @@ -35,7 +39,7 @@ Mudela_score::~Mudela_score() { } -void +void Mudela_score::add_item (Mudela_item* mudela_item_p) { mudela_staff_p_list_.bottom()->add_item (mudela_item_p); @@ -60,7 +64,7 @@ Mudela_score::find_column_l (Moment mom) int upper_i = max (0, column_l_array_.size () - 1); int lower_i = 0; int i = 0; //upper_i; - while (1) + while (1) { Moment i_mom = column_l_array_ [i]->at_mom (); if (i_mom == mom) @@ -69,7 +73,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); @@ -87,47 +91,55 @@ Mudela_score::find_column_l (Moment mom) Mudela_column* Mudela_score::get_column_l (Moment mom) { - if ( column_l_array_ [column_l_array_.size() - 1]->at_mom () > mom ) + int i; + Mudela_column *c=0; + for (i=column_l_array_.size() - 1; !c && i >=0; i--) + { + if (column_l_array_ [i]->at_mom () == mom ) + c = column_l_array_[i]; + else if (column_l_array_[i]->at_mom () < mom) + break; + } + if (!c) { - error ("ugh"); - exit (1); + c = new Mudela_column (this, mom); + column_l_array_.insert (c, i+1); } - if ( column_l_array_[column_l_array_.size() - 1]->at_mom () < mom ) - column_l_array_.push (new Mudela_column (this, mom)); - return column_l_array_ [column_l_array_.size() - 1]; + assert (c->at_mom () == mom); + return c; } + void Mudela_score::output (String filename_str) { - LOGOUT(NORMAL_ver) << "Lily output to " << 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; int track_i = 0; Mudela_stream mudela_stream (filename_str); - for (PCursor i (mudela_staff_p_list_); i.ok(); i++) + for (PCursor i (mudela_staff_p_list_); i.ok(); i++) { - LOGOUT(NORMAL_ver) << "track " << track_i++ << ": " << flush; + LOGOUT(NORMAL_ver) << _ ("track ") << track_i++ << ": " << flush; i->output (mudela_stream); - mudela_stream << "\n"; + mudela_stream << '\n'; LOGOUT(NORMAL_ver) << endl; } mudela_stream << "\\score{\n"; if (mudela_staff_p_list_.size() > 1) - mudela_stream << "<\n\\multi 3;\n"; - for (PCursor i (mudela_staff_p_list_); i.ok(); i++) + mudela_stream << "< \n"; + for (PCursor i (mudela_staff_p_list_); i.ok(); i++) { - if ( (mudela_staff_p_list_.size() != 1) + if ( (mudela_staff_p_list_.size() != 1) && (i == mudela_staff_p_list_.top())) continue; - mudela_stream << "\\melodic{ "; - mudela_stream << "\\$" << i->id_str(); - mudela_stream << " }\n"; + mudela_stream << "\\type Staff = \"" << i->id_str() << "\" "; + mudela_stream << String ("\\" + i->id_str ()) << "\n"; } if (mudela_staff_p_list_.size() > 1) mudela_stream << ">\n"; @@ -136,7 +148,7 @@ Mudela_score::output (String filename_str) mudela_stream << "\\midi{\n"; // let's not use silly 0 track - mudela_staff_p_list_.bottom()->mudela_tempo_p_->output (mudela_stream); + mudela_staff_p_list_.bottom()->mudela_tempo_l_->output (mudela_stream); mudela_stream << "}\n"; mudela_stream << "}\n"; @@ -145,22 +157,22 @@ Mudela_score::output (String filename_str) void Mudela_score::process() { - LOGOUT(NORMAL_ver) << "\nProcessing..." << endl; - + 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"; + // LOGOUT(DEBUG_ver) << "At: " << i->at_mom() << '\n'; settle_columns(); filter_tempo(); quantify_columns(); quantify_durations(); - LOGOUT(NORMAL_ver) << "\nCreating voices..." << endl; + LOGOUT(NORMAL_ver) << '\n' << _ ("Creating voices...") << endl; int track_i = 0; - for (PCursor i (mudela_staff_p_list_); i.ok(); i++) + for (PCursor i (mudela_staff_p_list_); i.ok(); i++) { - LOGOUT(NORMAL_ver) << "track " << track_i++ << ": " << flush; + LOGOUT(NORMAL_ver) << _ ("track ") << track_i++ << ": " << flush; i->process(); LOGOUT(NORMAL_ver) << endl; } @@ -169,37 +181,37 @@ Mudela_score::process() void Mudela_score::filter_tempo() { - LOGOUT(NORMAL_ver) << "\nNOT Filtering tempo..." << endl; + LOGOUT(NORMAL_ver) << '\n' << _ ("NOT Filtering tempo...") << endl; } void Mudela_score::quantify_columns() { // ugh - if (Duration_convert::no_quantify_b_s) + if (Duration_convert::no_quantify_b_s) { - LOGOUT(NORMAL_ver) << "\nNOT Quantifying columns..." << endl; + LOGOUT(NORMAL_ver) << '\n' << _("NOT Quantifying columns...") << endl; return; } - LOGOUT(NORMAL_ver) << "\nQuantifying columns..." << endl; + LOGOUT(NORMAL_ver) << '\n' << _("Quantifying columns...") << endl; int current_bar_i = 0; - Moment bar_mom = mudela_meter_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)); int bar_i = (int) (column_l_array_ [i]->at_mom () / bar_mom) + 1; - if (bar_i > current_bar_i) + if (bar_i > current_bar_i) { - LOGOUT (NORMAL_ver) << '[' << bar_i << ']' << flush; + LOGOUT (NORMAL_ver) << "[" << bar_i << "]" << flush; current_bar_i = bar_i; } } @@ -209,15 +221,15 @@ Mudela_score::quantify_columns() void Mudela_score::quantify_durations() { - // LOGOUT(NORMAL_ver) << "\nQuantifying durations..." << endl; + // LOGOUT(NORMAL_ver) << '\n' << "Quantifying durations..." << endl; } void Mudela_score::settle_columns() { - // LOGOUT(NORMAL_ver) << "\nNOT Settling columns..." << endl; + // LOGOUT(NORMAL_ver) << '\n' << "NOT Settling columns..." << endl; // return; - LOGOUT(NORMAL_ver) << "\nSettling columns..." << endl; + LOGOUT(NORMAL_ver) << '\n' << _("Settling columns...") << endl; #if 0 assert (!column_l_array_.size()); @@ -237,9 +249,9 @@ Mudela_score::settle_columns() 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();