From f282b4ae0ba74f64816fe6a65f7bfa1b2e611b61 Mon Sep 17 00:00:00 2001 From: lnd3 Date: Tue, 24 Sep 2024 15:15:48 +0200 Subject: [PATCH] Document. Optimize input meta data structures slightly. --- packages/audio/include/audio/AudioUtils.h | 16 ---------------- .../include/nodegraph/core/NodeGraphData.h | 15 +++++++-------- .../source/common/core/NodeGraphInput.cpp | 2 +- 3 files changed, 8 insertions(+), 25 deletions(-) diff --git a/packages/audio/include/audio/AudioUtils.h b/packages/audio/include/audio/AudioUtils.h index bcec4a50..100f2c5f 100644 --- a/packages/audio/include/audio/AudioUtils.h +++ b/packages/audio/include/audio/AudioUtils.h @@ -35,7 +35,6 @@ namespace l::audio { FilterRWA() : mSmooth(static_cast(0.005)), - mSmoothSkewed(mSmooth * mSmooth), mValue(static_cast(0)), mTargetValue(static_cast(0)), mRWAUpdateRate(static_cast(1.0)) @@ -52,19 +51,16 @@ namespace l::audio { FilterRWA& SetConvergenceInMs(T convergenceInMS, T limit = static_cast(0.0001), T sampleRate = static_cast(44100.0)) { mSmooth = GetRWAFactorFromMS(convergenceInMS, limit, mRWAUpdateRate, sampleRate); - mSmoothSkewed = GetRWAFactorFromMSSkewed(convergenceInMS, limit, mRWAUpdateRate, sampleRate); return *this; } FilterRWA& SetConvergenceFactor(T smooth = static_cast(0.005)) { mSmooth = smooth; - mSmoothSkewed = mSmooth * mSmooth; return *this; } FilterRWA& SetConvergenceInTicks(T ticks, T limit = static_cast(0.001)) { mSmooth = l::math::tween::GetRWAFactor(static_cast(ticks), limit); - mSmoothSkewed = mSmooth * mSmooth; return *this; } @@ -78,17 +74,6 @@ namespace l::audio { return *this; } - T NextSkewed() { - float delta = mTargetValue - mValue; - if (delta < 0) { - mValue += mSmooth * delta; - } - else { - mValue += mSmoothSkewed * delta; - } - return mValue; - } - T Next() { mValue += mSmooth * (mTargetValue - mValue); return mValue; @@ -100,7 +85,6 @@ namespace l::audio { protected: T mSmooth; - T mSmoothSkewed; T mValue; T mTargetValue; T mRWAUpdateRate; diff --git a/packages/nodegraph/include/nodegraph/core/NodeGraphData.h b/packages/nodegraph/include/nodegraph/core/NodeGraphData.h index d2aa9602..0fdc3371 100644 --- a/packages/nodegraph/include/nodegraph/core/NodeGraphData.h +++ b/packages/nodegraph/include/nodegraph/core/NodeGraphData.h @@ -82,9 +82,8 @@ namespace l::nodegraph { return 1.0f / mIncrement; } protected: - int32_t mSize = 0; - float mIndex = 0.0f; float* mData = nullptr; + float mIndex = 0.0f; float mIncrement = 0.0f; }; @@ -111,12 +110,12 @@ namespace l::nodegraph { }; /*********************************************************************************/ enum class InputTypeBase { - SAMPLED = 0, // interpolate in a buffer the size of a ProcessSubGraph(size) call. The actual size is defined by the lod factor of the output buffer. - SAMPLED_RWA, // todo: add a smoothed sampled variant. Will replace interp_rwa and interp_rwa_ms as we will add a separate config for passing ticks or millis - CONSTANT_ARRAY, // Same here, will be replaced - CUSTOM_INTERP_TWEEN, // custom input vars should not be used at all - CUSTOM_INTERP_TWEEN_MS, - CUSTOM_INTERP_RWA_MS + SAMPLED = 0, // interpolate in a buffer the size of a ProcessSubGraph(size) call. The actual size is defined by the lod factor of the source output buffer. + SAMPLED_RWA, // same as SAMPLED, but it also uses RWA on the output with a smoothing factor defined by the lod factor of the source output buffer + CONSTANT_ARRAY, // user defined array for custom usage + CUSTOM_INTERP_TWEEN, // custom input vars that tweens the input like a s curve + CUSTOM_INTERP_TWEEN_MS, // millisecond synchronized tweening + CUSTOM_INTERP_RWA_MS // custom input var for rwa smoothing synchronized to milliseconds }; union InputUnion { diff --git a/packages/nodegraph/source/common/core/NodeGraphInput.cpp b/packages/nodegraph/source/common/core/NodeGraphInput.cpp index e18e8f69..8a5b1e24 100644 --- a/packages/nodegraph/source/common/core/NodeGraphInput.cpp +++ b/packages/nodegraph/source/common/core/NodeGraphInput.cpp @@ -238,7 +238,7 @@ namespace l::nodegraph { mInput.mIterator = input.at(mInputIndex).GetIterator(numSamples); break; case InputTypeBase::SAMPLED_RWA: - mInput.mIteratorRwa = input.at(mInputIndex).GetIterator(numSamples); + mInput.mIteratorRwa = NodeDataIteratorRwa(input.at(mInputIndex).GetIterator(numSamples)); break; case InputTypeBase::CONSTANT_ARRAY: mInput.mIterator = input.at(mInputIndex).GetArrayIterator();