Added a simplistic wrapper on the hiir oversampling library and updated the makefile
This commit is contained in:
parent
0d9f61e612
commit
4aa370dd0a
5 changed files with 189 additions and 3 deletions
|
|
@ -10,7 +10,7 @@ endif()
|
|||
# SIMD checks
|
||||
if (HAVE_X86INTRIN_H AND UNIX)
|
||||
add_compile_options (-DHAVE_X86INTRIN_H)
|
||||
set (SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp)
|
||||
set (SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp sfizz/OversamplerSSE.cpp)
|
||||
elseif (HAVE_INTRIN_H AND WIN32)
|
||||
add_compile_options (/DHAVE_INTRIN_H)
|
||||
set (SFIZZ_SIMD_SOURCES sfizz/SIMDSSE.cpp)
|
||||
|
|
@ -20,9 +20,9 @@ elseif (HAVE_ARM_NEON_H AND UNIX)
|
|||
add_compile_options (-march=native)
|
||||
add_compile_options (-mtune=cortex-a53)
|
||||
add_compile_options (-funsafe-math-optimizations)
|
||||
set (SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp)
|
||||
set (SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp sfizz/OversamplerDummy.cpp)
|
||||
else()
|
||||
set (SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp)
|
||||
set (SFIZZ_SIMD_SOURCES sfizz/SIMDDummy.cpp sfizz/OversamplerDummy.cpp)
|
||||
endif()
|
||||
|
||||
set (SFIZZ_SOURCES ${SFIZZ_SOURCES} ${SFIZZ_SIMD_SOURCES})
|
||||
|
|
|
|||
|
|
@ -65,5 +65,6 @@ namespace SIMDConfig {
|
|||
constexpr bool sfzInterpolationCast { true };
|
||||
constexpr bool mean { false };
|
||||
constexpr bool meanSquared { false };
|
||||
constexpr bool upsampling { false };
|
||||
}
|
||||
} // namespace sfz
|
||||
|
|
|
|||
95
src/sfizz/Oversampler.h
Normal file
95
src/sfizz/Oversampler.h
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
// Copyright (c) 2019, Paul Ferrand
|
||||
// All rights reserved.
|
||||
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#pragma once
|
||||
#include <array>
|
||||
#include "absl/types/span.h"
|
||||
#include "Debug.h"
|
||||
#include "Config.h"
|
||||
#include "hiir/Upsampler2xFpu.h"
|
||||
|
||||
namespace sfz {
|
||||
|
||||
constexpr std::array<double, 12> coeffsStage2x {
|
||||
0.036681502163648017,
|
||||
0.13654762463195771,
|
||||
0.27463175937945411,
|
||||
0.42313861743656667,
|
||||
0.56109869787919475,
|
||||
0.67754004997416162,
|
||||
0.76974183386322659,
|
||||
0.83988962484963803,
|
||||
0.89226081800387891,
|
||||
0.9315419599631839,
|
||||
0.96209454837808395,
|
||||
0.98781637073289708
|
||||
};
|
||||
|
||||
constexpr std::array<double, 4> coeffsStage4x {
|
||||
0.042448989488488006,
|
||||
0.17072114107630679,
|
||||
0.39329183835224008,
|
||||
0.74569514831986694
|
||||
};
|
||||
|
||||
constexpr std::array<double, 3> coeffsStage8x {
|
||||
0.055748680811302048,
|
||||
0.24305119574153092,
|
||||
0.6466991311926823
|
||||
};
|
||||
|
||||
template<bool SIMD=SIMDConfig::upsampling>
|
||||
inline void upsample2xStage(absl::Span<const float> input, absl::Span<float> output)
|
||||
{
|
||||
ASSERT(output.size() >= 2 * input.size());
|
||||
hiir::Upsampler2xFpu<coeffsStage2x.size()> upsampler;
|
||||
upsampler.set_coefs(coeffsStage2x.data());
|
||||
upsampler.process_block(output.data(), input.data(), input.size());
|
||||
}
|
||||
|
||||
|
||||
template<bool SIMD=SIMDConfig::upsampling>
|
||||
inline void upsample4xStage(absl::Span<const float> input, absl::Span<float> output)
|
||||
{
|
||||
ASSERT(output.size() >= 2 * input.size());
|
||||
hiir::Upsampler2xFpu<coeffsStage4x.size()> upsampler;
|
||||
upsampler.set_coefs(coeffsStage4x.data());
|
||||
upsampler.process_block(output.data(), input.data(), input.size());
|
||||
}
|
||||
|
||||
template<bool SIMD=SIMDConfig::upsampling>
|
||||
inline void upsample8xStage(absl::Span<const float> input, absl::Span<float> output)
|
||||
{
|
||||
ASSERT(output.size() >= 2 * input.size());
|
||||
hiir::Upsampler2xFpu<coeffsStage8x.size()> upsampler;
|
||||
upsampler.set_coefs(coeffsStage8x.data());
|
||||
upsampler.process_block(output.data(), input.data(), input.size());
|
||||
}
|
||||
|
||||
template<>
|
||||
inline void upsample2xStage<true>(absl::Span<const float> input, absl::Span<float> output);
|
||||
template<>
|
||||
inline void upsample4xStage<true>(absl::Span<const float> input, absl::Span<float> output);
|
||||
template<>
|
||||
inline void upsample8xStage<true>(absl::Span<const float> input, absl::Span<float> output);
|
||||
}
|
||||
40
src/sfizz/OversamplerDummy.cpp
Normal file
40
src/sfizz/OversamplerDummy.cpp
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
// Copyright (c) 2019, Paul Ferrand
|
||||
// All rights reserved.
|
||||
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "Oversampler.h"
|
||||
|
||||
template<>
|
||||
inline void sfz::upsample2xStage<true>(absl::Span<const float> input, absl::Span<float> output)
|
||||
{
|
||||
sfz::upsample2xStage<false>(input, output);
|
||||
}
|
||||
template<>
|
||||
inline void sfz::upsample4xStage<true>(absl::Span<const float> input, absl::Span<float> output)
|
||||
{
|
||||
sfz::upsample4xStage<false>(input, output);
|
||||
}
|
||||
template<>
|
||||
inline void sfz::upsample8xStage<true>(absl::Span<const float> input, absl::Span<float> output)
|
||||
{
|
||||
sfz::upsample8xStage<false>(input, output);
|
||||
}
|
||||
50
src/sfizz/OversamplerSSE.cpp
Normal file
50
src/sfizz/OversamplerSSE.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
// Copyright (c) 2019, Paul Ferrand
|
||||
// All rights reserved.
|
||||
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
|
||||
// 1. Redistributions of source code must retain the above copyright notice, this
|
||||
// list of conditions and the following disclaimer.
|
||||
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
#include "Oversampler.h"
|
||||
#include "hiir/Upsampler2x4Sse.h"
|
||||
|
||||
template<>
|
||||
inline void sfz::upsample2xStage<true>(absl::Span<const float> input, absl::Span<float> output)
|
||||
{
|
||||
ASSERT(output.size() >= 2 * input.size());
|
||||
hiir::Upsampler2x4Sse<sfz::coeffsStage2x.size()> upsampler;
|
||||
upsampler.set_coefs(sfz::coeffsStage2x.data());
|
||||
upsampler.process_block(output.data(), input.data(), input.size());
|
||||
}
|
||||
template<>
|
||||
inline void sfz::upsample4xStage<true>(absl::Span<const float> input, absl::Span<float> output)
|
||||
{
|
||||
ASSERT(output.size() >= 2 * input.size());
|
||||
hiir::Upsampler2x4Sse<sfz::coeffsStage4x.size()> upsampler;
|
||||
upsampler.set_coefs(sfz::coeffsStage4x.data());
|
||||
upsampler.process_block(output.data(), input.data(), input.size());
|
||||
}
|
||||
template<>
|
||||
inline void sfz::upsample8xStage<true>(absl::Span<const float> input, absl::Span<float> output)
|
||||
{
|
||||
ASSERT(output.size() >= 2 * input.size());
|
||||
hiir::Upsampler2x4Sse<sfz::coeffsStage8x.size()> upsampler;
|
||||
upsampler.set_coefs(sfz::coeffsStage8x.data());
|
||||
upsampler.process_block(output.data(), input.data(), input.size());
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue