From 94c45cf2fd649013afcccfcbe62687a3209991f0 Mon Sep 17 00:00:00 2001 From: lnd3 Date: Sat, 7 Sep 2024 19:22:52 +0200 Subject: [PATCH] Clean up. --- .../include/nodegraph/NodeGraphOperations.h | 1 - .../nodegraph/source/common/NodeGraphOperations.cpp | 12 +++++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/packages/nodegraph/include/nodegraph/NodeGraphOperations.h b/packages/nodegraph/include/nodegraph/NodeGraphOperations.h index 3723058e..4c0fdf88 100644 --- a/packages/nodegraph/include/nodegraph/NodeGraphOperations.h +++ b/packages/nodegraph/include/nodegraph/NodeGraphOperations.h @@ -880,7 +880,6 @@ namespace l::nodegraph { protected: float mSamplesUntilUpdate = 0.0f; int32_t mGateIndex = 0; - std::vector mGate; float mGainTarget = 1.0f; float mGain = 1.0f; float mGateSmoothing = 0.01f; diff --git a/packages/nodegraph/source/common/NodeGraphOperations.cpp b/packages/nodegraph/source/common/NodeGraphOperations.cpp index b41b0afd..914a5d2a 100644 --- a/packages/nodegraph/source/common/NodeGraphOperations.cpp +++ b/packages/nodegraph/source/common/NodeGraphOperations.cpp @@ -891,10 +891,8 @@ namespace l::nodegraph { void GraphEffectTranceGate::Process(int32_t numSamples, std::vector& inputs, std::vector& outputs) { // "Bpm", "Fmod", "Attack", "Pattern" - float bpm = inputs.at(2).Get(); - //fmod = l::math::functions::pow(l::math::constants::E_f, (1.0f / 10.0f) * fmod); // range 0.1 - 10 with arg -1,1 - + float fmod = inputs.at(3).Get(); float attack = inputs.at(4).Get(); size_t patternsSize = patterns.size(); @@ -902,18 +900,18 @@ namespace l::nodegraph { auto& gate = patterns[patternId % patternsSize]; size_t patternSize = gate.size(); - float fmod = inputs.at(3).Get() / static_cast(patternSize); - mGateIndex %= patternSize; + float fmodPerPattern = fmod / static_cast(patternSize); mGateSmoothing = attack * attack; mGateSmoothingNeg = mGateSmoothing * 0.25f; float freq = 44100.0f * 60.0f / bpm; - mSamplesUntilUpdate = l::audio::BatchUpdate(freq * fmod, mSamplesUntilUpdate, 0, numSamples, + mSamplesUntilUpdate = l::audio::BatchUpdate(freq * fmodPerPattern, mSamplesUntilUpdate, 0, numSamples, [&]() { + mGateIndex %= gate.size(); mGainTarget = gate[mGateIndex]; - mGateIndex = (mGateIndex + 1) % gate.size(); + mGateIndex++; }, [&](int32_t start, int32_t end, bool) { for (int32_t i = start; i < end; i++) {