triggerbox: change API to allow providing velocity information when "banging" triggers
... and by extension using it (based on the magnitude of the velocity effect setting) to set the gain of audio triggers
This commit is contained in:
parent
503e6249f4
commit
36048ea651
@ -1386,7 +1386,7 @@ public:
|
||||
int num_triggerboxes () const;
|
||||
std::shared_ptr<TriggerBox> triggerbox_at (int32_t route_index) const;
|
||||
TriggerPtr trigger_at (int32_t route_index, int32_t row_index) const;
|
||||
bool bang_trigger_at(int32_t route_index, int32_t row_index);
|
||||
bool bang_trigger_at(int32_t route_index, int32_t row_index, float velocity = 1.0);
|
||||
bool unbang_trigger_at(int32_t route_index, int32_t row_index);
|
||||
void clear_cue (int row_index);
|
||||
|
||||
|
@ -261,7 +261,7 @@ class LIBARDOUR_API Trigger : public PBD::Stateful {
|
||||
/* Calling ::bang() will cause this Trigger to be placed in its owning
|
||||
TriggerBox's queue.
|
||||
*/
|
||||
void bang ();
|
||||
void bang (float velocity = 1.0f);
|
||||
|
||||
/* Calling ::unbang() is equivalent to a mouse-up or note-off
|
||||
... it MIGHT cause a clip to stop, but more likely has no effect, depending on the slot's launch-style.
|
||||
@ -745,7 +745,7 @@ class LIBARDOUR_API TriggerBox : public Processor
|
||||
|
||||
TriggerPtr trigger (Triggers::size_type);
|
||||
|
||||
void bang_trigger_at (Triggers::size_type row);
|
||||
void bang_trigger_at (Triggers::size_type row, float velocity = 1.0f);
|
||||
void unbang_trigger_at (Triggers::size_type row);
|
||||
|
||||
void add_trigger (TriggerPtr);
|
||||
|
@ -1729,7 +1729,7 @@ Session::trigger_cue_row (int32_t cue)
|
||||
|
||||
|
||||
bool
|
||||
Session::bang_trigger_at (int32_t route_index, int32_t row_index)
|
||||
Session::bang_trigger_at (int32_t route_index, int32_t row_index, float velocity)
|
||||
{
|
||||
/* this is a convenience function for simple control surfaces to bang a trigger without any regards to banking */
|
||||
|
||||
@ -1747,7 +1747,7 @@ Session::bang_trigger_at (int32_t route_index, int32_t row_index)
|
||||
continue;
|
||||
}
|
||||
if (index == route_index) {
|
||||
r->triggerbox()->bang_trigger_at(row_index);
|
||||
r->triggerbox()->bang_trigger_at(row_index, velocity);
|
||||
return true;
|
||||
}
|
||||
index++;
|
||||
|
@ -560,11 +560,12 @@ Trigger::set_ui (void* p)
|
||||
}
|
||||
|
||||
void
|
||||
Trigger::bang ()
|
||||
Trigger::bang (float velocity)
|
||||
{
|
||||
if (!_region) {
|
||||
return;
|
||||
}
|
||||
_pending_velocity_gain = velocity;
|
||||
_bang.fetch_add (1);
|
||||
DEBUG_TRACE (DEBUG::Triggers, string_compose ("bang on %1\n", _index));
|
||||
}
|
||||
@ -2072,7 +2073,13 @@ AudioTrigger::audio_run (BufferSet& bufs, samplepos_t start_sample, samplepos_t
|
||||
AudioBuffer& buf (bufs.get_audio (chn));
|
||||
Sample* src = do_stretch ? bufp[channel] : (data[channel] + read_index);
|
||||
|
||||
gain_t gain = _velocity_gain * _gain; //incorporate the gain from velocity_effect
|
||||
gain_t gain;
|
||||
|
||||
if (_velocity_effect) {
|
||||
gain = (_velocity_effect * _velocity_gain) * _gain;
|
||||
} else {
|
||||
gain = _gain;
|
||||
}
|
||||
|
||||
if (gain != 1.0f) {
|
||||
buf.accumulate_with_gain_from (src, from_stretcher, gain, dest_offset);
|
||||
@ -3762,11 +3769,11 @@ TriggerBox::stop_all_quantized ()
|
||||
}
|
||||
|
||||
void
|
||||
TriggerBox::bang_trigger_at (Triggers::size_type row)
|
||||
TriggerBox::bang_trigger_at (Triggers::size_type row, float velocity)
|
||||
{
|
||||
TriggerPtr t = trigger(row);
|
||||
if (t && t->region()) {
|
||||
t->bang();
|
||||
t->bang (velocity);
|
||||
} else {
|
||||
/* by convention, an empty slot is effectively a STOP button */
|
||||
stop_all_quantized();
|
||||
|
Loading…
Reference in New Issue
Block a user