From a09a71d6742b22fd8fb8636b672be1b62b05222a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 1 Feb 2012 03:32:59 +0000 Subject: [PATCH] slightly extend NotePlayer API git-svn-id: svn://localhost/ardour2/branches/3.0@11414 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/note_player.cc | 28 ++++++++++++++-------------- gtk2_ardour/note_player.h | 1 + 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/gtk2_ardour/note_player.cc b/gtk2_ardour/note_player.cc index 09c2e8add3..6355cc522b 100644 --- a/gtk2_ardour/note_player.cc +++ b/gtk2_ardour/note_player.cc @@ -38,27 +38,27 @@ NotePlayer::add (boost::shared_ptr note) notes.push_back (note); } +void +NotePlayer::clear () +{ + off (); + notes.clear (); +} + void NotePlayer::play () { - Evoral::MusicalTime longest_duration_beats = 0; + for (Notes::iterator n = notes.begin(); n != notes.end(); ++n) { + track->write_immediate_event ((*n)->on_event().size(), (*n)->on_event().buffer()); + } /* note: if there is more than 1 note, we will silence them all at the same time */ - 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(); - } - } + const uint32_t note_length_ms = 350; - uint32_t note_length_ms = 350; - /* beats_to_frames (longest_duration_beats) - * (1000 / (double)track->session().nominal_frame_rate()); */ - - 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()); } } diff --git a/gtk2_ardour/note_player.h b/gtk2_ardour/note_player.h index e5ff93e113..c39d352dd6 100644 --- a/gtk2_ardour/note_player.h +++ b/gtk2_ardour/note_player.h @@ -39,6 +39,7 @@ public: void add (boost::shared_ptr); void play (); void off (); + void clear (); static bool _off (NotePlayer*);