2 music-list.cc -- implement Music_sequence, Simultaneous_music, Sequential_music
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--1998 Han-Wen Nienhuys <hanwen@cs.uu.nl>
11 #include "music-list.hh"
12 #include "musical-pitch.hh"
14 #include "musical-request.hh"
17 IMPLEMENT_IS_TYPE_B1(Sequential_music,Music_sequence);
18 IMPLEMENT_IS_TYPE_B1(Simultaneous_music,Music_sequence);
21 Simultaneous_music::duration () const
24 for (iter (music_p_list_p_->top(), i); i.ok (); i++)
25 dur = dur >? i->duration ();
31 Music_sequence::compress (Moment m)
33 for (PCursor<Music*> i(music_p_list_p_->top()); i.ok (); i++)
37 Simultaneous_music::Simultaneous_music(Music_list *p)
43 Sequential_music::Sequential_music(Music_list *p)
49 Sequential_music::duration () const
52 for (iter (music_p_list_p_->top(), i); i.ok (); i++)
54 last += i->duration ();
60 Sequential_music::to_relative_octave (Musical_pitch p)
62 return music_p_list_p_->do_relative_octave (p, false);
66 Simultaneous_music::to_relative_octave (Musical_pitch p)
68 return music_p_list_p_->do_relative_octave (p, true);
73 Music_list::do_relative_octave (Musical_pitch last, bool ret_first)
77 for (PCursor<Music*> i (top ()); i.ok (); i++)
79 last = i->to_relative_octave (last);
89 Music_list::Music_list (Music_list const &s)
90 : Pointer_list<Music*> ()
92 for (PCursor<Music*> i(s.top()); i.ok (); i++)
93 add_music (i->clone());
97 Music_list::add_music (Music*m_p)
106 IMPLEMENT_IS_TYPE_B1(Request_chord, Simultaneous_music);
109 Request_chord::Request_chord()
110 : Simultaneous_music (new Music_list)
117 Request_chord::to_relative_octave (Musical_pitch last)
119 for (iter (music_p_list_p_->top(),i); i.ok (); i++)
121 Musical_req *m = dynamic_cast<Musical_req*> (i.ptr ());
122 if (m && dynamic_cast <Melodic_req *> (m))
124 Musical_pitch &pit = dynamic_cast <Melodic_req *> (m)->pitch_;
125 pit.to_relative_octave (last);
133 Music_list::Music_list ()
134 : Pointer_list<Music*> ()