1 #include <sigc++/bind.h>
2 #include <glibmm/main.h>
4 #include "ardour/midi_track.h"
5 #include "ardour/session.h"
7 #include "note_player.h"
9 using namespace ARDOUR
;
12 NotePlayer::NotePlayer (boost::shared_ptr
<MidiTrack
> mt
)
18 NotePlayer::add (boost::shared_ptr
<NoteType
> note
)
20 notes
.push_back (note
);
26 Evoral::MusicalTime longest_duration_beats
= 0;
28 /* note: if there is more than 1 note, we will silence them all at the same time
31 for (NoteList::iterator n
= notes
.begin(); n
!= notes
.end(); ++n
) {
32 track
->write_immediate_event ((*n
)->on_event().size(), (*n
)->on_event().buffer());
33 if ((*n
)->length() > longest_duration_beats
) {
34 longest_duration_beats
= (*n
)->length();
38 uint32_t note_length_ms
= 350;
39 /* beats_to_frames (longest_duration_beats)
40 * (1000 / (double)track->session().nominal_frame_rate()); */
42 Glib::signal_timeout().connect(sigc::bind (sigc::ptr_fun (&NotePlayer::_off
), this),
43 note_length_ms
, G_PRIORITY_DEFAULT
);
47 NotePlayer::_off (NotePlayer
* np
)
57 for (NoteList::iterator n
= notes
.begin(); n
!= notes
.end(); ++n
) {
58 track
->write_immediate_event((*n
)->off_event().size(), (*n
)->off_event().buffer());