diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-04-28 19:58:24 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-04-28 19:58:24 -0400 |
commit | 2cf411e4be0b10e6ecf47d2070963299b6a810e7 (patch) | |
tree | c6dfb7e7fcd71d5ee2d4a7c2ba490fb882dde3ca /libs/ardour/async_midi_port.cc | |
parent | b945cda5582d6565ef2ce4fa8cbafee8fd8e5db0 (diff) |
merge (squash) with scenechange topic branch to provide MIDI-driven scene change markers
Diffstat (limited to 'libs/ardour/async_midi_port.cc')
-rw-r--r-- | libs/ardour/async_midi_port.cc | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/libs/ardour/async_midi_port.cc b/libs/ardour/async_midi_port.cc index bd583328c3..21b59dec00 100644 --- a/libs/ardour/async_midi_port.cc +++ b/libs/ardour/async_midi_port.cc @@ -50,6 +50,7 @@ AsyncMIDIPort::AsyncMIDIPort (string const & name, PortFlags flags) , MIDI::Port (name, MIDI::Port::Flags (0)) , _currently_in_cycle (false) , _last_write_timestamp (0) + , have_timer (false) , output_fifo (512) , input_fifo (1024) #ifndef PLATFORM_WINDOWS @@ -63,6 +64,13 @@ AsyncMIDIPort::~AsyncMIDIPort () } void +AsyncMIDIPort::set_timer (boost::function<framecnt_t (void)>& f) +{ + timer = f; + have_timer = true; +} + +void AsyncMIDIPort::flush_output_fifo (MIDI::pframes_t nframes) { RingBuffer< Evoral::Event<double> >::rw_vector vec = { { 0, 0 }, { 0, 0 } }; @@ -113,9 +121,18 @@ AsyncMIDIPort::cycle_start (MIDI::pframes_t nframes) if (ARDOUR::Port::receives_input()) { MidiBuffer& mb (get_midi_buffer (nframes)); - pframes_t when = AudioEngine::instance()->sample_time_at_cycle_start(); + framecnt_t when; + + if (have_timer) { + when = timer (); + } else { + when = AudioEngine::instance()->sample_time_at_cycle_start(); + } for (MidiBuffer::iterator b = mb.begin(); b != mb.end(); ++b) { + if (!have_timer) { + when += (*b).time(); + } input_fifo.write (when, (Evoral::EventType) 0, (*b).size(), (*b).buffer()); } |