Skip to content

Commit

Permalink
Document. Optimize input meta data structures slightly.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuscu committed Sep 24, 2024
1 parent b0976d0 commit f282b4a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 25 deletions.
16 changes: 0 additions & 16 deletions packages/audio/include/audio/AudioUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ namespace l::audio {

FilterRWA() :
mSmooth(static_cast<T>(0.005)),
mSmoothSkewed(mSmooth * mSmooth),
mValue(static_cast<T>(0)),
mTargetValue(static_cast<T>(0)),
mRWAUpdateRate(static_cast<T>(1.0))
Expand All @@ -52,19 +51,16 @@ namespace l::audio {

FilterRWA<T>& SetConvergenceInMs(T convergenceInMS, T limit = static_cast<T>(0.0001), T sampleRate = static_cast<T>(44100.0)) {
mSmooth = GetRWAFactorFromMS(convergenceInMS, limit, mRWAUpdateRate, sampleRate);
mSmoothSkewed = GetRWAFactorFromMSSkewed(convergenceInMS, limit, mRWAUpdateRate, sampleRate);
return *this;
}

FilterRWA<T>& SetConvergenceFactor(T smooth = static_cast<T>(0.005)) {
mSmooth = smooth;
mSmoothSkewed = mSmooth * mSmooth;
return *this;
}

FilterRWA<T>& SetConvergenceInTicks(T ticks, T limit = static_cast<T>(0.001)) {
mSmooth = l::math::tween::GetRWAFactor(static_cast<int32_t>(ticks), limit);
mSmoothSkewed = mSmooth * mSmooth;
return *this;
}

Expand All @@ -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;
Expand All @@ -100,7 +85,6 @@ namespace l::audio {

protected:
T mSmooth;
T mSmoothSkewed;
T mValue;
T mTargetValue;
T mRWAUpdateRate;
Expand Down
15 changes: 7 additions & 8 deletions packages/nodegraph/include/nodegraph/core/NodeGraphData.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/nodegraph/source/common/core/NodeGraphInput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit f282b4a

Please sign in to comment.