diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index 681d5ba569..a90f4730cb 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -160,6 +160,7 @@ class LIBARDOUR_API Trigger : public PBD::Stateful { void set_region_internal (boost::shared_ptr); void request_state (State s); virtual void retrigger() = 0; + virtual void set_usable_length () = 0; }; class LIBARDOUR_API AudioTrigger : public Trigger { @@ -177,6 +178,7 @@ class LIBARDOUR_API AudioTrigger : public Trigger { protected: void retrigger (); + void set_usable_length (); private: std::vector data; diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 728b5a3da8..714f0a0cdb 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -69,6 +69,8 @@ void Trigger::set_launch_style (LaunchStyle l) { _launch_style = l; + + set_usable_length (); } XMLNode& @@ -87,6 +89,7 @@ void Trigger::set_quantization (Temporal::BBT_Offset const & q) { _quantization = q; + set_usable_length (); } void @@ -414,6 +417,32 @@ AudioTrigger::set_length (timecnt_t const & newlen) } } +void +AudioTrigger::set_usable_length () +{ + if (!_region) { + return; + } + + switch (_launch_style) { + case Repeat: + break; + default: + usable_length = data_length; + return; + } + + if (_quantization == Temporal::BBT_Offset ()) { + usable_length = data_length; + return; + } + + /* XXX MUST HANDLE BAR-LEVEL QUANTIZATION */ + + timecnt_t len (Temporal::Beats (_quantization.beats, _quantization.ticks), timepos_t (Temporal::Beats())); + usable_length = len.samples(); +} + timecnt_t AudioTrigger::current_length() const {