]> git.donarmstrong.com Git - lilypond.git/blob - lily/rhythmic-music-iterator.cc
run astyle 2.02
[lilypond.git] / lily / rhythmic-music-iterator.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 2012 Mike Solomon <mike@apollinemike.com>
5
6   LilyPond is free software: you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation, either version 3 of the License, or
9   (at your option) any later version.
10
11   LilyPond is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "rhythmic-music-iterator.hh"
21
22 #include "context.hh"
23 #include "dispatcher.hh"
24 #include "duration.hh"
25 #include "input.hh"
26 #include "international.hh"
27 #include "music.hh"
28 #include "warn.hh"
29
30 Rhythmic_music_iterator::Rhythmic_music_iterator ()
31 {
32 }
33
34 void
35 Rhythmic_music_iterator::construct_children ()
36 {
37   Simple_music_iterator::construct_children ();
38   descend_to_bottom_context ();
39 }
40
41 void
42 Rhythmic_music_iterator::process (Moment m)
43 {
44   if (last_processed_mom_ < Moment (0))
45     {
46
47       descend_to_bottom_context ();
48
49       Context *c = get_outlet ();
50       Stream_event *ev = get_music ()->to_event ();
51       SCM arts = ev->get_property ("articulations");
52
53       if (scm_is_pair (arts))
54         {
55           // There is no point in broadcasting articulations like
56           // harmonic events that nobody listens to.  Those work
57           // exclusively as articulations.
58           SCM listened = SCM_EOL;
59           SCM unlistened = SCM_EOL;
60           for (; scm_is_pair (arts); arts = scm_cdr (arts))
61             {
62               if (scm_is_true
63                   (scm_call_2
64                    (ly_lily_module_constant ("any"),
65                     ly_lily_module_constant ("ly:is-listened-event-class"),
66                     scm_call_1
67                     (ly_lily_module_constant ("ly:make-event-class"),
68                      unsmob_stream_event (scm_car (arts))
69                      ->get_property ("class")))))
70                 listened = scm_cons (scm_car (arts), listened);
71               else
72                 unlistened = scm_cons (scm_car (arts), unlistened);
73             }
74           ev->set_property ("articulations", scm_reverse_x (unlistened, SCM_EOL));
75           c->event_source ()->broadcast (ev);
76           arts = scm_reverse_x (listened, SCM_EOL);
77           for (; scm_is_pair (arts); arts = scm_cdr (arts))
78             c->event_source ()->broadcast (unsmob_stream_event (scm_car (arts)));
79         }
80       else
81         c->event_source ()->broadcast (ev);
82
83       ev->unprotect ();
84     }
85   Simple_music_iterator::process (m);
86 }
87
88 IMPLEMENT_CTOR_CALLBACK (Rhythmic_music_iterator);