13
0

trigger arming must be mutually exclusive within a triggerbox

This commit is contained in:
Paul Davis 2024-10-21 10:45:47 -06:00
parent 3228a61e62
commit 590400a95f
2 changed files with 25 additions and 2 deletions

View File

@ -814,6 +814,7 @@ class LIBARDOUR_API TriggerBox : public Processor, public std::enable_shared_fro
void arm_from_another_thread (Trigger& slot, samplepos_t, uint32_t chans);
void disarm();
void disarm_all();
bool armed() const { return (bool) _arm_info.load(); }
PBD::Signal<void()> ArmedChanged;

View File

@ -290,8 +290,20 @@ Trigger::request_trigger_delete (Trigger* t)
void
Trigger::arm ()
{
#warning paul need channel count here, somehow
_box.arm_from_another_thread (*this, _box.session().transport_sample(), 2);
/* trigger arming is mutually exclusive within a given TriggerBox */
_box.disarm_all ();
Track* trk = static_cast<Track*> (_box.owner());
int chns;
if (trk->data_type() == DataType::AUDIO) {
chns = dynamic_cast<AudioTrack*> (trk)->input()->n_ports().n_audio();
} else {
chns = 0;
}
_box.arm_from_another_thread (*this, _box.session().transport_sample(), chns);
_armed = true;
ArmChanged(); /* EMIT SIGNAL */
TriggerArmChanged (this);
@ -3569,6 +3581,16 @@ TriggerBox::arm_from_another_thread (Trigger& slot, samplepos_t now, uint32_t ch
void
TriggerBox::disarm ()
{
delete _arm_info;
_arm_info = nullptr;
}
void
TriggerBox::disarm_all ()
{
for (auto & t : all_triggers) {
t->disarm ();
}
}
void