Skip to content

Commit

Permalink
Reverb: add Dry/Wet parameter
Browse files Browse the repository at this point in the history
Using the Send parameter when the effect unit is in D+W mode does not
work as desired because it reduces the volume of the whole effect unit.
  • Loading branch information
Be-ing committed May 27, 2018
1 parent 3b4d6b3 commit 88d78fe
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 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, bool addDry) {
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 + (addDry ? in[i] : 0);
out[i + 1] = xr + (addDry ? in[i + 1] : 0);
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, bool addDry);
const sample_t decayParam, const sample_t dampingParam, const sample_t blendParam, double wet);

void init(float sampleRate) {
fs = sampleRate;
Expand Down
28 changes: 24 additions & 4 deletions src/effects/native/reverbeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ EffectManifestPointer ReverbEffect::getManifest() {
send->setName(QObject::tr("Send"));
send->setShortName(QObject::tr("Send"));
send->setDescription(QObject::tr(
"How much of the signal to send to the effect"));
"How much of the signal to send in to the effect\n"
"Lowering this fades out the effect smoothly\n"
"Use this to adjust the amount of the effect when the effect unit is in D/W mode\n"));
send->setControlHint(EffectManifestParameter::ControlHint::KNOB_LINEAR);
send->setSemanticHint(EffectManifestParameter::SemanticHint::UNKNOWN);
send->setUnitsHint(EffectManifestParameter::UnitsHint::UNKNOWN);
Expand All @@ -73,14 +75,31 @@ EffectManifestPointer ReverbEffect::getManifest() {
send->setMinimum(0);
send->setDefault(0);
send->setMaximum(1);

EffectManifestParameterPointer dryWet = pManifest->addParameter();
dryWet->setId("dry_wet");
dryWet->setName(QObject::tr("Dry/Wet"));
dryWet->setShortName(QObject::tr("Dry/Wet"));
dryWet->setDescription(QObject::tr(
"Mix between the input (dry) and output (wet) of the effect\n"
"Lowering this fades out the effect abruptly\n"
"Use this to adjust the amount of the effect when the effect unit is in D+W mode"));
dryWet->setControlHint(EffectManifestParameter::ControlHint::KNOB_LINEAR);
dryWet->setSemanticHint(EffectManifestParameter::SemanticHint::UNKNOWN);
dryWet->setUnitsHint(EffectManifestParameter::UnitsHint::UNKNOWN);
dryWet->setMinimum(0);
dryWet->setDefault(1);
dryWet->setMaximum(1);

return pManifest;
}

ReverbEffect::ReverbEffect(EngineEffect* pEffect)
: m_pDecayParameter(pEffect->getParameterById("decay")),
m_pBandWidthParameter(pEffect->getParameterById("bandwidth")),
m_pDampingParameter(pEffect->getParameterById("damping")),
m_pSendParameter(pEffect->getParameterById("send_amount")) {
m_pSendParameter(pEffect->getParameterById("send_amount")),
m_pDryWetParameter(pEffect->getParameterById("dry_wet")) {
}

ReverbEffect::~ReverbEffect() {
Expand All @@ -96,6 +115,7 @@ void ReverbEffect::processChannel(const ChannelHandle& handle,
const EffectChainInsertionType insertionType) {
Q_UNUSED(handle);
Q_UNUSED(groupFeatures);
Q_UNUSED(insertionType);

if (!pState || !m_pDecayParameter || !m_pBandWidthParameter || !m_pDampingParameter || !m_pSendParameter) {
qWarning() << "Could not retrieve all effect parameters";
Expand All @@ -106,7 +126,7 @@ void ReverbEffect::processChannel(const ChannelHandle& handle,
const auto bandwidth = m_pBandWidthParameter->value();
const auto damping = m_pDampingParameter->value();
const auto send = m_pSendParameter->value();
bool addDry = insertionType == EffectChainInsertionType::Insert;
const double wet = m_pDryWetParameter->value();

// Reinitialize the effect when turning it on to prevent replaying the old buffer
// from the last time the effect was enabled.
Expand All @@ -118,5 +138,5 @@ void ReverbEffect::processChannel(const ChannelHandle& handle,
}
pState->reverb.processBuffer(pInput, pOutput,
bufferParameters.samplesPerBuffer(),
bandwidth, decay, damping, send, addDry);
bandwidth, decay, damping, send, wet);
}
1 change: 1 addition & 0 deletions src/effects/native/reverbeffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class ReverbEffect : public EffectProcessorImpl<ReverbGroupState> {
EngineEffectParameter* m_pBandWidthParameter;
EngineEffectParameter* m_pDampingParameter;
EngineEffectParameter* m_pSendParameter;
EngineEffectParameter* m_pDryWetParameter;

DISALLOW_COPY_AND_ASSIGN(ReverbEffect);
};
Expand Down

0 comments on commit 88d78fe

Please sign in to comment.