]> git.donarmstrong.com Git - lilypond.git/blob - lily/request-chord.cc
release: 1.5.34
[lilypond.git] / lily / request-chord.cc
1 #include "pitch.hh" 
2 #include "request-chord-iterator.hh"
3 #include "music-list.hh"
4 #include "musical-request.hh"
5
6 Request_chord::Request_chord (SCM s)
7   : Simultaneous_music (s)
8 {
9   set_mus_property ("iterator-ctor",
10                     Request_chord_iterator::constructor_cxx_function);
11 }
12
13 Request_chord::Request_chord ()
14 {
15   set_mus_property ("iterator-ctor",
16                     Request_chord_iterator::constructor_cxx_function);
17 }
18
19 Pitch
20 Request_chord::to_relative_octave (Pitch last)
21 {
22   for (SCM s = music_list (); gh_pair_p (s);  s = ly_cdr (s))
23     {
24       Music * mus = unsmob_music (ly_car (s));
25       Melodic_req *m= dynamic_cast <Melodic_req *> (mus);
26
27       /*
28         kLudge: rests have pitches now as well.
29        */
30       Rest_req *r = dynamic_cast<Rest_req*> (mus);
31       
32       if (r || m)
33         {
34           Pitch *old_pit = unsmob_pitch (mus->get_mus_property ("pitch"));
35           if (!old_pit)
36             continue;
37           
38           Pitch new_pit = *old_pit;
39           new_pit.to_relative_octave (last);
40           mus->set_mus_property ("pitch", new_pit.smobbed_copy ());
41
42           return new_pit;
43         }
44
45     }
46   return last;
47 }
48
49 Moment
50 Request_chord::start_mom () const
51 {
52   return Music::start_mom ();
53 }
54
55 ADD_MUSIC (Request_chord);