]> git.donarmstrong.com Git - lilypond.git/blob - lily/time-signature-performer.cc
patch::: 1.3.136.jcn3
[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   VIRTUAL_COPY_CONS (Translator);
18   
19   Time_signature_performer ();
20   ~Time_signature_performer ();
21
22 protected:
23
24   virtual void stop_translation_timestep ();
25   virtual void create_audio_elements ();
26
27   SCM prev_fraction_;
28 private:
29
30   Audio_time_signature* audio_p_;
31 };
32
33
34 Time_signature_performer::Time_signature_performer ()
35 {
36   prev_fraction_ = SCM_BOOL_F;
37   audio_p_ = 0;
38 }
39
40 Time_signature_performer::~Time_signature_performer ()
41 {
42 }
43
44
45 void
46 Time_signature_performer::create_audio_elements ()
47 {
48   SCM fr = get_property ("timeSignatureFraction");
49   if (gh_pair_p (fr)
50       && scm_equal_p (fr, prev_fraction_) != SCM_BOOL_T)
51     {
52       prev_fraction_ = fr;
53       int b = gh_scm2int (gh_car (fr));
54       int o = gh_scm2int (gh_cdr (fr));
55       
56       audio_p_ = new Audio_time_signature (b,o);
57       Audio_element_info info (audio_p_, 0);
58       announce_element (info);
59
60     }
61 }
62
63 void
64 Time_signature_performer::stop_translation_timestep ()
65 {
66   if (audio_p_)
67     {
68       play_element (audio_p_);
69       audio_p_ = 0;
70     }
71 }
72 ADD_THIS_TRANSLATOR (Time_signature_performer);
73