JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_ResamplingAudioSource.h
Go to the documentation of this file.
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 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23namespace juce
24{
25
26//==============================================================================
34class JUCE_API ResamplingAudioSource : public AudioSource
35{
36public:
37 //==============================================================================
46 bool deleteInputWhenDeleted,
47 int numChannels = 2);
48
50 ~ResamplingAudioSource() override;
51
60 void setResamplingRatio (double samplesInPerOutputSample);
61
66 double getResamplingRatio() const noexcept { return ratio; }
67
69 void flushBuffers();
70
71 //==============================================================================
72 void prepareToPlay (int samplesPerBlockExpected, double sampleRate) override;
73 void releaseResources() override;
74 void getNextAudioBlock (const AudioSourceChannelInfo&) override;
75
76private:
77 //==============================================================================
79 double ratio = 1.0, lastRatio = 1.0;
80 AudioBuffer<float> buffer;
81 int bufferPos = 0, sampsInBuffer = 0;
82 double subSampleOffset = 0.0;
83 double coefficients[6];
84 SpinLock ratioLock;
85 CriticalSection callbackLock;
86 const int numChannels;
87 HeapBlock<float*> destBuffers;
88 HeapBlock<const float*> srcBuffers;
89
90 void setFilterCoefficients (double c1, double c2, double c3, double c4, double c5, double c6);
91 void createLowPass (double proportionalRate);
92
93 struct FilterState
94 {
95 double x1, x2, y1, y2;
96 };
97
98 HeapBlock<FilterState> filterStates;
99 void resetFilters();
100
101 void applyFilter (float* samples, int num, FilterState& fs);
102
104};
105
106} // namespace juce
A multi-channel buffer containing floating point audio samples.
Base class for objects that can produce a continuous stream of audio.
Very simple container class to hold a pointer to some data on the heap.
Holds a pointer to an object which can optionally be deleted when this pointer goes out of scope.
A type of AudioSource that takes an input source and changes its sample rate.
double getResamplingRatio() const noexcept
Returns the current resampling ratio.
A simple spin-lock class that can be used as a simple, low-overhead mutex for uncontended situations.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.
Used by AudioSource::getNextAudioBlock().
y1