2 * Copyright (C) 2010-2012 Paul Davis <paul@linuxaudiosystems.com>
3 * Copyright (C) 2011-2012 David Robillard <d@drobilla.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include <sigc++/bind.h>
21 #include <glibmm/main.h>
23 #include "ardour/midi_track.h"
25 #include "note_player.h"
27 using namespace ARDOUR;
30 NotePlayer::NotePlayer (boost::shared_ptr<MidiTrack> mt)
35 NotePlayer::~NotePlayer ()
41 NotePlayer::add (boost::shared_ptr<NoteType> note)
43 notes.push_back (note);
56 for (Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
57 track->write_immediate_event ((*n)->on_event().size(), (*n)->on_event().buffer());
66 /* note: if there is more than 1 note, we will silence them all at the same time
69 const uint32_t note_length_ms = 100;
71 Glib::signal_timeout().connect (sigc::bind (sigc::ptr_fun (&NotePlayer::_off), this),
72 note_length_ms, G_PRIORITY_DEFAULT);
76 NotePlayer::_off (NotePlayer* np)
86 for (Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
87 track->write_immediate_event ((*n)->off_event().size(), (*n)->off_event().buffer());