new file. (Thanks Hendrik Maryns)
[lilypond.git] / lily / relative-octave-check.cc
blobfedc58b9be1b4c5ee4bcf42401ce8ae64f0eea0f
1 #include "relative-octave-check.hh"
2 #include "input.hh"
3 #include "pitch.hh"
5 /*
6 yeah, so this should be in a separate file.
7 I'm lazy.
8 */
9 Pitch
10 Relative_octave_check::to_relative_octave (Pitch p)
12 Pitch * check_p = unsmob_pitch (get_property ("pitch"));
14 int delta_oct = 0;
15 if (check_p)
17 Pitch no_octave (-1,
18 check_p->get_notename (),
19 check_p->get_alteration ());
21 Pitch result = no_octave.to_relative_octave (p);
23 if (result != *check_p)
25 String s = _("Failed octave check, got: ");
26 s += result.to_string ();
28 origin ()->warning (s);
30 delta_oct = check_p->get_octave () - result.get_octave ();
34 return Pitch (p.get_octave () + delta_oct,
35 p.get_notename (), p.get_alteration ());
38 ADD_MUSIC (Relative_octave_check);