-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathflangereffect.h
More file actions
80 lines (68 loc) · 2.53 KB
/
flangereffect.h
File metadata and controls
80 lines (68 loc) · 2.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#pragma once
#include <QMap>
#include "effects/backends/effectprocessor.h"
#include "util/class.h"
#include "util/rampingvalue.h"
#include "util/sample.h"
#include "util/types.h"
namespace {
constexpr double kMaxDelayMs = 13.0;
constexpr double kMinDelayMs = 0.22;
constexpr double kCenterDelayMs = (kMaxDelayMs - kMinDelayMs) / 2 + kMinDelayMs;
constexpr double kMaxLfoWidthMs = kMaxDelayMs - kMinDelayMs;
// using + 1.0 instead of ceil() for Mac OS
constexpr SINT kBufferLenth = static_cast<SINT>(kMaxDelayMs + 1.0) * 96; // for 96 kHz
constexpr double kMinLfoBeats = 1 / 4.0;
constexpr double kMaxLfoBeats = 32.0;
} // anonymous namespace
struct FlangerGroupState : public EffectState {
FlangerGroupState(const mixxx::EngineParameters& engineParameters)
: EffectState(engineParameters),
delayPos(0),
lfoFrames(0),
previousPeriodFrames(-1),
prev_regen(0),
prev_mix(0),
prev_width(0),
prev_manual(static_cast<CSAMPLE_GAIN>(kCenterDelayMs)) {
SampleUtil::clear(delayLeft, kBufferLenth);
SampleUtil::clear(delayRight, kBufferLenth);
}
~FlangerGroupState() override = default;
CSAMPLE delayLeft[kBufferLenth];
CSAMPLE delayRight[kBufferLenth];
unsigned int delayPos;
unsigned int lfoFrames;
double previousPeriodFrames;
CSAMPLE_GAIN prev_regen;
CSAMPLE_GAIN prev_mix;
CSAMPLE_GAIN prev_width;
CSAMPLE_GAIN prev_manual;
};
class FlangerEffect : public EffectProcessorImpl<FlangerGroupState> {
public:
FlangerEffect() = default;
~FlangerEffect() override = default;
static QString getId();
static EffectManifestPointer getManifest();
void loadEngineEffectParameters(
const QMap<QString, EngineEffectParameterPointer>& parameters) override;
void processChannel(
FlangerGroupState* pState,
const CSAMPLE* pInput,
CSAMPLE* pOutput,
const mixxx::EngineParameters& engineParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) override;
private:
QString debugString() const {
return getId();
}
EngineEffectParameterPointer m_pSpeedParameter;
EngineEffectParameterPointer m_pWidthParameter;
EngineEffectParameterPointer m_pManualParameter;
EngineEffectParameterPointer m_pRegenParameter;
EngineEffectParameterPointer m_pMixParameter;
EngineEffectParameterPointer m_pTripletParameter;
DISALLOW_COPY_AND_ASSIGN(FlangerEffect);
};