Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ooops - forgot a line from the lag. Also clang format #97

Merged
merged 1 commit into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/sst/basic-blocks/dsp/FollowSlewAndSmooth.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
* https://github.com/surge-synthesizer/sst-basic-blocks
*/

#ifndef INCLUDE_SST_BASIC_BLOCKS_DSP_ENVELOPEFOLLOWER_H
#define INCLUDE_SST_BASIC_BLOCKS_DSP_ENVELOPEFOLLOWER_H
#ifndef INCLUDE_SST_BASIC_BLOCKS_DSP_FOLLOWSLEWANDSMOOTH_H
#define INCLUDE_SST_BASIC_BLOCKS_DSP_FOLLOWSLEWANDSMOOTH_H

#include <algorithm>
#include <utility>
Expand Down Expand Up @@ -145,7 +145,7 @@ struct RunningAverage
RunningAverage(float *ontoStorage, size_t np) : storage{ontoStorage}, nPoints{np}
{
reset();
oneOverN = 1.0 / (nPoints-1);
oneOverN = 1.0 / (nPoints - 1);
}
RunningAverage() = delete;

Expand Down
3 changes: 3 additions & 0 deletions include/sst/basic-blocks/dsp/Lag.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ struct UIComponentLagHandler

void instantlySnap()
{
if (!active)
return;

if (destination)
{
*destination = targetValue;
Expand Down
14 changes: 6 additions & 8 deletions tests/dsp_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1093,23 +1093,22 @@ TEST_CASE("Slew", "[dsp]")
auto sl = sst::basic_blocks::dsp::SlewLimiter();
sl.setParams(100, 1.0, 1000);

for (int i=0; i<100; ++i)
for (int i = 0; i < 100; ++i)
{
auto val = sl.step(0.5);
if (i < 50)
REQUIRE(val == Approx((i+1) * 0.01));
REQUIRE(val == Approx((i + 1) * 0.01));
else
REQUIRE(val == 0.5);
}

for (int i=0; i<200; ++i)
for (int i = 0; i < 200; ++i)
{
auto val = sl.step(-0.5);
if (i < 100)
REQUIRE(val == Approx(0.5 - (i+1) * 0.01).margin(1e-5));
REQUIRE(val == Approx(0.5 - (i + 1) * 0.01).margin(1e-5));
else
REQUIRE(val == -0.5);

}
}

Expand All @@ -1126,7 +1125,6 @@ TEST_CASE("Running Avg", "[dsp]")
}
}


SECTION("RAMP")
{
std::array<float, 101> data{};
Expand All @@ -1137,8 +1135,8 @@ TEST_CASE("Running Avg", "[dsp]")
if (i > data.size() - 1)
{
// Filled with a ramp. Average is start - end / count
auto avg = (i + (i - (data.size()-1 -1))) * 0.5 * 0.1;
REQUIRE( val == Approx(avg).margin(0.005));
auto avg = (i + (i - (data.size() - 1 - 1))) * 0.5 * 0.1;
REQUIRE(val == Approx(avg).margin(0.005));
}
}
}
Expand Down
Loading