slightly extend NotePlayer API

git-svn-id: svn://localhost/ardour2/branches/3.0@11414 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2012-02-01 03:32:59 +00:00
parent 452672f78f
commit a09a71d674
2 changed files with 15 additions and 14 deletions

View File

@ -38,27 +38,27 @@ NotePlayer::add (boost::shared_ptr<NoteType> 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());
}
}

View File

@ -39,6 +39,7 @@ public:
void add (boost::shared_ptr<NoteType>);
void play ();
void off ();
void clear ();
static bool _off (NotePlayer*);