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
89
90
91
92
93
94
95
96
97
|
// shameless stolen from enginemicrophone.cpp (from RJ)
#include "engine/channels/engineaux.h"
#include <QtDebug>
#include "control/control.h"
#include "preferences/usersettings.h"
#include "control/controlaudiotaperpot.h"
#include "effects/effectsmanager.h"
#include "engine/effects/engineeffectsmanager.h"
#include "util/sample.h"
EngineAux::EngineAux(const ChannelHandleAndGroup& handle_group, EffectsManager* pEffectsManager)
: EngineChannel(handle_group, EngineChannel::CENTER, pEffectsManager,
/*isTalkoverChannel*/ false,
/*isPrimaryDeck*/ false),
m_pInputConfigured(new ControlObject(ConfigKey(getGroup(), "input_configured"))),
m_pPregain(new ControlAudioTaperPot(ConfigKey(getGroup(), "pregain"), -12, 12, 0.5)),
m_wasActive(false) {
// Make input_configured read-only.
m_pInputConfigured->setReadOnly();
ControlDoublePrivate::insertAlias(ConfigKey(getGroup(), "enabled"),
ConfigKey(getGroup(), "input_configured"));
// by default Aux is disabled on the master and disabled on PFL. User
// can over-ride by setting the "pfl" or "master" controls.
// Skins can change that during initialisation, if the master control is not provided.
setMaster(false);
}
EngineAux::~EngineAux() {
delete m_pPregain;
}
bool EngineAux::isActive() {
bool enabled = m_pInputConfigured->toBool();
if (enabled && m_sampleBuffer) {
m_wasActive = true;
} else if (m_wasActive) {
m_vuMeter.reset();
m_wasActive = false;
}
return m_wasActive;
}
void EngineAux::onInputConfigured(AudioInput input) {
if (input.getType() != AudioPath::AUXILIARY) {
// This is an error!
qDebug() << "WARNING: EngineAux connected to AudioInput for a non-auxiliary type!";
return;
}
m_sampleBuffer = NULL;
m_pInputConfigured->forceSet(1.0);
}
void EngineAux::onInputUnconfigured(AudioInput input) {
if (input.getType() != AudioPath::AUXILIARY) {
// This is an error!
qDebug() << "WARNING: EngineAux connected to AudioInput for a non-auxiliary type!";
return;
}
m_sampleBuffer = NULL;
m_pInputConfigured->forceSet(0.0);
}
void EngineAux::receiveBuffer(AudioInput input, const CSAMPLE* pBuffer,
unsigned int nFrames) {
Q_UNUSED(input);
Q_UNUSED(nFrames);
m_sampleBuffer = pBuffer;
}
void EngineAux::process(CSAMPLE* pOut, const int iBufferSize) {
const CSAMPLE* sampleBuffer = m_sampleBuffer; // save pointer on stack
CSAMPLE_GAIN pregain = static_cast<CSAMPLE_GAIN>(m_pPregain->get());
if (sampleBuffer) {
SampleUtil::copyWithGain(pOut, sampleBuffer, pregain, iBufferSize);
EngineEffectsManager* pEngineEffectsManager = m_pEffectsManager->getEngineEffectsManager();
if (pEngineEffectsManager != nullptr) {
pEngineEffectsManager->processPreFaderInPlace(
m_group.handle(), m_pEffectsManager->getMasterHandle(), pOut, iBufferSize,
// TODO(jholthuis): Use mixxx::audio::SampleRate instead
static_cast<unsigned int>(m_pSampleRate->get()));
}
m_sampleBuffer = NULL;
} else {
SampleUtil::clear(pOut, iBufferSize);
}
// Update VU meter
m_vuMeter.process(pOut, iBufferSize);
}
void EngineAux::collectFeatures(GroupFeatureState* pGroupFeatures) const {
m_vuMeter.collectFeatures(pGroupFeatures);
}
|