Skip to content

Commit

Permalink
Fix a bug that ParallelComb doesn't output wet signal
Browse files Browse the repository at this point in the history
On `BasicLimiter` in common/dsp/basiclimiter.hpp, when buffer size (set by `resize()`) and attack time (set by `setFrames()`) are the same value, `IntDelay` incorrectly outputs 0 sample delay, because of wrap around. This stops output of `DoubleAverageFilter`, and probably introducing off by some number error everywhere.

There must be the same issue on BasicLimiter plugin, but resizing and setting attack time aren't tied. So it wasn't catched somehow.
  • Loading branch information
ryukau committed Jun 23, 2022
1 parent b892c17 commit 86bb16e
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion BasicLimiter/source/dsp/limiter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ template<typename Sample> class IntDelay {

void resize(size_t size)
{
buf.resize(size);
buf.resize(size + 1);
wptr = 0;
rptr = 0;
}
Expand Down
8 changes: 4 additions & 4 deletions BasicLimiter/source/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
#define SUB_VERSION_STR "1"
#define SUB_VERSION_INT 1

#define RELEASE_NUMBER_STR "8"
#define RELEASE_NUMBER_INT 8
#define RELEASE_NUMBER_STR "9"
#define RELEASE_NUMBER_INT 9

#define BUILD_NUMBER_STR "9"
#define BUILD_NUMBER_INT 9
#define BUILD_NUMBER_STR "10"
#define BUILD_NUMBER_INT 10

#define FULL_VERSION_STR \
MAJOR_VERSION_STR "." SUB_VERSION_STR "." RELEASE_NUMBER_STR "." BUILD_NUMBER_STR
Expand Down
2 changes: 1 addition & 1 deletion BasicLimiterAutoMake/source/dsp/limiter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ template<typename Sample> class IntDelay {

void resize(size_t size)
{
buf.resize(size);
buf.resize(size + 1);
wptr = 0;
rptr = 0;
}
Expand Down
8 changes: 4 additions & 4 deletions BasicLimiterAutoMake/source/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
#define SUB_VERSION_STR "1"
#define SUB_VERSION_INT 1

#define RELEASE_NUMBER_STR "8"
#define RELEASE_NUMBER_INT 8
#define RELEASE_NUMBER_STR "9"
#define RELEASE_NUMBER_INT 9

#define BUILD_NUMBER_STR "10"
#define BUILD_NUMBER_INT 10
#define BUILD_NUMBER_STR "11"
#define BUILD_NUMBER_INT 11

#define FULL_VERSION_STR \
MAJOR_VERSION_STR "." SUB_VERSION_STR "." RELEASE_NUMBER_STR "." BUILD_NUMBER_STR
Expand Down
2 changes: 1 addition & 1 deletion ParallelComb/source/dsp/dspcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

constexpr float feedbackLimiterAttackSeconds = 64.0f / 48000.0f;

template<typename T> T lerp(T a, T b, T t) { return a + t * (b - a); }
template<typename T> inline T lerp(T a, T b, T t) { return a + t * (b - a); }

void DSPCORE_NAME::setup(double sampleRate)
{
Expand Down
2 changes: 2 additions & 0 deletions ParallelComb/source/dsp/parallelcomb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ template<typename Sample, size_t nTap> class ParallelComb {
public:
ParallelCombSmoother<Sample, nTap> time;

ParallelComb() : buf(4) {}

void setup(Sample sampleRate, Sample maxTime)
{
auto &&size = size_t(sampleRate * maxTime) + 1;
Expand Down
8 changes: 4 additions & 4 deletions ParallelComb/source/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
#define SUB_VERSION_STR "2"
#define SUB_VERSION_INT 2

#define RELEASE_NUMBER_STR "0"
#define RELEASE_NUMBER_INT 0
#define RELEASE_NUMBER_STR "1"
#define RELEASE_NUMBER_INT 1

#define BUILD_NUMBER_STR "1"
#define BUILD_NUMBER_INT 1
#define BUILD_NUMBER_STR "2"
#define BUILD_NUMBER_INT 2

#define FULL_VERSION_STR \
MAJOR_VERSION_STR "." SUB_VERSION_STR "." RELEASE_NUMBER_STR "." BUILD_NUMBER_STR
Expand Down
8 changes: 4 additions & 4 deletions common/dsp/basiclimiter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ template<typename Sample> class IntDelay {

void resize(size_t size)
{
buf.resize(size);
buf.resize(size + 1);
wptr = 0;
rptr = 0;
}
Expand All @@ -48,15 +48,15 @@ template<typename Sample> class IntDelay {
{
if (delayFrames >= buf.size()) delayFrames = buf.size();
rptr = wptr - delayFrames;
if (rptr >= buf.size()) rptr += buf.size(); // Unsigned overflow case.
if (rptr >= buf.size()) rptr += buf.size(); // Unsigned negative overflow case.
}

Sample process(Sample input)
{
if (++wptr >= buf.size()) wptr -= buf.size();
if (++wptr >= buf.size()) wptr = 0;
buf[wptr] = input;

if (++rptr >= buf.size()) rptr -= buf.size();
if (++rptr >= buf.size()) rptr = 0;
return buf[rptr];
}
};
Expand Down

0 comments on commit 86bb16e

Please sign in to comment.