slightly extend NotePlayer API
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 1 Feb 2012 03:32:59 +0000 (03:32 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 1 Feb 2012 03:32:59 +0000 (03:32 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11414 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/note_player.cc
gtk2_ardour/note_player.h

index 09c2e8add3db235736a097cee0fc125bfa33e294..6355cc522bf85f73a5469ddc660699e15002679f 100644 (file)
@@ -39,26 +39,26 @@ NotePlayer::add (boost::shared_ptr<NoteType> note)
 }
 
 void
-NotePlayer::play ()
+NotePlayer::clear ()
 {
-       Evoral::MusicalTime longest_duration_beats = 0;
-
-       /* note: if there is more than 1 note, we will silence them all at the same time
-        */
+       off ();
+       notes.clear ();
+}
 
+void
+NotePlayer::play ()
+{
        for (Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
                track->write_immediate_event ((*n)->on_event().size(), (*n)->on_event().buffer());
-               if ((*n)->length() > longest_duration_beats) {
-                       longest_duration_beats = (*n)->length();
-               }
        }
 
-       uint32_t note_length_ms = 350;
-       /* beats_to_frames (longest_duration_beats)
-        * (1000 / (double)track->session().nominal_frame_rate()); */
+       /* note: if there is more than 1 note, we will silence them all at the same time
+        */
+
+       const uint32_t note_length_ms = 350;
 
-       Glib::signal_timeout().connect(sigc::bind (sigc::ptr_fun (&NotePlayer::_off), this),
-                                      note_length_ms, G_PRIORITY_DEFAULT);
+       Glib::signal_timeout().connect (sigc::bind (sigc::ptr_fun (&NotePlayer::_off), this),
+                                       note_length_ms, G_PRIORITY_DEFAULT);
 }
 
 bool
@@ -73,6 +73,6 @@ void
 NotePlayer::off ()
 {
        for (Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
-               track->write_immediate_event((*n)->off_event().size(), (*n)->off_event().buffer());
+               track->write_immediate_event ((*n)->off_event().size(), (*n)->off_event().buffer());
        }
 }
index e5ff93e113096cec16e7e72a31c1fe4b6e201c9c..c39d352dd6aa350d5068d9f42e5d296f2009e309 100644 (file)
@@ -39,6 +39,7 @@ public:
        void add (boost::shared_ptr<NoteType>);
        void play ();
        void off ();
+       void clear ();
 
        static bool _off (NotePlayer*);