triggerbox: redesign around a state machine concept, and just iterating over current triggers, no queues

This commit is contained in:
Paul Davis 2021-08-08 19:08:16 -06:00
parent ceb0cb861e
commit 147ca2108f
5 changed files with 619 additions and 555 deletions

View File

@ -97,6 +97,7 @@ namespace PBD {
LIBARDOUR_API extern DebugBits TempoMap;
LIBARDOUR_API extern DebugBits TempoMath;
LIBARDOUR_API extern DebugBits Transport;
LIBARDOUR_API extern DebugBits Triggers;
LIBARDOUR_API extern DebugBits US2400;
LIBARDOUR_API extern DebugBits VCA;
LIBARDOUR_API extern DebugBits VST3Callbacks;

View File

@ -19,6 +19,7 @@
#ifndef __ardour_triggerbox_h__
#define __ardour_triggerbox_h__
#include <atomic>
#include <map>
#include <vector>
#include <string>
@ -52,15 +53,32 @@ class TriggerBox;
class LIBARDOUR_API Trigger : public PBD::Stateful {
public:
enum State {
None = 0, /* mostly for _requested_state */
Stopped = 1,
WaitingToStart = 2,
Running = 3,
WaitingToStop = 4,
Stopping = 5
};
Trigger (size_t index, TriggerBox&);
virtual ~Trigger() {}
static void make_property_quarks ();
virtual void bang (TriggerBox&) = 0;
virtual void unbang (TriggerBox&, Temporal::Beats const &, samplepos_t) = 0;
/* semantics of "bang" depend on the trigger */
void bang ();
void unbang ();
/* explicitly call for the trigger to stop */
virtual void stop();
/* explicitly call for the trigger to start */
virtual void start();
bool running() const { return _running; }
void process_state_requests ();
bool active() const { return _state >= Running; }
State state() const { return _state; }
enum LaunchStyle {
Loop, /* runs till stopped, reclick just restarts */
@ -96,10 +114,6 @@ class LIBARDOUR_API Trigger : public PBD::Stateful {
virtual timecnt_t current_length() const = 0;
virtual timecnt_t natural_length() const = 0;
bool stop_requested() const { return _stop_requested; }
virtual void stop();
virtual void retrigger () {}
size_t index() const { return _index; }
/* Managed by TriggerBox */
@ -117,10 +131,14 @@ class LIBARDOUR_API Trigger : public PBD::Stateful {
ChangeTriggers = 0x8
};
bool maybe_compute_start_or_stop (Temporal::Beats const & start, Temporal::Beats const & end);
protected:
TriggerBox& _box;
bool _running;
bool _stop_requested;
State _state;
std::atomic<State> _requested_state;
std::atomic<int> _bang;
std::atomic<int> _unbang;
size_t _index;
LaunchStyle _launch_style;
FollowAction _follow_action;
@ -128,6 +146,8 @@ class LIBARDOUR_API Trigger : public PBD::Stateful {
Temporal::BBT_Offset _quantization;
void set_region_internal (boost::shared_ptr<Region>);
void request_state (State s);
virtual void retrigger() = 0;
};
class LIBARDOUR_API AudioTrigger : public Trigger {
@ -135,9 +155,6 @@ class LIBARDOUR_API AudioTrigger : public Trigger {
AudioTrigger (size_t index, TriggerBox&);
~AudioTrigger ();
void bang (TriggerBox&);
void unbang (TriggerBox&, Temporal::Beats const & , samplepos_t);
RunResult run (AudioBuffer&, uint32_t channel, pframes_t& nframes, pframes_t offset, bool first);
void set_length (timecnt_t const &);
@ -145,6 +162,8 @@ class LIBARDOUR_API AudioTrigger : public Trigger {
timecnt_t natural_length() const;
int set_region (boost::shared_ptr<Region>);
protected:
void retrigger ();
private:

View File

@ -92,6 +92,7 @@ PBD::DebugBits PBD::DEBUG::TXLTC = PBD::new_debug_bit ("tx-ltc");
PBD::DebugBits PBD::DEBUG::TempoMap = PBD::new_debug_bit ("tempomap");
PBD::DebugBits PBD::DEBUG::TempoMath = PBD::new_debug_bit ("tempomath");
PBD::DebugBits PBD::DEBUG::Transport = PBD::new_debug_bit ("transport");
PBD::DebugBits PBD::DEBUG::Triggers = PBD::new_debug_bit ("triggers");
PBD::DebugBits PBD::DEBUG::US2400 = PBD::new_debug_bit ("us2400");
PBD::DebugBits PBD::DEBUG::VCA = PBD::new_debug_bit ("vca");
PBD::DebugBits PBD::DEBUG::VST3Callbacks = PBD::new_debug_bit ("VST3Callbacks");

View File

@ -47,6 +47,7 @@
#include "ardour/track.h"
#include "ardour/transport_fsm.h"
#include "ardour/transport_master.h"
#include "ardour/triggerbox.h"
#include "ardour/types.h"
using namespace std;
@ -154,7 +155,8 @@ setup_enum_writer ()
LoopFadeChoice _LoopFadeChooice;
TransportState _TransportState;
LocateTransportDisposition _LocateTransportDisposition;
Trigger::State _TriggerState;
#define REGISTER(e) enum_writer.register_distinct (typeid(e).name(), i, s); i.clear(); s.clear()
#define REGISTER_BITS(e) enum_writer.register_bits (typeid(e).name(), i, s); i.clear(); s.clear()
#define REGISTER_ENUM(e) i.push_back (e); s.push_back (#e)
@ -836,6 +838,14 @@ setup_enum_writer ()
REGISTER_ENUM (MustRoll);
REGISTER_ENUM (RollIfAppropriate);
REGISTER (_LocateTransportDisposition);
REGISTER_CLASS_ENUM (Trigger, None);
REGISTER_CLASS_ENUM (Trigger, Stopped);
REGISTER_CLASS_ENUM (Trigger, WaitingToStart);
REGISTER_CLASS_ENUM (Trigger, Running);
REGISTER_CLASS_ENUM (Trigger, WaitingToStop);
REGISTER_CLASS_ENUM (Trigger, Stopping);
REGISTER (_TriggerState);
}
} /* namespace ARDOUR */

File diff suppressed because it is too large Load Diff