triggerbox: use follow length when quantizing re-start of Again-selected trigger
This also changes the virtual method from ::startup() to ::_startup() so that we can safely have a default argument in ::startup().
This commit is contained in:
parent
98cd0f1ba3
commit
d8c90decf3
|
@ -226,7 +226,7 @@ class LIBARDOUR_API Trigger : public PBD::Stateful {
|
|||
void set_legato (bool yn);
|
||||
bool legato () const { return _legato; }
|
||||
|
||||
virtual void startup ();
|
||||
void startup (Temporal::BBT_Offset const & start_quantization = Temporal::BBT_Offset ());
|
||||
virtual void shutdown (BufferSet& bufs, pframes_t dest_offset);
|
||||
virtual void jump_start ();
|
||||
virtual void jump_stop (BufferSet& bufs, pframes_t dest_offset);
|
||||
|
@ -319,12 +319,13 @@ class LIBARDOUR_API Trigger : public PBD::Stateful {
|
|||
double _barcnt; /* our estimate of the number of bars in the region */
|
||||
double _apparent_tempo;
|
||||
samplepos_t expected_end_sample;
|
||||
|
||||
Temporal::BBT_Offset _start_quantization;
|
||||
std::atomic<Trigger*> _pending;
|
||||
|
||||
void when_stopped_during_run (BufferSet& bufs, pframes_t dest_offset);
|
||||
void set_region_internal (boost::shared_ptr<Region>);
|
||||
virtual void retrigger() = 0;
|
||||
virtual void _startup (Temporal::BBT_Offset const &);
|
||||
};
|
||||
|
||||
typedef boost::shared_ptr<Trigger> TriggerPtr;
|
||||
|
@ -351,7 +352,6 @@ class LIBARDOUR_API AudioTrigger : public Trigger {
|
|||
double position_as_fraction() const;
|
||||
|
||||
int set_region_in_worker_thread (boost::shared_ptr<Region>);
|
||||
void startup ();
|
||||
void jump_start ();
|
||||
void jump_stop (BufferSet& bufs, pframes_t dest_offset);
|
||||
|
||||
|
@ -398,6 +398,7 @@ class LIBARDOUR_API AudioTrigger : public Trigger {
|
|||
int load_data (boost::shared_ptr<AudioRegion>);
|
||||
void determine_tempo ();
|
||||
void setup_stretcher ();
|
||||
void _startup (Temporal::BBT_Offset const &);
|
||||
};
|
||||
|
||||
|
||||
|
@ -423,7 +424,6 @@ class LIBARDOUR_API MIDITrigger : public Trigger {
|
|||
double position_as_fraction() const;
|
||||
|
||||
int set_region_in_worker_thread (boost::shared_ptr<Region>);
|
||||
void startup ();
|
||||
void jump_start ();
|
||||
void shutdown (BufferSet& bufs, pframes_t dest_offset);
|
||||
void jump_stop (BufferSet& bufs, pframes_t dest_offset);
|
||||
|
@ -455,9 +455,9 @@ class LIBARDOUR_API MIDITrigger : public Trigger {
|
|||
|
||||
int load_data (boost::shared_ptr<MidiRegion>);
|
||||
void compute_and_set_length ();
|
||||
void _startup (Temporal::BBT_Offset const &);
|
||||
};
|
||||
|
||||
|
||||
class LIBARDOUR_API TriggerBoxThread
|
||||
{
|
||||
public:
|
||||
|
|
|
@ -431,12 +431,28 @@ Trigger::request_stop ()
|
|||
}
|
||||
|
||||
void
|
||||
Trigger::startup()
|
||||
Trigger::startup (Temporal::BBT_Offset const & start_quantization)
|
||||
{
|
||||
/* This is just a non-virtual wrapper with a default parameter that calls _startup() */
|
||||
_startup (start_quantization);
|
||||
}
|
||||
|
||||
void
|
||||
Trigger::_startup (Temporal::BBT_Offset const & start_quantization)
|
||||
{
|
||||
_state = WaitingToStart;
|
||||
_loop_cnt = 0;
|
||||
_velocity_gain = _pending_velocity_gain;
|
||||
_explicitly_stopped = false;
|
||||
|
||||
if (start_quantization != Temporal::BBT_Offset()) {
|
||||
_start_quantization = start_quantization;
|
||||
} else {
|
||||
_start_quantization = _quantization;
|
||||
}
|
||||
|
||||
retrigger ();
|
||||
|
||||
DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1 starts up\n", name()));
|
||||
PropertyChanged (ARDOUR::Properties::running);
|
||||
}
|
||||
|
@ -605,7 +621,7 @@ Trigger::maybe_compute_next_transition (samplepos_t start_sample, Temporal::Beat
|
|||
TempoMap::SharedPtr tmap (TempoMap::use());
|
||||
Temporal::BBT_Time transition_bbt;
|
||||
pframes_t extra_offset = 0;
|
||||
BBT_Offset q (_quantization);
|
||||
BBT_Offset q (_start_quantization);
|
||||
|
||||
/* Clips don't stop on their own quantize; in Live they stop on the Global Quantize setting; we will choose 1 bar (Live's default) for now */
|
||||
#warning when Global Quantize is implemented, use that instead of '1 bar' here
|
||||
|
@ -811,10 +827,9 @@ AudioTrigger::get_segment_descriptor () const
|
|||
}
|
||||
|
||||
void
|
||||
AudioTrigger::startup ()
|
||||
AudioTrigger::_startup (Temporal::BBT_Offset const & start_quantization)
|
||||
{
|
||||
Trigger::startup ();
|
||||
retrigger ();
|
||||
Trigger::_startup (start_quantization);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1555,9 +1570,9 @@ AudioTrigger::reload (BufferSet&, void*)
|
|||
|
||||
MIDITrigger::MIDITrigger (uint32_t n, TriggerBox& b)
|
||||
: Trigger (n, b)
|
||||
, _start_offset (0, 0, 0)
|
||||
, data_length (Temporal::Beats())
|
||||
, last_event_beats (Temporal::Beats())
|
||||
, _start_offset (0, 0, 0)
|
||||
, _legato_offset (0, 0, 0)
|
||||
{
|
||||
}
|
||||
|
@ -1624,10 +1639,9 @@ MIDITrigger::get_segment_descriptor () const
|
|||
}
|
||||
|
||||
void
|
||||
MIDITrigger::startup ()
|
||||
MIDITrigger::_startup (Temporal::BBT_Offset const & start_quantization)
|
||||
{
|
||||
Trigger::startup ();
|
||||
retrigger ();
|
||||
Trigger::_startup (start_quantization);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -2734,6 +2748,7 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
|||
|
||||
if (_currently_playing->use_follow()) {
|
||||
int n = determine_next_trigger (_currently_playing->index());
|
||||
Temporal::BBT_Offset start_quantization;
|
||||
std::cerr << "dnt = " << n << endl;
|
||||
if (n < 0) {
|
||||
DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1 finished, no next trigger\n", _currently_playing->name()));
|
||||
|
@ -2741,9 +2756,14 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
|||
PropertyChanged (Properties::currently_playing);
|
||||
break; /* no triggers to come next, break out of nframes loop */
|
||||
}
|
||||
DEBUG_TRACE (DEBUG::Triggers, string_compose ("switching to next trigger %1\n", _currently_playing->name()));
|
||||
if (_currently_playing->index() == n) {
|
||||
start_quantization = _currently_playing->follow_length();
|
||||
DEBUG_TRACE (DEBUG::Triggers, string_compose ("switching to next trigger %1\n, will use start Q %2", all_triggers[n]->name(), _currently_playing->follow_length()));
|
||||
} else {
|
||||
DEBUG_TRACE (DEBUG::Triggers, string_compose ("switching to next trigger %1\n", all_triggers[n]->name()));
|
||||
}
|
||||
_currently_playing = all_triggers[n];
|
||||
_currently_playing->startup ();
|
||||
_currently_playing->startup (start_quantization);
|
||||
can_clear = true;
|
||||
PropertyChanged (Properties::currently_playing);
|
||||
} else {
|
||||
|
|
|
@ -240,6 +240,9 @@ struct LIBTEMPORAL_API BBT_Offset
|
|||
return bars != other.bars || beats != other.beats || ticks != other.ticks;
|
||||
}
|
||||
|
||||
operator bool() const {
|
||||
return bars == 0 && beats == 0 && ticks == 0;
|
||||
}
|
||||
};
|
||||
|
||||
inline BBT_Offset LIBTEMPORAL_API bbt_delta (Temporal::BBT_Time const & a, Temporal::BBT_Time const & b) {
|
||||
|
|
Loading…
Reference in New Issue