source file of the GNU LilyPond music typesetter
- (c) 1998--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
+ (c) 1998--2000 Han-Wen Nienhuys <hanwen@cs.uu.nl>
*/
#include "musical-pitch.hh"
#include "debug.hh"
#include "main.hh"
-String Musical_pitch::name_str_arr_arr_[7][5];
+int
+compare (Array<Musical_pitch>* left, Array<Musical_pitch>* right)
+{
+ assert (left);
+ assert (right);
+
+ if (left->size () == right->size ())
+ {
+ for (int i = 0; i < left->size (); i++)
+ {
+ int r = Musical_pitch::compare ((*left)[i], (*right)[i]);
+ if (r)
+ return r;
+ }
+ }
+ else
+ return 1;
+
+ return 0;
+}
+
+SCM
+Musical_pitch::to_scm ()const
+{
+ return gh_list (gh_int2scm (octave_i_),
+ gh_int2scm (notename_i_),
+ gh_int2scm (accidental_i_),
+ SCM_UNDEFINED);
+}
+
+
+Musical_pitch::Musical_pitch (SCM s)
+{
+ octave_i_ = gh_scm2int (gh_car (s));
+ notename_i_ = gh_scm2int (gh_cadr (s));
+ accidental_i_ = gh_scm2int (gh_caddr (s));
+}
Musical_pitch::Musical_pitch (int n, int a, int o)
{
octave_i_ = o;
}
-void
-Musical_pitch::print () const
-{
-#ifndef NPRINT
- DOUT << str ();
-#endif
-}
int
Musical_pitch::compare (Musical_pitch const &m1, Musical_pitch const &m2)
accidental_i_ -= delta_acc;
}
+
+#if 0
+// nice test for internationalisation strings
+char const *accname[] = {"double flat", "flat", "natural",
+ "sharp" , "double sharp"};
+#else
+char const *accname[] = {"eses", "es", "", "is" , "isis"};
+#endif
+
String
Musical_pitch::str () const
{
- String s = name_str_arr_arr_[notename_i_ % 7][accidental_i_ + 2];
+ int n = (notename_i_ + 2) % 7;
+ String s = to_str (char(n + 'a'));
+ if (accidental_i_)
+ s += String (accname[accidental_i_ + 2]);
if (octave_i_ > 0)
{
int o = octave_i_ + 1;
while (o--)
- s += to_str ('\'');
+ s += "'";
}
else if (octave_i_ <0)
{
while (o--)
s += to_str (',');
}
+
+
return s;
}