Skip to content

Commit

Permalink
Unify initalization of EffectState members and fix e memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Mar 9, 2023
1 parent 227148a commit b0bbe0e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
3 changes: 2 additions & 1 deletion src/effects/backends/builtin/autopaneffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,8 @@ void AutoPanEffect::processChannel(
pGroupState->frac.setWithRampingApplied(static_cast<float>((sinusoid + 1.0f) / 2.0f));

// apply the delay
pGroupState->delay->process(&pInput[i],
pGroupState->pDelay->process(
&pInput[i],
&pOutput[i],
-0.005 *
math_clamp(
Expand Down
10 changes: 5 additions & 5 deletions src/effects/backends/builtin/autopaneffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,16 @@ static constexpr int panMaxDelay = 3300; // allows a 30 Hz filter at 97346;
class AutoPanGroupState : public EffectState {
public:
AutoPanGroupState(const mixxx::EngineParameters& engineParameters)
: EffectState(engineParameters) {
time = 0;
delay = new EngineFilterPanSingle<panMaxDelay>();
m_dPreviousPeriod = -1.0;
: EffectState(engineParameters),
time(0),
pDelay(std::make_unique<EngineFilterPanSingle<panMaxDelay>>()),
m_dPreviousPeriod(-1.0) {
}
~AutoPanGroupState() override = default;

unsigned int time;
RampedSample frac;
EngineFilterPanSingle<panMaxDelay>* delay;
std::unique_ptr<EngineFilterPanSingle<panMaxDelay>> pDelay;
double m_dPreviousPeriod;
};

Expand Down
3 changes: 2 additions & 1 deletion src/effects/backends/builtin/bitcrushereffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ struct BitCrusherGroupState : public EffectState {
}
~BitCrusherGroupState() override = default;

CSAMPLE hold_l, hold_r;
CSAMPLE hold_l;
CSAMPLE hold_r;
// Accumulated fractions of a samplerate period.
CSAMPLE accumulator;
};
Expand Down
2 changes: 1 addition & 1 deletion src/effects/backends/builtin/reverbeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ReverbGroupState : public EffectState {

float sampleRate;
float sendPrevious;
MixxxPlateX2 reverb{};
MixxxPlateX2 reverb;
};

class ReverbEffect : public EffectProcessorImpl<ReverbGroupState> {
Expand Down
10 changes: 7 additions & 3 deletions src/effects/backends/builtin/tremoloeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@
class TremoloState : public EffectState {
public:
TremoloState(const mixxx::EngineParameters& engineParameters)
: EffectState(engineParameters){};
: EffectState(engineParameters),
gain(0),
currentFrame(0),
quantizeEnabled(false),
tripletEnabled(false){};
~TremoloState() override = default;

double gain;
unsigned int currentFrame;
bool quantizeEnabled = false;
bool tripletEnabled = false;
bool quantizeEnabled;
bool tripletEnabled;
};

class TremoloEffect : public EffectProcessorImpl<TremoloState> {
Expand Down

0 comments on commit b0bbe0e

Please sign in to comment.