Loading...
Searching...
No Matches
juce_ProcessContext.h
/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce::dsp
{
struct ProcessSpec
{
double sampleRate;
uint32 maximumBlockSize;
uint32 numChannels;
};
constexpr bool operator== (const ProcessSpec& a, const ProcessSpec& b)
{
const auto tie = [] (const ProcessSpec& p)
{
return std::tie (p.sampleRate, p.maximumBlockSize, p.numChannels);
};
return tie (a) == tie (b);
}
constexpr bool operator!= (const ProcessSpec& a, const ProcessSpec& b) { return ! (a == b); }
//==============================================================================
struct ProcessorState : public ReferenceCountedObject
{
using Ptr = ReferenceCountedObjectPtr<ProcessorState>;
};
//==============================================================================
template <typename ContextSampleType>
struct ProcessContextReplacing
{
public:
using SampleType = ContextSampleType;
using AudioBlockType = AudioBlock<SampleType>;
using ConstAudioBlockType = AudioBlock<const SampleType>;
ProcessContextReplacing (AudioBlockType& block) noexcept : ioBlock (block) {}
ProcessContextReplacing (const ProcessContextReplacing&) = default;
ProcessContextReplacing (ProcessContextReplacing&&) = default;
const ConstAudioBlockType& getInputBlock() const noexcept { return constBlock; }
AudioBlockType& getOutputBlock() const noexcept { return ioBlock; }
static constexpr bool usesSeparateInputAndOutputBlocks() { return false; }
bool isBypassed = false;
private:
AudioBlockType& ioBlock;
ConstAudioBlockType constBlock { ioBlock };
};
//==============================================================================
template <typename ContextSampleType>
struct ProcessContextNonReplacing
{
public:
using SampleType = ContextSampleType;
using AudioBlockType = AudioBlock<SampleType>;
using ConstAudioBlockType = AudioBlock<const SampleType>;
ProcessContextNonReplacing (const ConstAudioBlockType& input, AudioBlockType& output) noexcept
: inputBlock (input), outputBlock (output)
{
// If the input and output blocks are the same then you should use
// ProcessContextReplacing instead.
jassert (input != output);
}
ProcessContextNonReplacing (const ProcessContextNonReplacing&) = default;
ProcessContextNonReplacing (ProcessContextNonReplacing&&) = default;
const ConstAudioBlockType& getInputBlock() const noexcept { return inputBlock; }
AudioBlockType& getOutputBlock() const noexcept { return outputBlock; }
static constexpr bool usesSeparateInputAndOutputBlocks() { return true; }
bool isBypassed = false;
private:
ConstAudioBlockType inputBlock;
AudioBlockType& outputBlock;
};
} // namespace juce::dsp
juce::ReferenceCountedObjectPtr
Definition juce_ReferenceCountedObject.h:247
juce::ReferenceCountedObject::ReferenceCountedObject
ReferenceCountedObject()=default
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::AudioBlockType
AudioBlock< SampleType > AudioBlockType
Definition juce_ProcessContext.h:147
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::ProcessContextReplacing::AudioBlockType
AudioBlock< SampleType > AudioBlockType
Definition juce_ProcessContext.h:94
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
juce::dsp::ProcessorState::Ptr
ReferenceCountedObjectPtr< ProcessorState > Ptr
Definition juce_ProcessContext.h:72