]> git.donarmstrong.com Git - lilypond.git/blob - lily/relative-octave-music.cc
* The grand 2005-2006 replace.
[lilypond.git] / lily / relative-octave-music.cc
1 /*
2   relative-music.cc -- implement Relative_octave_music
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1998--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
7 */
8
9 #include "music.hh"
10 #include "pitch.hh"
11 #include "warn.hh"
12 #include "program-option.hh"
13
14 class Relative_octave_music
15 {
16 public:
17   DECLARE_SCHEME_CALLBACK (relative_callback, (SCM, SCM));
18   DECLARE_SCHEME_CALLBACK (no_relative_callback, (SCM, SCM));
19 };
20
21 MAKE_SCHEME_CALLBACK (Relative_octave_music, no_relative_callback, 2)
22   SCM
23 Relative_octave_music::no_relative_callback (SCM music, SCM pitch)
24 {
25   (void)music;
26   return pitch;
27 }
28
29 MAKE_SCHEME_CALLBACK (Relative_octave_music, relative_callback, 2)
30   SCM
31 Relative_octave_music::relative_callback (SCM music, SCM pitch)
32 {
33   Music *me = unsmob_music (music);
34   if (lily_1_8_relative)
35     {
36       lily_1_8_compatibility_used = true;
37       /*  last-pitch should be junked some time, when
38           we ditch 1.8 compat too.
39
40           When you do, B should start where A left off.
41
42           \relative { A \relative { ...} B }  */
43       SCM last_pitch = me->get_property ("last-pitch");
44       Pitch *ptr = unsmob_pitch (last_pitch);
45       return (ptr) ? last_pitch : pitch;
46     }
47   else
48     return pitch;
49 }
50