Loading...
Searching...
No Matches
juce_Oversampling.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
{
//==============================================================================
template <typename SampleType>
class JUCE_API Oversampling
{
public:
enum FilterType
{
filterHalfBandFIREquiripple = 0,
filterHalfBandPolyphaseIIR,
numFilterTypes
};
//==============================================================================
explicit Oversampling (size_t numChannels = 1);
Oversampling (size_t numChannels,
size_t factor,
FilterType type,
bool isMaxQuality = true,
bool useIntegerLatency = false);
~Oversampling();
//==============================================================================
/* Sets if this processor should add some fractional delay at the end of the signal
path to ensure that the overall latency of the oversampling is an integer.
*/
void setUsingIntegerLatency (bool shouldUseIntegerLatency) noexcept;
SampleType getLatencyInSamples() const noexcept;
size_t getOversamplingFactor() const noexcept;
//==============================================================================
void initProcessing (size_t maximumNumberOfSamplesBeforeOversampling);
void reset() noexcept;
AudioBlock<SampleType> processSamplesUp (const AudioBlock<const SampleType>& inputBlock) noexcept;
void processSamplesDown (AudioBlock<SampleType>& outputBlock) noexcept;
//==============================================================================
void addOversamplingStage (FilterType,
float normalisedTransitionWidthUp, float stopbandAmplitudedBUp,
float normalisedTransitionWidthDown, float stopbandAmplitudedBDown);
void addDummyOversamplingStage();
void clearOversamplingStages();
//==============================================================================
size_t factorOversampling = 1;
size_t numChannels = 1;
#ifndef DOXYGEN
struct OversamplingStage;
#endif
private:
//==============================================================================
void updateDelayLine();
SampleType getUncompensatedLatency() const noexcept;
//==============================================================================
OwnedArray<OversamplingStage> stages;
bool isReady = false, shouldUseIntegerLatency = false;
DelayLine<SampleType, DelayLineInterpolationTypes::Thiran> delay { 8 };
SampleType fractionalDelay = 0;
//==============================================================================
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Oversampling)
};
} // namespace juce::dsp
juce::OwnedArray
Definition juce_OwnedArray.h:50
juce::dsp::AudioBlock
Definition juce_AudioBlock.h:68
juce::dsp::DelayLine
Definition juce_DelayLine.h:93
juce::dsp::Oversampling
Definition juce_Oversampling.h:54
juce::dsp::Oversampling::FilterType
FilterType
Definition juce_Oversampling.h:58
juce::dsp::Oversampling::Oversampling
Oversampling(size_t numChannels=1)
Definition juce_Oversampling.cpp:531
juce::dsp::DelayLineInterpolationTypes
Definition juce_DelayLine.h:35