]> git.donarmstrong.com Git - lilypond.git/blob - lily/relative-octave-check.cc
* lily/accidental-placement.cc (position_accidentals): bugfix in
[lilypond.git] / lily / relative-octave-check.cc
1 #include "relative-octave-check.hh"
2 #include "input.hh"
3 #include "pitch.hh"
4
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)
11 {
12   Pitch * check_p = unsmob_pitch (get_property ("pitch"));
13
14   int delta_oct = 0;
15   if (check_p)
16     {
17       Pitch no_octave (-1,
18                        check_p->get_notename (),
19                        check_p->get_alteration ());
20
21       Pitch result = no_octave.to_relative_octave (p);
22
23       if (result != *check_p)
24         {
25           String s = _("Failed octave check, got: ");
26           s += result.to_string ();
27           
28           origin ()->warning (s);
29           
30           delta_oct = check_p->get_octave () - result.get_octave ();
31         }
32     }
33   
34   return  Pitch (p.get_octave () + delta_oct,
35                  p.get_notename (), p.get_alteration ());
36 }
37
38 ADD_MUSIC (Relative_octave_check);