move RecordState enum from ARDOUR::Session to ARDOUR so we can use it in TriggerBox (libs)

This commit is contained in:
Paul Davis 2024-09-30 16:04:12 -06:00
parent 90858279bc
commit d7d208dc34
15 changed files with 49 additions and 55 deletions

View file

@ -211,12 +211,6 @@ class LIBARDOUR_API Session : public PBD::HistoryOwner,
public Temporal::TimeDomainProvider public Temporal::TimeDomainProvider
{ {
public: public:
enum RecordState {
Disabled = 0,
Enabled = 1,
Recording = 2
};
/* a new session might have non-empty mix_template, an existing session should always have an empty one. /* a new session might have non-empty mix_template, an existing session should always have an empty one.
the bus profile can be null if no master out bus is required. the bus profile can be null if no master out bus is required.
*/ */

View file

@ -799,7 +799,7 @@ class LIBARDOUR_API TriggerBox : public Processor, public std::enable_shared_fro
static PBD::Signal0<void> CueRecordingChanged; static PBD::Signal0<void> CueRecordingChanged;
void set_record_enabled (bool yn); void set_record_enabled (bool yn);
bool record_enabled() const { return _record_enabled; } RecordState record_enabled() const { return _record_state; }
PBD::Signal0<void> RecEnableChanged; PBD::Signal0<void> RecEnableChanged;
void arm_from_another_thread (Trigger& slot, samplepos_t, uint32_t chans); void arm_from_another_thread (Trigger& slot, samplepos_t, uint32_t chans);
@ -955,7 +955,7 @@ class LIBARDOUR_API TriggerBox : public Processor, public std::enable_shared_fro
bool _locate_armed; bool _locate_armed;
bool _cancel_locate_armed; bool _cancel_locate_armed;
bool _fast_forwarding; bool _fast_forwarding;
bool _record_enabled; RecordState _record_state;
PBD::PCGRand _pcg; PBD::PCGRand _pcg;
@ -1019,8 +1019,6 @@ class LIBARDOUR_API TriggerBox : public Processor, public std::enable_shared_fro
PBD::ScopedConnection stop_all_connection; PBD::ScopedConnection stop_all_connection;
std::atomic<SlotArmInfo*> _arm_info; std::atomic<SlotArmInfo*> _arm_info;
static TriggerBox* currently_recording;
typedef std::map<std::vector<uint8_t>,std::pair<int,int> > CustomMidiMap; typedef std::map<std::vector<uint8_t>,std::pair<int,int> > CustomMidiMap;
static CustomMidiMap _custom_midi_map; static CustomMidiMap _custom_midi_map;

View file

@ -984,6 +984,13 @@ enum SelectionOperation {
SelectionExtend /* UI only operation, not core */ SelectionExtend /* UI only operation, not core */
}; };
enum RecordState {
Disabled = 0,
Enabled = 1,
Recording = 2
};
} // namespace ARDOUR } // namespace ARDOUR
/* for now, break the rules and use "using" to make this "global" */ /* for now, break the rules and use "using" to make this "global" */

View file

@ -102,7 +102,7 @@ setup_enum_writer ()
SyncSource _SyncSource; SyncSource _SyncSource;
TransportRequestType _TransportRequestType; TransportRequestType _TransportRequestType;
ShuttleUnits _ShuttleUnits; ShuttleUnits _ShuttleUnits;
Session::RecordState _Session_RecordState; RecordState _RecordState;
SessionEvent::Type _SessionEvent_Type; SessionEvent::Type _SessionEvent_Type;
SessionEvent::Action _SessionEvent_Action; SessionEvent::Action _SessionEvent_Action;
TimecodeFormat _Session_TimecodeFormat; TimecodeFormat _Session_TimecodeFormat;
@ -471,10 +471,10 @@ setup_enum_writer ()
REGISTER_ENUM (Semitones); REGISTER_ENUM (Semitones);
REGISTER (_ShuttleUnits); REGISTER (_ShuttleUnits);
REGISTER_CLASS_ENUM (Session, Disabled); REGISTER_ENUM (Disabled);
REGISTER_CLASS_ENUM (Session, Enabled); REGISTER_ENUM (Enabled);
REGISTER_CLASS_ENUM (Session, Recording); REGISTER_ENUM (Recording);
REGISTER (_Session_RecordState); REGISTER (_RecordState);
REGISTER_CLASS_ENUM (SessionEvent, SetTransportSpeed); REGISTER_CLASS_ENUM (SessionEvent, SetTransportSpeed);
REGISTER_CLASS_ENUM (SessionEvent, SetDefaultPlaySpeed); REGISTER_CLASS_ENUM (SessionEvent, SetDefaultPlaySpeed);

View file

@ -3162,9 +3162,9 @@ LuaBindings::common (lua_State* L)
.beginNamespace ("Session") .beginNamespace ("Session")
.beginNamespace ("RecordState") .beginNamespace ("RecordState")
.addConst ("Disabled", ARDOUR::Session::RecordState(Session::Disabled)) .addConst ("Disabled", ARDOUR::RecordState(ARDOUR::Disabled))
.addConst ("Enabled", ARDOUR::Session::RecordState(Session::Enabled)) .addConst ("Enabled", ARDOUR::RecordState(ARDOUR::Enabled))
.addConst ("Recording", ARDOUR::Session::RecordState(Session::Recording)) .addConst ("Recording", ARDOUR::RecordState(ARDOUR::Recording))
.endNamespace () .endNamespace ()
.endNamespace () // end Session enums .endNamespace () // end Session enums

View file

@ -780,7 +780,7 @@ MidiTrack::MidiControl::actually_set_value (double val, PBD::Controllable::Group
void void
MidiTrack::set_step_editing (bool yn) MidiTrack::set_step_editing (bool yn)
{ {
if (_session.record_status() != Session::Disabled) { if (_session.record_status() != Disabled) {
return; return;
} }

View file

@ -3433,7 +3433,6 @@ CueRecords TriggerBox::cue_records (256);
std::atomic<bool> TriggerBox::_cue_recording (false); std::atomic<bool> TriggerBox::_cue_recording (false);
PBD::Signal0<void> TriggerBox::CueRecordingChanged; PBD::Signal0<void> TriggerBox::CueRecordingChanged;
bool TriggerBox::roll_requested = false; bool TriggerBox::roll_requested = false;
TriggerBox* TriggerBox::currently_recording (nullptr);
bool TriggerBox::_learning = false; bool TriggerBox::_learning = false;
TriggerBox::CustomMidiMap TriggerBox::_custom_midi_map; TriggerBox::CustomMidiMap TriggerBox::_custom_midi_map;
std::pair<int,int> TriggerBox::learning_for; std::pair<int,int> TriggerBox::learning_for;
@ -3490,7 +3489,7 @@ TriggerBox::TriggerBox (Session& s, DataType dt)
, _locate_armed (false) , _locate_armed (false)
, _cancel_locate_armed (false) , _cancel_locate_armed (false)
, _fast_forwarding (false) , _fast_forwarding (false)
, _record_enabled (false) , _record_state (Disabled)
, requests (1024) , requests (1024)
, _arm_info (nullptr) , _arm_info (nullptr)
{ {
@ -3547,12 +3546,8 @@ TriggerBox::arm_from_another_thread (Trigger& slot, samplepos_t now, uint32_t ch
ai->start = t_samples; ai->start = t_samples;
if (currently_recording) {
currently_recording->disarm ();
currently_recording = nullptr;
}
_arm_info = ai; _arm_info = ai;
_record_state = Enabled;
} }
void void
@ -3567,7 +3562,7 @@ TriggerBox::finish_recording (BufferSet& bufs)
assert (ai); assert (ai);
ai->slot.captured (*ai, bufs); ai->slot.captured (*ai, bufs);
_arm_info = nullptr; _arm_info = nullptr;
currently_recording = nullptr; _record_state = Disabled;
} }
void void
@ -3584,7 +3579,7 @@ TriggerBox::maybe_capture (BufferSet& bufs, samplepos_t start_sample, samplepos_
pframes_t offset = 0; pframes_t offset = 0;
bool reached_end = false; bool reached_end = false;
if (!ai->slot.armed() && (currently_recording == this)) { if (!ai->slot.armed()) {
if (!ai->end) { if (!ai->end) {
/* disarmed: compute end */ /* disarmed: compute end */
Beats start_b; Beats start_b;
@ -3602,7 +3597,7 @@ TriggerBox::maybe_capture (BufferSet& bufs, samplepos_t start_sample, samplepos_
} }
} }
if (speed == 0. && currently_recording == this) { if (speed == 0.) {
/* We stopped the transport, so just stop immediately (no quantization) */ /* We stopped the transport, so just stop immediately (no quantization) */
finish_recording (bufs); finish_recording (bufs);
return; return;
@ -3626,7 +3621,7 @@ TriggerBox::maybe_capture (BufferSet& bufs, samplepos_t start_sample, samplepos_
/* Let's get going */ /* Let's get going */
offset = ai->start.samples() - start_sample; offset = ai->start.samples() - start_sample;
nframes -= offset; nframes -= offset;
currently_recording = this; _record_state = Recording;
} }
if ((ai->end.samples() != 0) && (start_sample <= ai->end.samples() && ai->end.samples() < end_sample)) { if ((ai->end.samples() != 0) && (start_sample <= ai->end.samples() && ai->end.samples() < end_sample)) {
@ -3691,7 +3686,7 @@ TriggerBox::maybe_capture (BufferSet& bufs, samplepos_t start_sample, samplepos_
void void
TriggerBox::set_record_enabled (bool yn) TriggerBox::set_record_enabled (bool yn)
{ {
_record_enabled = yn; _record_state = yn ? Enabled : Disabled;
RecEnableChanged (); /* EMIT SIGNAL */ RecEnableChanged (); /* EMIT SIGNAL */
} }

View file

@ -369,7 +369,7 @@ void
BasicUI::rec_enable_toggle () BasicUI::rec_enable_toggle ()
{ {
switch (session->record_status()) { switch (session->record_status()) {
case Session::Disabled: case Disabled:
if (session->ntracks() == 0) { if (session->ntracks() == 0) {
// string txt = _("Please create 1 or more track\nbefore trying to record.\nCheck the Session menu."); // string txt = _("Please create 1 or more track\nbefore trying to record.\nCheck the Session menu.");
// MessageDialog msg (*editor, txt); // MessageDialog msg (*editor, txt);
@ -378,8 +378,8 @@ BasicUI::rec_enable_toggle ()
} }
session->maybe_enable_record (); session->maybe_enable_record ();
break; break;
case Session::Recording: case Recording:
case Session::Enabled: case Enabled:
session->disable_record (false, true); session->disable_record (false, true);
} }
} }

View file

@ -631,13 +631,13 @@ CC121::map_recenable_state ()
bool onoff; bool onoff;
switch (session->record_status()) { switch (session->record_status()) {
case Session::Disabled: case Disabled:
onoff = false; onoff = false;
break; break;
case Session::Enabled: case Enabled:
onoff = blink_state; onoff = blink_state;
break; break;
case Session::Recording: case Recording:
if (session->have_rec_enabled_track ()) { if (session->have_rec_enabled_track ()) {
onoff = true; onoff = true;
} else { } else {

View file

@ -505,13 +505,13 @@ FaderPort::map_recenable_state ()
bool onoff; bool onoff;
switch (session->record_status()) { switch (session->record_status()) {
case Session::Disabled: case Disabled:
onoff = false; onoff = false;
break; break;
case Session::Enabled: case Enabled:
onoff = blink_state; onoff = blink_state;
break; break;
case Session::Recording: case Recording:
if (session->have_rec_enabled_track ()) { if (session->have_rec_enabled_track ()) {
onoff = true; onoff = true;
} else { } else {

View file

@ -149,15 +149,15 @@ void
FaderPort8::notify_record_state_changed () FaderPort8::notify_record_state_changed ()
{ {
switch (session->record_status ()) { switch (session->record_status ()) {
case Session::Disabled: case Disabled:
_ctrls.button (FP8Controls::BtnRecord).set_active (0); _ctrls.button (FP8Controls::BtnRecord).set_active (0);
_ctrls.button (FP8Controls::BtnRecord).set_blinking (false); _ctrls.button (FP8Controls::BtnRecord).set_blinking (false);
break; break;
case Session::Enabled: case Enabled:
_ctrls.button (FP8Controls::BtnRecord).set_active (true); _ctrls.button (FP8Controls::BtnRecord).set_active (true);
_ctrls.button (FP8Controls::BtnRecord).set_blinking (true); _ctrls.button (FP8Controls::BtnRecord).set_blinking (true);
break; break;
case Session::Recording: case Recording:
_ctrls.button (FP8Controls::BtnRecord).set_active (true); _ctrls.button (FP8Controls::BtnRecord).set_active (true);
_ctrls.button (FP8Controls::BtnRecord).set_blinking (false); _ctrls.button (FP8Controls::BtnRecord).set_blinking (false);
break; break;

View file

@ -1413,15 +1413,15 @@ MackieControlProtocol::notify_record_state_changed ()
LedState ls; LedState ls;
switch (session->record_status()) { switch (session->record_status()) {
case Session::Disabled: case Disabled:
DEBUG_TRACE (DEBUG::MackieControl, "record state changed to disabled, LED off\n"); DEBUG_TRACE (DEBUG::MackieControl, "record state changed to disabled, LED off\n");
ls = off; ls = off;
break; break;
case Session::Recording: case Recording:
DEBUG_TRACE (DEBUG::MackieControl, "record state changed to recording, LED on\n"); DEBUG_TRACE (DEBUG::MackieControl, "record state changed to recording, LED on\n");
ls = on; ls = on;
break; break;
case Session::Enabled: case Enabled:
if(_device_info.is_qcon()){ if(_device_info.is_qcon()){
// For qcon the rec button is two state only (on/off) // For qcon the rec button is two state only (on/off)

View file

@ -109,15 +109,15 @@ void
Maschine2::notify_record_state_changed () Maschine2::notify_record_state_changed ()
{ {
switch (session->record_status ()) { switch (session->record_status ()) {
case Session::Disabled: case Disabled:
_ctrl->button (M2Contols::Rec)->set_color (0); _ctrl->button (M2Contols::Rec)->set_color (0);
_ctrl->button (M2Contols::Rec)->set_blinking (false); _ctrl->button (M2Contols::Rec)->set_blinking (false);
break; break;
case Session::Enabled: case Enabled:
_ctrl->button (M2Contols::Rec)->set_color (COLOR_WHITE); _ctrl->button (M2Contols::Rec)->set_color (COLOR_WHITE);
_ctrl->button (M2Contols::Rec)->set_blinking (true); _ctrl->button (M2Contols::Rec)->set_blinking (true);
break; break;
case Session::Recording: case Recording:
_ctrl->button (M2Contols::Rec)->set_color (COLOR_WHITE); _ctrl->button (M2Contols::Rec)->set_color (COLOR_WHITE);
_ctrl->button (M2Contols::Rec)->set_blinking (false); _ctrl->button (M2Contols::Rec)->set_blinking (false);
break; break;

View file

@ -736,15 +736,15 @@ Push2::notify_record_state_changed ()
} }
switch (session->record_status ()) { switch (session->record_status ()) {
case Session::Disabled: case Disabled:
b->second->set_color (LED::White); b->second->set_color (LED::White);
b->second->set_state (LED::NoTransition); b->second->set_state (LED::NoTransition);
break; break;
case Session::Enabled: case Enabled:
b->second->set_color (LED::Red); b->second->set_color (LED::Red);
b->second->set_state (LED::Blinking4th); b->second->set_state (LED::Blinking4th);
break; break;
case Session::Recording: case Recording:
b->second->set_color (LED::Red); b->second->set_color (LED::Red);
b->second->set_state (LED::OneShot24th); b->second->set_state (LED::OneShot24th);
break; break;

View file

@ -1131,15 +1131,15 @@ US2400Protocol::notify_record_state_changed ()
LedState ls; LedState ls;
switch (session->record_status()) { switch (session->record_status()) {
case Session::Disabled: case Disabled:
DEBUG_TRACE (DEBUG::US2400, "record state changed to disabled, LED off\n"); DEBUG_TRACE (DEBUG::US2400, "record state changed to disabled, LED off\n");
ls = off; ls = off;
break; break;
case Session::Recording: case Recording:
DEBUG_TRACE (DEBUG::US2400, "record state changed to recording, LED on\n"); DEBUG_TRACE (DEBUG::US2400, "record state changed to recording, LED on\n");
ls = on; ls = on;
break; break;
case Session::Enabled: case Enabled:
DEBUG_TRACE (DEBUG::US2400, "record state changed to enabled, LED flashing\n"); DEBUG_TRACE (DEBUG::US2400, "record state changed to enabled, LED flashing\n");
ls = flashing; ls = flashing;
break; break;