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
26namespace juce::dsp
27{
28
29enum 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
50template <typename SampleType>
52{
53public:
54 //==============================================================================
55 using MixingRule = DryWetMixingRule;
56
57 //==============================================================================
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
101private:
102 //==============================================================================
103 void update();
104
105 //==============================================================================
108 AudioBuffer<SampleType> bufferDry;
109
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
void pushDrySamples(const AudioBlock< const SampleType > drySamples)
void setWetMixProportion(SampleType newWetMixProportion)
void setMixingRule(MixingRule newRule)
void setWetLatency(SampleType wetLatencyInSamples)
void prepare(const ProcessSpec &spec)
void mixWetSamples(AudioBlock< SampleType > wetSamples)