OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_DryWetMixer.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26 namespace juce::dsp
27{
28
29 enum class DryWetMixingRule
30{
31 linear, // dry volume is equal to 1 - wet volume
32 balanced, // both dry and wet are 1 when mix is 0.5, with dry decreasing to 0
33 // above this value and wet decreasing to 0 below it
34 sin3dB, // alternate dry/wet mixing rule using the 3 dB sine panning rule
35 sin4p5dB, // alternate dry/wet mixing rule using the 4.5 dB sine panning rule
36 sin6dB, // alternate dry/wet mixing rule using the 6 dB sine panning rule
37 squareRoot3dB, // alternate dry/wet mixing rule using the regular 3 dB panning rule
38 squareRoot4p5dB // alternate dry/wet mixing rule using the regular 4.5 dB panning rule
39};
40
50 template <typename SampleType>
51 class DryWetMixer
52{
53 public:
54 //==============================================================================
55 using MixingRule = DryWetMixingRule;
56
57 //==============================================================================
59 DryWetMixer();
60
62 explicit DryWetMixer (int maximumWetLatencyInSamples);
63
64 //==============================================================================
66 void setMixingRule (MixingRule newRule);
67
71 void setWetMixProportion (SampleType newWetMixProportion);
72
77 void setWetLatency (SampleType wetLatencyInSamples);
78
79 //==============================================================================
81 void prepare (const ProcessSpec& spec);
82
84 void reset();
85
86 //==============================================================================
88 void pushDrySamples (const AudioBlock<const SampleType> drySamples);
89
99 void mixWetSamples (AudioBlock<SampleType> wetSamples);
100
101 private:
102 //==============================================================================
103 void update();
104
105 //==============================================================================
106 SmoothedValue<SampleType, ValueSmoothingTypes::Linear> dryVolume, wetVolume;
107 DelayLine<SampleType, DelayLineInterpolationTypes::Thiran> dryDelayLine;
108 AudioBuffer<SampleType> bufferDry;
109
110 SingleThreadedAbstractFifo fifo;
111 SampleType mix = 1.0;
112 MixingRule currentMixingRule = MixingRule::linear;
113 double sampleRate = 44100.0;
114 int maximumWetLatencyInSamples = 0;
115};
116
117} // 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
Definition juce_DryWetMixer.h:52
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