30template <
typename SampleType>
38template <
typename SampleType>
41 currentRule = newRule;
45template <
typename SampleType>
48 jassert (newPan >= -1.0 && newPan <= 1.0);
50 pan =
jlimit (
static_cast<SampleType
> (-1.0),
static_cast<SampleType
> (1.0), newPan);
55template <
typename SampleType>
66template <
typename SampleType>
69 leftVolume .reset (sampleRate, 0.05);
70 rightVolume.reset (sampleRate, 0.05);
74template <
typename SampleType>
77 SampleType leftValue, rightValue, boostValue;
79 auto normalisedPan =
static_cast<SampleType
> (0.5) * (pan +
static_cast<SampleType
> (1.0));
84 leftValue =
jmin (
static_cast<SampleType
> (0.5),
static_cast<SampleType
> (1.0) - normalisedPan);
85 rightValue =
jmin (
static_cast<SampleType
> (0.5), normalisedPan);
86 boostValue =
static_cast<SampleType
> (2.0);
90 leftValue =
static_cast<SampleType
> (1.0) - normalisedPan;
91 rightValue = normalisedPan;
92 boostValue =
static_cast<SampleType
> (2.0);
98 boostValue =
std::sqrt (
static_cast<SampleType
> (2.0));
104 boostValue =
static_cast<SampleType
> (
std::pow (2.0, 3.0 / 4.0));
110 boostValue =
static_cast<SampleType
> (2.0);
113 case Rule::squareRoot3dB:
114 leftValue =
std::sqrt (
static_cast<SampleType
> (1.0) - normalisedPan);
116 boostValue =
std::sqrt (
static_cast<SampleType
> (2.0));
119 case Rule::squareRoot4p5dB:
120 leftValue =
static_cast<SampleType
> (
std::pow (
std::sqrt (1.0 - normalisedPan), 1.5));
121 rightValue =
static_cast<SampleType
> (
std::pow (
std::sqrt (normalisedPan), 1.5));
122 boostValue =
static_cast<SampleType
> (
std::pow (2.0, 3.0 / 4.0));
126 leftValue =
jmin (
static_cast<SampleType
> (0.5),
static_cast<SampleType
> (1.0) - normalisedPan);
127 rightValue =
jmin (
static_cast<SampleType
> (0.5), normalisedPan);
128 boostValue =
static_cast<SampleType
> (2.0);
132 leftVolume .setTargetValue (leftValue * boostValue);
133 rightVolume.setTargetValue (rightValue * boostValue);
137template class Panner<float>;
138template class Panner<double>;
A processor to perform panning operations on stereo buffers.
void prepare(const ProcessSpec &spec)
Initialises the processor.
void setPan(SampleType newPan)
Sets the current panning value, between -1 (full left) and 1 (full right).
void reset()
Resets the internal state variables of the processor.
void setRule(Rule newRule)
Sets the panning rule.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
Type jlimit(Type lowerLimit, Type upperLimit, Type valueToConstrain) noexcept
Constrains a value to keep it within a given range.
Commonly used mathematical constants.
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...
uint32 numChannels
The number of channels that the process() method will be expected to handle.
double sampleRate
The sample rate that will be used for the data that is sent to the processor.