Skip to content

Commit

Permalink
Merge pull request mixxxdj#1676 from Be-ing/effects_mixing_mode
Browse files Browse the repository at this point in the history
Effect unit mixing mode
  • Loading branch information
ronso0 authored and GitHub committed May 31, 2018
2 parents ba82654 + ac8b7be commit f542eb4
Show file tree
Hide file tree
Showing 63 changed files with 287 additions and 150 deletions.
7 changes: 4 additions & 3 deletions lib/reverb/Reverb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ Descriptor<PlateX2>::setup()

// (timrae) we have our left / right samples interleaved in the same array, so use slightly modified version of PlateX2::cycle
void MixxxPlateX2::processBuffer(const sample_t* in, sample_t* out, const uint frames, const sample_t bandwidthParam,
const sample_t decayParam, const sample_t dampingParam, const sample_t blendParam) {
const sample_t decayParam, const sample_t dampingParam, const sample_t blendParam, double wet) {
// set bandwidth
input.bandwidth.set(exp(-M_PI * (1. - (.005 + .994*bandwidthParam))));
// set decay
Expand All @@ -454,7 +454,8 @@ void MixxxPlateX2::processBuffer(const sample_t* in, sample_t* out, const uint f
sample_t mono_sample = blend * (in[i] + in[i + 1]) / 2;
sample_t xl, xr;
PlateStub::process(mono_sample, decay, &xl, &xr);
out[i] = xl + in[i];
out[i + 1] = xr + in[i + 1];
out[i] = (xl * wet) + (in[i] * (1 - wet));
out[i + 1] = (xr * wet) + (in[i + 1] * (1 - wet));
}
}

2 changes: 1 addition & 1 deletion lib/reverb/Reverb.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class PlateX2
class MixxxPlateX2 : public PlateStub {
public:
void processBuffer(const sample_t* in, sample_t* out, const uint frames, const sample_t bandwidthParam,
const sample_t decayParam, const sample_t dampingParam, const sample_t blendParam);
const sample_t decayParam, const sample_t dampingParam, const sample_t blendParam, double wet);

void init(float sampleRate) {
fs = sampleRate;
Expand Down
11 changes: 11 additions & 0 deletions res/skins/Tango/fx_unit_left.xml
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,17 @@ Variables:

<WidgetGroup><Size>1min,0me</Size></WidgetGroup>

<Template src="skin:button_2state.xml">
<SetVariable name="ObjectName">MixModeButtons</SetVariable>
<SetVariable name="TooltipId">EffectUnit_mix_mode</SetVariable>
<SetVariable name="Size">35f,20f</SetVariable>
<SetVariable name="state_0_text">D/W</SetVariable>
<SetVariable name="state_1_text">D+W</SetVariable>
<SetVariable name="ConfigKey">[EffectRack1_EffectUnit<Variable name="FxUnit"/>],mix_mode</SetVariable>
</Template>

<WidgetGroup><Size>1min,0me</Size></WidgetGroup>

<WidgetGroup><!-- Super Knob, if enabled -->
<SizePolicy>min,min</SizePolicy>
<Layout>vertical</Layout>
Expand Down
9 changes: 9 additions & 0 deletions res/skins/Tango/fx_unit_left_mini.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@ Variables:
</Connection>
</WidgetGroup>

<Template src="skin:button_2state.xml">
<SetVariable name="ObjectName">MixModeButtons</SetVariable>
<SetVariable name="TooltipId">EffectUnit_mix_mode</SetVariable>
<SetVariable name="Size">35f,20f</SetVariable>
<SetVariable name="state_0_text">D/W</SetVariable>
<SetVariable name="state_1_text">D+W</SetVariable>
<SetVariable name="ConfigKey">[EffectRack1_EffectUnit<Variable name="FxUnit"/>],mix_mode</SetVariable>
</Template>

<Template src="skin:knob_textless.xml">
<SetVariable name="ObjectName">SuperWetDryKnob</SetVariable>
<SetVariable name="TooltipId">EffectUnit_mix</SetVariable>
Expand Down
11 changes: 11 additions & 0 deletions res/skins/Tango/fx_unit_right.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ Variables:

<WidgetGroup><Size>1min,0me</Size></WidgetGroup>

<Template src="skin:button_2state.xml">
<SetVariable name="ObjectName">MixModeButtons</SetVariable>
<SetVariable name="TooltipId">EffectUnit_mix_mode</SetVariable>
<SetVariable name="Size">35f,20f</SetVariable>
<SetVariable name="state_0_text">D/W</SetVariable>
<SetVariable name="state_1_text">D+W</SetVariable>
<SetVariable name="ConfigKey">[EffectRack1_EffectUnit<Variable name="FxUnit"/>],mix_mode</SetVariable>
</Template>

<WidgetGroup><Size>1min,0me</Size></WidgetGroup>

<WidgetGroup><!-- Super Knob, if enabled -->
<SizePolicy>min,min</SizePolicy>
<Layout>vertical</Layout>
Expand Down
9 changes: 9 additions & 0 deletions res/skins/Tango/fx_unit_right_mini.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ Variables:
<SetVariable name="Color">red</SetVariable>
</Template>

<Template src="skin:button_2state.xml">
<SetVariable name="ObjectName">MixModeButtons</SetVariable>
<SetVariable name="TooltipId">EffectUnit_mix_mode</SetVariable>
<SetVariable name="Size">35f,20f</SetVariable>
<SetVariable name="state_0_text">D/W</SetVariable>
<SetVariable name="state_1_text">D+W</SetVariable>
<SetVariable name="ConfigKey">[EffectRack1_EffectUnit<Variable name="FxUnit"/>],mix_mode</SetVariable>
</Template>

<WidgetGroup>
<SizePolicy>max,min</SizePolicy>
<Layout>vertical</Layout>
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/controlpickermenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,9 +500,9 @@ ControlPickerMenu::ControlPickerMenu(QWidget* pParent)
tr("Super Knob (control effects' Meta Knobs)"),
descriptionPrefix,
effectUnitMenu, true);
addPrefixedControl(effectUnitGroup, "insertion_type",
tr("Insert/Send Toggle"),
tr("Insert/Send Toggle"),
addPrefixedControl(effectUnitGroup, "Mix Mode",
tr("Mix Mode Toggle"),
tr("Toggle effect unit between D/W and D+W modes"),
descriptionPrefix,
effectUnitMenu);
addPrefixedControl(effectUnitGroup, "next_chain",
Expand Down
4 changes: 3 additions & 1 deletion src/effects/builtin/autopaneffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ void AutoPanEffect::processChannel(
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode) {
Q_UNUSED(handle);
Q_UNUSED(mixMode);

if (enableState == EffectEnableState::Disabled) {
return;
Expand Down
3 changes: 2 additions & 1 deletion src/effects/builtin/autopaneffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ class AutoPanEffect : public EffectProcessorImpl<AutoPanGroupState> {
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures);
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode);

double computeLawCoefficient(double position);

Expand Down
4 changes: 3 additions & 1 deletion src/effects/builtin/balanceeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,11 @@ void BalanceEffect::processChannel(const ChannelHandle& handle,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode) {
Q_UNUSED(handle);
Q_UNUSED(groupFeatures);
Q_UNUSED(mixMode);

CSAMPLE_GAIN balance = 0;
CSAMPLE_GAIN midSide = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/effects/builtin/balanceeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class BalanceEffect : public EffectProcessorImpl<BalanceGroupState> {
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures);
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode);

private:

Expand Down
4 changes: 3 additions & 1 deletion src/effects/builtin/bessel4lvmixeqeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ void Bessel4LVMixEQEffect::processChannel(const ChannelHandle& handle,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode) {
Q_UNUSED(handle);
Q_UNUSED(groupFeatures);
Q_UNUSED(mixMode);

if (enableState == EffectEnableState::Disabling) {
// Ramp to dry, when disabling, this will ramp from dry when enabling as well
Expand Down
3 changes: 2 additions & 1 deletion src/effects/builtin/bessel4lvmixeqeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class Bessel4LVMixEQEffect : public EffectProcessorImpl<Bessel4LVMixEQEffectGrou
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatureState);
const GroupFeatureState& groupFeatureState,
const EffectChainMixMode mixMode);

private:
QString debugString() const {
Expand Down
4 changes: 3 additions & 1 deletion src/effects/builtin/bessel8lvmixeqeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ void Bessel8LVMixEQEffect::processChannel(const ChannelHandle& handle,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode) {
Q_UNUSED(handle);
Q_UNUSED(groupFeatures);
Q_UNUSED(mixMode);


if (enableState == EffectEnableState::Disabling) {
Expand Down
3 changes: 2 additions & 1 deletion src/effects/builtin/bessel8lvmixeqeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class Bessel8LVMixEQEffect : public EffectProcessorImpl<Bessel8LVMixEQEffectGrou
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatureState);
const GroupFeatureState& groupFeatureState,
const EffectChainMixMode mixMode);

private:
QString debugString() const {
Expand Down
4 changes: 3 additions & 1 deletion src/effects/builtin/biquadfullkilleqeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,11 @@ void BiquadFullKillEQEffect::processChannel(
CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode) {
Q_UNUSED(handle);
Q_UNUSED(groupFeatures);
Q_UNUSED(mixMode);

if (pState->m_oldSampleRate != bufferParameters.sampleRate() ||
(pState->m_loFreqCorner != m_pLoFreqCorner->get()) ||
Expand Down
3 changes: 2 additions & 1 deletion src/effects/builtin/biquadfullkilleqeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ class BiquadFullKillEQEffect : public EffectProcessorImpl<BiquadFullKillEQEffect
const CSAMPLE* pInput, CSAMPLE *pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatureState);
const GroupFeatureState& groupFeatureState,
const EffectChainMixMode mixMode);

private:
BiquadFullKillEQEffect(const BiquadFullKillEQEffect&) = delete;
Expand Down
4 changes: 3 additions & 1 deletion src/effects/builtin/bitcrushereffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ void BitCrusherEffect::processChannel(const ChannelHandle& handle,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode) {
Q_UNUSED(handle);
Q_UNUSED(groupFeatures);
Q_UNUSED(mixMode);
Q_UNUSED(enableState); // no need to ramp, it is just a bitcrusher ;-)

const CSAMPLE downsample = m_pDownsampleParameter ?
Expand Down
3 changes: 2 additions & 1 deletion src/effects/builtin/bitcrushereffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ class BitCrusherEffect : public EffectProcessorImpl<BitCrusherGroupState> {
const CSAMPLE* pInput, CSAMPLE *pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatureState);
const GroupFeatureState& groupFeatureState,
const EffectChainMixMode mixMode);

private:
QString debugString() const {
Expand Down
16 changes: 10 additions & 6 deletions src/effects/builtin/echoeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ EffectManifestPointer EchoEffect::getManifest() {
send->setName(QObject::tr("Send"));
send->setShortName(QObject::tr("Send"));
send->setDescription(QObject::tr(
"How much of the signal to send into the delay buffer"));
"How much of the signal to send into the delay buffer\n"
"When the effect unit is in D+W mode, keep this turned up all the way"));
send->setControlHint(EffectManifestParameter::ControlHint::KNOB_LINEAR);
send->setSemanticHint(EffectManifestParameter::SemanticHint::UNKNOWN);
send->setUnitsHint(EffectManifestParameter::UnitsHint::UNKNOWN);
Expand Down Expand Up @@ -134,7 +135,8 @@ void EchoEffect::processChannel(const ChannelHandle& handle, EchoGroupState* pGr
CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode) {
Q_UNUSED(handle);

EchoGroupState& gs = *pGroupState;
Expand Down Expand Up @@ -184,6 +186,8 @@ void EchoEffect::processChannel(const ChannelHandle& handle, EchoGroupState* pGr
bufferParameters.framesPerBuffer();
const CSAMPLE_GAIN feedback_start = gs.prev_feedback + feedback_delta;

const bool addDry = mixMode == EffectChainMixMode::DrySlashWet;

//TODO: rewrite to remove assumption of stereo buffer
for (unsigned int i = 0;
i < bufferParameters.samplesPerBuffer();
Expand Down Expand Up @@ -221,19 +225,19 @@ void EchoEffect::processChannel(const ChannelHandle& handle, EchoGroupState* pGr
if (gs.ping_pong < delay_samples / 2) {
// Left sample plus a fraction of the right sample, normalized
// by 1 + fraction.
pOutput[i] = pInput[i] +
pOutput[i] = (addDry ? pInput[i] : 0) +
((bufferedSampleLeft + bufferedSampleRight * pingpong_frac) /
(1 + pingpong_frac));
// Right sample reduced by (1 - fraction)
pOutput[i + 1] = pInput[i + 1] +
pOutput[i + 1] = (addDry ? pInput[i + 1] : 0) +
(bufferedSampleRight * (1 - pingpong_frac));
} else {
// Left sample reduced by (1 - fraction)
pOutput[i] = pInput[i] +
pOutput[i] = (addDry ? pInput[i] : 0) +
(bufferedSampleLeft * (1 - pingpong_frac));
// Right sample plus fraction of left sample, normalized by
// 1 + fraction
pOutput[i + 1] = pInput[i + 1] +
pOutput[i + 1] = (addDry ? pInput[i + 1] : 0) +
((bufferedSampleRight + bufferedSampleLeft * pingpong_frac) /
(1 + pingpong_frac));
}
Expand Down
3 changes: 2 additions & 1 deletion src/effects/builtin/echoeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class EchoEffect : public EffectProcessorImpl<EchoGroupState> {
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) override;
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode) override;

private:
QString debugString() const {
Expand Down
4 changes: 3 additions & 1 deletion src/effects/builtin/filtereffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,11 @@ void FilterEffect::processChannel(const ChannelHandle& handle,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode) {
Q_UNUSED(handle);
Q_UNUSED(groupFeatures);
Q_UNUSED(mixMode);

double hpf;
double lpf;
Expand Down
3 changes: 2 additions & 1 deletion src/effects/builtin/filtereffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ class FilterEffect : public EffectProcessorImpl<FilterGroupState> {
const CSAMPLE* pInput, CSAMPLE *pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures);
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode);

private:
QString debugString() const {
Expand Down
4 changes: 3 additions & 1 deletion src/effects/builtin/flangereffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ void FlangerEffect::processChannel(const ChannelHandle& handle,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode) {
Q_UNUSED(handle);
Q_UNUSED(mixMode);

double lfoPeriodParameter = m_pSpeedParameter->value();
double lfoPeriodFrames;
Expand Down
3 changes: 2 additions & 1 deletion src/effects/builtin/flangereffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ class FlangerEffect : public EffectProcessorImpl<FlangerGroupState> {
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures);
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode);

private:
QString debugString() const {
Expand Down
4 changes: 3 additions & 1 deletion src/effects/builtin/graphiceqeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,11 @@ void GraphicEQEffect::processChannel(const ChannelHandle& handle,
const CSAMPLE* pInput, CSAMPLE* pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatures) {
const GroupFeatureState& groupFeatures,
const EffectChainMixMode mixMode) {
Q_UNUSED(handle);
Q_UNUSED(groupFeatures);
Q_UNUSED(mixMode);

// If the sample rate has changed, initialize the filters using the new
// sample rate
Expand Down
3 changes: 2 additions & 1 deletion src/effects/builtin/graphiceqeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class GraphicEQEffect : public EffectProcessorImpl<GraphicEQEffectGroupState> {
const CSAMPLE* pInput, CSAMPLE *pOutput,
const mixxx::EngineParameters& bufferParameters,
const EffectEnableState enableState,
const GroupFeatureState& groupFeatureState);
const GroupFeatureState& groupFeatureState,
const EffectChainMixMode mixMode);

private:
QString debugString() const {
Expand Down
Loading

0 comments on commit f542eb4

Please sign in to comment.