Revert "modify API of MIDI Clock ticker to use ProcessedRange"
This reverts commit 720102f98a
.
This commit is contained in:
parent
328b4f2d1a
commit
909a2ad639
@ -299,7 +299,7 @@ public:
|
|||||||
void process (pframes_t nframes);
|
void process (pframes_t nframes);
|
||||||
|
|
||||||
void send_ltc_for_cycle (samplepos_t, samplepos_t, pframes_t);
|
void send_ltc_for_cycle (samplepos_t, samplepos_t, pframes_t);
|
||||||
void send_mclk_for_cycle (pframes_t, samplecnt_t);
|
void send_mclk_for_cycle (samplepos_t, samplepos_t, pframes_t, samplecnt_t);
|
||||||
|
|
||||||
BufferSet& get_silent_buffers (ChanCount count = ChanCount::ZERO);
|
BufferSet& get_silent_buffers (ChanCount count = ChanCount::ZERO);
|
||||||
BufferSet& get_noinplace_buffers (ChanCount count = ChanCount::ZERO);
|
BufferSet& get_noinplace_buffers (ChanCount count = ChanCount::ZERO);
|
||||||
|
@ -43,7 +43,7 @@ public:
|
|||||||
MidiClockTicker (Session&);
|
MidiClockTicker (Session&);
|
||||||
virtual ~MidiClockTicker ();
|
virtual ~MidiClockTicker ();
|
||||||
|
|
||||||
void tick (ProcessedRanges const &, pframes_t, samplecnt_t);
|
void tick (samplepos_t, samplepos_t, pframes_t, samplecnt_t);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ARDOUR::Session& _session;
|
ARDOUR::Session& _session;
|
||||||
@ -59,7 +59,6 @@ private:
|
|||||||
void reset ();
|
void reset ();
|
||||||
void resync_latency (bool);
|
void resync_latency (bool);
|
||||||
double one_ppqn_in_samples (samplepos_t transport_position) const;
|
double one_ppqn_in_samples (samplepos_t transport_position) const;
|
||||||
void sub_tick (samplepos_t start, samplepos_t end, pframes_t n_samples, samplecnt_t& pre_roll, double speed);
|
|
||||||
|
|
||||||
void send_midi_clock_event (pframes_t offset, pframes_t nframes);
|
void send_midi_clock_event (pframes_t offset, pframes_t nframes);
|
||||||
void send_start_event (pframes_t offset, pframes_t nframes);
|
void send_start_event (pframes_t offset, pframes_t nframes);
|
||||||
|
@ -558,10 +558,9 @@ AudioEngine::process_callback (pframes_t nframes)
|
|||||||
|
|
||||||
/* send timecode for current cycle */
|
/* send timecode for current cycle */
|
||||||
samplepos_t end_sample = _session->transport_sample ();
|
samplepos_t end_sample = _session->transport_sample ();
|
||||||
|
|
||||||
_session->send_ltc_for_cycle (start_sample, end_sample, nframes);
|
_session->send_ltc_for_cycle (start_sample, end_sample, nframes);
|
||||||
/* and MIDI Clock */
|
/* and MIDI Clock */
|
||||||
_session->send_mclk_for_cycle (nframes, pre_roll);
|
_session->send_mclk_for_cycle (start_sample, end_sample, nframes, pre_roll);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_freewheeling) {
|
if (_freewheeling) {
|
||||||
|
@ -7563,9 +7563,9 @@ Session::maybe_update_tempo_from_midiclock_tempo (float bpm)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
Session::send_mclk_for_cycle (pframes_t n_samples, samplecnt_t pre_roll)
|
Session::send_mclk_for_cycle (samplepos_t start_sample, samplepos_t end_sample, pframes_t n_samples, samplecnt_t pre_roll)
|
||||||
{
|
{
|
||||||
midi_clock->tick (processed_ranges, n_samples, pre_roll);
|
midi_clock->tick (start_sample, end_sample, n_samples, pre_roll);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -178,7 +178,6 @@ Session::locate (samplepos_t target_sample, bool for_loop_end, bool force, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool need_butler = false;
|
bool need_butler = false;
|
||||||
samplepos_t existing = _transport_sample;
|
|
||||||
|
|
||||||
/* Locates for seamless looping are fairly different from other
|
/* Locates for seamless looping are fairly different from other
|
||||||
* locates. They assume that the diskstream buffers for each track
|
* locates. They assume that the diskstream buffers for each track
|
||||||
|
@ -35,7 +35,6 @@
|
|||||||
#include "ardour/session.h"
|
#include "ardour/session.h"
|
||||||
#include "ardour/tempo.h"
|
#include "ardour/tempo.h"
|
||||||
#include "ardour/ticker.h"
|
#include "ardour/ticker.h"
|
||||||
#include "ardour/transport_fsm.h"
|
|
||||||
|
|
||||||
using namespace ARDOUR;
|
using namespace ARDOUR;
|
||||||
using namespace PBD;
|
using namespace PBD;
|
||||||
@ -61,7 +60,6 @@ MidiClockTicker::~MidiClockTicker ()
|
|||||||
void
|
void
|
||||||
MidiClockTicker::reset ()
|
MidiClockTicker::reset ()
|
||||||
{
|
{
|
||||||
DEBUG_TRACE (DEBUG::MidiClock, "reset!\n");
|
|
||||||
_rolling = false;
|
_rolling = false;
|
||||||
_next_tick = 0;
|
_next_tick = 0;
|
||||||
_beat_pos = 0;
|
_beat_pos = 0;
|
||||||
@ -81,43 +79,22 @@ MidiClockTicker::resync_latency (bool playback)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
MidiClockTicker::tick (ProcessedRanges const & pr, pframes_t n_samples, samplecnt_t pre_roll)
|
MidiClockTicker::tick (samplepos_t start_sample, samplepos_t end_sample, pframes_t n_samples, samplecnt_t pre_roll)
|
||||||
{
|
{
|
||||||
DEBUG_TRACE (DEBUG::MidiClock, string_compose ("tick for %1 ranges (%2) w/preroll %3\n", pr.cnt, n_samples, pre_roll));
|
/* silence buffer */
|
||||||
|
|
||||||
const pframes_t full_nsamples = n_samples;
|
|
||||||
samplecnt_t total = pr.end[0] - pr.start[0];
|
|
||||||
|
|
||||||
if (pr.cnt > 1) {
|
|
||||||
total += pr.end[1] - pr.start[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
const double speed = total / n_samples;
|
|
||||||
|
|
||||||
_midi_port->cycle_start (n_samples);
|
_midi_port->cycle_start (n_samples);
|
||||||
|
|
||||||
/* If told not to send, or we're not moving, or we're moving backwards,
|
double speed = (end_sample - start_sample) / (double)n_samples;
|
||||||
* ensure we have sent a stop message, reset and be done.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (!Config->get_send_midi_clock () || pr.start[0] == pr.end[0] || pr.end[0] < pr.start[0]) { /*|| !TransportMasterManager::instance().current()*/
|
if (!Config->get_send_midi_clock () /*|| !TransportMasterManager::instance().current()*/) {
|
||||||
if (_rolling) {
|
if (_rolling) {
|
||||||
send_stop_event (0, n_samples);
|
send_stop_event (0, n_samples);
|
||||||
DEBUG_TRACE (DEBUG::MidiClock, "stopped sending!\n");
|
|
||||||
}
|
}
|
||||||
DEBUG_TRACE (DEBUG::MidiClock, "not sending!\n");
|
|
||||||
reset ();
|
reset ();
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
n_samples -= pr.end[0] - pr.start[0];
|
if (speed == 0 && start_sample == 0 && end_sample == 0) {
|
||||||
|
|
||||||
/* Special case code for "pre-roll ends during this call, and position
|
|
||||||
* is zero
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ((speed == 0) && (pr.start[0] == 0)) {
|
|
||||||
|
|
||||||
/* test if pre-roll is active, special-case
|
/* test if pre-roll is active, special-case
|
||||||
* "start at zero"
|
* "start at zero"
|
||||||
*/
|
*/
|
||||||
@ -168,59 +145,26 @@ MidiClockTicker::tick (ProcessedRanges const & pr, pframes_t n_samples, samplecn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (speed == 0) {
|
if (speed != 1.0) {
|
||||||
|
if (_rolling) {
|
||||||
|
DEBUG_TRACE (DEBUG::MidiClock, string_compose ("Speed != 1 - Stop @ cycle: 1 .. %2 (- preroll %3) nsamples: %4\n",
|
||||||
|
start_sample, end_sample, end_sample, pre_roll, n_samples));
|
||||||
|
send_stop_event (0, n_samples);
|
||||||
|
}
|
||||||
|
reset ();
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub_tick (pr.start[0], pr.end[0], n_samples, pre_roll, speed);
|
/* test for discontinuity */
|
||||||
|
if (start_sample != _transport_pos) {
|
||||||
if (pr.cnt > 1) {
|
if (_rolling) {
|
||||||
|
DEBUG_TRACE (DEBUG::MidiClock, string_compose ("Discontinuty start_sample: %1 ticker-pos: %2\n", start_sample, _transport_pos));
|
||||||
/* we located for the end of a loop, so notify the receiver
|
send_stop_event (0, n_samples);
|
||||||
* appropriately. If we located back to zero, treat that as a
|
|
||||||
* special case.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (pr.start[1] == 0) {
|
|
||||||
send_start_event (0, n_samples);
|
|
||||||
} else {
|
|
||||||
|
|
||||||
uint32_t beat_pos;
|
|
||||||
samplepos_t clk_pos;
|
|
||||||
|
|
||||||
Temporal::TempoMap::use()->midi_clock_beat_at_or_after (pr.start[1] + _mclk_out_latency.max, clk_pos, beat_pos);
|
|
||||||
|
|
||||||
_beat_pos = beat_pos;
|
|
||||||
_next_tick = clk_pos - _mclk_out_latency.max;
|
|
||||||
|
|
||||||
send_position_event (_beat_pos, 0, n_samples); // consider sending this early
|
|
||||||
send_continue_event (_next_tick - pr.start[1], n_samples);
|
|
||||||
}
|
}
|
||||||
|
_rolling = false;
|
||||||
sub_tick (pr.start[1], pr.end[1], n_samples, pre_roll, speed);
|
_transport_pos = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
_transport_pos = pr.end[pr.cnt - 1];
|
|
||||||
|
|
||||||
out:
|
|
||||||
_midi_port->flush_buffers (full_nsamples);
|
|
||||||
_midi_port->cycle_end (full_nsamples);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* start_sanple .. end_sample is guaranteed to represent a single continuous,
|
|
||||||
* advancing time range.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
void
|
|
||||||
MidiClockTicker::sub_tick (samplepos_t start_sample, samplepos_t end_sample, pframes_t n_samples, samplecnt_t& pre_roll, double speed)
|
|
||||||
{
|
|
||||||
DEBUG_TRACE (DEBUG::MidiClock, string_compose ("sub-tick for %1 .. %2 (%3) w/preroll %4\n", start_sample, end_sample, n_samples, pre_roll));
|
|
||||||
|
|
||||||
/* silence buffer */
|
|
||||||
|
|
||||||
if (!_rolling) {
|
if (!_rolling) {
|
||||||
if (_transport_pos < 0 || _next_tick < start_sample) {
|
if (_transport_pos < 0 || _next_tick < start_sample) {
|
||||||
/* get the next downbeat */
|
/* get the next downbeat */
|
||||||
@ -231,52 +175,51 @@ MidiClockTicker::sub_tick (samplepos_t start_sample, samplepos_t end_sample, pfr
|
|||||||
|
|
||||||
_beat_pos = beat_pos;
|
_beat_pos = beat_pos;
|
||||||
_next_tick = clk_pos - _mclk_out_latency.max;
|
_next_tick = clk_pos - _mclk_out_latency.max;
|
||||||
|
_transport_pos = end_sample;
|
||||||
|
}
|
||||||
|
|
||||||
if (_next_tick >= start_sample && _next_tick < end_sample) {
|
if (_next_tick >= start_sample && _next_tick < end_sample) {
|
||||||
DEBUG_TRACE (DEBUG::MidiClock, string_compose ("Start rolling at %1 beat-pos: %2\n", _next_tick, _beat_pos));
|
DEBUG_TRACE (DEBUG::MidiClock, string_compose ("Start rolling at %1 beat-pos: %2\n", _next_tick, _beat_pos));
|
||||||
|
|
||||||
_rolling = true;
|
_rolling = true;
|
||||||
_clock_cnt = 0;
|
|
||||||
|
|
||||||
if (_beat_pos == 0 && _next_tick == 0 && start_sample == 0) {
|
|
||||||
send_start_event (0, n_samples);
|
|
||||||
} else {
|
|
||||||
send_position_event (_beat_pos, 0, n_samples); // consider sending this early
|
|
||||||
send_continue_event (_next_tick - start_sample, n_samples);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
_rolling = true;
|
|
||||||
_clock_cnt = 0;
|
_clock_cnt = 0;
|
||||||
|
|
||||||
DEBUG_TRACE (DEBUG::MidiClock, string_compose ("next tick reset to %1 from %2 + %3 & %4\n", _next_tick, start_sample, _mclk_out_latency.max, clk_pos));
|
if (_beat_pos == 0 && _next_tick == 0 && start_sample == 0) {
|
||||||
|
send_start_event (0, n_samples);
|
||||||
|
} else {
|
||||||
|
send_position_event (_beat_pos, 0, n_samples); // consider sending this early
|
||||||
|
send_continue_event (_next_tick - start_sample, n_samples);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (_next_tick >= start_sample && _next_tick < end_sample) {
|
assert (_rolling);
|
||||||
|
|
||||||
|
while (_next_tick >= start_sample && _next_tick < end_sample) {
|
||||||
DEBUG_TRACE (DEBUG::MidiClock, string_compose ("Tick @ %1 cycle: %2 .. %3 nsamples: %4, ticker-pos: %5\n",
|
DEBUG_TRACE (DEBUG::MidiClock, string_compose ("Tick @ %1 cycle: %2 .. %3 nsamples: %4, ticker-pos: %5\n",
|
||||||
_next_tick, start_sample, end_sample, n_samples, _transport_pos));
|
_next_tick, start_sample, end_sample, n_samples, _transport_pos));
|
||||||
send_midi_clock_event (_next_tick - start_sample, n_samples);
|
send_midi_clock_event (_next_tick - start_sample, n_samples);
|
||||||
|
|
||||||
if (++_clock_cnt == 6) {
|
if (++_clock_cnt == 6) {
|
||||||
_clock_cnt = 0;
|
_clock_cnt = 0;
|
||||||
++_beat_pos;
|
++_beat_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
_next_tick += one_ppqn_in_samples (llrint (_next_tick));
|
_next_tick += one_ppqn_in_samples (llrint (_next_tick));
|
||||||
}
|
}
|
||||||
|
|
||||||
pre_roll -= end_sample - start_sample;
|
_transport_pos = end_sample;
|
||||||
|
|
||||||
|
out:
|
||||||
|
_midi_port->flush_buffers (n_samples);
|
||||||
|
_midi_port->cycle_end (n_samples);
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
MidiClockTicker::one_ppqn_in_samples (samplepos_t transport_position) const
|
MidiClockTicker::one_ppqn_in_samples (samplepos_t transport_position) const
|
||||||
{
|
{
|
||||||
Tempo const & tempo (TempoMap::use()->metric_at (transport_position).tempo());
|
Tempo const & tempo (TempoMap::use()->metric_at (transport_position).tempo());
|
||||||
const double samples_per_quarter_note = tempo.samples_per_quarter_note (_session.nominal_sample_rate());
|
const double samples_per_quarter_note = tempo.samples_per_quarter_note (_session->nominal_sample_rate());
|
||||||
return samples_per_quarter_note / 24.0;
|
return samples_per_quarter_note / 24.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user