Skip to content

Commit

Permalink
Move FastMath entirely to sst-basic-blocks; turn on gcc12 build (#6943)
Browse files Browse the repository at this point in the history
FastMath is now entirely from sst-basic-blocks for both filters
and for surge.  Closes #6532
  • Loading branch information
baconpaul authored Apr 17, 2023
1 parent d57eed2 commit 385bb55
Show file tree
Hide file tree
Showing 18 changed files with 30 additions and 486 deletions.
2 changes: 1 addition & 1 deletion libs/sst/sst-basic-blocks
3 changes: 1 addition & 2 deletions src/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ else()
target_compile_definitions(luajit-5.1 INTERFACE HAS_LUA=0)
endif()

surge_add_lib_subdirectory(sst/sst-basic-blocks)
surge_add_lib_subdirectory(sst/sst-cpputils)
surge_add_lib_subdirectory(sst/sst-plugininfra)
surge_add_lib_subdirectory(sst/sst-filters)
surge_add_lib_subdirectory(sst/sst-waveshapers)
surge_add_lib_subdirectory(sst/sst-basic-blocks)

set(PEGTL_BUILD_TESTS OFF CACHE BOOL "")
set(PEGTL_BUILD_EXAMPLES OFF CACHE BOOL "")
Expand Down Expand Up @@ -279,7 +279,6 @@ add_library(${PROJECT_NAME}
dsp/oscillators/WindowOscillator.h
dsp/utilities/DSPUtils.cpp
dsp/utilities/DSPUtils.h
dsp/utilities/FastMath.h
dsp/utilities/SSEComplex.h
dsp/utilities/SSESincDelayLine.h
dsp/vembertech/basic_dsp.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/common/dsp/Oscillator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "Oscillator.h"
#include "DSPUtils.h"
#include "FastMath.h"
#include "sst/basic-blocks/dsp/FastMath.h"
#include <cmath>

#include "AliasOscillator.h"
Expand Down
7 changes: 4 additions & 3 deletions src/common/dsp/effects/RingModulatorEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#include "Tunings.h"
#include "SineOscillator.h"
#include "DebugHelpers.h"
#include "FastMath.h"
#include "sst/basic-blocks/dsp/FastMath.h"

// http://recherche.ircam.fr/pub/dafx11/Papers/66_e.pdf

Expand Down Expand Up @@ -119,8 +119,9 @@ void RingModulatorEffect::process(float *dataL, float *dataR)
{
// TODO efficiency of course
auto vc = SineOscillator::valueFromSinAndCos(
Surge::DSP::fastsin(2.0 * M_PI * (phase[u] - 0.5)),
Surge::DSP::fastcos(2.0 * M_PI * (phase[u] - 0.5)), *pd_int[rm_carrier_shape]);
sst::basic_blocks::dsp::fastsin(2.0 * M_PI * (phase[u] - 0.5)),
sst::basic_blocks::dsp::fastcos(2.0 * M_PI * (phase[u] - 0.5)),
*pd_int[rm_carrier_shape]);
phase[u] += dphase[u];

if (phase[u] > 1)
Expand Down
2 changes: 1 addition & 1 deletion src/common/dsp/effects/WaveShaperEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

#include "WaveShaperEffect.h"
#include "DebugHelpers.h"
#include "FastMath.h"
#include "sst/basic-blocks/dsp/FastMath.h"

// http://recherche.ircam.fr/pub/dafx11/Papers/66_e.pdf

Expand Down
2 changes: 1 addition & 1 deletion src/common/dsp/effects/chowdsp/shared/wdf_sse.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include <cmath>
#include <memory>
#include <type_traits>
#include "FastMath.h"
#include "sst/basic-blocks/dsp/FastMath.h"
#include "portable_intrinsics.h"

namespace chowdsp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <random>

#include "SpringReverbProc.h"
#include "utilities/FastMath.h"
#include "sst/basic-blocks/dsp/FastMath.h"

namespace
{
Expand Down Expand Up @@ -111,7 +111,7 @@ void SpringReverbProc::processBlock(float *left, float *right, const int numSamp
}

auto doSpringInput = [=](int ch, float input, int n) -> float {
auto output = Surge::DSP::fasttanh(input - feedbackGain * delay.popSample(ch));
auto output = sst::basic_blocks::dsp::fasttanh(input - feedbackGain * delay.popSample(ch));
return dcBlocker.processSample<StateVariableFilterType::Highpass>(ch, output) +
shortShakeBuffer[n];
};
Expand Down
3 changes: 2 additions & 1 deletion src/common/dsp/effects/chowdsp/tape/HysteresisOps.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#pragma once

#include <cmath>
#include "FastMath.h"
#include "globals.h"
#include "sst/basic-blocks/dsp/FastMath.h"

#define CHOWTAPE_HYSTERESIS_USE_SIMD 1

Expand Down
2 changes: 1 addition & 1 deletion src/common/dsp/modulators/MSEGModulationHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <iostream>
#include "DebugHelpers.h"
#include "basic_dsp.h" // for limit_range
#include "FastMath.h"
#include "sst/basic-blocks/dsp/FastMath.h"

namespace Surge
{
Expand Down
15 changes: 8 additions & 7 deletions src/common/dsp/oscillators/SineOscillator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

#include "SineOscillator.h"
#include "FastMath.h"
#include "sst/basic-blocks/dsp/FastMath.h"
#include <algorithm>

/*
Expand Down Expand Up @@ -671,10 +671,10 @@ void SineOscillator::process_block_internal(float pitch, float drift, float fmde
auto lv = _mm_load_ps(&lastvalue[u]);
auto x = _mm_add_ps(_mm_add_ps(ph, lv), fmpds);

x = Surge::DSP::clampToPiRangeSSE(x);
x = sst::basic_blocks::dsp::clampToPiRangeSSE(x);

auto sxl = Surge::DSP::fastsinSSE(x);
auto cxl = Surge::DSP::fastcosSSE(x);
auto sxl = sst::basic_blocks::dsp::fastsinSSE(x);
auto cxl = sst::basic_blocks::dsp::fastcosSSE(x);

auto out_local = valueFromSinAndCosForMode<mode>(sxl, cxl, std::min(n_unison - u, 4));

Expand Down Expand Up @@ -787,8 +787,9 @@ void SineOscillator::process_block_legacy(float pitch, float drift, bool stereo,

for (int u = 0; u < n_unison; u++)
{
float out_local = singleValueFromSinAndCos<mode>(Surge::DSP::fastsin(phase[u]),
Surge::DSP::fastcos(phase[u]));
float out_local =
singleValueFromSinAndCos<mode>(sst::basic_blocks::dsp::fastsin(phase[u]),
sst::basic_blocks::dsp::fastcos(phase[u]));

outL += (panL[u] * out_local) * out_attenuation * playingramp[u];
outR += (panR[u] * out_local) * out_attenuation * playingramp[u];
Expand All @@ -799,7 +800,7 @@ void SineOscillator::process_block_legacy(float pitch, float drift, bool stereo,
playingramp[u] = 1;

phase[u] += omega[u] + master_osc[k] * FMdepth.v;
phase[u] = Surge::DSP::clampToPiRange(phase[u]);
phase[u] = sst::basic_blocks::dsp::clampToPiRange(phase[u]);
}

FMdepth.process();
Expand Down
5 changes: 3 additions & 2 deletions src/common/dsp/oscillators/StringOscillator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

#include "globals.h"
#include "FastMath.h"
#include "sst/basic-blocks/dsp/FastMath.h"

/*
* String oscillator is a self-oscillating delay with various filters and
Expand Down Expand Up @@ -689,7 +689,8 @@ void StringOscillator::process_block_internal(float pitch, float drift, bool ste

if (FM)
{
v *= Surge::DSP::fastexp(limit_range(fmdepth.v * master_osc[i] * 3, -6.f, 4.f));
v *= sst::basic_blocks::dsp::fastexp(
limit_range(fmdepth.v * master_osc[i] * 3, -6.f, 4.f));
}

v *= OS;
Expand Down
Loading

0 comments on commit 385bb55

Please sign in to comment.