]> git.donarmstrong.com Git - lilypond.git/blob - lily/time-signature-performer.cc
cb3f1322a9a1ca307d78d9f408f3306dffc2be9e
[lilypond.git] / lily / time-signature-performer.cc
1 /*
2   time-signature-performer.cc -- implement Time_signature_performer
3
4   source file of the GNU LilyPond music typesetter
5
6   (c)  1997--2001 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
8
9 #include "audio-item.hh"
10 #include "lily-proto.hh"
11 #include "performer.hh"
12
13
14 class Time_signature_performer : public Performer
15 {
16 public:
17   TRANSLATOR_DECLARATIONS(Time_signature_performer);
18   ~Time_signature_performer ();
19
20 protected:
21
22   virtual void stop_translation_timestep ();
23   virtual void create_audio_elements ();
24
25   SCM prev_fraction_;
26 private:
27
28   Audio_time_signature* audio_p_;
29 };
30
31
32 Time_signature_performer::Time_signature_performer ()
33 {
34   prev_fraction_ = SCM_BOOL_F;
35   audio_p_ = 0;
36 }
37
38 Time_signature_performer::~Time_signature_performer ()
39 {
40 }
41
42
43 void
44 Time_signature_performer::create_audio_elements ()
45 {
46   SCM fr = get_property ("timeSignatureFraction");
47   if (gh_pair_p (fr) && !gh_equal_p (fr, prev_fraction_))
48     {
49       prev_fraction_ = fr;
50       int b = gh_scm2int (ly_car (fr));
51       int o = gh_scm2int (ly_cdr (fr));
52       
53       audio_p_ = new Audio_time_signature (b,o);
54       Audio_element_info info (audio_p_, 0);
55       announce_element (info);
56
57     }
58 }
59
60 void
61 Time_signature_performer::stop_translation_timestep ()
62 {
63   if (audio_p_)
64     {
65       play_element (audio_p_);
66       audio_p_ = 0;
67     }
68 }
69
70 ENTER_DESCRIPTION (Time_signature_performer, "","","","","" );