OpenShot Audio Library | OpenShotAudio  0.3.2
juce_Oversampling.h
1 /*
2  ==============================================================================
3 
4  This file is part of the JUCE library.
5  Copyright (c) 2017 - ROLI Ltd.
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 5 End-User License
11  Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
12  27th April 2017).
13 
14  End User License Agreement: www.juce.com/juce-5-licence
15  Privacy Policy: www.juce.com/juce-5-privacy-policy
16 
17  Or: You may also use this code under the terms of the GPL v3 (see
18  www.gnu.org/licenses).
19 
20  JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21  EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22  DISCLAIMED.
23 
24  ==============================================================================
25 */
26 
27 namespace juce
28 {
29 namespace dsp
30 {
31 
32 //==============================================================================
56 template <typename SampleType>
57 class JUCE_API Oversampling
58 {
59 public:
62  {
63  filterHalfBandFIREquiripple = 0,
64  filterHalfBandPolyphaseIIR,
65  numFilterTypes
66  };
67 
68  //==============================================================================
81  Oversampling (size_t numChannels,
82  size_t factor,
83  FilterType type,
84  bool isMaxQuality = true);
85 
94  explicit Oversampling (size_t numChannels = 1);
95 
97  ~Oversampling();
98 
99  //==============================================================================
108  SampleType getLatencyInSamples() noexcept;
109 
111  size_t getOversamplingFactor() noexcept;
112 
113  //==============================================================================
117  void initProcessing (size_t maximumNumberOfSamplesBeforeOversampling);
118 
120  void reset() noexcept;
121 
129  AudioBlock<SampleType> processSamplesUp (const AudioBlock<const SampleType>& inputBlock) noexcept;
130 
136  void processSamplesDown (AudioBlock<SampleType>& outputBlock) noexcept;
137 
138  //==============================================================================
162  void addOversamplingStage (FilterType,
163  float normalisedTransitionWidthUp, float stopbandAmplitudedBUp,
164  float normalisedTransitionWidthDown, float stopbandAmplitudedBDown);
165 
173  void addDummyOversamplingStage();
174 
180  void clearOversamplingStages();
181 
182  //==============================================================================
183  size_t factorOversampling = 1;
184  size_t numChannels = 1;
185 
186  #ifndef DOXYGEN
187  struct OversamplingStage;
188  #endif
189 
190 private:
191  //==============================================================================
193  bool isReady = false;
194 
195  //==============================================================================
196  JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Oversampling)
197 };
198 
199 } // namespace dsp
200 } // namespace juce