]> git.donarmstrong.com Git - lilypond.git/blob - lily/rhythmic-music-iterator.cc
Web-ja: update introduction
[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@mikesolomon.org>
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               SCM art = scm_car (arts);
63
64               if (c->event_source ()->is_listened_class
65                   (unsmob<Stream_event> (art)->get_property ("class")))
66                 listened = scm_cons (art, listened);
67               else
68                 unlistened = scm_cons (art, unlistened);
69             }
70           ev->set_property ("articulations", scm_reverse_x (unlistened, SCM_EOL));
71           c->event_source ()->broadcast (ev);
72           arts = scm_reverse_x (listened, SCM_EOL);
73           for (; scm_is_pair (arts); arts = scm_cdr (arts))
74             c->event_source ()->broadcast (unsmob<Stream_event> (scm_car (arts)));
75         }
76       else
77         c->event_source ()->broadcast (ev);
78
79       ev->unprotect ();
80     }
81   Simple_music_iterator::process (m);
82 }
83
84 IMPLEMENT_CTOR_CALLBACK (Rhythmic_music_iterator);