25#include "../vctr/vctr.h"
26#include <juce_dsp/juce_dsp.h>
62template <is::anyVctr Src>
65 using SIMDRegister = juce::dsp::SIMDRegister<typename Src::value_type>;
67 VCTR_ASSERT (src.size() == SIMDRegister::SIMDNumElements);
69 if constexpr (Config::archARM)
71 return SIMDRegister { src.getNeon (i).value };
75 constexpr size_t registerSize = SIMDRegister::SIMDRegisterSize;
77 if constexpr (registerSize == 32)
79 return SIMDRegister { src.getAVX (i).value };
82 return SIMDRegister { src.getSSE (i).value };
102template <
class SampleType>
105 auto numSamples = block.getNumSamples();
106 return Span { block.getChannelPointer (channelIdx), numSamples };
116template <
class SampleType>
119 auto numSamples = block.getNumSamples();
120 return Span { block.getChannelPointer (channelIdx), numSamples, simdAlignedSpanStorageInfo<SampleType>() };
131template <
class SampleType>
134 auto numSamples = size_t (buffer.getNumSamples());
135 return Span { buffer.getWritePointer (
int (channelIdx)), numSamples };
146template <
class SampleType>
149 auto numSamples = size_t (buffer.getNumSamples());
150 return Span { buffer.getReadPointer (
int (channelIdx)), numSamples };
155namespace vctr::expressions
158template <std::
floating_po
int SampleType, is::reductionExpressionChainBuilderForSource<Span<const SampleType>> ChannelReduction>
167 channelReduction (re)
170 constexpr const auto& getStorageInfo()
const
175 constexpr size_t size()
const
177 return src.getNumChannels();
180 constexpr bool isNotAliased (
const void*)
const
185 template <
size_t i,
class RuntimeArgs>
186 constexpr void iterateOverRuntimeArgChain (
const RuntimeArgs& rtArgs)
188 tryApplyingRuntimeArgsToSrc<i + 1> (rtArgs, src);
191 VCTR_FORCEDINLINE
constexpr auto operator[] (
size_t i)
const
197 juce::dsp::AudioBlock<const SampleType> src;
198 ChannelReduction& channelReduction;
200 static constexpr StaticStorageInfo<
false,
false,
alignof (SampleType)> storageInfo;
231template <std::
floating_po
int SampleType, is::reductionExpressionChainBuilderForSource<Span<const SampleType>> ChannelReduction>
The view type.
Definition: Span.h:66
Definition: vctr_juce_helpers.h:160
Helper functions to integrate vctr into dsp code written with JUCE (https://github....
Definition: vctr_juce_helpers.h:33
auto blockChannelAsSpanSIMDAligned(const juce::dsp::AudioBlock< SampleType > &block, size_t channelIdx)
Returns a Span that views a single channel of a juce::dsp::AudioBlock, expecting SIMD aligned memory.
Definition: vctr_juce_helpers.h:117
auto blockChannelAsSpan(const juce::dsp::AudioBlock< SampleType > &block, size_t channelIdx)
Returns a Span that views a single channel of a juce::dsp::AudioBlock.
Definition: vctr_juce_helpers.h:103
auto transformChannelsByExpression(const juce::dsp::AudioBlock< SampleType > &block, ChannelReduction &channelReduction)
Returns an expression that will apply channelReduction on each channel of the source AudioBlock.
Definition: vctr_juce_helpers.h:232
auto toSIMDRegister(const Src &src, size_t i=0)
Loads elements of src into a juce::SIMDRegister.
Definition: vctr_juce_helpers.h:63
auto audioBufferChannelAsSpan(juce::AudioBuffer< SampleType > &buffer, size_t channelIdx)
Returns a Span that views a single channel of a juce::AudioBuffer.
Definition: vctr_juce_helpers.h:132
typename detail::ValueType< std::remove_cvref_t< T > >::Type ValueType
If T is an expression template, it equals its return type, if it's a type that defines value_type as ...
Definition: Traits.h:201
The base class to every expression template.
Definition: ExpressionTemplate.h:37
A storage info type especially used to pass compile time constant traits when viewing externally owne...
Definition: SIMDHelpers.h:183