Skip to content

Commit

Permalink
refactor mixxx::AudioParameters and rename to mixxx::EngineParameters
Browse files Browse the repository at this point in the history
  • Loading branch information
Be-ing committed Dec 15, 2017
1 parent b7c6bbf commit 33405b2
Show file tree
Hide file tree
Showing 44 changed files with 194 additions and 192 deletions.
2 changes: 1 addition & 1 deletion src/effects/effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Effect::~Effect() {
}
}

EffectState* Effect::createState(const mixxx::AudioParameters& bufferParameters) {
EffectState* Effect::createState(const mixxx::EngineParameters& bufferParameters) {
return m_pEngineEffect->createState(bufferParameters);
}

Expand Down
2 changes: 1 addition & 1 deletion src/effects/effect.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class Effect : public QObject {
EffectInstantiatorPointer pInstantiator);
virtual ~Effect();

EffectState* createState(const mixxx::AudioParameters& bufferParameters);
EffectState* createState(const mixxx::EngineParameters& bufferParameters);

const EffectManifest& getManifest() const;

Expand Down
4 changes: 1 addition & 3 deletions src/effects/effectchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,7 @@ void EffectChain::enableForChannel(const ChannelHandleAndGroup& handle_group) {
pStatesForEffectsInChain->reserve(m_effects.size());

//TODO: get actual configuration of engine
const mixxx::AudioParameters bufferParameters(
mixxx::AudioSignal::SampleLayout::Interleaved,
mixxx::kEngineChannelCount,
const mixxx::EngineParameters bufferParameters(
mixxx::AudioSignal::SampleRate(96000),
MAX_BUFFER_LEN / mixxx::kEngineChannelCount);

Expand Down
22 changes: 11 additions & 11 deletions src/effects/effectprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ class EngineEffect;
// without wasting a lot of memory.
class EffectState {
public:
EffectState(const mixxx::AudioParameters& bufferParameters) {
// Subclasses should call audioParametersChanged here.
EffectState(const mixxx::EngineParameters& bufferParameters) {
// Subclasses should call engineParametersChanged here.
Q_UNUSED(bufferParameters);
};
virtual ~EffectState() {};

// TODO: implement this for all subclasses and call it when the buffer
// size and sample rate are configured by SoundManager
virtual void audioParametersChanged(const mixxx::AudioParameters& bufferParameters) {
virtual void engineParametersChanged(const mixxx::EngineParameters& bufferParameters) {
Q_UNUSED(bufferParameters);
};
// Subclasses should clear any mixxx::SampleBuffer members and set
Expand All @@ -65,8 +65,8 @@ class EffectProcessor {
virtual void initialize(
const QSet<ChannelHandleAndGroup>& activeInputChannels,
EffectsManager* pEffectsManager,
const mixxx::AudioParameters& bufferParameters) = 0;
virtual EffectState* createState(const mixxx::AudioParameters& bufferParameters) = 0;
const mixxx::EngineParameters& bufferParameters) = 0;
virtual EffectState* createState(const mixxx::EngineParameters& bufferParameters) = 0;
virtual bool loadStatesForInputChannel(const ChannelHandle& inputChannel,
const EffectStatesPointer pStates) = 0;
// Called from main thread for garbage collection after the last audio thread
Expand All @@ -79,14 +79,14 @@ class EffectProcessor {
// effects should not be written assuming this will remain true. The properties
// of the buffer necessary for determining how to process it (frames per
// buffer, number of channels, and sample rate) are available on the
// mixxx::AudioParameters argument. The provided channel handles allow
// mixxx::EngineParameters argument. The provided channel handles allow
// EffectProcessorImpl::process to fetch the appropriate EffectState and
// pass it on to EffectProcessorImpl::processChannel, allowing one
// EffectProcessor instance to process multiple signals simultaneously.
virtual void process(const ChannelHandle& inputHandle,
const ChannelHandle& outputHandle,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::AudioParameters& bufferParameters,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) = 0;
};
Expand Down Expand Up @@ -129,13 +129,13 @@ class EffectProcessorImpl : public EffectProcessor {
virtual void processChannel(const ChannelHandle& handle,
EffectSpecificState* channelState,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::AudioParameters& bufferParameters,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) = 0;

void process(const ChannelHandle& inputHandle, const ChannelHandle& outputHandle,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::AudioParameters& bufferParameters,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) final {
EffectSpecificState* pState = m_channelStateMatrix[inputHandle][outputHandle];
Expand All @@ -153,7 +153,7 @@ class EffectProcessorImpl : public EffectProcessor {

void initialize(const QSet<ChannelHandleAndGroup>& activeInputChannels,
EffectsManager* pEffectsManager,
const mixxx::AudioParameters& bufferParameters) final {
const mixxx::EngineParameters& bufferParameters) final {
for (const ChannelHandleAndGroup& inputChannel : activeInputChannels) {
//qDebug() << this << "EffectProcessorImpl::initialize allocating EffectStates for input" << inputChannel;
ChannelHandleMap<EffectSpecificState*> outputChannelMap;
Expand All @@ -169,7 +169,7 @@ class EffectProcessorImpl : public EffectProcessor {
DEBUG_ASSERT(m_pEffectsManager != nullptr);
};

EffectSpecificState* createState(const mixxx::AudioParameters& bufferParameters) final {
EffectSpecificState* createState(const mixxx::EngineParameters& bufferParameters) final {
return new EffectSpecificState(bufferParameters);
};

Expand Down
4 changes: 2 additions & 2 deletions src/effects/native/autopaneffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ AutoPanEffect::~AutoPanEffect() {
void AutoPanEffect::processChannel(
const ChannelHandle& handle, AutoPanGroupState* pGroupState,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::AudioParameters& bufferParameters,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
Q_UNUSED(handle);
Expand Down Expand Up @@ -145,7 +145,7 @@ void AutoPanEffect::processChannel(
double sinusoid = 0;

// NOTE: Assuming engine is working in stereo.
for (unsigned int i = 0; i + 1 < bufferParameters.bufferSize(); i += 2) {
for (unsigned int i = 0; i + 1 < bufferParameters.samplesPerBuffer(); i += 2) {

CSAMPLE periodFraction = CSAMPLE(gs.time) / period;

Expand Down
4 changes: 2 additions & 2 deletions src/effects/native/autopaneffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ static const int panMaxDelay = 3300; // allows a 30 Hz filter at 97346;

class AutoPanGroupState : public EffectState {
public:
AutoPanGroupState(const mixxx::AudioParameters& bufferParameters)
AutoPanGroupState(const mixxx::EngineParameters& bufferParameters)
: EffectState(bufferParameters) {
time = 0;
delay = new EngineFilterPanSingle<panMaxDelay>();
Expand All @@ -88,7 +88,7 @@ class AutoPanEffect : public EffectProcessorImpl<AutoPanGroupState> {
void processChannel(const ChannelHandle& handle,
AutoPanGroupState* pState,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::AudioParameters& bufferParameters,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures);

Expand Down
16 changes: 8 additions & 8 deletions src/effects/native/balanceeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ EffectManifest BalanceEffect::getManifest() {
return manifest;
}

BalanceGroupState::BalanceGroupState(const mixxx::AudioParameters& bufferParameters)
BalanceGroupState::BalanceGroupState(const mixxx::EngineParameters& bufferParameters)
: EffectState(bufferParameters),
m_pHighBuf(MAX_BUFFER_LEN),
m_oldSampleRate(bufferParameters.sampleRate()),
Expand Down Expand Up @@ -100,7 +100,7 @@ BalanceEffect::~BalanceEffect() {
void BalanceEffect::processChannel(const ChannelHandle& handle,
BalanceGroupState* pGroupState,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::AudioParameters& bufferParameters,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
Q_UNUSED(handle);
Expand Down Expand Up @@ -131,14 +131,14 @@ void BalanceEffect::processChannel(const ChannelHandle& handle,

if (pGroupState->m_freq > kMinCornerHz) {
if (freq > kMinCornerHz && enableState != EffectEnableState::Disabling) {
pGroupState->m_high->process(pInput, pGroupState->m_pHighBuf.data(), bufferParameters.bufferSize());
pGroupState->m_low->process(pInput, pOutput, bufferParameters.bufferSize());
pGroupState->m_high->process(pInput, pGroupState->m_pHighBuf.data(), bufferParameters.samplesPerBuffer());
pGroupState->m_low->process(pInput, pOutput, bufferParameters.samplesPerBuffer());
} else {
pGroupState->m_high->processAndPauseFilter(pInput, pGroupState->m_pHighBuf.data(), bufferParameters.bufferSize());
pGroupState->m_low->processAndPauseFilter(pInput, pOutput, bufferParameters.bufferSize());
pGroupState->m_high->processAndPauseFilter(pInput, pGroupState->m_pHighBuf.data(), bufferParameters.samplesPerBuffer());
pGroupState->m_low->processAndPauseFilter(pInput, pOutput, bufferParameters.samplesPerBuffer());
}

for (SINT i = 0; i < bufferParameters.bufferSize() / 2; ++i) {
for (SINT i = 0; i < bufferParameters.samplesPerBuffer() / 2; ++i) {
CSAMPLE mid = (pGroupState->m_pHighBuf[i * 2] + pGroupState->m_pHighBuf[i * 2 + 1]) / 2.0f;
CSAMPLE side = (pGroupState->m_pHighBuf[i * 2 + 1] - pGroupState->m_pHighBuf[i * 2]) / 2.0f;
CSAMPLE_GAIN currentMidSide = midSideStart + midSideDelta * i;
Expand All @@ -160,7 +160,7 @@ void BalanceEffect::processChannel(const ChannelHandle& handle,
pGroupState->m_high->pauseFilter();
pGroupState->m_low->pauseFilter();

for (SINT i = 0; i < bufferParameters.bufferSize() / 2; ++i) {
for (SINT i = 0; i < bufferParameters.samplesPerBuffer() / 2; ++i) {
CSAMPLE mid = (pInput[i * 2] + pInput[i * 2 + 1]) / 2.0f;
CSAMPLE side = (pInput[i * 2 + 1] - pInput[i * 2]) / 2.0f;
CSAMPLE_GAIN currentMidSide = midSideStart + midSideDelta * i;
Expand Down
4 changes: 2 additions & 2 deletions src/effects/native/balanceeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BalanceGroupState : public EffectState {
public:
BalanceGroupState(const mixxx::AudioParameters& bufferParameters);
BalanceGroupState(const mixxx::EngineParameters& bufferParameters);
~BalanceGroupState();

void setFilters(int sampleRate, int freq);
Expand Down Expand Up @@ -38,7 +38,7 @@ class BalanceEffect : public EffectProcessorImpl<BalanceGroupState> {
void processChannel(const ChannelHandle& handle,
BalanceGroupState* pState,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::AudioParameters& bufferParameters,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures);

Expand Down
6 changes: 3 additions & 3 deletions src/effects/native/bessel4lvmixeqeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ Bessel4LVMixEQEffect::~Bessel4LVMixEQEffect() {
void Bessel4LVMixEQEffect::processChannel(const ChannelHandle& handle,
Bessel4LVMixEQEffectGroupState* pState,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::AudioParameters& bufferParameters,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
Q_UNUSED(handle);
Q_UNUSED(groupFeatures);

if (enableState == EffectEnableState::Disabling) {
// Ramp to dry, when disabling, this will ramp from dry when enabling as well
pState->processChannelAndPause(pInput, pOutput, bufferParameters.bufferSize());
pState->processChannelAndPause(pInput, pOutput, bufferParameters.samplesPerBuffer());
} else {
double fLow;
double fMid;
Expand All @@ -75,7 +75,7 @@ void Bessel4LVMixEQEffect::processChannel(const ChannelHandle& handle,
fHigh = 0;
}
pState->processChannel(pInput, pOutput,
bufferParameters.bufferSize(),
bufferParameters.samplesPerBuffer(),
bufferParameters.sampleRate(),
fLow, fMid, fHigh,
m_pLoFreqCorner->get(), m_pHiFreqCorner->get());
Expand Down
4 changes: 2 additions & 2 deletions src/effects/native/bessel4lvmixeqeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class Bessel4LVMixEQEffectGroupState :
public LVMixEQEffectGroupState<EngineFilterBessel4Low> {
public:
Bessel4LVMixEQEffectGroupState(const mixxx::AudioParameters& bufferParameters)
Bessel4LVMixEQEffectGroupState(const mixxx::EngineParameters& bufferParameters)
: LVMixEQEffectGroupState<EngineFilterBessel4Low>(bufferParameters) {
}
};
Expand All @@ -35,7 +35,7 @@ class Bessel4LVMixEQEffect : public EffectProcessorImpl<Bessel4LVMixEQEffectGrou
void processChannel(const ChannelHandle& handle,
Bessel4LVMixEQEffectGroupState* pState,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::AudioParameters& bufferParameters,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatureState);

Expand Down
6 changes: 3 additions & 3 deletions src/effects/native/bessel8lvmixeqeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Bessel8LVMixEQEffect::~Bessel8LVMixEQEffect() {
void Bessel8LVMixEQEffect::processChannel(const ChannelHandle& handle,
Bessel8LVMixEQEffectGroupState* pState,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::AudioParameters& bufferParameters,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
Q_UNUSED(handle);
Expand All @@ -55,7 +55,7 @@ void Bessel8LVMixEQEffect::processChannel(const ChannelHandle& handle,

if (enableState == EffectEnableState::Disabling) {
// Ramp to dry, when disabling, this will ramp from dry when enabling as well
pState->processChannelAndPause(pInput, pOutput, bufferParameters.bufferSize());
pState->processChannelAndPause(pInput, pOutput, bufferParameters.samplesPerBuffer());
} else {
double fLow;
double fMid;
Expand All @@ -77,7 +77,7 @@ void Bessel8LVMixEQEffect::processChannel(const ChannelHandle& handle,
}
pState->processChannel(
pInput, pOutput,
bufferParameters.bufferSize(), bufferParameters.sampleRate(),
bufferParameters.samplesPerBuffer(), bufferParameters.sampleRate(),
fLow, fMid, fHigh,
m_pLoFreqCorner->get(), m_pHiFreqCorner->get());
}
Expand Down
4 changes: 2 additions & 2 deletions src/effects/native/bessel8lvmixeqeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
class Bessel8LVMixEQEffectGroupState :
public LVMixEQEffectGroupState<EngineFilterBessel8Low> {
public:
Bessel8LVMixEQEffectGroupState(const mixxx::AudioParameters& bufferParameters)
Bessel8LVMixEQEffectGroupState(const mixxx::EngineParameters& bufferParameters)
: LVMixEQEffectGroupState<EngineFilterBessel8Low>(bufferParameters) {
}
};
Expand All @@ -38,7 +38,7 @@ class Bessel8LVMixEQEffect : public EffectProcessorImpl<Bessel8LVMixEQEffectGrou
void processChannel(const ChannelHandle& handle,
Bessel8LVMixEQEffectGroupState* pState,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::AudioParameters& bufferParameters,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatureState);

Expand Down
Loading

0 comments on commit 33405b2

Please sign in to comment.