]> git.donarmstrong.com Git - lilypond.git/blob - lily/part-combine-music.cc
7ab0a6f95a8db99b7ed0cef04272bf51aa0a28ef
[lilypond.git] / lily / part-combine-music.cc
1 /*   
2   part-combine-music.cc --  implement Part_combine_music
3   
4   source file of the GNU LilyPond music typesetter
5   
6   (c) 2000--2002 Jan Nieuwenhuizen <janneke@gnu.org>
7   
8  */
9
10 #include "part-combine-music.hh"
11 #include "part-combine-music-iterator.hh"
12 #include "pitch.hh"
13
14 Part_combine_music::Part_combine_music (SCM l)
15   : Music (l)
16 {
17   set_mus_property ("iterator-ctor",
18                     Part_combine_music_iterator::constructor_cxx_function);
19 }
20
21 void
22 Part_combine_music::transpose (Pitch p)
23 {
24   get_first ()->transpose (p);
25   get_second () ->transpose (p);
26 }
27
28 Moment
29 Part_combine_music::length_mom () const
30 {
31   return get_first ()->length_mom ();
32 }
33
34 Pitch
35 Part_combine_music::to_relative_octave (Pitch p)
36 {
37   p = get_first ()->to_relative_octave (p);
38   return get_second ()->to_relative_octave (p);
39 }
40
41 void
42 Part_combine_music::compress (Moment m)
43 {
44   get_first ()->compress (m);
45   get_second ()->compress (m);
46 }
47
48 Music*
49 Part_combine_music::get_first () const
50 {
51   SCM l = get_mus_property ("elements");
52   if (!gh_pair_p (l))
53     return 0;
54   return unsmob_music (gh_car (l));
55 }
56
57
58 Music*
59 Part_combine_music::get_second () const
60 {
61   SCM l = get_mus_property ("elements");
62   if (!gh_pair_p (l))
63     return 0;
64   l = gh_cdr (l);
65   if (!gh_pair_p (l))
66     return 0;
67   return unsmob_music (gh_car (l));
68 }
69
70
71 Part_combine_music::Part_combine_music ()
72   : Music (SCM_EOL)
73 {
74 }
75
76 ADD_MUSIC (Part_combine_music);