mp4chaps Lua script: don't clutter global environment
[ardour.git] / gtk2_ardour / note_player.cc
index c9c9f9de0ebbf6690c81f6ab09bc4a981bde4a97..cd5c058209b76181fe063af8fff5e2ec158f02cc 100644 (file)
@@ -20,7 +20,6 @@
 #include <glibmm/main.h>
 
 #include "ardour/midi_track.h"
-#include "ardour/session.h"
 
 #include "note_player.h"
 
@@ -32,6 +31,11 @@ NotePlayer::NotePlayer (boost::shared_ptr<MidiTrack> mt)
 {
 }
 
+NotePlayer::~NotePlayer ()
+{
+       clear ();
+}
+
 void
 NotePlayer::add (boost::shared_ptr<NoteType> note)
 {
@@ -46,11 +50,17 @@ NotePlayer::clear ()
 }
 
 void
-NotePlayer::play ()
+NotePlayer::on ()
 {
        for (Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
                track->write_immediate_event ((*n)->on_event().size(), (*n)->on_event().buffer());
        }
+}
+
+void
+NotePlayer::play ()
+{
+       on ();
 
        /* note: if there is more than 1 note, we will silence them all at the same time
         */