]> git.donarmstrong.com Git - lilypond.git/commitdiff
lilypond-1.3.108
authorfred <fred>
Wed, 27 Mar 2002 00:33:14 +0000 (00:33 +0000)
committerfred <fred>
Wed, 27 Mar 2002 00:33:14 +0000 (00:33 +0000)
lily/include/pitch.hh [new file with mode: 0644]
lily/parser.yy

diff --git a/lily/include/pitch.hh b/lily/include/pitch.hh
new file mode 100644 (file)
index 0000000..0ad1581
--- /dev/null
@@ -0,0 +1,83 @@
+/*   
+  pitch.hh -- declare Pitch
+  
+  source file of the GNU LilyPond music typesetter
+  
+  (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+  
+ */
+
+#ifndef MUSICAL_PITCH_HH
+#define MUSICAL_PITCH_HH
+
+#include "lily-proto.hh"
+#include "smobs.hh"
+
+/** A "tonal" pitch. This is a pitch as it figures in diatonal western
+   music (12 semitones in an octave), as opposed to a frequence in Hz
+   or a integer number of semitones.
+   
+*/
+class Pitch
+{
+public:                                // fixme
+  /*
+    TODO: use SCM -- (make private?)
+   */
+  
+  /// 0 is c, 6 is b
+  int notename_i_;
+  
+  /// 0 natural, 1 sharp, etc
+  int alteration_i_;
+
+  /// 0 is central c
+  int octave_i_;
+  /*
+    mutators, so JUNKME.
+   */
+  void transpose (Pitch);
+  void up_to (int);
+  void down_to (int);
+
+public:
+
+  int octave_i () const;
+  int notename_i () const;
+  int alteration_i () const;
+
+  /*
+    Pitch is lexicographically ordered by (octave, notename,
+    alteration).    
+   */
+  Pitch (int octave, int notename,int accidental);
+  Pitch ();
+
+  Pitch to_relative_octave (Pitch);
+
+  static int compare (Pitch const&,Pitch const&);
+  /// return large part of interval from central c
+  int steps() const;
+  /// return pitch from central c (in halfnotes)
+  int semitone_pitch() const; 
+  String str () const;
+
+  static SCM transpose (SCM p, SCM delta);
+
+  SCM smobbed_copy () const;
+  DECLARE_SCHEME_CALLBACK(less_p, (SCM a, SCM b));
+  DECLARE_SIMPLE_SMOBS(Pitch,);
+
+
+};
+
+Pitch* unsmob_pitch (SCM);
+
+#include "compare.hh"
+INSTANTIATE_COMPARE(Pitch, Pitch::compare);
+
+int compare (Array<Pitch>*, Array<Pitch>*);
+
+#endif /* MUSICAL_PITCH_HH */
+
+
index 8b1fd7b85bfed59f21aec298c040813d13047cb6..6f6b260081854f7136953215f49c5c6808a57c2c 100644 (file)
@@ -1180,12 +1180,12 @@ steno_musical_pitch:
                $$ = $1;
        }
        | NOTENAME_PITCH sup_quotes     {
-               Musical_pitch p = *unsmob_pitch ($1);
+               Pitch p = *unsmob_pitch ($1);
                p.octave_i_ +=  $2;
                $$ = p.smobbed_copy ();
        }
        | NOTENAME_PITCH sub_quotes      {
-               Musical_pitch p =* unsmob_pitch ($1);
+               Pitch p =* unsmob_pitch ($1);
 
                p.octave_i_ +=  -$2;
                $$ = p.smobbed_copy ();
@@ -1202,12 +1202,12 @@ steno_tonic_pitch:
                $$ = $1;
        }
        | TONICNAME_PITCH sup_quotes    {
-               Musical_pitch p = *unsmob_pitch ($1);
+               Pitch p = *unsmob_pitch ($1);
                p.octave_i_ +=  $2;
                $$ = p.smobbed_copy ();
        }
        | TONICNAME_PITCH sub_quotes     {
-               Musical_pitch p =* unsmob_pitch ($1);
+               Pitch p =* unsmob_pitch ($1);
 
                p.octave_i_ +=  -$2;
                $$ = p.smobbed_copy ();
@@ -1222,7 +1222,7 @@ musical_pitch:
        | MUSICAL_PITCH embedded_scm {
                if (!unsmob_pitch ($2))
                        THIS->parser_error (_f ("Expecting musical-pitch value", 3));
-                Musical_pitch m;
+                Pitch m;
                $$ = m.smobbed_copy ();
        }
        ;
@@ -1533,7 +1533,7 @@ FIXME
 
 chord:
        steno_tonic_pitch optional_notemode_duration chord_additions chord_subtractions chord_inversion chord_bass {
-                $$ = get_chord ($1, $3, $4, $5, $6, $2);
+                $$ = Chord::get_chord ($1, $3, $4, $5, $6, $2);
                $$->set_spot (THIS->here_input ());
         };
 
@@ -1597,7 +1597,7 @@ chord_step:
 
 chord_note:
        bare_unsigned {
-                Musical_pitch m;
+                Pitch m;
                m.notename_i_ = ($1 - 1) % 7;
                m.octave_i_ = $1 > 7 ? 1 : 0;
                m.alteration_i_ = 0;
@@ -1605,7 +1605,7 @@ chord_note:
                $$ = m.smobbed_copy ();
         } 
        | bare_unsigned '+' {
-               Musical_pitch m;
+               Pitch m;
                m.notename_i_ = ($1 - 1) % 7;
                m.octave_i_ = $1 > 7 ? 1 : 0;
                m.alteration_i_ = 1;
@@ -1614,7 +1614,7 @@ chord_note:
                $$ = m.smobbed_copy ();
        }
        | bare_unsigned CHORD_MINUS {
-               Musical_pitch m;
+               Pitch m;
                m.notename_i_ = ($1 - 1) % 7;
                m.octave_i_ = $1 > 7 ? 1 : 0;
                m.alteration_i_ = -1;