From 9d4a1f080db39fa4d3783717d145a75b54255201 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 12 Dec 2021 11:20:58 -0700 Subject: [PATCH] triggers: return a segment descriptor --- libs/ardour/ardour/triggerbox.h | 7 +++++++ libs/ardour/triggerbox.cc | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/libs/ardour/ardour/triggerbox.h b/libs/ardour/ardour/triggerbox.h index 1d287d834c..6e0e529e10 100644 --- a/libs/ardour/ardour/triggerbox.h +++ b/libs/ardour/ardour/triggerbox.h @@ -43,6 +43,7 @@ #include "ardour/midi_model.h" #include "ardour/midi_state_tracker.h" #include "ardour/processor.h" +#include "ardour/segment_descriptor.h" #include "ardour/libardour_visibility.h" @@ -223,6 +224,8 @@ class LIBARDOUR_API Trigger : public PBD::Stateful { double apparent_tempo() const { return _apparent_tempo; } double set_tempo (double t); + virtual SegmentDescriptor get_segment_descriptor () const = 0; + protected: struct UIRequests { std::atomic stop; @@ -288,6 +291,8 @@ class LIBARDOUR_API AudioTrigger : public Trigger { RubberBand::RubberBandStretcher* stretcher() { return (_stretcher); } + SegmentDescriptor get_segment_descriptor () const; + protected: void retrigger (); void set_usable_length (); @@ -343,6 +348,8 @@ class LIBARDOUR_API MIDITrigger : public Trigger { XMLNode& get_state (void); int set_state (const XMLNode&, int version); + SegmentDescriptor get_segment_descriptor () const; + protected: void retrigger (); void set_usable_length (); diff --git a/libs/ardour/triggerbox.cc b/libs/ardour/triggerbox.cc index 5db193cc38..8a4e7096c0 100644 --- a/libs/ardour/triggerbox.cc +++ b/libs/ardour/triggerbox.cc @@ -550,6 +550,17 @@ AudioTrigger::~AudioTrigger () delete _stretcher; } +SegmentDescriptor +AudioTrigger::get_segment_descriptor () const +{ + SegmentDescriptor sd; + + sd.set_extent (_start_offset, usable_length); + sd.set_tempo (Temporal::Tempo (_apparent_tempo, 4)); + + return sd; +} + void AudioTrigger::startup () { @@ -1133,6 +1144,21 @@ MIDITrigger::~MIDITrigger () { } +SegmentDescriptor +MIDITrigger::get_segment_descriptor () const +{ + SegmentDescriptor sd; + boost::shared_ptr mr = boost::dynamic_pointer_cast (_region); + assert (mr); + + sd.set_extent (Temporal::Beats(), mr->length().beats()); + + /* we don't really have tempo information for MIDI yet */ + sd.set_tempo (Temporal::Tempo (120, 4)); + + return sd; +} + void MIDITrigger::startup () {