Use labs() for long instead of abs()
[ardour.git] / gtk2_ardour / note_player.cc
index b9f480a6be41b10c3a7a912b6388322f7ba32e7a..cfeaf82def4a0bfe91000524f7801f6ba14fe08c 100644 (file)
@@ -1,20 +1,21 @@
 /*
-    Copyright (C) 2011 Paul Davis
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-*/
+ * Copyright (C) 2010-2012 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2011-2012 David Robillard <d@drobilla.net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
 #include <sigc++/bind.h>
 #include <glibmm/main.h>
@@ -31,6 +32,11 @@ NotePlayer::NotePlayer (boost::shared_ptr<MidiTrack> mt)
 {
 }
 
+NotePlayer::~NotePlayer ()
+{
+       clear ();
+}
+
 void
 NotePlayer::add (boost::shared_ptr<NoteType> note)
 {
@@ -45,11 +51,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
         */