Skip to content

Commit

Permalink
add Noise effect
Browse files Browse the repository at this point in the history
I came up with an interesting formula having no idea what it would
sound like. It turned out to make some gnarly noise. :)
  • Loading branch information
Be-ing committed May 3, 2020
1 parent 63e5db9 commit 02cb69b
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 8 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ add_library(mixxx-lib STATIC EXCLUDE_FROM_ALL
src/effects/backends/builtin/loudnesscontoureffect.cpp
src/effects/backends/builtin/metronomeeffect.cpp
src/effects/backends/builtin/moogladder4filtereffect.cpp
src/effects/backends/builtin/noiseeffect.cpp
src/effects/backends/builtin/parametriceqeffect.cpp
src/effects/backends/builtin/phasereffect.cpp
src/effects/backends/builtin/reverbeffect.cpp
Expand Down
19 changes: 11 additions & 8 deletions src/effects/backends/builtin/builtinbackend.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@

#include "effects/backends/builtin/builtinbackend.h"

#include <QtDebug>

#include "effects/backends/builtin/builtinbackend.h"
#include "effects/backends/builtin/flangereffect.h"
#include "effects/backends/builtin/bitcrushereffect.h"
#include "effects/backends/builtin/balanceeffect.h"
#include "effects/backends/builtin/linkwitzriley8eqeffect.h"
#include "effects/backends/builtin/bessel8lvmixeqeffect.h"
#include "effects/backends/builtin/bessel4lvmixeqeffect.h"
#include "effects/backends/builtin/threebandbiquadeqeffect.h"
#include "effects/backends/builtin/bessel8lvmixeqeffect.h"
#include "effects/backends/builtin/biquadfullkilleqeffect.h"
#include "effects/backends/builtin/graphiceqeffect.h"
#include "effects/backends/builtin/parametriceqeffect.h"
#include "effects/backends/builtin/bitcrushereffect.h"
#include "effects/backends/builtin/filtereffect.h"
#include "effects/backends/builtin/flangereffect.h"
#include "effects/backends/builtin/graphiceqeffect.h"
#include "effects/backends/builtin/linkwitzriley8eqeffect.h"
#include "effects/backends/builtin/moogladder4filtereffect.h"
#include "effects/backends/builtin/noiseeffect.h"
#include "effects/backends/builtin/parametriceqeffect.h"
#include "effects/backends/builtin/threebandbiquadeqeffect.h"
#ifndef __MACAPPSTORE__
#include "effects/backends/builtin/reverbeffect.h"
#endif
Expand All @@ -40,6 +42,7 @@ BuiltInBackend::BuiltInBackend() {
registerEffect<FilterEffect>();
registerEffect<MoogLadder4FilterEffect>();
registerEffect<BitCrusherEffect>();
registerEffect<NoiseEffect>();
registerEffect<BalanceEffect>();
// Fancy effects
registerEffect<FlangerEffect>();
Expand Down
60 changes: 60 additions & 0 deletions src/effects/backends/builtin/noiseeffect.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#include "effects/backends/builtin/noiseeffect.h"

#include "effects/backends/effectmanifest.h"

// static
QString NoiseEffect::getId() {
return "org.mixxx.effects.noise";
}

// static
EffectManifestPointer NoiseEffect::getManifest() {
EffectManifestPointer pManifest(new EffectManifest());
pManifest->setId(getId());
pManifest->setName(QObject::tr("Noise"));
pManifest->setShortName(QObject::tr("Noise"));
pManifest->setAuthor("The Mixxx Team");
pManifest->setVersion("1.0");
pManifest->setDescription(QObject::tr(
"Adds noise"));
pManifest->setEffectRampsFromDry(true);
pManifest->setMetaknobDefault(0.0);

EffectManifestParameterPointer depth = pManifest->addParameter();
depth->setId("depth");
depth->setName(QObject::tr("Depth"));
depth->setShortName(QObject::tr("Depth"));
depth->setDescription(QObject::tr(
"Depth"));
depth->setValueScaler(EffectManifestParameter::ValueScaler::LOGARITHMIC);
depth->setSemanticHint(EffectManifestParameter::SemanticHint::UNKNOWN);
depth->setUnitsHint(EffectManifestParameter::UnitsHint::UNKNOWN);
depth->setDefaultLinkType(EffectManifestParameter::LinkType::LINKED);
depth->setRange(0, 0, 1);

return pManifest;
}

void NoiseEffect::loadEngineEffectParameters(
const QMap<QString, EngineEffectParameterPointer>& parameters) {
m_pDepthParameter = parameters.value("depth");
}

void NoiseEffect::processChannel(
NoiseGroupState* pState,
const CSAMPLE* pInput,
CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
Q_UNUSED(pState);
Q_UNUSED(groupFeatures);
Q_UNUSED(enableState);

const CSAMPLE depth = m_pDepthParameter->value();

for (unsigned int i = 0; i < bufferParameters.samplesPerBuffer(); i++) {
int sign = (pInput[i] >= 0) ? 1 : -1;
pOutput[i] = sign * depth - pInput[i];
}
}
41 changes: 41 additions & 0 deletions src/effects/backends/builtin/noiseeffect.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#pragma once

#include "effects/backends/effectprocessor.h"
#include "engine/effects/engineeffectparameter.h"
#include "util/types.h"

// This effect requires no state.
struct NoiseGroupState : public EffectState {
NoiseGroupState(const mixxx::EngineParameters& bufferParameters)
: EffectState(bufferParameters) {
}
};

class NoiseEffect : public EffectProcessorImpl<NoiseGroupState> {
public:
NoiseEffect(){};
~NoiseEffect(){};

static QString getId();
static EffectManifestPointer getManifest();

void loadEngineEffectParameters(
const QMap<QString, EngineEffectParameterPointer>& parameters) override;

void processChannel(
NoiseGroupState* pState,
const CSAMPLE* pInput,
CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatureState) override;

private:
QString debugString() const {
return getId();
}

EngineEffectParameterPointer m_pDepthParameter;

DISALLOW_COPY_AND_ASSIGN(NoiseEffect);
};

0 comments on commit 02cb69b

Please sign in to comment.