OpenShot Audio Library | OpenShotAudio: juce_Oversampling.h Source File

OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_Oversampling.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
29//==============================================================================
52template <typename SampleType>
53 class JUCE_API Oversampling
54{
55public:
57 enum FilterType
58 {
59 filterHalfBandFIREquiripple = 0,
60 filterHalfBandPolyphaseIIR,
61 numFilterTypes
62 };
63
64 //==============================================================================
74 explicit Oversampling (size_t numChannels = 1);
75
89 Oversampling (size_t numChannels,
90 size_t factor,
91 FilterType type,
92 bool isMaxQuality = true,
93 bool useIntegerLatency = false);
94
96 ~Oversampling();
97
98 //==============================================================================
99 /* Sets if this processor should add some fractional delay at the end of the signal
100 path to ensure that the overall latency of the oversampling is an integer.
101 */
102 void setUsingIntegerLatency (bool shouldUseIntegerLatency) noexcept;
103
114 SampleType getLatencyInSamples() const noexcept;
115
117 size_t getOversamplingFactor() const noexcept;
118
119 //==============================================================================
123 void initProcessing (size_t maximumNumberOfSamplesBeforeOversampling);
124
126 void reset() noexcept;
127
135 AudioBlock<SampleType> processSamplesUp (const AudioBlock<const SampleType>& inputBlock) noexcept;
136
142 void processSamplesDown (AudioBlock<SampleType>& outputBlock) noexcept;
143
144 //==============================================================================
168 void addOversamplingStage (FilterType,
169 float normalisedTransitionWidthUp, float stopbandAmplitudedBUp,
170 float normalisedTransitionWidthDown, float stopbandAmplitudedBDown);
171
179 void addDummyOversamplingStage();
180
186 void clearOversamplingStages();
187
188 //==============================================================================
189 size_t factorOversampling = 1;
190 size_t numChannels = 1;
191
192 #ifndef DOXYGEN
193 struct OversamplingStage;
194 #endif
195
196private:
197 //==============================================================================
198 void updateDelayLine();
199 SampleType getUncompensatedLatency() const noexcept;
200
201 //==============================================================================
202 OwnedArray<OversamplingStage> stages;
203 bool isReady = false, shouldUseIntegerLatency = false;
204 DelayLine<SampleType, DelayLineInterpolationTypes::Thiran> delay { 8 };
205 SampleType fractionalDelay = 0;
206
207 //==============================================================================
208 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Oversampling)
209};
210
211} // 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