lilypond-1.3.11
[lilypond.git] / lily / music-list.cc
blob2b2fce2fda216187f7917b1cb343cfcba5073df9
1 /*
2 music-list.cc -- implement Music_sequence, Simultaneous_music, Sequential_music
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1999 Han-Wen Nienhuys <hanwen@cs.uu.nl>
7 */
9 #include "music-list.hh"
10 #include "music-wrapper.hh"
11 #include "musical-pitch.hh"
12 #include "request.hh"
13 #include "musical-request.hh"
14 #include "music-iterator.hh"
15 #include "main.hh"
16 #include "killing-cons.tcc"
18 Moment
19 Simultaneous_music::length_mom () const
21 return maximum_length ();
25 void
26 Music_sequence::compress (Moment m)
28 for (Cons<Music> *i = music_p_list_p_->head_; i; i = i->next_)
29 i->car_->compress (m);
32 Simultaneous_music::Simultaneous_music(Music_list *p)
33 : Music_sequence (p)
38 Sequential_music::Sequential_music(Music_list *p)
39 : Music_sequence (p)
43 Moment
44 Sequential_music::length_mom () const
46 return cumulative_length ();
49 Musical_pitch
50 Simultaneous_music::to_relative_octave (Musical_pitch p)
52 return do_relative_octave (p, true);
56 Musical_pitch
57 Music_sequence::do_relative_octave (Musical_pitch p, bool b)
59 return music_p_list_p_->do_relative_octave (p, b);
63 Musical_pitch
64 Music_list::do_relative_octave (Musical_pitch last, bool ret_first)
66 Musical_pitch retval;
67 int count=0;
68 for (Cons<Music> *i = head_; i ; i = i->next_)
70 last = i->car_->to_relative_octave (last);
71 if (!count ++ )
72 retval = last;
75 if (!ret_first)
76 retval = last;
78 return retval;
82 Music_list::Music_list (Music_list const &s)
83 : Cons_list<Music> (s), Input (s)
85 Cons_list<Music>::init ();
86 clone_killing_cons_list (*this, s.head_);
90 void
91 Music_list::add_music (Music*m_p)
93 if (!m_p)
94 return;
96 append (new Killing_cons<Music> (m_p, 0));
99 Request_chord::Request_chord()
100 : Simultaneous_music (new Music_list)
105 Musical_pitch
106 Request_chord::to_relative_octave (Musical_pitch last)
108 for (Cons<Music> *i = music_p_list_p_->head_; i ; i = i->next_)
110 if (Melodic_req *m= dynamic_cast <Melodic_req *> (i->car_))
112 Musical_pitch &pit = m->pitch_;
113 pit.to_relative_octave (last);
114 return pit;
117 return last;
121 Music_list::Music_list ()
125 Music_sequence::~Music_sequence ()
127 delete music_p_list_p_;