Fix inconsistent session-check
[ardour.git] / gtk2_ardour / note_player.cc
index 6355cc522bf85f73a5469ddc660699e15002679f..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,16 +50,22 @@ 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
         */
 
-       const uint32_t note_length_ms = 350;
+       const uint32_t note_length_ms = 100;
 
        Glib::signal_timeout().connect (sigc::bind (sigc::ptr_fun (&NotePlayer::_off), this),
                                        note_length_ms, G_PRIORITY_DEFAULT);