-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expand file tree
/
Copy pathechoeffect.h
More file actions
78 lines (64 loc) · 2.23 KB
/
echoeffect.h
File metadata and controls
78 lines (64 loc) · 2.23 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
#pragma once
#include <QMap>
#include "effects/backends/effectprocessor.h"
#include "engine/engine.h"
#include "util/class.h"
#include "util/samplebuffer.h"
class EchoGroupState : public EffectState {
public:
// 3 seconds max. This supports the full range of 2 beats for tempos down to
// 40 BPM.
static constexpr int kMaxDelaySeconds = 3;
EchoGroupState(const mixxx::EngineParameters& engineParameters)
: EffectState(engineParameters) {
audioParametersChanged(engineParameters);
clear();
}
~EchoGroupState() override = default;
void audioParametersChanged(const mixxx::EngineParameters& engineParameters) {
delay_buf = mixxx::SampleBuffer(kMaxDelaySeconds *
engineParameters.sampleRate() *
engineParameters.channelCount());
};
void clear() {
delay_buf.clear();
prev_send = 0.0f;
prev_feedback = 0.0f;
prev_delay_samples = 0;
write_position = 0;
ping_pong = 0;
};
mixxx::SampleBuffer delay_buf;
CSAMPLE_GAIN prev_send;
CSAMPLE_GAIN prev_feedback;
int prev_delay_samples;
int write_position;
int ping_pong;
};
class EchoEffect : public EffectProcessorImpl<EchoGroupState> {
public:
EchoEffect() = default;
~EchoEffect() override = default;
static QString getId();
static EffectManifestPointer getManifest();
void loadEngineEffectParameters(
const QMap<QString, EngineEffectParameterPointer>& parameters) override;
void processChannel(
EchoGroupState* 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_pDelayParameter;
EngineEffectParameterPointer m_pSendParameter;
EngineEffectParameterPointer m_pFeedbackParameter;
EngineEffectParameterPointer m_pPingPongParameter;
EngineEffectParameterPointer m_pQuantizeParameter;
EngineEffectParameterPointer m_pTripletParameter;
DISALLOW_COPY_AND_ASSIGN(EchoEffect);
};