mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 16:46:35 +01:00
triggerbox: follow action "probability"
This commit is contained in:
parent
3f47c7dcc5
commit
c620d3d411
2 changed files with 20 additions and 4 deletions
|
|
@ -145,6 +145,9 @@ class LIBARDOUR_API Trigger : public PBD::Stateful {
|
||||||
void set_next_trigger (int n);
|
void set_next_trigger (int n);
|
||||||
int next_trigger() const { return _next_trigger; }
|
int next_trigger() const { return _next_trigger; }
|
||||||
|
|
||||||
|
void set_follow_action_probability (int zero_to_a_hundred);
|
||||||
|
int follow_action_probability() const { return _follow_action_probability; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TriggerBox& _box;
|
TriggerBox& _box;
|
||||||
State _state;
|
State _state;
|
||||||
|
|
@ -155,6 +158,7 @@ class LIBARDOUR_API Trigger : public PBD::Stateful {
|
||||||
int _next_trigger;
|
int _next_trigger;
|
||||||
LaunchStyle _launch_style;
|
LaunchStyle _launch_style;
|
||||||
FollowAction _follow_action[2];
|
FollowAction _follow_action[2];
|
||||||
|
int _follow_action_probability;
|
||||||
boost::shared_ptr<Region> _region;
|
boost::shared_ptr<Region> _region;
|
||||||
Temporal::BBT_Offset _quantization;
|
Temporal::BBT_Offset _quantization;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -559,7 +559,7 @@ AudioTrigger::run (BufferSet& bufs, pframes_t nframes, pframes_t dest_offset, bo
|
||||||
|
|
||||||
/* We reached the end */
|
/* We reached the end */
|
||||||
|
|
||||||
if (_follow_action[0] == Again) {
|
if (_next_trigger > 0 && (size_t) _next_trigger == _index) { /* self repeat */
|
||||||
nframes -= this_read;
|
nframes -= this_read;
|
||||||
dest_offset += this_read;
|
dest_offset += this_read;
|
||||||
DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1 was reached end, but set to loop, so retrigger\n", index()));
|
DEBUG_TRACE (DEBUG::Triggers, string_compose ("%1 was reached end, but set to loop, so retrigger\n", index()));
|
||||||
|
|
@ -917,7 +917,7 @@ TriggerBox::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp
|
||||||
|
|
||||||
if (trigger.state() == Trigger::Stopped) {
|
if (trigger.state() == Trigger::Stopped) {
|
||||||
|
|
||||||
if (trigger.follow_action(0) != Trigger::Stop) {
|
if (trigger.next_trigger() != -1) {
|
||||||
|
|
||||||
int nxt = trigger.next_trigger();
|
int nxt = trigger.next_trigger();
|
||||||
|
|
||||||
|
|
@ -950,9 +950,21 @@ TriggerBox::set_next_trigger (size_t current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (all_triggers[current]->follow_action(0)) {
|
int which_follow_action;
|
||||||
|
int r = random() % 100;
|
||||||
|
|
||||||
|
if (r <= all_triggers[current]->follow_action_probability()) {
|
||||||
|
which_follow_action = 0;
|
||||||
|
} else {
|
||||||
|
which_follow_action = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (all_triggers[current]->follow_action (which_follow_action)) {
|
||||||
|
|
||||||
case Trigger::Stop:
|
case Trigger::Stop:
|
||||||
|
all_triggers[current]->set_next_trigger (-1);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case Trigger::QueuedTrigger:
|
case Trigger::QueuedTrigger:
|
||||||
/* XXX implement me */
|
/* XXX implement me */
|
||||||
return;
|
return;
|
||||||
|
|
@ -963,7 +975,7 @@ TriggerBox::set_next_trigger (size_t current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (all_triggers[current]->follow_action(0)) {
|
switch (all_triggers[current]->follow_action (which_follow_action)) {
|
||||||
|
|
||||||
case Trigger::Again:
|
case Trigger::Again:
|
||||||
all_triggers[current]->set_next_trigger (current);
|
all_triggers[current]->set_next_trigger (current);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue