Loading...
Searching...
No Matches
juce_DryWetMixer.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce::dsp
{
enum class DryWetMixingRule
{
linear, // dry volume is equal to 1 - wet volume
balanced, // both dry and wet are 1 when mix is 0.5, with dry decreasing to 0
// above this value and wet decreasing to 0 below it
sin3dB, // alternate dry/wet mixing rule using the 3 dB sine panning rule
sin4p5dB, // alternate dry/wet mixing rule using the 4.5 dB sine panning rule
sin6dB, // alternate dry/wet mixing rule using the 6 dB sine panning rule
squareRoot3dB, // alternate dry/wet mixing rule using the regular 3 dB panning rule
squareRoot4p5dB // alternate dry/wet mixing rule using the regular 4.5 dB panning rule
};
template <typename SampleType>
class DryWetMixer
{
public:
//==============================================================================
using MixingRule = DryWetMixingRule;
//==============================================================================
DryWetMixer();
explicit DryWetMixer (int maximumWetLatencyInSamples);
//==============================================================================
void setMixingRule (MixingRule newRule);
void setWetMixProportion (SampleType newWetMixProportion);
void setWetLatency (SampleType wetLatencyInSamples);
//==============================================================================
void prepare (const ProcessSpec& spec);
void reset();
//==============================================================================
void pushDrySamples (const AudioBlock<const SampleType> drySamples);
void mixWetSamples (AudioBlock<SampleType> wetSamples);
private:
//==============================================================================
void update();
//==============================================================================
SmoothedValue<SampleType, ValueSmoothingTypes::Linear> dryVolume, wetVolume;
DelayLine<SampleType, DelayLineInterpolationTypes::Thiran> dryDelayLine;
AudioBuffer<SampleType> bufferDry;
SingleThreadedAbstractFifo fifo;
SampleType mix = 1.0;
MixingRule currentMixingRule = MixingRule::linear;
double sampleRate = 44100.0;
int maximumWetLatencyInSamples = 0;
};
} // namespace juce::dsp
juce::AudioBuffer
Definition juce_AudioSampleBuffer.h:34
juce::SingleThreadedAbstractFifo
Definition juce_SingleThreadedAbstractFifo.h:64
juce::SmoothedValue
Definition juce_SmoothedValue.h:227
juce::dsp::AudioBlock
Definition juce_AudioBlock.h:68
juce::dsp::DelayLine
Definition juce_DelayLine.h:93
juce::dsp::DryWetMixer::pushDrySamples
void pushDrySamples(const AudioBlock< const SampleType > drySamples)
Definition juce_DryWetMixer.cpp:100
juce::dsp::DryWetMixer::setWetMixProportion
void setWetMixProportion(SampleType newWetMixProportion)
Definition juce_DryWetMixer.cpp:56
juce::dsp::DryWetMixer::reset
void reset()
Definition juce_DryWetMixer.cpp:87
juce::dsp::DryWetMixer::setMixingRule
void setMixingRule(MixingRule newRule)
Definition juce_DryWetMixer.cpp:49
juce::dsp::DryWetMixer::setWetLatency
void setWetLatency(SampleType wetLatencyInSamples)
Definition juce_DryWetMixer.cpp:65
juce::dsp::DryWetMixer::prepare
void prepare(const ProcessSpec &spec)
Definition juce_DryWetMixer.cpp:72
juce::dsp::DryWetMixer::mixWetSamples
void mixWetSamples(AudioBlock< SampleType > wetSamples)
Definition juce_DryWetMixer.cpp:127
juce::dsp::DryWetMixer::DryWetMixer
DryWetMixer()
Definition juce_DryWetMixer.cpp:31
juce::dsp::ProcessSpec
Definition juce_ProcessContext.h:36