Moved Siren DSP functions to submodule
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -22,3 +22,6 @@
|
|||||||
[submodule "mimir"]
|
[submodule "mimir"]
|
||||||
path = mimir
|
path = mimir
|
||||||
url = https://src.kearwood.com/kraken_engine/mimir
|
url = https://src.kearwood.com/kraken_engine/mimir
|
||||||
|
[submodule "siren"]
|
||||||
|
path = siren
|
||||||
|
url = https://github.com/KrakenEngine/siren.git
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ add_public_header(hydra/include/vector2i.h)
|
|||||||
add_public_header(mimir/include/mimir.h)
|
add_public_header(mimir/include/mimir.h)
|
||||||
add_public_header(mimir/include/block.h)
|
add_public_header(mimir/include/block.h)
|
||||||
|
|
||||||
|
add_public_header(siren/include/siren.h)
|
||||||
|
add_public_header(siren/include/dsp.h)
|
||||||
|
|
||||||
# ---- Android ----
|
# ---- Android ----
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
add_subdirectory(kraken_android)
|
add_subdirectory(kraken_android)
|
||||||
@@ -105,6 +108,11 @@ add_subdirectory(hydra)
|
|||||||
include_directories(hydra/include)
|
include_directories(hydra/include)
|
||||||
list (APPEND EXTRA_LIBS hydra)
|
list (APPEND EXTRA_LIBS hydra)
|
||||||
|
|
||||||
|
# ---- Siren ----
|
||||||
|
add_subdirectory(siren)
|
||||||
|
include_directories(siren/include)
|
||||||
|
list (APPEND EXTRA_LIBS siren)
|
||||||
|
|
||||||
# ---- Mimir ----
|
# ---- Mimir ----
|
||||||
add_subdirectory(mimir)
|
add_subdirectory(mimir)
|
||||||
include_directories(mimir/include)
|
include_directories(mimir/include)
|
||||||
|
|||||||
@@ -33,11 +33,6 @@ add_sources(KRStreamerThread.cpp)
|
|||||||
add_sources(KRSwapchain.cpp)
|
add_sources(KRSwapchain.cpp)
|
||||||
add_sources(KRContextObject.cpp)
|
add_sources(KRContextObject.cpp)
|
||||||
add_sources(KRDirectionalLight.cpp)
|
add_sources(KRDirectionalLight.cpp)
|
||||||
IF(APPLE)
|
|
||||||
add_sources(KRDSP_vDSP.cpp)
|
|
||||||
ELSE()
|
|
||||||
add_sources(KRDSP_slow.cpp)
|
|
||||||
ENDIF()
|
|
||||||
add_sources(KRHelpers.cpp)
|
add_sources(KRHelpers.cpp)
|
||||||
add_sources(KRLight.cpp)
|
add_sources(KRLight.cpp)
|
||||||
add_sources(KRLocator.cpp)
|
add_sources(KRLocator.cpp)
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
#include "KRAudioBuffer.h"
|
#include "KRAudioBuffer.h"
|
||||||
#include "KRContext.h"
|
#include "KRContext.h"
|
||||||
#include "KRCollider.h"
|
#include "KRCollider.h"
|
||||||
#include "KRDSP.h"
|
#include "siren.h"
|
||||||
|
|
||||||
using namespace mimir;
|
using namespace mimir;
|
||||||
using namespace hydra;
|
using namespace hydra;
|
||||||
|
|||||||
@@ -38,7 +38,7 @@
|
|||||||
#include "KRContextObject.h"
|
#include "KRContextObject.h"
|
||||||
#include "block.h"
|
#include "block.h"
|
||||||
#include "KRAudioSource.h"
|
#include "KRAudioSource.h"
|
||||||
#include "KRDSP.h"
|
#include "siren.h"
|
||||||
|
|
||||||
const int KRENGINE_AUDIO_MAX_POOL_SIZE = 60; //32;
|
const int KRENGINE_AUDIO_MAX_POOL_SIZE = 60; //32;
|
||||||
// for Circa we play a maximum of 11 mono audio streams at once + cross fading with ambient
|
// for Circa we play a maximum of 11 mono audio streams at once + cross fading with ambient
|
||||||
|
|||||||
@@ -34,9 +34,10 @@
|
|||||||
#include "block.h"
|
#include "block.h"
|
||||||
#include "KRAudioBuffer.h"
|
#include "KRAudioBuffer.h"
|
||||||
#include "KRContext.h"
|
#include "KRContext.h"
|
||||||
#include "KRDSP.h"
|
#include "siren.h"
|
||||||
|
|
||||||
using namespace mimir;
|
using namespace mimir;
|
||||||
|
using namespace siren;
|
||||||
|
|
||||||
KRAudioSample::KRAudioSample(KRContext& context, std::string name, std::string extension) : KRResource(context, name)
|
KRAudioSample::KRAudioSample(KRContext& context, std::string name, std::string extension) : KRResource(context, name)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,95 +0,0 @@
|
|||||||
//
|
|
||||||
// dsp.h
|
|
||||||
// Kraken Engine
|
|
||||||
//
|
|
||||||
// Copyright 2023 Kearwood Gilbert. 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 KEARWOOD GILBERT ''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 KEARWOOD GILBERT 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.
|
|
||||||
//
|
|
||||||
// The views and conclusions contained in the software and documentation are those of the
|
|
||||||
// authors and should not be interpreted as representing official policies, either expressed
|
|
||||||
// or implied, of Kearwood Gilbert.
|
|
||||||
//
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "KREngine-common.h"
|
|
||||||
namespace siren {
|
|
||||||
namespace dsp {
|
|
||||||
|
|
||||||
#ifdef __APPLE__
|
|
||||||
#define KRDSP_APPLE_VDSP
|
|
||||||
#include <Accelerate/Accelerate.h>
|
|
||||||
#else
|
|
||||||
// Slow, but portable fallback implementation
|
|
||||||
#define KRDSP_SLOW
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(KRDSP_APPLE_VDSP)
|
|
||||||
|
|
||||||
// Apple vDSP
|
|
||||||
typedef DSPSplitComplex SplitComplex;
|
|
||||||
struct FFTWorkspace
|
|
||||||
{
|
|
||||||
FFTSetup setup;
|
|
||||||
|
|
||||||
void create(size_t length);
|
|
||||||
void destroy();
|
|
||||||
FFTWorkspace();
|
|
||||||
~FFTWorkspace();
|
|
||||||
};
|
|
||||||
|
|
||||||
#elif defined(KRDSP_SLOW)
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
float* realp;
|
|
||||||
float* imagp;
|
|
||||||
} SplitComplex;
|
|
||||||
|
|
||||||
struct FFTWorkspace
|
|
||||||
{
|
|
||||||
float* sin_table;
|
|
||||||
float* cos_table;
|
|
||||||
|
|
||||||
void create(size_t length);
|
|
||||||
void destroy();
|
|
||||||
FFTWorkspace();
|
|
||||||
~FFTWorkspace();
|
|
||||||
};
|
|
||||||
|
|
||||||
#else
|
|
||||||
#error Not Implemented
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void FFTForward(const FFTWorkspace& workspace, SplitComplex* src, size_t count);
|
|
||||||
void FFTInverse(const FFTWorkspace& workspace, SplitComplex* src, size_t count);
|
|
||||||
void Int16ToFloat(const short* src, size_t srcStride, float* dest, size_t destStride, size_t count);
|
|
||||||
void Scale(float* buffer, float scale, size_t count);
|
|
||||||
void ScaleCopy(const float* src, float scale, float* dest, size_t count);
|
|
||||||
void ScaleCopy(const SplitComplex* src, float scale, SplitComplex* dest, size_t count);
|
|
||||||
void ScaleRamp(float* buffer, float scaleStart, float scaleStep, size_t count);
|
|
||||||
void Accumulate(float* buffer, size_t bufferStride, const float* buffer2, size_t buffer2Stride, size_t count);
|
|
||||||
void Accumulate(SplitComplex* buffer, const SplitComplex* buffer2, size_t count);
|
|
||||||
void Multiply(const SplitComplex* a, const SplitComplex* b, SplitComplex* c, size_t count);
|
|
||||||
|
|
||||||
} // namespace dsp
|
|
||||||
} // namespace siren
|
|
||||||
@@ -1,209 +0,0 @@
|
|||||||
//
|
|
||||||
// KRDSP_slow.cpp
|
|
||||||
// Kraken Engine
|
|
||||||
//
|
|
||||||
// Copyright 2023 Kearwood Gilbert. 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 KEARWOOD GILBERT ''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 KEARWOOD GILBERT 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.
|
|
||||||
//
|
|
||||||
// The views and conclusions contained in the software and documentation are those of the
|
|
||||||
// authors and should not be interpreted as representing official policies, either expressed
|
|
||||||
// or implied, of Kearwood Gilbert.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "KRDSP.h"
|
|
||||||
|
|
||||||
#ifdef KRDSP_SLOW
|
|
||||||
|
|
||||||
#include "KREngine-common.h"
|
|
||||||
|
|
||||||
namespace siren {
|
|
||||||
namespace dsp {
|
|
||||||
|
|
||||||
FFTWorkspace::FFTWorkspace()
|
|
||||||
{
|
|
||||||
sin_table = nullptr;
|
|
||||||
cos_table = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
FFTWorkspace::~FFTWorkspace()
|
|
||||||
{
|
|
||||||
destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FFTWorkspace::create(size_t length)
|
|
||||||
{
|
|
||||||
size_t size = (length / 2);
|
|
||||||
cos_table = new float[size];
|
|
||||||
sin_table = new float[size];
|
|
||||||
for (int i = 0; i < size / 2; i++) {
|
|
||||||
float a = 2.0f * (float)M_PI * i / length;
|
|
||||||
cos_table[i] = cos(a);
|
|
||||||
sin_table[i] = sin(a);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FFTWorkspace::destroy()
|
|
||||||
{
|
|
||||||
if (sin_table) {
|
|
||||||
delete sin_table;
|
|
||||||
sin_table = nullptr;
|
|
||||||
}
|
|
||||||
if (cos_table) {
|
|
||||||
delete cos_table;
|
|
||||||
cos_table = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FFTForward(const FFTWorkspace& workspace, SplitComplex* src, size_t count)
|
|
||||||
{
|
|
||||||
// Radix-2 Decimation in Time FFT Algorithm
|
|
||||||
// http://en.dsplib.org/content/fft_dec_in_time.html
|
|
||||||
|
|
||||||
// Only power-of-two sizes supported
|
|
||||||
assert((count & (count - 1)) == 0);
|
|
||||||
|
|
||||||
unsigned int levels = 0;
|
|
||||||
while (1 << levels <= (int)count) {
|
|
||||||
levels++;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
|
||||||
size_t j = 0;
|
|
||||||
for (int k = 0; k < (int)levels; k++) {
|
|
||||||
j <<= 1;
|
|
||||||
j |= ((i >> k) & 1);
|
|
||||||
}
|
|
||||||
if (j > i) {
|
|
||||||
float temp = src->realp[i];
|
|
||||||
src->realp[i] = src->realp[j];
|
|
||||||
src->realp[j] = temp;
|
|
||||||
temp = src->imagp[i];
|
|
||||||
src->imagp[i] = src->imagp[j];
|
|
||||||
src->imagp[j] = temp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t size = 2; size <= count; size *= 2) {
|
|
||||||
size_t halfsize = size / 2;
|
|
||||||
size_t step = count / size;
|
|
||||||
for (size_t i = 0; i < count; i += size) {
|
|
||||||
for (size_t j = i, k = 0; j < i + halfsize; j++, k += step) {
|
|
||||||
float temp_real = src->realp[j + halfsize] * workspace.cos_table[k];
|
|
||||||
temp_real += src->imagp[j + halfsize] * workspace.sin_table[k];
|
|
||||||
float temp_imag = -src->realp[j + halfsize] * workspace.sin_table[k];
|
|
||||||
temp_imag += src->imagp[j + halfsize] * workspace.cos_table[k];
|
|
||||||
src->realp[j + halfsize] = src->realp[j] - temp_real;
|
|
||||||
src->imagp[j + halfsize] = src->imagp[j] - temp_imag;
|
|
||||||
src->realp[j] += temp_real;
|
|
||||||
src->imagp[j] += temp_imag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FFTInverse(const FFTWorkspace& workspace, SplitComplex* src, size_t count)
|
|
||||||
{
|
|
||||||
SplitComplex swapped;
|
|
||||||
swapped.imagp = src->realp;
|
|
||||||
swapped.realp = src->imagp;
|
|
||||||
FFTForward(workspace, &swapped, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Int16ToFloat(const short* src, size_t srcStride, float* dest, size_t destStride, size_t count)
|
|
||||||
{
|
|
||||||
const short* r = src;
|
|
||||||
float* w = dest;
|
|
||||||
while (w < dest + destStride * count) {
|
|
||||||
*w = (float)*r;
|
|
||||||
r += srcStride;
|
|
||||||
w += destStride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scale(float* buffer, float scale, size_t count)
|
|
||||||
{
|
|
||||||
float* w = buffer;
|
|
||||||
while (w < buffer + count) {
|
|
||||||
*w *= scale;
|
|
||||||
w++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScaleCopy(const float* src, float scale, float* dest, size_t count)
|
|
||||||
{
|
|
||||||
const float* r = src;
|
|
||||||
float* w = dest;
|
|
||||||
while (w < dest + count) {
|
|
||||||
*w = *r * scale;
|
|
||||||
w++;
|
|
||||||
r++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScaleCopy(const SplitComplex* src, float scale, SplitComplex* dest, size_t count)
|
|
||||||
{
|
|
||||||
ScaleCopy(src->realp, scale, dest->realp, count);
|
|
||||||
ScaleCopy(src->imagp, scale, dest->imagp, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScaleRamp(float* buffer, float scaleStart, float scaleStep, size_t count)
|
|
||||||
{
|
|
||||||
float* w = buffer;
|
|
||||||
float s = scaleStart;
|
|
||||||
while (w < buffer + count) {
|
|
||||||
*w *= s;
|
|
||||||
w++;
|
|
||||||
s += scaleStep;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Accumulate(float* buffer, size_t bufferStride, const float* buffer2, size_t buffer2Stride, size_t count)
|
|
||||||
{
|
|
||||||
float* w = buffer;
|
|
||||||
const float* r = buffer2;
|
|
||||||
while (w < buffer + bufferStride * count) {
|
|
||||||
*w *= *r;
|
|
||||||
w += bufferStride;
|
|
||||||
r += buffer2Stride;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Accumulate(SplitComplex* buffer, const SplitComplex* buffer2, size_t count)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
|
||||||
buffer->imagp[i] += buffer2->imagp[i];
|
|
||||||
buffer->realp[i] += buffer2->realp[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Multiply(const SplitComplex* a, const SplitComplex* b, SplitComplex* c, size_t count)
|
|
||||||
{
|
|
||||||
for (size_t i = 0; i < count; i++) {
|
|
||||||
c->realp[i] = a->realp[i] * b->realp[i] - a->imagp[i] * b->imagp[i];
|
|
||||||
c->imagp[i] = a->realp[i] * b->imagp[i] + a->imagp[i] * b->realp[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace dsp
|
|
||||||
} // namespace siren
|
|
||||||
|
|
||||||
#endif // KRDSP_SLOW
|
|
||||||
@@ -1,121 +0,0 @@
|
|||||||
//
|
|
||||||
// KRDSP_vDSP.cpp
|
|
||||||
// Kraken Engine
|
|
||||||
//
|
|
||||||
// Copyright 2022 Kearwood Gilbert. 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 KEARWOOD GILBERT ''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 KEARWOOD GILBERT 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.
|
|
||||||
//
|
|
||||||
// The views and conclusions contained in the software and documentation are those of the
|
|
||||||
// authors and should not be interpreted as representing official policies, either expressed
|
|
||||||
// or implied, of Kearwood Gilbert.
|
|
||||||
//
|
|
||||||
|
|
||||||
#include "KRDSP.h"
|
|
||||||
|
|
||||||
#ifdef KRDSP_APPLE_VDSP
|
|
||||||
|
|
||||||
#include <Accelerate/Accelerate.h>
|
|
||||||
|
|
||||||
namespace siren {
|
|
||||||
namespace dsp {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FFTWorkspace::FFTWorkspace()
|
|
||||||
{
|
|
||||||
setup = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
FFTWorkspace::~FFTWorkspace()
|
|
||||||
{
|
|
||||||
destroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
void FFTWorkspace::create(size_t length)
|
|
||||||
{
|
|
||||||
setup = vDSP_create_fftsetup(length, kFFTRadix2);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FFTWorkspace::destroy()
|
|
||||||
{
|
|
||||||
if (setup) {
|
|
||||||
vDSP_destroy_fftsetup(setup);
|
|
||||||
setup = nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void FFTForward(const FFTWorkspace& workspace, SplitComplex* src, size_t count)
|
|
||||||
{
|
|
||||||
vDSP_fft_zip(workspace.setup, src, 1, count, kFFTDirection_Forward);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FFTInverse(const FFTWorkspace& workspace, SplitComplex* src, size_t count)
|
|
||||||
{
|
|
||||||
vDSP_fft_zip(workspace.setup, src, 1, count, kFFTDirection_Inverse);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Int16ToFloat(const short* src, size_t srcStride, float* dest, size_t destStride, size_t count)
|
|
||||||
{
|
|
||||||
vDSP_vflt16(src, srcStride, dest, destStride, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Scale(float* buffer, float scale, size_t count)
|
|
||||||
{
|
|
||||||
vDSP_vsmul(buffer, 1, &scale, buffer, 1, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScaleCopy(const float* src, float scale, float* dest, size_t count)
|
|
||||||
{
|
|
||||||
vDSP_vsmul(src, 1, &scale, dest, 1, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScaleCopy(const SplitComplex* src, float scale, SplitComplex* dest, size_t count)
|
|
||||||
{
|
|
||||||
ScaleCopy(src->realp, scale, dest->realp, count);
|
|
||||||
ScaleCopy(src->imagp, scale, dest->imagp, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScaleRamp(float* buffer, float scaleStart, float scaleStep, size_t count)
|
|
||||||
{
|
|
||||||
vDSP_vrampmul(buffer, 1, &scaleStart, &scaleStep, buffer, 1, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Accumulate(float* buffer, size_t bufferStride, const float* buffer2, size_t buffer2Stride, size_t count)
|
|
||||||
{
|
|
||||||
vDSP_vadd(buffer, bufferStride, buffer2, buffer2Stride, buffer, bufferStride, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Accumulate(SplitComplex* buffer, const SplitComplex* buffer2, size_t count)
|
|
||||||
{
|
|
||||||
vDSP_zvadd(buffer2, 1, buffer, 1, buffer, 1, count);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Multiply(const SplitComplex* a, const SplitComplex* b, SplitComplex* c, size_t count)
|
|
||||||
{
|
|
||||||
vDSP_zvmul(a, 1, b, 1, c, 1, count, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace dsp
|
|
||||||
} // namespace siren
|
|
||||||
|
|
||||||
#endif // KRDSP_APPLE_VDSP
|
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
using namespace kraken;
|
using namespace kraken;
|
||||||
|
|
||||||
#include "hydra.h"
|
#include "hydra.h"
|
||||||
|
#include "siren.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|||||||
1
siren
Submodule
1
siren
Submodule
Submodule siren added at d5023bc5fa
Reference in New Issue
Block a user