From: fred Date: Sun, 24 Mar 2002 20:12:42 +0000 (+0000) Subject: lilypond-1.0.1 X-Git-Tag: release/1.5.59~3044 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6ab9e024bf46ae02d2038de215ba220ec660a071;p=lilypond.git lilypond-1.0.1 --- diff --git a/lily/command-request.cc b/lily/command-request.cc index 5cc36319bf..24f2fee50b 100644 --- a/lily/command-request.cc +++ b/lily/command-request.cc @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--1998 Han-Wen Nienhuys */ #include "command-request.hh" @@ -32,7 +32,7 @@ Cadenza_req::do_print() const bool Cadenza_req::do_equal_b (Request*r) const { - Cadenza_req*cad = r->command()->timing ()->cadenza (); + Cadenza_req*cad = r->access_Command_req ()->access_Timing_req ()->access_Cadenza_req (); return cad->on_b_ == on_b_; } @@ -41,13 +41,13 @@ Cadenza_req::Cadenza_req (bool b) { on_b_ =b; } -/* *************** */ + bool Bar_req::do_equal_b (Request*r) const { - Bar_req * b = r->command()->bar (); + Bar_req * b = r->access_Command_req ()->access_Bar_req (); return type_str_ == b->type_str_; } @@ -73,7 +73,7 @@ Partial_measure_req::Partial_measure_req (Moment m) bool Partial_measure_req::do_equal_b (Request* r) const { - Partial_measure_req *p = r->command()->timing ()->partial (); + Partial_measure_req *p = r->access_Command_req ()->access_Timing_req ()->access_Partial_measure_req (); return p->duration_ == duration_; } @@ -100,7 +100,7 @@ Barcheck_req::do_equal_b (Request*) const { return true; } -/* *************** */ + IMPLEMENT_IS_TYPE_B1(Clef_change_req,Command_req); @@ -117,7 +117,7 @@ Clef_change_req::Clef_change_req (String s) clef_str_ = s; } -/* *************** */ + IMPLEMENT_IS_TYPE_B1(Partial_measure_req,Timing_req); @@ -129,10 +129,10 @@ Partial_measure_req::do_print() const } -IMPLEMENT_IS_TYPE_B1(Meter_change_req,Timing_req); +IMPLEMENT_IS_TYPE_B1(Time_signature_change_req,Timing_req); void -Meter_change_req::do_print() const +Time_signature_change_req::do_print() const { #ifndef NPRINT DOUT << beats_i_ << "/" << one_beat_i_; @@ -140,27 +140,20 @@ Meter_change_req::do_print() const } bool -Meter_change_req::do_equal_b (Request * r) const +Time_signature_change_req::do_equal_b (Request * r) const { - Meter_change_req * m = r->command()->timing ()->meterchange (); + Time_signature_change_req * m = r->access_Command_req ()->access_Timing_req ()->access_Time_signature_change_req (); return m->beats_i_ == beats_i_ && one_beat_i_ == m->one_beat_i_; } -Meter_change_req::Meter_change_req() +Time_signature_change_req::Time_signature_change_req() { beats_i_ = 0; one_beat_i_ =0; } -void -Meter_change_req::set (int b,int o) -{ - beats_i_=b; - one_beat_i_=o; -} - Tempo_req::Tempo_req() { @@ -171,19 +164,19 @@ Tempo_req::Tempo_req() void Tempo_req::do_print() const { - DOUT << dur_.str() << " = " < 0) + pitch_arr_[0].transpose(d); + else + { + warning(_ ("don't know how handle empty keys")); // TODO + } + } + else + { + Array old_pitch_arr_; + for (int i = 0; i < pitch_arr_.size(); i++) + { + old_pitch_arr_.push(pitch_arr_[i]); + } + // set accidentals for \key d (as in Key_engraver::read_req) + // (later called "new accidentals") + int p = d.semitone_pitch (); + /* Solve the equation 7*no_of_acc mod 12 = p, -6 <= no_of_acc <= 5 */ + int no_of_acc = (7*p) % 12; + no_of_acc = (no_of_acc + 18) % 12 -6; + + /* Correct from flats to sharps or vice versa */ + if (no_of_acc * d.accidental_i_ < 0) + no_of_acc += 12 * sign (d.accidental_i_); + + pitch_arr_.clear (); + if (no_of_acc < 0) + { + int accidental = 6 ; // First accidental: bes + for ( ; no_of_acc < 0 ; no_of_acc++ ) + { + Musical_pitch m; + m.accidental_i_ = -1; + m.notename_i_ = accidental; + pitch_arr_.push(m); + + accidental = (accidental + 3) % 7 ; + } + } + else + { + int accidental = 3 ; // First accidental: fis + for ( ; no_of_acc > 0 ; no_of_acc-- ) + { + Musical_pitch m; + m.accidental_i_ = 1; + m.notename_i_ = accidental; + pitch_arr_.push(m); + + accidental = (accidental + 4) % 7 ; + } + } + // Check if transposed old accidentals and the new ones coincide + no_of_acc = pitch_arr_.size(); + int acc_found; + Musical_pitch mm; + for (int i=0; i < old_pitch_arr_.size(); i++) + { + acc_found = 0; + mm = old_pitch_arr_[i]; + mm.transpose(d); + for (int j=0; ((j < no_of_acc) && (acc_found == 0)); j++) + { + if (pitch_arr_[j].notename_i_ == mm.notename_i_) + { + if (mm.accidental_i_ == 0) + { + // remove new accidental + pitch_arr_.del(j); + no_of_acc--; + acc_found = 1; + } + else + { + // change new accidental + pitch_arr_[j].accidental_i_ = mm.accidental_i_; + acc_found = 1; + } + } + } + if (acc_found == 0) + { + // add transposed old accidental + pitch_arr_.push(mm); + } + } + } } - IMPLEMENT_IS_TYPE_B1(Key_change_req,Command_req); void Key_change_req::squash_octaves() @@ -237,7 +315,7 @@ Key_change_req::do_print() const Key_change_req::Key_change_req() { minor_b_ = false; - multi_octave_b_= false; + ordinary_key_b_= false; } IMPLEMENT_IS_TYPE_B1(Break_req, Command_req); @@ -252,6 +330,19 @@ Break_req::do_print () const { } +IMPLEMENT_IS_TYPE_B1 (Mark_req, Command_req); + +Mark_req::Mark_req (String s) +{ + str_ = s; +} + +void +Mark_req::do_print () const +{ + DOUT << str_; +} + int Key_change_req::flats_i() { @@ -264,8 +355,8 @@ Key_change_req::flats_i() return flats_i; } -int -Key_change_req::minor_b() +bool +Key_change_req::minor_b() const { return minor_b_; } @@ -276,7 +367,7 @@ Key_change_req::sharps_i() int sharps_i = 0; for (int i = 0; i < pitch_arr_.size(); i++) { - if (pitch_arr_[i].accidental_i_ < 0) + if (pitch_arr_[i].accidental_i_ > 0) sharps_i += pitch_arr_[i].accidental_i_; } return sharps_i; diff --git a/lily/include/command-request.hh b/lily/include/command-request.hh index 8085fd6621..3e187487f3 100644 --- a/lily/include/command-request.hh +++ b/lily/include/command-request.hh @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--1998 Han-Wen Nienhuys */ @@ -11,7 +11,7 @@ #define COMMANDREQUEST_HH #include "request.hh" -#include "varray.hh" +#include "array.hh" #include "duration.hh" #include "musical-pitch.hh" @@ -19,17 +19,19 @@ musical requests. */ class Command_req : public virtual Request { public: - REQUESTMETHODS(Command_req, command); - virtual Measure_grouping_req * measuregrouping() { return 0; } - virtual Clef_change_req * clefchange() { return 0; } - virtual Key_change_req * keychange() { return 0; } - virtual Partial_measure_req * partial() { return 0; } - virtual Meter_change_req * meterchange() { return 0; } - virtual Bar_req *bar() { return 0; } - virtual Cadenza_req *cadenza() { return 0; } - virtual Timing_req*timing() { return 0; } - virtual Command_script_req*commandscript() { return 0;} - virtual Break_req *linebreak () { return 0; } + REQUESTMETHODS(Command_req); + + DEFAULTACCESSOR(Measure_grouping_req) + DEFAULTACCESSOR(Clef_change_req) + DEFAULTACCESSOR(Key_change_req) + DEFAULTACCESSOR(Partial_measure_req) + DEFAULTACCESSOR(Time_signature_change_req) + DEFAULTACCESSOR(Bar_req) + DEFAULTACCESSOR(Cadenza_req) + DEFAULTACCESSOR(Timing_req) + DEFAULTACCESSOR(Command_script_req) + DEFAULTACCESSOR(Break_req) + DEFAULTACCESSOR(Mark_req) }; @@ -38,7 +40,14 @@ public: enum { DISALLOW = -10000, FORCE = 10000 }; int penalty_i_; Break_req (); - REQUESTMETHODS (Break_req, linebreak); + REQUESTMETHODS (Break_req); +}; + +class Mark_req : public Command_req { +public: + Mark_req (String); + String str_; + REQUESTMETHODS (Mark_req); }; class Command_script_req : public Command_req, public Script_req { @@ -46,15 +55,15 @@ public: // huh? Command_script_req(); ~Command_script_req(); - REQUESTMETHODS(Command_script_req, commandscript); + REQUESTMETHODS(Command_script_req); }; -/** Baseclass for meter/partial req. It has to be handled by +/** Baseclass for time_signature/partial req. It has to be handled by Staff_{walker,column} baseclass. */ class Timing_req : public Command_req { public: - REQUESTMETHODS(Timing_req, timing); - virtual Tempo_req * tempo(){return 0; } + REQUESTMETHODS(Timing_req); + DEFAULTACCESSOR(Tempo_req) }; @@ -65,7 +74,7 @@ public: int metronome_i_; Tempo_req(); - REQUESTMETHODS(Tempo_req, tempo); + REQUESTMETHODS(Tempo_req); bool do_equal_b (Request *) const; }; @@ -74,21 +83,20 @@ public: Moment duration_; Partial_measure_req (Moment); - REQUESTMETHODS(Partial_measure_req, partial); + REQUESTMETHODS(Partial_measure_req); bool do_equal_b (Request*) const; }; /** - todo: allow C meter + todo: allow C time_signature */ -class Meter_change_req : public Timing_req { +class Time_signature_change_req : public Timing_req { public: int beats_i_, one_beat_i_; - Meter_change_req(); - void set (int,int); + Time_signature_change_req(); bool do_equal_b (Request*) const; - REQUESTMETHODS(Meter_change_req, meterchange); + REQUESTMETHODS(Time_signature_change_req); }; /// toggle Cadenza mode @@ -98,14 +106,14 @@ public: bool on_b_; bool do_equal_b (Request*) const; Cadenza_req (bool); - REQUESTMETHODS(Cadenza_req,cadenza); + REQUESTMETHODS(Cadenza_req); }; /// check if we're at start of a measure. class Barcheck_req : public Timing_req { public: bool do_equal_b (Request *) const; - REQUESTMETHODS(Barcheck_req,barcheck); + REQUESTMETHODS(Barcheck_req); }; class Measure_grouping_req : public Timing_req { @@ -113,7 +121,7 @@ public: Array beat_i_arr_; Array elt_length_arr_; bool do_equal_b (Request *) const; - REQUESTMETHODS(Measure_grouping_req, measuregrouping); + REQUESTMETHODS(Measure_grouping_req); }; /** draw a (repeat)-bar. This something different than #Barcheck_req#, @@ -124,7 +132,7 @@ public: Bar_req (String); bool do_equal_b (Request*) const; - REQUESTMETHODS(Bar_req,bar); + REQUESTMETHODS(Bar_req); }; @@ -137,11 +145,10 @@ class Key_change_req : public Command_req { public: Array pitch_arr_; bool minor_b_; + bool ordinary_key_b_; - /// don't ignore the octaves in #melodic_p_arr_#? - bool multi_octave_b_; Key_change_req(); - REQUESTMETHODS(Key_change_req, keychange); + REQUESTMETHODS(Key_change_req); /// squash the octaves to 1 void squash_octaves(); @@ -151,16 +158,16 @@ public: /// return number of sharps in key int sharps_i(); - void transpose (Musical_pitch d) const; + void transpose (Musical_pitch d); /// is minor key? - int minor_b(); + bool minor_b() const; }; class Clef_change_req : public Command_req { public: String clef_str_; Clef_change_req (String); - REQUESTMETHODS(Clef_change_req, clefchange); + REQUESTMETHODS(Clef_change_req); }; #endif // COMMANDREQUEST_HH diff --git a/lily/include/paper-def.hh b/lily/include/paper-def.hh index ea7b9d39e3..aa8973d8a8 100644 --- a/lily/include/paper-def.hh +++ b/lily/include/paper-def.hh @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1996, 1997--1998 Han-Wen Nienhuys + (c) 1996, 1997--1998 Han-Wen Nienhuys */ @@ -14,7 +14,7 @@ #include "real.hh" #include "moment.hh" -#include "varray.hh" +#include "array.hh" #include "interval.hh" #include "music-output-def.hh" @@ -36,7 +36,7 @@ */ class Paper_def : public Music_output_def { - Lookup *lookup_p_; + Assoc *lookup_p_assoc_p_; Scope* scope_p_; static int default_count_i_; @@ -52,7 +52,7 @@ public: Real get_var (String) const; void reinit (); Paper_def (); - void set (Lookup*); + void set_lookup (int, Lookup*); Paper_def (Paper_def const&); /// The distance between beams of multiplicity_i @@ -82,10 +82,10 @@ public: Real note_width () const; void print () const; - Lookup const * lookup_l (); // TODO naming + Lookup const * lookup_l (int sz) const; // TODO naming /** convert a duration to an idealspacing - influence using the geometric_ and parameters. + influence using the geometric_ and paratime_signatures. */ Real duration_to_dist (Moment, Real) const; Real geometric_spacing (Moment) const; diff --git a/lily/include/tex.hh b/lily/include/tex.hh index 43a35d2ad3..3d5cf308b3 100644 --- a/lily/include/tex.hh +++ b/lily/include/tex.hh @@ -3,7 +3,7 @@ source file of the LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--1998 Han-Wen Nienhuys */ @@ -12,10 +12,10 @@ #define TEX_HH #include "string.hh" -#include "boxes.hh" +#include "box.hh" #include "scalar.hh" -/** parameter substitution in TeX_strings. +/** paratime_signature substitution in TeX_strings. this function provides a simple macro mechanism: if source == "tex%bla%", then @@ -24,7 +24,7 @@ String substitute_args (String source, Array args); -/// parameter substitution in TeX_strings +/// paratime_signature substitution in TeX_strings String substitute_args (String source, Array args); diff --git a/lily/include/timing-translator.hh b/lily/include/timing-translator.hh index 1b2fe054ea..e62ee388f0 100644 --- a/lily/include/timing-translator.hh +++ b/lily/include/timing-translator.hh @@ -3,7 +3,7 @@ source file of the GNU LilyPond music typesetter - (c) 1997--1998 Han-Wen Nienhuys + (c) 1997--1998 Han-Wen Nienhuys */ @@ -19,7 +19,7 @@ class Timing_translator : public virtual Translator { public: TRANSLATOR_CLONE(Timing_translator); - Meter_change_req * meter_req_l () const; + Time_signature_change_req * time_signature_req_l () const; Timing_translator (); DECLARE_MY_RUNTIME_TYPEINFO; Time_description time_;