commit
a2ecaf9a95
9 changed files with 226 additions and 9 deletions
|
|
@ -60,6 +60,9 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
|
||||||
add_compile_options(-Werror=return-type)
|
add_compile_options(-Werror=return-type)
|
||||||
if (SFIZZ_SYSTEM_PROCESSOR MATCHES "^(i.86|x86_64)$")
|
if (SFIZZ_SYSTEM_PROCESSOR MATCHES "^(i.86|x86_64)$")
|
||||||
add_compile_options(-msse2)
|
add_compile_options(-msse2)
|
||||||
|
elseif (SFIZZ_SYSTEM_PROCESSOR MATCHES "^(armv.*)$")
|
||||||
|
add_compile_options(-mfloat-abi=hard)
|
||||||
|
add_compile_options(-mfpu=neon)
|
||||||
endif()
|
endif()
|
||||||
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
elseif (CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
@ -76,6 +79,10 @@ endfunction()
|
||||||
# The sndfile library
|
# The sndfile library
|
||||||
add_library(sfizz-sndfile INTERFACE)
|
add_library(sfizz-sndfile INTERFACE)
|
||||||
|
|
||||||
|
# The jsl utility library for C++
|
||||||
|
add_library(sfizz-jsl INTERFACE)
|
||||||
|
target_include_directories(sfizz-jsl INTERFACE "external/jsl/include")
|
||||||
|
|
||||||
if (SFIZZ_USE_VCPKG OR CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
if (SFIZZ_USE_VCPKG OR CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
||||||
find_package(SndFile CONFIG REQUIRED)
|
find_package(SndFile CONFIG REQUIRED)
|
||||||
find_path(SNDFILE_INCLUDE_DIR sndfile.hh)
|
find_path(SNDFILE_INCLUDE_DIR sndfile.hh)
|
||||||
|
|
|
||||||
23
external/jsl/LICENSE.md
vendored
Normal file
23
external/jsl/LICENSE.md
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Boost Software License - Version 1.0 - August 17th, 2003
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person or organization
|
||||||
|
obtaining a copy of the software and accompanying documentation covered by
|
||||||
|
this license (the "Software") to use, reproduce, display, distribute,
|
||||||
|
execute, and transmit the Software, and to prepare derivative works of the
|
||||||
|
Software, and to permit third-parties to whom the Software is furnished to
|
||||||
|
do so, all subject to the following:
|
||||||
|
|
||||||
|
The copyright notices in the Software and this entire statement, including
|
||||||
|
the above license grant, this restriction and the following disclaimer,
|
||||||
|
must be included in all copies of the Software, in whole or in part, and
|
||||||
|
all derivative works of the Software, unless such copies or derivative
|
||||||
|
works are solely in the form of machine-executable object code generated by
|
||||||
|
a source language processor.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
|
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
|
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||||
|
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
||||||
73
external/jsl/include/jsl/allocator
vendored
Normal file
73
external/jsl/include/jsl/allocator
vendored
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
// -*- C++ -*-
|
||||||
|
#pragma once
|
||||||
|
#include <limits>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
namespace jsl {
|
||||||
|
|
||||||
|
template <class T, class Traits>
|
||||||
|
struct ordinary_allocator {
|
||||||
|
typedef T value_type;
|
||||||
|
typedef T *pointer;
|
||||||
|
typedef const T *const_pointer;
|
||||||
|
typedef T &reference;
|
||||||
|
typedef const T &const_reference;
|
||||||
|
typedef std::size_t size_type;
|
||||||
|
typedef std::ptrdiff_t difference_type;
|
||||||
|
typedef std::true_type propagate_on_container_move_assignment;
|
||||||
|
template <class U> struct rebind { typedef ordinary_allocator<U, Traits> other; };
|
||||||
|
typedef std::true_type is_always_equal;
|
||||||
|
|
||||||
|
ordinary_allocator() noexcept {}
|
||||||
|
ordinary_allocator(const ordinary_allocator &) noexcept {}
|
||||||
|
template <class U> ordinary_allocator(const ordinary_allocator<U, Traits>&) noexcept {}
|
||||||
|
|
||||||
|
T *address(T &x) const noexcept;
|
||||||
|
const T *address(const T &x) const noexcept;
|
||||||
|
|
||||||
|
T *allocate(std::size_t n, const void * = nullptr);
|
||||||
|
void deallocate(T *p, std::size_t n) noexcept;
|
||||||
|
std::size_t max_size() const noexcept;
|
||||||
|
|
||||||
|
template <class U, class... Args> void construct(U *p, Args &&...args);
|
||||||
|
template <class U> void destroy(U *p);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, class Traits>
|
||||||
|
inline bool operator==(const ordinary_allocator<T, Traits> &, const ordinary_allocator<T, Traits> &) noexcept
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class Traits>
|
||||||
|
inline bool operator!=(const ordinary_allocator<T, Traits> &, const ordinary_allocator<T, Traits> &) noexcept
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
struct stdc_allocator_traits {
|
||||||
|
static void *allocate(std::size_t n);
|
||||||
|
static void deallocate(void *p, std::size_t = 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
using stdc_allocator = ordinary_allocator<T, stdc_allocator_traits>;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
template <std::size_t Al>
|
||||||
|
struct aligned_allocator_traits {
|
||||||
|
static void *allocate(std::size_t n);
|
||||||
|
static void deallocate(void *p, std::size_t = 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T, std::size_t Al>
|
||||||
|
using aligned_allocator = ordinary_allocator<T, aligned_allocator_traits<Al>>;
|
||||||
|
|
||||||
|
} // namespace jsl
|
||||||
|
|
||||||
|
#include "bits/allocator/ordinary_allocator.tcc"
|
||||||
|
#include "bits/allocator/stdc_allocator.tcc"
|
||||||
|
#include "bits/allocator/aligned_allocator.tcc"
|
||||||
41
external/jsl/include/jsl/bits/allocator/aligned_allocator.tcc
vendored
Normal file
41
external/jsl/include/jsl/bits/allocator/aligned_allocator.tcc
vendored
Normal file
|
|
@ -0,0 +1,41 @@
|
||||||
|
#include "../../allocator"
|
||||||
|
#include <new>
|
||||||
|
#if defined(_WIN32)
|
||||||
|
# include <malloc.h>
|
||||||
|
#else
|
||||||
|
# include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace jsl {
|
||||||
|
|
||||||
|
template <std::size_t Al>
|
||||||
|
void *aligned_allocator_traits<Al>::allocate(std::size_t n)
|
||||||
|
{
|
||||||
|
static_assert(Al % sizeof(void *) == 0,
|
||||||
|
"alignment must be a multiple of the pointer size");
|
||||||
|
static_assert((Al & (~Al + 1)) == Al,
|
||||||
|
"alignment must be a power of two");
|
||||||
|
#if defined(_WIN32)
|
||||||
|
void *p = ::_aligned_malloc(n, Al);
|
||||||
|
if (!p)
|
||||||
|
throw std::bad_alloc();
|
||||||
|
return p;
|
||||||
|
#else
|
||||||
|
void *p;
|
||||||
|
if (::posix_memalign(&p, Al, n) != 0)
|
||||||
|
throw std::bad_alloc();
|
||||||
|
return p;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
template <std::size_t Al>
|
||||||
|
void aligned_allocator_traits<Al>::deallocate(void *p, std::size_t)
|
||||||
|
{
|
||||||
|
#if defined(_WIN32)
|
||||||
|
::_aligned_free(p);
|
||||||
|
#else
|
||||||
|
::free(p);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace jsl
|
||||||
53
external/jsl/include/jsl/bits/allocator/ordinary_allocator.tcc
vendored
Normal file
53
external/jsl/include/jsl/bits/allocator/ordinary_allocator.tcc
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
#include "../../allocator"
|
||||||
|
#include <new>
|
||||||
|
|
||||||
|
namespace jsl {
|
||||||
|
|
||||||
|
template <class T, class Traits>
|
||||||
|
inline T *ordinary_allocator<T, Traits>::address(T &x) const noexcept
|
||||||
|
{
|
||||||
|
return &x;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class Traits>
|
||||||
|
inline const T *ordinary_allocator<T, Traits>::address(const T &x) const noexcept
|
||||||
|
{
|
||||||
|
return &x;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class Traits>
|
||||||
|
T *ordinary_allocator<T, Traits>::allocate(std::size_t n, const void *)
|
||||||
|
{
|
||||||
|
T *ptr = (T *)Traits::allocate(n * sizeof(T));
|
||||||
|
if (!ptr)
|
||||||
|
throw std::bad_alloc();
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class Traits>
|
||||||
|
void ordinary_allocator<T, Traits>::deallocate(T *p, std::size_t n) noexcept
|
||||||
|
{
|
||||||
|
Traits::deallocate(p, n * sizeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class Traits>
|
||||||
|
std::size_t ordinary_allocator<T, Traits>::max_size() const noexcept
|
||||||
|
{
|
||||||
|
return std::numeric_limits<std::size_t>::max() / sizeof(T);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class Traits>
|
||||||
|
template <class U, class... Args>
|
||||||
|
void ordinary_allocator<T, Traits>::construct(U *p, Args &&...args)
|
||||||
|
{
|
||||||
|
::new((void *)p) U(std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class Traits>
|
||||||
|
template <class U>
|
||||||
|
void ordinary_allocator<T, Traits>::destroy(U *p)
|
||||||
|
{
|
||||||
|
p->~U();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace jsl
|
||||||
16
external/jsl/include/jsl/bits/allocator/stdc_allocator.tcc
vendored
Normal file
16
external/jsl/include/jsl/bits/allocator/stdc_allocator.tcc
vendored
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#include "../../allocator"
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
namespace jsl {
|
||||||
|
|
||||||
|
inline void *stdc_allocator_traits::allocate(std::size_t n)
|
||||||
|
{
|
||||||
|
return ::malloc(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void stdc_allocator_traits::deallocate(void *p, std::size_t)
|
||||||
|
{
|
||||||
|
::free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace jsl
|
||||||
|
|
@ -30,7 +30,7 @@ clang-tidy \
|
||||||
vst/SfizzVstProcessor.cpp \
|
vst/SfizzVstProcessor.cpp \
|
||||||
vst/SfizzVstEditor.cpp \
|
vst/SfizzVstEditor.cpp \
|
||||||
vst/SfizzVstState.cpp \
|
vst/SfizzVstState.cpp \
|
||||||
-- -Iexternal/abseil-cpp -Isrc/external -Isrc/external/pugixml/src \
|
-- -Iexternal/abseil-cpp -Iexternal/jsl/include -Isrc/external -Isrc/external/pugixml/src \
|
||||||
-Isrc/sfizz -Isrc -Isrc/external/spline -Isrc/external/cpuid/src \
|
-Isrc/sfizz -Isrc -Isrc/external/spline -Isrc/external/cpuid/src \
|
||||||
-Ivst -Ivst/external/VST_SDK/VST3_SDK -Ivst/external/VST_SDK/VST3_SDK/vstgui4 -Ivst/external/ring_buffer \
|
-Ivst -Ivst/external/VST_SDK/VST3_SDK -Ivst/external/VST_SDK/VST3_SDK/vstgui4 -Ivst/external/ring_buffer \
|
||||||
-Ieditor/src \
|
-Ieditor/src \
|
||||||
|
|
|
||||||
|
|
@ -216,7 +216,7 @@ target_sources(sfizz_static PRIVATE
|
||||||
target_include_directories (sfizz_static PUBLIC .)
|
target_include_directories (sfizz_static PUBLIC .)
|
||||||
target_include_directories (sfizz_static PUBLIC external)
|
target_include_directories (sfizz_static PUBLIC external)
|
||||||
target_link_libraries (sfizz_static PUBLIC absl::strings absl::span)
|
target_link_libraries (sfizz_static PUBLIC absl::strings absl::span)
|
||||||
target_link_libraries (sfizz_static PRIVATE sfizz_parser absl::flat_hash_map Threads::Threads sfizz-sndfile sfizz-pugixml sfizz-spline sfizz-tunings sfizz-kissfft sfizz-cpuid sfizz-atomic)
|
target_link_libraries (sfizz_static PRIVATE sfizz_parser absl::flat_hash_map Threads::Threads sfizz-sndfile sfizz-pugixml sfizz-spline sfizz-tunings sfizz-kissfft sfizz-cpuid sfizz-jsl sfizz-atomic)
|
||||||
set_target_properties (sfizz_static PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER "sfizz.h;sfizz.hpp")
|
set_target_properties (sfizz_static PROPERTIES OUTPUT_NAME sfizz PUBLIC_HEADER "sfizz.h;sfizz.hpp")
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_compile_definitions (sfizz_static PRIVATE _USE_MATH_DEFINES)
|
target_compile_definitions (sfizz_static PRIVATE _USE_MATH_DEFINES)
|
||||||
|
|
@ -255,7 +255,7 @@ if (SFIZZ_SHARED)
|
||||||
${SFIZZ_HEADERS} ${SFIZZ_SOURCES} ${FAUST_FILES} sfizz/sfizz_wrapper.cpp sfizz/sfizz.cpp)
|
${SFIZZ_HEADERS} ${SFIZZ_SOURCES} ${FAUST_FILES} sfizz/sfizz_wrapper.cpp sfizz/sfizz.cpp)
|
||||||
target_include_directories (sfizz_shared PRIVATE .)
|
target_include_directories (sfizz_shared PRIVATE .)
|
||||||
target_include_directories (sfizz_shared PRIVATE external)
|
target_include_directories (sfizz_shared PRIVATE external)
|
||||||
target_link_libraries (sfizz_shared PRIVATE absl::strings absl::span sfizz_parser absl::flat_hash_map Threads::Threads sfizz-sndfile sfizz-pugixml sfizz-spline sfizz-tunings sfizz-kissfft sfizz-cpuid sfizz-atomic)
|
target_link_libraries (sfizz_shared PRIVATE absl::strings absl::span sfizz_parser absl::flat_hash_map Threads::Threads sfizz-sndfile sfizz-pugixml sfizz-spline sfizz-tunings sfizz-kissfft sfizz-cpuid sfizz-jsl sfizz-atomic)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_compile_definitions (sfizz_shared PRIVATE _USE_MATH_DEFINES)
|
target_compile_definitions (sfizz_shared PRIVATE _USE_MATH_DEFINES)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,10 @@
|
||||||
#include "AudioSpan.h"
|
#include "AudioSpan.h"
|
||||||
#include "AudioReader.h"
|
#include "AudioReader.h"
|
||||||
#include "SIMDConfig.h"
|
#include "SIMDConfig.h"
|
||||||
|
#include <jsl/allocator>
|
||||||
|
|
||||||
|
template <class T, std::size_t A = sfz::config::defaultAlignment>
|
||||||
|
using aligned_vector = std::vector<T, jsl::aligned_allocator<T, A>>;
|
||||||
|
|
||||||
constexpr std::array<double, 12> coeffsStage2x {
|
constexpr std::array<double, 12> coeffsStage2x {
|
||||||
0.036681502163648017,
|
0.036681502163648017,
|
||||||
|
|
@ -70,9 +74,9 @@ void sfz::Oversampler::stream(AudioSpan<float> input, AudioSpan<float> output, s
|
||||||
const auto numFrames = input.getNumFrames();
|
const auto numFrames = input.getNumFrames();
|
||||||
const auto numChannels = input.getNumChannels();
|
const auto numChannels = input.getNumChannels();
|
||||||
|
|
||||||
std::vector<Upsampler2x> upsampler2x;
|
aligned_vector<Upsampler2x> upsampler2x;
|
||||||
std::vector<Upsampler4x> upsampler4x;
|
aligned_vector<Upsampler4x> upsampler4x;
|
||||||
std::vector<Upsampler8x> upsampler8x;
|
aligned_vector<Upsampler8x> upsampler8x;
|
||||||
|
|
||||||
switch(factor)
|
switch(factor)
|
||||||
{
|
{
|
||||||
|
|
@ -145,9 +149,9 @@ void sfz::Oversampler::stream(AudioReader& input, AudioSpan<float> output, std::
|
||||||
const auto numFrames = static_cast<size_t>(input.frames());
|
const auto numFrames = static_cast<size_t>(input.frames());
|
||||||
const auto numChannels = input.channels();
|
const auto numChannels = input.channels();
|
||||||
|
|
||||||
std::vector<Upsampler2x> upsampler2x;
|
aligned_vector<Upsampler2x> upsampler2x;
|
||||||
std::vector<Upsampler4x> upsampler4x;
|
aligned_vector<Upsampler4x> upsampler4x;
|
||||||
std::vector<Upsampler8x> upsampler8x;
|
aligned_vector<Upsampler8x> upsampler8x;
|
||||||
|
|
||||||
switch(factor)
|
switch(factor)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue