OpenShot Audio Library | OpenShotAudio: juce_ProcessContext.h Source File

OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_ProcessContext.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
35 struct ProcessSpec
36{
38 double sampleRate;
39
41 uint32 maximumBlockSize;
42
44 uint32 numChannels;
45};
46
47constexpr bool operator== (const ProcessSpec& a, const ProcessSpec& b)
48{
49 const auto tie = [] (const ProcessSpec& p)
50 {
51 return std::tie (p.sampleRate, p.maximumBlockSize, p.numChannels);
52 };
53
54 return tie (a) == tie (b);
55}
56
57constexpr bool operator!= (const ProcessSpec& a, const ProcessSpec& b) { return ! (a == b); }
58
59//==============================================================================
67 struct ProcessorState : public ReferenceCountedObject
68{
72 using Ptr = ReferenceCountedObjectPtr<ProcessorState>;
73};
74
75//==============================================================================
87template <typename ContextSampleType>
88 struct ProcessContextReplacing
89{
90public:
92 using SampleType = ContextSampleType;
94 using AudioBlockType = AudioBlock<SampleType>;
95 using ConstAudioBlockType = AudioBlock<const SampleType>;
96
100 ProcessContextReplacing (AudioBlockType& block) noexcept : ioBlock (block) {}
101
102 ProcessContextReplacing (const ProcessContextReplacing&) = default;
103 ProcessContextReplacing (ProcessContextReplacing&&) = default;
104
106 const ConstAudioBlockType& getInputBlock() const noexcept { return constBlock; }
107
109 AudioBlockType& getOutputBlock() const noexcept { return ioBlock; }
110
115 static constexpr bool usesSeparateInputAndOutputBlocks() { return false; }
116
120 bool isBypassed = false;
121
122private:
123 AudioBlockType& ioBlock;
124 ConstAudioBlockType constBlock { ioBlock };
125};
126
127//==============================================================================
140template <typename ContextSampleType>
141 struct ProcessContextNonReplacing
142{
143public:
145 using SampleType = ContextSampleType;
147 using AudioBlockType = AudioBlock<SampleType>;
148 using ConstAudioBlockType = AudioBlock<const SampleType>;
149
153 ProcessContextNonReplacing (const ConstAudioBlockType& input, AudioBlockType& output) noexcept
154 : inputBlock (input), outputBlock (output)
155 {
156 // If the input and output blocks are the same then you should use
157 // ProcessContextReplacing instead.
158 jassert (input != output);
159 }
160
161 ProcessContextNonReplacing (const ProcessContextNonReplacing&) = default;
162 ProcessContextNonReplacing (ProcessContextNonReplacing&&) = default;
163
165 const ConstAudioBlockType& getInputBlock() const noexcept { return inputBlock; }
166
168 AudioBlockType& getOutputBlock() const noexcept { return outputBlock; }
169
174 static constexpr bool usesSeparateInputAndOutputBlocks() { return true; }
175
179 bool isBypassed = false;
180
181private:
182 ConstAudioBlockType inputBlock;
183 AudioBlockType& outputBlock;
184};
185
186} // namespace juce::dsp
juce::ReferenceCountedObjectPtr
Definition juce_ReferenceCountedObject.h:247
juce::ReferenceCountedObject
Definition juce_ReferenceCountedObject.h:66
juce::dsp::AudioBlock
Definition juce_AudioBlock.h:68
juce::dsp::ProcessContextNonReplacing
Definition juce_ProcessContext.h:142
juce::dsp::ProcessContextNonReplacing::usesSeparateInputAndOutputBlocks
static constexpr bool usesSeparateInputAndOutputBlocks()
Definition juce_ProcessContext.h:174
juce::dsp::ProcessContextNonReplacing::getOutputBlock
AudioBlockType & getOutputBlock() const noexcept
Definition juce_ProcessContext.h:168
juce::dsp::ProcessContextNonReplacing::getInputBlock
const ConstAudioBlockType & getInputBlock() const noexcept
Definition juce_ProcessContext.h:165
juce::dsp::ProcessContextNonReplacing::ProcessContextNonReplacing
ProcessContextNonReplacing(const ConstAudioBlockType &input, AudioBlockType &output) noexcept
Definition juce_ProcessContext.h:153
juce::dsp::ProcessContextNonReplacing::isBypassed
bool isBypassed
Definition juce_ProcessContext.h:179
juce::dsp::ProcessContextNonReplacing::SampleType
ContextSampleType SampleType
Definition juce_ProcessContext.h:145
juce::dsp::ProcessContextReplacing
Definition juce_ProcessContext.h:89
juce::dsp::ProcessContextReplacing::ProcessContextReplacing
ProcessContextReplacing(AudioBlockType &block) noexcept
Definition juce_ProcessContext.h:100
juce::dsp::ProcessContextReplacing::SampleType
ContextSampleType SampleType
Definition juce_ProcessContext.h:92
juce::dsp::ProcessContextReplacing::usesSeparateInputAndOutputBlocks
static constexpr bool usesSeparateInputAndOutputBlocks()
Definition juce_ProcessContext.h:115
juce::dsp::ProcessContextReplacing::getInputBlock
const ConstAudioBlockType & getInputBlock() const noexcept
Definition juce_ProcessContext.h:106
juce::dsp::ProcessContextReplacing::getOutputBlock
AudioBlockType & getOutputBlock() const noexcept
Definition juce_ProcessContext.h:109
juce::dsp::ProcessContextReplacing::isBypassed
bool isBypassed
Definition juce_ProcessContext.h:120
juce::dsp::ProcessSpec
Definition juce_ProcessContext.h:36
juce::dsp::ProcessSpec::numChannels
uint32 numChannels
Definition juce_ProcessContext.h:44
juce::dsp::ProcessSpec::sampleRate
double sampleRate
Definition juce_ProcessContext.h:38
juce::dsp::ProcessSpec::maximumBlockSize
uint32 maximumBlockSize
Definition juce_ProcessContext.h:41
juce::dsp::ProcessorState
Definition juce_ProcessContext.h:68