]> git.donarmstrong.com Git - lilypond.git/blob - lily/relative-octave-check.cc
* lily/include/music.hh (class Music): include SCM init argument.
[lilypond.git] / lily / relative-octave-check.cc
1 /*
2   relative-octave-check.cc --  implement Relative_octave_check
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 2005 Han-Wen Nienhuys <hanwen@xs4all.nl>
7
8 */
9
10 #include "relative-octave-check.hh"
11
12 #include "input.hh"
13 #include "pitch.hh"
14
15 Pitch
16 Relative_octave_check::to_relative_octave (Pitch p)
17 {
18   Pitch * check_p = unsmob_pitch (get_property ("pitch"));
19
20   int delta_oct = 0;
21   if (check_p)
22     {
23       Pitch no_octave (-1,
24                        check_p->get_notename (),
25                        check_p->get_alteration ());
26
27       Pitch result = no_octave.to_relative_octave (p);
28
29       if (result != *check_p)
30         {
31           String s = _("Failed octave check, got: ");
32           s += result.to_string ();
33           
34           origin ()->warning (s);
35           
36           delta_oct = check_p->get_octave () - result.get_octave ();
37         }
38     }
39   
40   return  Pitch (p.get_octave () + delta_oct,
41                  p.get_notename (), p.get_alteration ());
42 }
43
44
45 Relative_octave_check::Relative_octave_check (SCM x)
46   : Music (x)
47 {
48 }
49
50 ADD_MUSIC (Relative_octave_check);