Skip to content

Commit

Permalink
Fix signal input error.
Browse files Browse the repository at this point in the history
  • Loading branch information
linuscu committed Sep 20, 2024
1 parent 3c95574 commit 335b8b3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ namespace l::nodegraph {
float mSamplesUntilUpdate = 0.0f;
float mUpdateRate = 16.0f;

l::audio::FilterRWA<float> mFilterVolume;
l::audio::FilterRWA<float> mRWAFreq;
};

/*********************************************************************/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace l::nodegraph {

mSmooth = mNodeInputManager.GetValueNext(4);

mNodeInputManager.SetDuration(2, 10000.0f * (1.0f - mSmooth), 0.05f);
mRWAFreq.SetConvergenceInMs(1000.0f * (1.0f - mSmooth), 0.05f);

mDeltaTime = 1.0f / 44100.0f;

Expand All @@ -37,7 +37,9 @@ namespace l::nodegraph {
},
[&](int32_t start, int32_t end, bool) {
for (int32_t i = start; i < end; i++) {
float signalTarget = ProcessSignal(mDeltaTime, mNodeInputManager.GetValueNext(2));
float freq = mNodeInputManager.GetValueNext(2);
mRWAFreq.SetTarget(freq);
float signalTarget = ProcessSignal(mDeltaTime, mRWAFreq.Next());
*output0++ = mNodeInputManager.GetValueNext(3) * signalTarget;
}
}
Expand Down
3 changes: 2 additions & 1 deletion packages/nodegraph/tests/common/NodeGraphBatchingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ TEST(NodeGraphBatching, Simple) {
auto nodeSine = group.NewNode<GraphSignalSine2>(OutputType::Default);
nodeSine->SetInput(1, 4.0f); // sine update rate
nodeSine->SetInput(2, 1400.0f); // sine freq
nodeSine->SetInput(3, 0.5f); // sine freq

auto nodeLowpass = group.NewNode<GraphFilterLowpass>(OutputType::Default);

Expand All @@ -35,7 +36,7 @@ TEST(NodeGraphBatching, Simple) {

auto output = &group.GetOutput(0, 8);

TEST_FUZZY(0.000151574f, output[7], 0.0001f, "");
TEST_FUZZY(0.034771f, output[7], 0.0001f, "");

return 0;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/nodegraph/tests/common/NodeGraphSchemaTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ TEST(NodeGraph, FilterLowpass) {
//LOG(LogInfo) << nodeLowpass.GetOutput(0);
}

TEST_FUZZY(nodeLowpass.GetOutput(0), -0.005843f, 0.0001f, "");
TEST_FUZZY(nodeLowpass.GetOutput(0), -0.201134, 0.0001f, "");

return 0;
}
Expand Down Expand Up @@ -173,8 +173,8 @@ TEST(NodeGraph, GraphGroups) {
float output1 = group2.GetOutput(0);
float output2 = group2.GetOutput(1);

TEST_FUZZY(output1, 0.00000537335563f, 0.00000001, "");
TEST_FUZZY(output2, 0.00000358223701f, 0.00000001, "");
TEST_FUZZY(output1, 0.149999559f, 0.00001, "");
TEST_FUZZY(output2, 0.0999997109f, 0.00001, "");

return 0;
}
Expand Down

0 comments on commit 335b8b3

Please sign in to comment.