Processes the source to destination bus. The number of channels must match in source and destination.
| 55 | |
| 56 | // Processes the source to destination bus. The number of channels must match in source and destination. |
| 57 | virtual void process(ContextRenderLock & r, const lab::AudioBus * sourceBus, lab::AudioBus* destinationBus, int framesToProcess) override |
| 58 | { |
| 59 | using std::deque; |
| 60 | |
| 61 | if (!destinationBus->numberOfChannels()) |
| 62 | return; |
| 63 | |
| 64 | if (!sourceBus->numberOfChannels()) |
| 65 | { |
| 66 | destinationBus->zero(); |
| 67 | return; |
| 68 | } |
| 69 | |
| 70 | if (framesToProcess != _gateArray.size()) |
| 71 | _gateArray.resize(framesToProcess); |
| 72 | if (envelope.size() != framesToProcess) |
| 73 | envelope.resize(framesToProcess); |
| 74 | |
| 75 | // scan the gate signal |
| 76 | const bool gate_is_connected = m_gate->hasSampleAccurateValues(); |
| 77 | if (gate_is_connected) |
| 78 | { |
| 79 | m_gate->calculateSampleAccurateValues(r, _gateArray.data(), framesToProcess); |
| 80 | |
| 81 | // threshold the gate to on or off |
| 82 | for (int i = 0; i < framesToProcess; ++i) |
| 83 | _gateArray[i] = _gateArray[i] > 0 ? 1.f : 0.f; |
| 84 | } |
| 85 | else |
| 86 | { |
| 87 | float g = m_gate->value(); |
| 88 | // threshold the gate to on or off |
| 89 | for (int i = 0; i < framesToProcess; ++i) |
| 90 | _gateArray[i] = g > 0 ? 1.f : 0.f; |
| 91 | } |
| 92 | |
| 93 | // oneshot == false means gate controls Attack/Sustain |
| 94 | // oneshot == true means sustain param controls sustain |
| 95 | bool oneshot = m_oneShot->valueBool(); |
| 96 | |
| 97 | cached_sample_rate = r.context()->sampleRate(); |
| 98 | for (int i = 0; i < framesToProcess; ++i) |
| 99 | { |
| 100 | if (_currentGate == 0 && _gateArray[i] > 0) |
| 101 | { |
| 102 | // attack begin |
| 103 | _currentGate = 1; |
| 104 | _lerp.clear(); // forget all previous lerps |
| 105 | float attackLevel = m_attackLevel->valueFloat(); |
| 106 | float attackDelta = m_attackLevel->valueFloat() - currentEnvelope; |
| 107 | float attackRatio = attackDelta / attackLevel; |
| 108 | float attackSteps = m_attackTime->valueFloat() * attackRatio * cached_sample_rate; |
| 109 | float attackStepSize = attackDelta / attackSteps; |
| 110 | |
| 111 | _lerp.emplace_back(LerpTarget{ attackSteps, attackStepSize }); |
| 112 | |
| 113 | float sustainLevel = m_sustainLevel->valueFloat(); |
| 114 | float decaySteps = m_decayTime->valueFloat() * cached_sample_rate; |
nothing calls this directly
no test coverage detected