32template <
typename SampleType>
40template <
typename SampleType>
47template <
typename SampleType>
50 jassert (newPan >= -1.0 && newPan <= 1.0);
52 pan =
jlimit (
static_cast<SampleType
> (-1.0),
static_cast<SampleType
> (1.0), newPan);
57template <
typename SampleType>
68template <
typename SampleType>
76template <
typename SampleType>
79 SampleType leftValue, rightValue, boostValue;
81 auto normalisedPan =
static_cast<SampleType
> (0.5) * (
pan +
static_cast<SampleType
> (1.0));
86 leftValue =
jmin (
static_cast<SampleType
> (0.5),
static_cast<SampleType
> (1.0) - normalisedPan);
87 rightValue =
jmin (
static_cast<SampleType
> (0.5), normalisedPan);
88 boostValue =
static_cast<SampleType
> (2.0);
92 leftValue =
static_cast<SampleType
> (1.0) - normalisedPan;
93 rightValue = normalisedPan;
94 boostValue =
static_cast<SampleType
> (2.0);
100 boostValue = std::sqrt (
static_cast<SampleType
> (2.0));
104 leftValue =
static_cast<SampleType
> (std::pow (std::sin (0.5 *
MathConstants<double>::pi * (1.0 - normalisedPan)), 1.5));
106 boostValue =
static_cast<SampleType
> (std::pow (2.0, 3.0 / 4.0));
110 leftValue =
static_cast<SampleType
> (std::pow (std::sin (0.5 *
MathConstants<double>::pi * (1.0 - normalisedPan)), 2.0));
112 boostValue =
static_cast<SampleType
> (2.0);
115 case Rule::squareRoot3dB:
116 leftValue = std::sqrt (
static_cast<SampleType
> (1.0) - normalisedPan);
117 rightValue = std::sqrt (normalisedPan);
118 boostValue = std::sqrt (
static_cast<SampleType
> (2.0));
121 case Rule::squareRoot4p5dB:
122 leftValue =
static_cast<SampleType
> (std::pow (std::sqrt (1.0 - normalisedPan), 1.5));
123 rightValue =
static_cast<SampleType
> (std::pow (std::sqrt (normalisedPan), 1.5));
124 boostValue =
static_cast<SampleType
> (std::pow (2.0, 3.0 / 4.0));
128 leftValue =
jmin (
static_cast<SampleType
> (0.5),
static_cast<SampleType
> (1.0) - normalisedPan);
129 rightValue =
jmin (
static_cast<SampleType
> (0.5), normalisedPan);
130 boostValue =
static_cast<SampleType
> (2.0);
134 leftVolume .setTargetValue (leftValue * boostValue);
135 rightVolume.setTargetValue (rightValue * boostValue);
Type jmin(const Type a, const Type b)
Definition MathsFunctions.h:60
Definition juce_Panner.h:52
Rule currentRule
Definition juce_Panner.h:114
PannerRule Rule
Definition juce_Panner.h:55
SmoothedValue< SampleType > leftVolume
Definition juce_Panner.h:116
void update()
Definition juce_Panner.cpp:77
void prepare(const ProcessSpec &spec)
Definition juce_Panner.cpp:58
void setPan(SampleType newPan)
Definition juce_Panner.cpp:48
void reset()
Definition juce_Panner.cpp:69
void setRule(Rule newRule)
Definition juce_Panner.cpp:41
Panner()
Definition juce_Panner.cpp:33
SmoothedValue< SampleType > rightVolume
Definition juce_Panner.h:116
SampleType pan
Definition juce_Panner.h:115
double sampleRate
Definition juce_Panner.h:117
Definition juce_AudioBlock.h:29
Definition carla_juce.cpp:31
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Definition juce_MathsFunctions.h:262
static constexpr FloatType pi
Definition juce_MathsFunctions.h:382
Definition juce_ProcessContext.h:38
uint32 numChannels
Definition juce_ProcessContext.h:46
double sampleRate
Definition juce_ProcessContext.h:40