OpenShot Library | OpenShotAudio 0.2.2
juce_ProcessContext.h
1
2/** @weakgroup juce_dsp-processors
3 * @{
4 */
5/*
6 ==============================================================================
7
8 This file is part of the JUCE library.
9 Copyright (c) 2017 - ROLI Ltd.
10
11 JUCE is an open source library subject to commercial or open-source
12 licensing.
13
14 By using JUCE, you agree to the terms of both the JUCE 5 End-User License
15 Agreement and JUCE 5 Privacy Policy (both updated and effective as of the
16 27th April 2017).
17
18 End User License Agreement: www.juce.com/juce-5-licence
19 Privacy Policy: www.juce.com/juce-5-privacy-policy
20
21 Or: You may also use this code under the terms of the GPL v3 (see
22 www.gnu.org/licenses).
23
24 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
25 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
26 DISCLAIMED.
27
28 ==============================================================================
29*/
30
31namespace juce
32{
33namespace dsp
34{
35
36/**
37 This structure is passed into a DSP algorithm's prepare() method, and contains
38 information about various aspects of the context in which it can expect to be called.
39
40 @tags{DSP}
41*/
43{
44 /** The sample rate that will be used for the data that is sent to the processor. */
45 double sampleRate;
46
47 /** The maximum number of samples that will be in the blocks sent to process() method. */
49
50 /** The number of channels that the process() method will be expected to handle. */
52};
53
54//==============================================================================
55/**
56 This is a handy base class for the state of a processor (such as parameter values)
57 which is typically shared among several processors. This is useful for multi-mono
58 filters which share the same state among several mono processors.
59
60 @tags{DSP}
61*/
63{
64 /** The ProcessorState structure is ref-counted, so this is a handy type that can be used
65 as a pointer to one.
66 */
68};
69
70//==============================================================================
71/**
72 Contains context information that is passed into an algorithm's process method.
73
74 This context is intended for use in situations where a single block is being used
75 for both the input and output, so it will return the same object for both its
76 getInputBlock() and getOutputBlock() methods.
77
78 @see ProcessContextNonReplacing
79
80 @tags{DSP}
81*/
82template <typename ContextSampleType>
84{
85public:
86 /** The type of a single sample (which may be a vector if multichannel). */
87 using SampleType = ContextSampleType;
88 /** The type of audio block that this context handles. */
91
92 /** Creates a ProcessContextReplacing that uses the given audio block.
93 Note that the caller must not delete the block while it is still in use by this object!
94 */
95 ProcessContextReplacing (AudioBlockType& block) noexcept : ioBlock (block) {}
96
99
100 /** Returns the audio block to use as the input to a process function. */
101 const ConstAudioBlockType& getInputBlock() const noexcept { return constBlock; }
102
103 /** Returns the audio block to use as the output to a process function. */
104 AudioBlockType& getOutputBlock() const noexcept { return ioBlock; }
105
106 /** All process context classes will define this constant method so that templated
107 code can determine whether the input and output blocks refer to the same buffer,
108 or to two different ones.
109 */
110 static constexpr bool usesSeparateInputAndOutputBlocks() { return false; }
111
112 /** If set to true, then a processor's process() method is expected to do whatever
113 is appropriate for it to be in a bypassed state.
114 */
115 bool isBypassed = false;
116
117private:
118 AudioBlockType& ioBlock;
119 ConstAudioBlockType constBlock { ioBlock };
120};
121
122//==============================================================================
123/**
124 Contains context information that is passed into an algorithm's process method.
125
126 This context is intended for use in situations where two different blocks are being
127 used the input and output to the process algorithm, so the processor must read from
128 the block returned by getInputBlock() and write its results to the block returned by
129 getOutputBlock().
130
131 @see ProcessContextReplacing
132
133 @tags{DSP}
134*/
135template <typename ContextSampleType>
137{
138public:
139 /** The type of a single sample (which may be a vector if multichannel). */
140 using SampleType = ContextSampleType;
141 /** The type of audio block that this context handles. */
144
145 /** Creates a ProcessContextReplacing that uses the given input and output blocks.
146 Note that the caller must not delete these blocks while they are still in use by this object!
147 */
149 : inputBlock (input), outputBlock (output)
150 {
151 // If the input and output blocks are the same then you should use
152 // ProcessContextReplacing instead.
153 jassert (input != output);
154 }
155
158
159 /** Returns the audio block to use as the input to a process function. */
160 const ConstAudioBlockType& getInputBlock() const noexcept { return inputBlock; }
161
162 /** Returns the audio block to use as the output to a process function. */
163 AudioBlockType& getOutputBlock() const noexcept { return outputBlock; }
164
165 /** All process context classes will define this constant method so that templated
166 code can determine whether the input and output blocks refer to the same buffer,
167 or to two different ones.
168 */
169 static constexpr bool usesSeparateInputAndOutputBlocks() { return true; }
170
171 /** If set to true, then a processor's process() method is expected to do whatever
172 is appropriate for it to be in a bypassed state.
173 */
174 bool isBypassed = false;
175
176private:
177 ConstAudioBlockType inputBlock;
178 AudioBlockType& outputBlock;
179};
180
181} // namespace dsp
182} // namespace juce
183
184/** @}*/
A smart-pointer class which points to a reference-counted object.
A base class which provides methods for reference-counting.
Minimal and lightweight data-structure which contains a list of pointers to channels containing some ...
uint32 numChannels
The number of channels that the process() method will be expected to handle.
double sampleRate
The sample rate that will be used for the data that is sent to the processor.
uint32 maximumBlockSize
The maximum number of samples that will be in the blocks sent to process() method.
This structure is passed into a DSP algorithm's prepare() method, and contains information about vari...
Contains context information that is passed into an algorithm's process method.
static constexpr bool usesSeparateInputAndOutputBlocks()
All process context classes will define this constant method so that templated code can determine whe...
AudioBlockType & getOutputBlock() const noexcept
Returns the audio block to use as the output to a process function.
const ConstAudioBlockType & getInputBlock() const noexcept
Returns the audio block to use as the input to a process function.
ProcessContextNonReplacing(const ConstAudioBlockType &input, AudioBlockType &output) noexcept
Creates a ProcessContextReplacing that uses the given input and output blocks.
bool isBypassed
If set to true, then a processor's process() method is expected to do whatever is appropriate for it ...
ContextSampleType SampleType
The type of a single sample (which may be a vector if multichannel).
Contains context information that is passed into an algorithm's process method.
ProcessContextReplacing(AudioBlockType &block) noexcept
Creates a ProcessContextReplacing that uses the given audio block.
ContextSampleType SampleType
The type of a single sample (which may be a vector if multichannel).
static constexpr bool usesSeparateInputAndOutputBlocks()
All process context classes will define this constant method so that templated code can determine whe...
const ConstAudioBlockType & getInputBlock() const noexcept
Returns the audio block to use as the input to a process function.
AudioBlockType & getOutputBlock() const noexcept
Returns the audio block to use as the output to a process function.
bool isBypassed
If set to true, then a processor's process() method is expected to do whatever is appropriate for it ...
This is a handy base class for the state of a processor (such as parameter values) which is typically...