]> git.donarmstrong.com Git - lilypond.git/blob - lily/tempo-performer.cc
Run `make grand-replace'.
[lilypond.git] / lily / tempo-performer.cc
1 /*
2   tempo-performer.cc -- implement Tempo_performer
3
4   source file of the GNU LilyPond music typesetter
5
6   (c) 1997--2008 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "performer.hh"
10
11 #include "audio-item.hh"
12 #include "duration.hh"
13 #include "stream-event.hh"
14
15 #include "translator.icc"
16
17 class Tempo_performer : public Performer
18 {
19 public:
20   TRANSLATOR_DECLARATIONS (Tempo_performer);
21   ~Tempo_performer ();
22
23 protected:
24
25   virtual void derived_mark () const; 
26   void stop_translation_timestep ();
27   void process_music ();
28 private:
29   Audio_tempo *audio_;
30   SCM last_tempo_; 
31 };
32
33 void
34 Tempo_performer::derived_mark () const
35 {
36   scm_gc_mark (last_tempo_);
37 }
38
39 Tempo_performer::Tempo_performer ()
40 {
41   last_tempo_ = SCM_EOL;
42   audio_ = 0;
43 }
44
45 Tempo_performer::~Tempo_performer ()
46 {
47 }
48
49 void
50 Tempo_performer::process_music ()
51 {
52   SCM w = get_property ("tempoWholesPerMinute");
53   if (unsmob_moment (w)
54       && !ly_is_equal (w, last_tempo_))
55     {
56       Rational r = unsmob_moment (w)->main_part_;
57       r *= Rational (4, 1);
58
59       audio_ = new Audio_tempo (r.to_int ());
60
61       Audio_element_info info (audio_, 0);
62       announce_element (info);
63
64       last_tempo_ = w;
65     }
66 }
67
68 void
69 Tempo_performer::stop_translation_timestep ()
70 {
71   if (audio_)
72     {
73       audio_ = 0;
74     }
75 }
76
77 ADD_TRANSLATOR (Tempo_performer,
78                 /* doc */
79                 "",
80
81                 /* create */
82                 "",
83
84                 /* read */
85                 "tempoWholesPerMinute ",
86
87                 /* write */
88                 ""
89                 );