]> git.donarmstrong.com Git - lilypond.git/commitdiff
partial: 1.1.61.jcn
authorJan Nieuwenhuizen <janneke@gnu.org>
Fri, 16 Jul 1999 13:24:41 +0000 (15:24 +0200)
committerJan Nieuwenhuizen <janneke@gnu.org>
Fri, 16 Jul 1999 13:24:41 +0000 (15:24 +0200)
lily/include/tempo-performer.hh [new file with mode: 0644]
lily/tempo-performer.cc [new file with mode: 0644]

diff --git a/lily/include/tempo-performer.hh b/lily/include/tempo-performer.hh
new file mode 100644 (file)
index 0000000..97c272f
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+  tempo-performer.hh -- declare Tempo_performer
+
+  source file of the GNU LilyPond music typesetter
+
+  (c)  1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#ifndef TEMPO_PERFORMER_HH
+#define TEMPO_PERFORMER_HH
+
+#include "lily-proto.hh"
+#include "performer.hh"
+
+class Tempo_performer : public Performer
+{
+public:
+  VIRTUAL_COPY_CONS(Translator);
+  
+  Tempo_performer();
+  ~Tempo_performer();
+
+protected:
+  void do_print() const;
+  virtual bool do_try_music (Music* req_l);
+  virtual void do_process_requests();
+  virtual void do_pre_move_processing ();
+
+private:
+  Tempo_req* tempo_req_l_;
+  Audio_tempo* audio_p_;
+};
+
+#endif // TEMPO_PERFORMER_HH
diff --git a/lily/tempo-performer.cc b/lily/tempo-performer.cc
new file mode 100644 (file)
index 0000000..bb9f4ae
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+  tempo-performer.cc -- implement Tempo_performer
+
+  source file of the GNU LilyPond music typesetter
+
+  (c)  1997--1999 Jan Nieuwenhuizen <janneke@gnu.org>
+*/
+
+#include "tempo-performer.hh"
+#include "command-request.hh"
+#include "audio-item.hh"
+
+ADD_THIS_TRANSLATOR (Tempo_performer);
+
+Tempo_performer::Tempo_performer ()
+{
+  tempo_req_l_ = 0;
+  audio_p_ = 0;
+}
+
+Tempo_performer::~Tempo_performer ()
+{
+}
+
+void 
+Tempo_performer::do_print () const
+{
+#ifndef NPRINT
+  if (tempo_req_l_)
+    tempo_req_l_->print ();
+#endif
+}
+
+void
+Tempo_performer::do_process_requests ()
+{
+  if (tempo_req_l_)
+    {
+      audio_p_ = new Audio_tempo (tempo_req_l_->dur_.length_mom () /
+                                 Moment (1, 4) 
+                                 * Moment(tempo_req_l_->metronome_i_));
+      Audio_element_info info (audio_p_, tempo_req_l_);
+      announce_element (info);
+      tempo_req_l_ = 0;
+    }
+}
+
+void
+Tempo_performer::do_pre_move_processing ()
+{
+  if (audio_p_)
+    {
+      play_element (audio_p_);
+      audio_p_ = 0;
+    }
+}
+
+bool
+Tempo_performer::do_try_music (Music* req_l)
+{
+  if (tempo_req_l_)
+    return false;
+
+  if (Tempo_req *t =
+      dynamic_cast <Tempo_req *> (req_l))
+    {
+      tempo_req_l_ = t;
+      return true;
+    }
+
+  return false;
+}
+