Skip to content

Commit

Permalink
Merge pull request #11346 from daschuer/effect_override
Browse files Browse the repository at this point in the history
Fix a memory leak and use override and default for build in effects
  • Loading branch information
Swiftb0y authored Mar 9, 2023
2 parents 96c5b49 + b0bbe0e commit 6dc6f40
Show file tree
Hide file tree
Showing 37 changed files with 68 additions and 95 deletions.
6 changes: 2 additions & 4 deletions src/effects/backends/builtin/autopaneffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ void AutoPanEffect::loadEngineEffectParameters(
m_pWidthParameter = parameters.value("width");
}

AutoPanEffect::~AutoPanEffect() {
}

void AutoPanEffect::processChannel(
AutoPanGroupState* pGroupState,
const CSAMPLE* pInput,
Expand Down Expand Up @@ -168,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
16 changes: 8 additions & 8 deletions src/effects/backends/builtin/autopaneffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,23 @@ 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;
}
~AutoPanGroupState() {
: 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;
};

class AutoPanEffect : public EffectProcessorImpl<AutoPanGroupState> {
public:
AutoPanEffect() = default;
virtual ~AutoPanEffect();
~AutoPanEffect() override = default;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
6 changes: 0 additions & 6 deletions src/effects/backends/builtin/balanceeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ BalanceGroupState::BalanceGroupState(const mixxx::EngineParameters& engineParame
m_high->setStartFromDry(true);
}

BalanceGroupState::~BalanceGroupState() {
}

void BalanceGroupState::setFilters(int sampleRate, double freq) {
m_low->setFrequencyCorners(sampleRate, freq);
m_high->setFrequencyCorners(sampleRate, freq);
Expand All @@ -94,9 +91,6 @@ void BalanceEffect::loadEngineEffectParameters(
m_pBypassFreqParameter = parameters.value("bypassFreq");
}

BalanceEffect::~BalanceEffect() {
}

void BalanceEffect::processChannel(
BalanceGroupState* pGroupState,
const CSAMPLE* pInput,
Expand Down
4 changes: 2 additions & 2 deletions src/effects/backends/builtin/balanceeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class BalanceGroupState : public EffectState {
public:
BalanceGroupState(const mixxx::EngineParameters& engineParameters);
~BalanceGroupState();
~BalanceGroupState() override = default;

void setFilters(int sampleRate, double freq);

Expand All @@ -29,7 +29,7 @@ class BalanceGroupState : public EffectState {
class BalanceEffect : public EffectProcessorImpl<BalanceGroupState> {
public:
BalanceEffect() = default;
virtual ~BalanceEffect();
~BalanceEffect() override = default;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
2 changes: 1 addition & 1 deletion src/effects/backends/builtin/bessel4lvmixeqeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class Bessel4LVMixEQEffectGroupState : public LVMixEQEffectGroupState<EngineFilt
class Bessel4LVMixEQEffect : public EffectProcessorImpl<Bessel4LVMixEQEffectGroupState> {
public:
Bessel4LVMixEQEffect();
virtual ~Bessel4LVMixEQEffect();
~Bessel4LVMixEQEffect() override;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
2 changes: 1 addition & 1 deletion src/effects/backends/builtin/bessel8lvmixeqeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Bessel8LVMixEQEffectGroupState : public LVMixEQEffectGroupState<EngineFilt
class Bessel8LVMixEQEffect : public EffectProcessorImpl<Bessel8LVMixEQEffectGroupState> {
public:
Bessel8LVMixEQEffect();
virtual ~Bessel8LVMixEQEffect();
~Bessel8LVMixEQEffect() override;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
2 changes: 2 additions & 0 deletions src/effects/backends/builtin/biquadfullkilleqeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
class BiquadFullKillEQEffectGroupState : public EffectState {
public:
BiquadFullKillEQEffectGroupState(const mixxx::EngineParameters& engineParameters);
~BiquadFullKillEQEffectGroupState() override = default;

void setFilters(
mixxx::audio::SampleRate sampleRate,
Expand Down Expand Up @@ -59,6 +60,7 @@ class BiquadFullKillEQEffectGroupState : public EffectState {
class BiquadFullKillEQEffect : public EffectProcessorImpl<BiquadFullKillEQEffectGroupState> {
public:
BiquadFullKillEQEffect();
~BiquadFullKillEQEffect() override = default;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
4 changes: 0 additions & 4 deletions src/effects/backends/builtin/bitcrushereffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ void BitCrusherEffect::loadEngineEffectParameters(
m_pDownsampleParameter = parameters.value("downsample");
}

BitCrusherEffect::~BitCrusherEffect() {
//qDebug() << debugString() << "destroyed";
}

void BitCrusherEffect::processChannel(
BitCrusherGroupState* pState,
const CSAMPLE* pInput,
Expand Down
7 changes: 5 additions & 2 deletions src/effects/backends/builtin/bitcrushereffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ struct BitCrusherGroupState : public EffectState {
hold_r(0),
accumulator(1) {
}
CSAMPLE hold_l, hold_r;
~BitCrusherGroupState() override = default;

CSAMPLE hold_l;
CSAMPLE hold_r;
// Accumulated fractions of a samplerate period.
CSAMPLE accumulator;
};

class BitCrusherEffect : public EffectProcessorImpl<BitCrusherGroupState> {
public:
BitCrusherEffect() = default;
virtual ~BitCrusherEffect();
~BitCrusherEffect() override = default;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
2 changes: 2 additions & 0 deletions src/effects/backends/builtin/distortioneffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
class DistortionGroupState : public EffectState {
public:
DistortionGroupState(const mixxx::EngineParameters& engineParameters);
~DistortionGroupState() override = default;

CSAMPLE_GAIN m_driveGain;
CSAMPLE m_crossfadeParameter;
Expand All @@ -23,6 +24,7 @@ class DistortionGroupState : public EffectState {
class DistortionEffect : public EffectProcessorImpl<DistortionGroupState> {
public:
DistortionEffect() = default;
~DistortionEffect() override = default;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
2 changes: 2 additions & 0 deletions src/effects/backends/builtin/echoeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class EchoGroupState : public EffectState {
audioParametersChanged(engineParameters);
clear();
}
~EchoGroupState() override = default;

void audioParametersChanged(const mixxx::EngineParameters& engineParameters) {
delay_buf = mixxx::SampleBuffer(kMaxDelaySeconds *
Expand Down Expand Up @@ -49,6 +50,7 @@ class EchoGroupState : public EffectState {
class EchoEffect : public EffectProcessorImpl<EchoGroupState> {
public:
EchoEffect() = default;
~EchoEffect() override = default;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
4 changes: 0 additions & 4 deletions src/effects/backends/builtin/filtereffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,6 @@ void FilterEffect::loadEngineEffectParameters(
m_pHPF = parameters.value("hpf");
}

FilterEffect::~FilterEffect() {
//qDebug() << debugString() << "destroyed";
}

void FilterEffect::processChannel(
FilterGroupState* pState,
const CSAMPLE* pInput,
Expand Down
4 changes: 2 additions & 2 deletions src/effects/backends/builtin/filtereffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

struct FilterGroupState : public EffectState {
FilterGroupState(const mixxx::EngineParameters& engineParameters);
~FilterGroupState();
~FilterGroupState() override;

void setFilters(int sampleRate, double lowFreq, double highFreq);

Expand All @@ -28,7 +28,7 @@ struct FilterGroupState : public EffectState {
class FilterEffect : public EffectProcessorImpl<FilterGroupState> {
public:
FilterEffect() = default;
virtual ~FilterEffect();
~FilterEffect() override = default;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
4 changes: 0 additions & 4 deletions src/effects/backends/builtin/flangereffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,6 @@ void FlangerEffect::loadEngineEffectParameters(
m_pTripletParameter = parameters.value("triplet");
}

FlangerEffect::~FlangerEffect() {
//qDebug() << debugString() << "destroyed";
}

void FlangerEffect::processChannel(
FlangerGroupState* pState,
const CSAMPLE* pInput,
Expand Down
4 changes: 3 additions & 1 deletion src/effects/backends/builtin/flangereffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ struct FlangerGroupState : public EffectState {
SampleUtil::clear(delayLeft, kBufferLenth);
SampleUtil::clear(delayRight, kBufferLenth);
}
~FlangerGroupState() override = default;

CSAMPLE delayLeft[kBufferLenth];
CSAMPLE delayRight[kBufferLenth];
unsigned int delayPos;
Expand All @@ -49,7 +51,7 @@ struct FlangerGroupState : public EffectState {
class FlangerEffect : public EffectProcessorImpl<FlangerGroupState> {
public:
FlangerEffect() = default;
virtual ~FlangerEffect();
~FlangerEffect() override = default;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
3 changes: 0 additions & 3 deletions src/effects/backends/builtin/graphiceqeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,6 @@ void GraphicEQEffect::loadEngineEffectParameters(
m_pPotHigh = parameters.value("high");
}

GraphicEQEffect::~GraphicEQEffect() {
}

void GraphicEQEffect::processChannel(
GraphicEQEffectGroupState* pState,
const CSAMPLE* pInput,
Expand Down
4 changes: 2 additions & 2 deletions src/effects/backends/builtin/graphiceqeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class GraphicEQEffectGroupState : public EffectState {
public:
GraphicEQEffectGroupState(const mixxx::EngineParameters& engineParameters);
virtual ~GraphicEQEffectGroupState();
~GraphicEQEffectGroupState() override;

void setFilters(int sampleRate);

Expand All @@ -32,7 +32,7 @@ class GraphicEQEffectGroupState : public EffectState {
class GraphicEQEffect : public EffectProcessorImpl<GraphicEQEffectGroupState> {
public:
GraphicEQEffect() = default;
virtual ~GraphicEQEffect();
~GraphicEQEffect() override = default;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
4 changes: 2 additions & 2 deletions src/effects/backends/builtin/linkwitzriley8eqeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class LinkwitzRiley8EQEffectGroupState : public EffectState {
public:
LinkwitzRiley8EQEffectGroupState(const mixxx::EngineParameters& engineParameters);
virtual ~LinkwitzRiley8EQEffectGroupState();
~LinkwitzRiley8EQEffectGroupState() override;

void setFilters(int sampleRate, int lowFreq, int highFreq);

Expand All @@ -40,7 +40,7 @@ class LinkwitzRiley8EQEffectGroupState : public EffectState {
class LinkwitzRiley8EQEffect : public EffectProcessorImpl<LinkwitzRiley8EQEffectGroupState> {
public:
LinkwitzRiley8EQEffect();
virtual ~LinkwitzRiley8EQEffect();
~LinkwitzRiley8EQEffect() override;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
3 changes: 0 additions & 3 deletions src/effects/backends/builtin/loudnesscontoureffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,6 @@ void LoudnessContourEffect::loadEngineEffectParameters(
m_pUseGain = parameters.value("useGain");
}

LoudnessContourEffect::~LoudnessContourEffect() {
}

void LoudnessContourEffect::processChannel(
LoudnessContourEffectGroupState* pState,
const CSAMPLE* pInput,
Expand Down
4 changes: 2 additions & 2 deletions src/effects/backends/builtin/loudnesscontoureffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
class LoudnessContourEffectGroupState final : public EffectState {
public:
LoudnessContourEffectGroupState(const mixxx::EngineParameters& engineParameters);
~LoudnessContourEffectGroupState();
~LoudnessContourEffectGroupState() override;

void setFilters(int sampleRate, double gain);

Expand All @@ -33,7 +33,7 @@ class LoudnessContourEffect
: public EffectProcessorImpl<LoudnessContourEffectGroupState> {
public:
LoudnessContourEffect() = default;
~LoudnessContourEffect() override;
~LoudnessContourEffect() override = default;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
3 changes: 0 additions & 3 deletions src/effects/backends/builtin/metronomeeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ void MetronomeEffect::loadEngineEffectParameters(
m_pSyncParameter = parameters.value("sync");
}

MetronomeEffect::~MetronomeEffect() {
}

void MetronomeEffect::processChannel(
MetronomeGroupState* pGroupState,
const CSAMPLE* pInput,
Expand Down
5 changes: 2 additions & 3 deletions src/effects/backends/builtin/metronomeeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@ class MetronomeGroupState final : public EffectState {
: EffectState(engineParameters),
m_framesSinceClickStart(0) {
}
~MetronomeGroupState() {
}
~MetronomeGroupState() override = default;

SINT m_framesSinceClickStart;
};

class MetronomeEffect : public EffectProcessorImpl<MetronomeGroupState> {
public:
MetronomeEffect() = default;
virtual ~MetronomeEffect();
~MetronomeEffect() override = default;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
4 changes: 0 additions & 4 deletions src/effects/backends/builtin/moogladder4filtereffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ void MoogLadder4FilterEffect::loadEngineEffectParameters(
m_pHPF = parameters.value("hpf");
}

MoogLadder4FilterEffect::~MoogLadder4FilterEffect() {
//qDebug() << debugString() << "destroyed";
}

void MoogLadder4FilterEffect::processChannel(
MoogLadder4FilterGroupState* pState,
const CSAMPLE* pInput,
Expand Down
5 changes: 3 additions & 2 deletions src/effects/backends/builtin/moogladder4filtereffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
class MoogLadder4FilterGroupState : public EffectState {
public:
MoogLadder4FilterGroupState(const mixxx::EngineParameters& engineParameters);
~MoogLadder4FilterGroupState();
~MoogLadder4FilterGroupState() override;

void setFilters(int sampleRate, double lowFreq, double highFreq);

CSAMPLE* m_pBuf;
Expand All @@ -27,7 +28,7 @@ class MoogLadder4FilterGroupState : public EffectState {
class MoogLadder4FilterEffect : public EffectProcessorImpl<MoogLadder4FilterGroupState> {
public:
MoogLadder4FilterEffect() = default;
virtual ~MoogLadder4FilterEffect();
~MoogLadder4FilterEffect() override = default;

static QString getId();
static EffectManifestPointer getManifest();
Expand Down
3 changes: 0 additions & 3 deletions src/effects/backends/builtin/parametriceqeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,6 @@ void ParametricEQEffect::loadEngineEffectParameters(
m_pPotCenter.append(parameters.value("center2"));
}

ParametricEQEffect::~ParametricEQEffect() {
}

void ParametricEQEffect::processChannel(
ParametricEQEffectGroupState* pState,
const CSAMPLE* pInput,
Expand Down
Loading

0 comments on commit 6dc6f40

Please sign in to comment.