]> git.donarmstrong.com Git - lilypond.git/blob - lily/performer-group.cc
Web-ja: update introduction
[lilypond.git] / lily / performer-group.cc
1 /*
2   This file is part of LilyPond, the GNU music typesetter.
3
4   Copyright (C) 1996--2015 Han-Wen Nienhuys <hanwen@xs4all.nl>
5   Jan Nieuwenhuizen <janneke@gnu.org>
6
7   LilyPond is free software: you can redistribute it and/or modify
8   it under the terms of the GNU General Public License as published by
9   the Free Software Foundation, either version 3 of the License, or
10   (at your option) any later version.
11
12   LilyPond is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16
17   You should have received a copy of the GNU General Public License
18   along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "performer-group.hh"
22
23 #include "context.hh"
24 #include "audio-element.hh"
25 #include "warn.hh"
26
27 ADD_TRANSLATOR_GROUP (Performer_group,
28                       /* doc */
29                       "",
30
31                       /* create */
32                       "",
33
34                       /* read */
35                       "",
36
37                       /* write */
38                       ""
39                      );
40
41 void
42 Performer_group::announce_element (Audio_element_info info)
43 {
44   announce_infos_.push_back (info);
45   Translator_group *t
46     = context ()->get_parent_context ()->implementation ();
47
48   if (Performer_group *eg = dynamic_cast<Performer_group *> (t))
49     eg->announce_element (info);
50 }
51
52 void
53 Performer_group::acknowledge_audio_elements ()
54 {
55   for (vsize j = 0; j < announce_infos_.size (); j++)
56     {
57       Audio_element_info info = announce_infos_[j];
58
59       for (SCM p = get_simple_trans_list (); scm_is_pair (p); p = scm_cdr (p))
60         {
61           Translator *t = unsmob<Translator> (scm_car (p));
62           Performer *eng = dynamic_cast<Performer *> (t);
63           if (eng && eng != info.origin_trans_)
64             eng->acknowledge_audio_element (info);
65         }
66     }
67 }
68
69 void
70 performer_each (SCM list, Performer_method method)
71 {
72   for (SCM p = list; scm_is_pair (p); p = scm_cdr (p))
73     {
74       Performer *e = unsmob<Performer> (scm_car (p));
75       if (e)
76         (e->*method) ();
77     }
78 }
79
80 void
81 Performer_group::do_announces ()
82 {
83   for (SCM s = context ()->children_contexts ();
84        scm_is_pair (s); s = scm_cdr (s))
85     {
86       Context *c = unsmob<Context> (scm_car (s));
87       Performer_group *group
88         = dynamic_cast<Performer_group *> (c->implementation ());
89       if (group)
90         group->do_announces ();
91     }
92
93   while (1)
94     {
95       performer_each (get_simple_trans_list (),
96                       &Performer::create_audio_elements);
97
98       if (!announce_infos_.size ())
99         break;
100
101       acknowledge_audio_elements ();
102       announce_infos_.clear ();
103     }
104 }