Use scalar instead of embedded_scm for context mod overrides.
[lilypond/mpolesky.git] / lily / tempo-performer.cc
blob5387d49a3a4ca6233e997b2d1529fd3b020a1224
1 /*
2 tempo-performer.cc -- implement Tempo_performer
4 source file of the GNU LilyPond music typesetter
6 (c) 1997--2009 Jan Nieuwenhuizen <janneke@gnu.org>
7 */
9 #include "performer.hh"
11 #include "audio-item.hh"
12 #include "duration.hh"
13 #include "stream-event.hh"
15 #include "translator.icc"
17 class Tempo_performer : public Performer
19 public:
20 TRANSLATOR_DECLARATIONS (Tempo_performer);
21 ~Tempo_performer ();
23 protected:
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_;
33 void
34 Tempo_performer::derived_mark () const
36 scm_gc_mark (last_tempo_);
39 Tempo_performer::Tempo_performer ()
41 last_tempo_ = SCM_EOL;
42 audio_ = 0;
45 Tempo_performer::~Tempo_performer ()
49 void
50 Tempo_performer::process_music ()
52 SCM w = get_property ("tempoWholesPerMinute");
53 if (unsmob_moment (w)
54 && !ly_is_equal (w, last_tempo_))
56 Rational r = unsmob_moment (w)->main_part_;
57 r *= Rational (4, 1);
59 audio_ = new Audio_tempo (r.to_int ());
61 Audio_element_info info (audio_, 0);
62 announce_element (info);
64 last_tempo_ = w;
68 void
69 Tempo_performer::stop_translation_timestep ()
71 if (audio_)
73 audio_ = 0;
77 ADD_TRANSLATOR (Tempo_performer,
78 /* doc */
79 "",
81 /* create */
82 "",
84 /* read */
85 "tempoWholesPerMinute ",
87 /* write */