From 563dc9ae21d849b59aeabae1d90cfaf466bedaae Mon Sep 17 00:00:00 2001 From: Ben Loftis Date: Sat, 12 Feb 2022 11:12:08 -0600 Subject: [PATCH] triggerbox: setup_stretcher must be called for stretch_mode to have any effect --- libs/ardour/ardour/triggerbox.h | 8 ++++++-- libs/ardour/triggerbox.cc | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index 9aa168223d..6e57c2095a 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -336,6 +336,8 @@ class LIBARDOUR_API Trigger : public PBD::Stateful { virtual double segment_tempo() const = 0; virtual void set_segment_tempo (double t) = 0; + virtual void setup_stretcher () = 0; + Temporal::Meter meter() const { return _meter; } void set_velocity_gain (gain_t g) {_pending_velocity_gain=g;} @@ -492,10 +494,11 @@ class LIBARDOUR_API AudioTrigger : public Trigger { samplecnt_t to_pad; samplecnt_t to_drop; + virtual void setup_stretcher (); + void drop_data (); int load_data (boost::shared_ptr); void estimate_tempo (); - void setup_stretcher (); void reset_stretcher (); void _startup (BufferSet&, pframes_t dest_offset, Temporal::BBT_Offset const &); }; @@ -546,9 +549,10 @@ class LIBARDOUR_API MIDITrigger : public Trigger { bool patch_change_set (uint8_t channel) const; /* theoretically, MIDI files can have a dedicated tempo outside the session tempo map (*un-stretched*) but this is currently unimplemented */ - /* boilerplate tempo functions are provided here so we don't have to do constant dynamic_cast checks to use the tempo API */ + /* boilerplate tempo functions are provided here so we don't have to do constant dynamic_cast checks to use the tempo+stretch APIs */ virtual double segment_tempo() const {return 120.0;} virtual void set_segment_tempo (double t) {} + virtual void setup_stretcher () {} void set_channel_map (int channel, int target); void unset_channel_map (int channel); diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index b2ee751348..9b73f8356b 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -265,6 +265,8 @@ Trigger::update_properties () while ((g = ui_state.generation.load()) != last_property_generation) { + StretchMode old_stretch = _stretch_mode; + std::cerr << "prop copy for " << index() << endl; _launch_style = ui_state.launch_style; @@ -283,6 +285,13 @@ Trigger::update_properties () _stretch_mode = ui_state.stretch_mode; _color = ui_state.color; + /* @paul: is this safe to do here ?*/ + /* the UI only allows changing stretch_mode when the clip is stopped, + * and you can't d+d or create a new clip while it's playing, so I think it's OK */ + if (_stretch_mode != old_stretch) { + setup_stretcher (); + } + /* during construction of a new trigger, the ui_state.name is initialized and queued * ...but in the interim, we have likely been assigned a name from a region in a separate thread * ...so don't overwrite our name if ui_state.name is empty