source file of the GNU LilyPond music typesetter
- (c) 1998 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"
-Musical_pitch::Musical_pitch ()
+SCM
+Musical_pitch::to_scm ()const
{
- init ();
+ return gh_list (gh_int2scm (octave_i_),
+ gh_int2scm (notename_i_),
+ gh_int2scm (accidental_i_),
+ SCM_UNDEFINED);
}
-void
-Musical_pitch::init ()
+
+Musical_pitch::Musical_pitch (SCM s)
{
- notename_i_ = 0;
- octave_i_ = 0;
- accidental_i_ = 0;
- cautionary_b_ = false;
+ 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)
+{
+ notename_i_ = n;
+ accidental_i_ = a;
+ octave_i_ = o;
}
void
Musical_pitch::print () const
{
#ifndef NPRINT
- DOUT << str ();
+ DEBUG_OUT << str ();
#endif
}
if (accidental_i_)
s += String (accname[accidental_i_ + 2]);
- if (octave_i_)
- s += String ((octave_i_> 0)? "^": "_") + to_str (octave_i_);
+ if (octave_i_ > 0)
+ {
+ int o = octave_i_ + 1;
+ while (o--)
+ s += "'";
+ }
+ else if (octave_i_ <0)
+ {
+ int o = (-octave_i_) - 1;
+ while (o--)
+ s += to_str (',');
+ }
+
return s;
}
else
n = down_pitch;
- if (find_quarts_global_b)
- {
- int d = this->semitone_pitch () - n.semitone_pitch ();
- if (d)
- {
- int i = 1 + (abs (d) - 1) / 12;
- String quote_str = d < 0 ? to_str (',', i) : to_str ('\'', i);
- Musical_pitch w = *this;
- w.octave_i_ = 0;
- String name_str = w.str ();
- name_str + quote_str;
- w.warning (_f ("Interval greater than quart, relative: %s",
- name_str + quote_str));
- // don't actually do any relative stuff
- n = *this;
- }
- }
- else
- n.octave_i_ += oct_mod;
+ n.octave_i_ += oct_mod;
*this = n;
return *this;