]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.0.1
authorfred <fred>
Sun, 24 Mar 2002 20:12:42 +0000 (20:12 +0000)
committerfred <fred>
Sun, 24 Mar 2002 20:12:42 +0000 (20:12 +0000)
lily/command-request.cc
lily/include/command-request.hh
lily/include/paper-def.hh
lily/include/tex.hh
lily/include/timing-translator.hh

index 5cc36319bf48aa426b045857f9232dc3405796bf..24f2fee50bdbf9bbabb8b829ecb0fdf63062e9fe 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 #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() << " = " <<metronome_i_ ;
+  DOUT << dur_.str() << " = " << metronome_i_;
 }
 IMPLEMENT_IS_TYPE_B1(Tempo_req, Timing_req);
 
 bool
 Tempo_req::do_equal_b (Request *r) const
 {
-  Tempo_req *t = r->command()->timing ()->tempo ();
+  Tempo_req *t = r->access_Command_req ()->access_Timing_req ()->access_Tempo_req ();
 
   return t->dur_.length()== dur_.length () && metronome_i_ == t->metronome_i_;
 }
 
-/* *************** */
+
 
 
 IMPLEMENT_IS_TYPE_B1(Measure_grouping_req,Timing_req);
@@ -193,7 +186,7 @@ Measure_grouping_req::do_print() const
 {
   for (int i=0; i < elt_length_arr_.size(); i++)
     {
-      DOUT << beat_i_arr_[i] <<"*" << elt_length_arr_[i]<<" ";
+      DOUT << beat_i_arr_[i] << "*" << elt_length_arr_[i].str () << " ";
     }
 }
 
@@ -204,15 +197,100 @@ Measure_grouping_req::do_equal_b (Request*) const
   return false;                // todo
 }
 
-/* *************** */
-
 void
-Key_change_req::transpose (Musical_pitch  d) const
+Key_change_req::transpose (Musical_pitch d) 
 {
-  WARN << _("don't know how to transpose a key. \n"); //  TODO!
+  if (ordinary_key_b_ ) 
+    { 
+      if (pitch_arr_.size () > 0) 
+        pitch_arr_[0].transpose(d);
+      else
+        {
+          warning(_ ("don't know how handle empty keys")); // TODO 
+        }
+    }
+  else
+    {
+      Array<Musical_pitch> 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;
index 8085fd6621ef2807603dbd0e6cd6faac9a289917..3e187487f3895eee0d4dd0c9dc4fadac1b2fa07f 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 
@@ -11,7 +11,7 @@
 #define COMMANDREQUEST_HH
 
 #include "request.hh"
-#include "varray.hh"
+#include "array.hh"
 #include "duration.hh"
 #include "musical-pitch.hh"
 
   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<int> beat_i_arr_;
   Array<Moment> 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<Musical_pitch> 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
index ea7b9d39e329421ae2e86b328c14e75386cc7d14..aa8973d8a8b7042a46763f260274b93716ef5b00 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c) 1996, 1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c) 1996, 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 
@@ -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<int, Lookup *> *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;
index 43a35d2ad34f2edda3d365677adcd49cf8d895e0..3d5cf308b357328c199d537ad9e510519ed27e69 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 
 #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<String> args);
 
-/// parameter substitution in TeX_strings
+/// paratime_signature substitution in TeX_strings
 String
 substitute_args (String source, Array<Scalar> args);
 
index 1b2fe054eaca9887c4a5ccfd98beb7d963bba7e9..e62ee388f038e37566d63507f2a804c2f944a3e9 100644 (file)
@@ -3,7 +3,7 @@
 
   source file of the GNU LilyPond music typesetter
 
-  (c)  1997--1998 Han-Wen Nienhuys <hanwen@stack.nl>
+  (c)  1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
 */
 
 
@@ -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_;