/
engineeffectchain.h
88 lines (75 loc) · 2.97 KB
/
engineeffectchain.h
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
81
82
83
84
85
86
87
88
#pragma once
#include <QList>
#include <QString>
#include "engine/channelhandle.h"
#include "engine/effects/engineeffectsdelay.h"
#include "engine/effects/groupfeaturestate.h"
#include "engine/effects/message.h"
#include "util/class.h"
#include "util/memory.h"
#include "util/samplebuffer.h"
#include "util/types.h"
class EngineEffect;
/// EngineEffectChain is the audio thread counterpart of EffectChain.
/// The lifetime of EngineEffectChain corresponds to the lifetime of
/// its EffectChain counterpart; EngineEffectChains are neither created
/// nor destroyed apart from Mixxx startup and shutdown.
///
/// EngineEffectChain processes a list of EngineEffects in series.
/// EngineEffectChain manages the input channel routing switches,
/// the mix knob, and the chain enable switch.
class EngineEffectChain final : public EffectsRequestHandler {
public:
/// called from main thread
EngineEffectChain(const QString& group,
const QSet<ChannelHandleAndGroup>& registeredInputChannels,
const QSet<ChannelHandleAndGroup>& registeredOutputChannels);
/// called from main thread
~EngineEffectChain();
/// called from audio thread
bool processEffectsRequest(
EffectsRequest& message,
EffectsResponsePipe* pResponsePipe) override;
/// called from audio thread
bool process(const ChannelHandle& inputHandle,
const ChannelHandle& outputHandle,
CSAMPLE* pIn,
CSAMPLE* pOut,
const unsigned int numSamples,
const unsigned int sampleRate,
const GroupFeatureState& groupFeatures);
/// called from main thread
void deleteStatesForInputChannel(const ChannelHandle channel);
private:
struct ChannelStatus {
ChannelStatus()
: oldMixKnob(0),
enableState(EffectEnableState::Disabled) {
}
CSAMPLE oldMixKnob;
EffectEnableState enableState;
};
QString debugString() const {
return QString("EngineEffectChain(%1)").arg(m_group);
}
bool updateParameters(const EffectsRequest& message);
bool addEffect(EngineEffect* pEffect, int iIndex);
bool removeEffect(EngineEffect* pEffect, int iIndex);
bool enableForInputChannel(ChannelHandle inputHandle,
EffectStatesMapArray* statesForEffectsInChain);
bool disableForInputChannel(ChannelHandle inputHandle);
// Gets or creates a ChannelStatus entry in m_channelStatus for the provided
// handle.
ChannelStatus& getChannelStatus(const ChannelHandle& inputHandle,
const ChannelHandle& outputHandle);
QString m_group;
EffectEnableState m_enableState;
EffectChainMixMode::Type m_mixMode;
CSAMPLE m_dMix;
QList<EngineEffect*> m_effects;
mixxx::SampleBuffer m_buffer1;
mixxx::SampleBuffer m_buffer2;
ChannelHandleMap<ChannelHandleMap<ChannelStatus>> m_chainStatusForChannelMatrix;
EngineEffectsDelay m_effectsDelay;
DISALLOW_COPY_AND_ASSIGN(EngineEffectChain);
};