1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Use more concise stdlib type aliases

This commit is contained in:
reuk 2022-09-08 12:41:54 +01:00
parent 21d87c02c2
commit 7c14c1fcd7
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C
36 changed files with 438 additions and 494 deletions

View file

@ -201,126 +201,104 @@ public:
private:
//==============================================================================
template <typename T = InterpolationType>
typename std::enable_if <std::is_same <T, DelayLineInterpolationTypes::None>::value, SampleType>::type
interpolateSample (int channel) const
SampleType interpolateSample (int channel)
{
auto index = (readPos[(size_t) channel] + delayInt) % totalSize;
return bufferData.getSample (channel, index);
}
template <typename T = InterpolationType>
typename std::enable_if <std::is_same <T, DelayLineInterpolationTypes::Linear>::value, SampleType>::type
interpolateSample (int channel) const
{
auto index1 = readPos[(size_t) channel] + delayInt;
auto index2 = index1 + 1;
if (index2 >= totalSize)
if constexpr (std::is_same_v<InterpolationType, DelayLineInterpolationTypes::None>)
{
index1 %= totalSize;
index2 %= totalSize;
auto index = (readPos[(size_t) channel] + delayInt) % totalSize;
return bufferData.getSample (channel, index);
}
auto value1 = bufferData.getSample (channel, index1);
auto value2 = bufferData.getSample (channel, index2);
return value1 + delayFrac * (value2 - value1);
}
template <typename T = InterpolationType>
typename std::enable_if <std::is_same <T, DelayLineInterpolationTypes::Lagrange3rd>::value, SampleType>::type
interpolateSample (int channel) const
{
auto index1 = readPos[(size_t) channel] + delayInt;
auto index2 = index1 + 1;
auto index3 = index2 + 1;
auto index4 = index3 + 1;
if (index4 >= totalSize)
else if constexpr (std::is_same_v<InterpolationType, DelayLineInterpolationTypes::Linear>)
{
index1 %= totalSize;
index2 %= totalSize;
index3 %= totalSize;
index4 %= totalSize;
auto index1 = readPos[(size_t) channel] + delayInt;
auto index2 = index1 + 1;
if (index2 >= totalSize)
{
index1 %= totalSize;
index2 %= totalSize;
}
auto value1 = bufferData.getSample (channel, index1);
auto value2 = bufferData.getSample (channel, index2);
return value1 + delayFrac * (value2 - value1);
}
auto* samples = bufferData.getReadPointer (channel);
auto value1 = samples[index1];
auto value2 = samples[index2];
auto value3 = samples[index3];
auto value4 = samples[index4];
auto d1 = delayFrac - 1.f;
auto d2 = delayFrac - 2.f;
auto d3 = delayFrac - 3.f;
auto c1 = -d1 * d2 * d3 / 6.f;
auto c2 = d2 * d3 * 0.5f;
auto c3 = -d1 * d3 * 0.5f;
auto c4 = d1 * d2 / 6.f;
return value1 * c1 + delayFrac * (value2 * c2 + value3 * c3 + value4 * c4);
}
template <typename T = InterpolationType>
typename std::enable_if <std::is_same <T, DelayLineInterpolationTypes::Thiran>::value, SampleType>::type
interpolateSample (int channel)
{
auto index1 = readPos[(size_t) channel] + delayInt;
auto index2 = index1 + 1;
if (index2 >= totalSize)
else if constexpr (std::is_same_v<InterpolationType, DelayLineInterpolationTypes::Lagrange3rd>)
{
index1 %= totalSize;
index2 %= totalSize;
auto index1 = readPos[(size_t) channel] + delayInt;
auto index2 = index1 + 1;
auto index3 = index2 + 1;
auto index4 = index3 + 1;
if (index4 >= totalSize)
{
index1 %= totalSize;
index2 %= totalSize;
index3 %= totalSize;
index4 %= totalSize;
}
auto* samples = bufferData.getReadPointer (channel);
auto value1 = samples[index1];
auto value2 = samples[index2];
auto value3 = samples[index3];
auto value4 = samples[index4];
auto d1 = delayFrac - 1.f;
auto d2 = delayFrac - 2.f;
auto d3 = delayFrac - 3.f;
auto c1 = -d1 * d2 * d3 / 6.f;
auto c2 = d2 * d3 * 0.5f;
auto c3 = -d1 * d3 * 0.5f;
auto c4 = d1 * d2 / 6.f;
return value1 * c1 + delayFrac * (value2 * c2 + value3 * c3 + value4 * c4);
}
else if constexpr (std::is_same_v<InterpolationType, DelayLineInterpolationTypes::Thiran>)
{
auto index1 = readPos[(size_t) channel] + delayInt;
auto index2 = index1 + 1;
auto value1 = bufferData.getSample (channel, index1);
auto value2 = bufferData.getSample (channel, index2);
if (index2 >= totalSize)
{
index1 %= totalSize;
index2 %= totalSize;
}
auto output = delayFrac == 0 ? value1 : value2 + alpha * (value1 - v[(size_t) channel]);
v[(size_t) channel] = output;
auto value1 = bufferData.getSample (channel, index1);
auto value2 = bufferData.getSample (channel, index2);
return output;
auto output = delayFrac == 0 ? value1 : value2 + alpha * (value1 - v[(size_t) channel]);
v[(size_t) channel] = output;
return output;
}
}
//==============================================================================
template <typename T = InterpolationType>
typename std::enable_if <std::is_same <T, DelayLineInterpolationTypes::None>::value, void>::type
updateInternalVariables()
void updateInternalVariables()
{
}
template <typename T = InterpolationType>
typename std::enable_if <std::is_same <T, DelayLineInterpolationTypes::Linear>::value, void>::type
updateInternalVariables()
{
}
template <typename T = InterpolationType>
typename std::enable_if <std::is_same <T, DelayLineInterpolationTypes::Lagrange3rd>::value, void>::type
updateInternalVariables()
{
if (delayInt >= 1)
if constexpr (std::is_same_v<InterpolationType, DelayLineInterpolationTypes::Lagrange3rd>)
{
delayFrac++;
delayInt--;
if (delayInt >= 1)
{
delayFrac++;
delayInt--;
}
}
}
template <typename T = InterpolationType>
typename std::enable_if <std::is_same <T, DelayLineInterpolationTypes::Thiran>::value, void>::type
updateInternalVariables()
{
if (delayFrac < (SampleType) 0.618 && delayInt >= 1)
else if constexpr (std::is_same_v<InterpolationType, DelayLineInterpolationTypes::Thiran>)
{
delayFrac++;
delayInt--;
}
if (delayFrac < (SampleType) 0.618 && delayInt >= 1)
{
delayFrac++;
delayInt--;
}
alpha = (1 - delayFrac) / (1 + delayFrac);
alpha = (1 - delayFrac) / (1 + delayFrac);
}
}
//==============================================================================

View file

@ -122,7 +122,7 @@ namespace FIR
template <typename ProcessContext>
void process (const ProcessContext& context) noexcept
{
static_assert (std::is_same<typename ProcessContext::SampleType, SampleType>::value,
static_assert (std::is_same_v<typename ProcessContext::SampleType, SampleType>,
"The sample-type of the FIR filter must match the sample-type supplied to this process callback");
check();

View file

@ -89,7 +89,7 @@ template <typename SampleType>
template <typename ProcessContext, bool bypassed>
void Filter<SampleType>::processInternal (const ProcessContext& context) noexcept
{
static_assert (std::is_same<typename ProcessContext::SampleType, SampleType>::value,
static_assert (std::is_same_v<typename ProcessContext::SampleType, SampleType>,
"The sample-type of the IIR filter must match the sample-type supplied to this process callback");
check();

View file

@ -42,7 +42,7 @@ namespace detail
}
template <typename T>
using TupleIndexSequence = std::make_index_sequence<std::tuple_size<std::remove_cv_t<std::remove_reference_t<T>>>::value>;
using TupleIndexSequence = std::make_index_sequence<std::tuple_size_v<std::remove_cv_t<std::remove_reference_t<T>>>>;
template <typename Fn, typename Tuple>
constexpr void forEachInTuple (Fn&& fn, Tuple&& tuple)
@ -99,23 +99,24 @@ public:
}
private:
template <typename Context, typename Proc, size_t Ix, std::enable_if_t<! detail::useContextDirectly<Context, Ix>, int> = 0>
template <typename Context, typename Proc, size_t Ix>
void processOne (const Context& context, Proc& proc, std::integral_constant<size_t, Ix>) noexcept
{
jassert (context.getOutputBlock().getNumChannels() == context.getInputBlock().getNumChannels());
ProcessContextReplacing<typename Context::SampleType> replacingContext (context.getOutputBlock());
replacingContext.isBypassed = (bypassed[Ix] || context.isBypassed);
if constexpr (detail::useContextDirectly<Context, Ix>)
{
auto contextCopy = context;
contextCopy.isBypassed = (bypassed[Ix] || context.isBypassed);
proc.process (replacingContext);
}
proc.process (contextCopy);
}
else
{
jassert (context.getOutputBlock().getNumChannels() == context.getInputBlock().getNumChannels());
ProcessContextReplacing<typename Context::SampleType> replacingContext (context.getOutputBlock());
replacingContext.isBypassed = (bypassed[Ix] || context.isBypassed);
template <typename Context, typename Proc, size_t Ix, std::enable_if_t<detail::useContextDirectly<Context, Ix>, int> = 0>
void processOne (const Context& context, Proc& proc, std::integral_constant<size_t, Ix>) noexcept
{
auto contextCopy = context;
contextCopy.isBypassed = (bypassed[Ix] || context.isBypassed);
proc.process (contextCopy);
proc.process (replacingContext);
}
}
std::tuple<Processors...> processors;

View file

@ -110,7 +110,7 @@ namespace StateVariableFilter
template <typename ProcessContext>
void process (const ProcessContext& context) noexcept
{
static_assert (std::is_same<typename ProcessContext::SampleType, SampleType>::value,
static_assert (std::is_same_v<typename ProcessContext::SampleType, SampleType>,
"The sample-type of the filter must match the sample-type supplied to this process callback");
if (context.isBypassed)