~ubuntu-branches/ubuntu/precise/lilypond/precise

« back to all changes in this revision

Viewing changes to lily/performer-group.cc

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Bushnell, BSG
  • Date: 2006-12-19 10:18:12 UTC
  • mfrom: (3.1.4 feisty)
  • Revision ID: james.westby@ubuntu.com-20061219101812-7awtjkp0i393wxty
Tags: 2.8.7-3
scripts/midi2ly.py: When setting DATADIR, find Lilypond python files
in the @TOPLEVEL_VERSION@ directory, not 'current'.  Patch thanks to
Chris Lamb (chris@chris-lamb.co.uk).  (Closes: #400550)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
  performer-group-performer.cc -- implement Performer_group
 
3
 
 
4
  source file of the GNU LilyPond music typesetter
 
5
 
 
6
  (c) 1996--2006 Han-Wen Nienhuys <hanwen@xs4all.nl>
 
7
  Jan Nieuwenhuizen <janneke@gnu.org>
 
8
*/
 
9
 
 
10
#include "performer-group.hh"
 
11
 
 
12
#include "context.hh"
 
13
#include "audio-element.hh"
 
14
#include "warn.hh"
 
15
 
 
16
ADD_TRANSLATOR_GROUP (Performer_group,
 
17
                      /* doc */ "",
 
18
                      /* create */ "",
 
19
                      /* accept */ "",
 
20
                      /* read */ "",
 
21
                      /* write */ "");
 
22
 
 
23
void
 
24
Performer_group::announce_element (Audio_element_info info)
 
25
{
 
26
  announce_infos_.push_back (info);
 
27
  Translator_group *t
 
28
    = context ()->get_parent_context ()->implementation ();
 
29
 
 
30
  if (Performer_group *eg = dynamic_cast<Performer_group *> (t))
 
31
    eg->announce_element (info);
 
32
}
 
33
 
 
34
void
 
35
Performer_group::acknowledge_audio_elements ()
 
36
{
 
37
  for (vsize j = 0; j < announce_infos_.size (); j++)
 
38
    {
 
39
      Audio_element_info info = announce_infos_[j];
 
40
 
 
41
      for (SCM p = get_simple_trans_list (); scm_is_pair (p); p = scm_cdr (p))
 
42
        {
 
43
          Translator *t = unsmob_translator (scm_car (p));
 
44
          Performer *eng = dynamic_cast<Performer *> (t);
 
45
          if (eng && eng != info.origin_trans_)
 
46
            eng->acknowledge_audio_element (info);
 
47
        }
 
48
    }
 
49
}
 
50
 
 
51
void
 
52
performer_each (SCM list, Performer_method method)
 
53
{
 
54
  for (SCM p = list; scm_is_pair (p); p = scm_cdr (p))
 
55
    {
 
56
      Performer *e = dynamic_cast<Performer *> (unsmob_translator (scm_car (p)));
 
57
      if (e)
 
58
        (e->*method) ();
 
59
    }
 
60
}
 
61
 
 
62
void
 
63
Performer_group::do_announces ()
 
64
{
 
65
  for (SCM s = context ()->children_contexts ();
 
66
       scm_is_pair (s); s = scm_cdr (s))
 
67
    {
 
68
      Context *c = unsmob_context (scm_car (s));
 
69
      Performer_group *group
 
70
        = dynamic_cast<Performer_group *> (c->implementation ());
 
71
      if (group)
 
72
        group->do_announces ();
 
73
    }
 
74
 
 
75
  while (1)
 
76
    {
 
77
      performer_each (get_simple_trans_list (),
 
78
                      &Performer::create_audio_elements);
 
79
 
 
80
      if (!announce_infos_.size ())
 
81
        break;
 
82
 
 
83
      acknowledge_audio_elements ();
 
84
      announce_infos_.clear ();
 
85
    }
 
86
}
 
87
 
 
88
void
 
89
Performer_group::play_element (Audio_element *e)
 
90
{
 
91
  Context *c = context_->get_parent_context ();
 
92
  if (c)
 
93
    {
 
94
      Performer_group *pgp = dynamic_cast<Performer_group *> (c->implementation ());
 
95
      pgp->play_element (e);
 
96
    }
 
97
}
 
98
 
 
99
int
 
100
Performer_group::get_tempo () const
 
101
{
 
102
  Context *c = context_->get_parent_context ();
 
103
  if (c)
 
104
    {
 
105
      Performer_group *pgp = dynamic_cast<Performer_group *> (c->implementation ());
 
106
      return pgp->get_tempo ();
 
107
    }
 
108
  return 60;
 
109
}
 
110