X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fmidi_source.cc;h=d104fa79495f85e066d13c73897e2c3c63de6d8c;hb=47ba20143e06445a9977f4757d816439ea8042d0;hp=70364b684166f1e0acee9408c74413f85b376474;hpb=f1802667ba2251e1d963bb3434179235aef65739;p=ardour.git diff --git a/libs/ardour/midi_source.cc b/libs/ardour/midi_source.cc index 70364b6841..d104fa7949 100644 --- a/libs/ardour/midi_source.cc +++ b/libs/ardour/midi_source.cc @@ -48,7 +48,7 @@ #include "ardour/session_directory.h" #include "ardour/source_factory.h" -#include "i18n.h" +#include "pbd/i18n.h" namespace ARDOUR { template class MidiRingBuffer; } @@ -63,6 +63,7 @@ MidiSource::MidiSource (Session& s, string name, Source::Flag flags) , _writing(false) , _model_iter_valid(false) , _length_beats(0.0) + , _length_pulse(0.0) , _last_read_end(0) , _capture_length(0) , _capture_loop_length(0) @@ -74,6 +75,7 @@ MidiSource::MidiSource (Session& s, const XMLNode& node) , _writing(false) , _model_iter_valid(false) , _length_beats(0.0) + , _length_pulse(0.0) , _last_read_end(0) , _capture_length(0) , _capture_loop_length(0) @@ -191,110 +193,146 @@ MidiSource::midi_read (const Lock& lm, framepos_t source_start, framepos_t start, framecnt_t cnt, + Evoral::Range* loop_range, MidiStateTracker* tracker, MidiChannelFilter* filter, const std::set& filtered, - double beat, - double start_beat) const + const double pulse, + const double start_beats) const { //BeatsFramesConverter converter(_session.tempo_map(), source_start); + const int32_t tpb = Timecode::BBT_Time::ticks_per_beat; + const double pulse_tick_res = floor ((pulse * 4.0 * tpb) + 0.5) / tpb; + const double start_qn = (pulse * 4.0) - start_beats; DEBUG_TRACE (DEBUG::MidiSourceIO, string_compose ("MidiSource::midi_read() %5 sstart %1 start %2 cnt %3 tracker %4\n", source_start, start, cnt, tracker, name())); - if (_model) { - // Find appropriate model iterator - Evoral::Sequence::const_iterator& i = _model_iter; - const bool linear_read = _last_read_end != 0 && start == _last_read_end; - if (!linear_read || !_model_iter_valid) { + if (!_model) { + return read_unlocked (lm, dst, source_start, start, cnt, loop_range, tracker, filter); + } + + // Find appropriate model iterator + Evoral::Sequence::const_iterator& i = _model_iter; + const bool linear_read = _last_read_end != 0 && start == _last_read_end; + if (!linear_read || !_model_iter_valid) { #if 0 - // Cached iterator is invalid, search for the first event past start - i = _model->begin(converter.from(start), false, filtered, - linear_read ? &_model->active_notes() : NULL); - _model_iter_valid = true; - if (!linear_read) { - _model->active_notes().clear(); - } + // Cached iterator is invalid, search for the first event past start + i = _model->begin(converter.from(start), false, filtered, + linear_read ? &_model->active_notes() : NULL); + _model_iter_valid = true; + if (!linear_read) { + _model->active_notes().clear(); + } #else - /* hot-fix http://tracker.ardour.org/view.php?id=6541 - * "parallel playback of linked midi regions -> no note-offs" - * - * A midi source can be used by multiple tracks simultaneously, - * in which case midi_read() may be called from different tracks for - * overlapping time-ranges. - * - * However there is only a single iterator for a given midi-source. - * This results in every midi_read() performing a seek. - * - * If seeking is performed with - * _model->begin(converter.from(start),...) - * the model is used for seeking. That method seeks to the first - * *note-on* event after 'start'. - * - * _model->begin(converter.from( ) ,..) eventually calls - * Sequence