Bug in SampleTypeHelpers

I just tried to instantiate a dsp::DelayLine<dsp::SIMDRegister<float>> and it failed with a compile error, telling that the reinterpret_cast in dsp::AudioBlock::getDataPointer would cast away the const qualifier. Looking at the implantation I found that NumericType is deduced by SampleTypeHelpers::ElementType. In case of a SIMDRegister the template specialisation is picked and it will always define Type to a non-const type, no matter if the register is const or not. Adding another explicit specialisation for the const case fixed it:

namespace SampleTypeHelpers // Internal classes needed for handling sample type classes
{
    template <typename T, bool = std::is_floating_point<T>::value>
    struct ElementType
    {
        using Type = T;
    };

    template <typename T>
    struct ElementType<const T, false>
    {
        using Type = const typename T::value_type;
    };

    template <typename T>
    struct ElementType<T, false>
    {
        using Type = typename T::value_type;
    };
}

Ah, I just found out that using the DelayLine with a SIMDRegister causes which I took as an example above actually causes Iinker errors – so this might not serve as the best example :wink: Still I think that the behaviour should be fixed for const SIMDRegister audio blocks.

But while I’m at it, the build errors in the DelayLine were relatively easy to fix with a few tweaks to the implementation – at least for the non-interpolating version. I just had to define a delay time value type via SampleTypeHelpers and swapping out the AudioBuffer with an AudioBlock + HeapBlock.

Maybe this is something you would also consider?

Just as a note here, I just found out that the fix proposed above has been added in the meantime