slightly extend NotePlayer API
git-svn-id: svn://localhost/ardour2/branches/3.0@11414 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
452672f78f
commit
a09a71d674
@ -38,27 +38,27 @@ NotePlayer::add (boost::shared_ptr<NoteType> note)
|
|||||||
notes.push_back (note);
|
notes.push_back (note);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
NotePlayer::clear ()
|
||||||
|
{
|
||||||
|
off ();
|
||||||
|
notes.clear ();
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
NotePlayer::play ()
|
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
|
/* 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) {
|
const uint32_t note_length_ms = 350;
|
||||||
track->write_immediate_event ((*n)->on_event().size(), (*n)->on_event().buffer());
|
|
||||||
if ((*n)->length() > longest_duration_beats) {
|
|
||||||
longest_duration_beats = (*n)->length();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t note_length_ms = 350;
|
Glib::signal_timeout().connect (sigc::bind (sigc::ptr_fun (&NotePlayer::_off), this),
|
||||||
/* beats_to_frames (longest_duration_beats)
|
note_length_ms, G_PRIORITY_DEFAULT);
|
||||||
* (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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
@ -73,6 +73,6 @@ void
|
|||||||
NotePlayer::off ()
|
NotePlayer::off ()
|
||||||
{
|
{
|
||||||
for (Notes::iterator n = notes.begin(); n != notes.end(); ++n) {
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ public:
|
|||||||
void add (boost::shared_ptr<NoteType>);
|
void add (boost::shared_ptr<NoteType>);
|
||||||
void play ();
|
void play ();
|
||||||
void off ();
|
void off ();
|
||||||
|
void clear ();
|
||||||
|
|
||||||
static bool _off (NotePlayer*);
|
static bool _off (NotePlayer*);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user