Skip to content

Commit 985471f

Browse files
committed
Test Module Noodling Continues
1 parent 33dcadd commit 985471f

File tree

4 files changed

+51
-1
lines changed

4 files changed

+51
-1
lines changed

Diff for: .gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "libs/midifile"]
22
path = libs/midifile
33
url = https://github.com/craigsapp/midifile.git
4+
[submodule "libs/sst/sst-basic-blocks"]
5+
path = libs/sst/sst-basic-blocks
6+
url = https://github.com/surge-synthesizer/sst-basic-blocks

Diff for: CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ include(RackSDK.cmake)
1212
message(STATUS "BaconMusic for Rack Build Process" )
1313
message(STATUS "Installing into '${CMAKE_INSTALL_PREFIX}'")
1414

15+
add_subdirectory(libs/sst/sst-basic-blocks)
16+
1517
file(GLOB SOURCES src/*.cpp libs/midifile/src/*.cpp libs/open303-code/Source/DSPCode/*.cpp)
1618
add_compile_options(-fvisibility=hidden -fvisibility-inlines-hidden)
1719

1820
target_include_directories(${RACK_PLUGIN_LIB} PRIVATE src libs/midifile/include libs/open303-code/Source/DSPCode)
1921
target_sources(${RACK_PLUGIN_LIB} PRIVATE
2022
${SOURCES})
23+
target_link_libraries(${RACK_PLUGIN_LIB} PRIVATE sst-basic-blocks)
2124

Diff for: libs/sst/sst-basic-blocks

Submodule sst-basic-blocks added at 0960274

Diff for: src/BaconTestModule.cpp

+44-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
#include "BaconModule.hpp"
33
#include "BaconModuleWidget.h"
44

5+
#include "sst/basic-blocks/dsp/HilbertTransform.h"
6+
#include "sst/basic-blocks/dsp/QuadratureOscillators.h"
7+
58
namespace bp = baconpaul::rackplugs;
69

710
struct BaconTest : bp::BaconModule
@@ -30,6 +33,10 @@ struct BaconTest : bp::BaconModule
3033
NUM_LIGHTS
3134
};
3235

36+
sst::basic_blocks::dsp::HilbertTransformMonoFloat hilbertMono;
37+
sst::basic_blocks::dsp::HilbertTransformStereoSSE hilbert;
38+
sst::basic_blocks::dsp::QuadratureOscillator<float> qo;
39+
3340
BaconTest()
3441
{
3542
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
@@ -43,7 +50,43 @@ struct BaconTest : bp::BaconModule
4350
}
4451
}
4552

46-
void process(const ProcessArgs &args) override {}
53+
double theSampleRate{1};
54+
void onSampleRateChange(const SampleRateChangeEvent &e) override
55+
{
56+
qo.setRate(2.0 * M_PI * 50 * e.sampleTime);
57+
hilbert.setSampleRate(e.sampleRate);
58+
hilbertMono.setSampleRate(e.sampleRate);
59+
Module::onSampleRateChange(e);
60+
}
61+
float lrt = -1.f;
62+
float prior[2]{0.f, 0.f};
63+
void process(const ProcessArgs &args) override {
64+
auto iL = inputs[INPUT_0].getVoltage() / 5.0f;
65+
auto iR = inputs[INPUT_0 + 1].getVoltage() / 5.0f;
66+
67+
qo.step();
68+
69+
if (params[PARAM_0].getValue() != lrt)
70+
{
71+
lrt = params[PARAM_0].getValue();
72+
auto rf = lrt * 800 - 200;
73+
qo.setRate(2.0 * M_PI * rf * args.sampleTime);
74+
}
75+
auto fb = params[PARAM_0 + 1].getValue();
76+
iL = 0.8 * ( iL + fb * fb * fb * prior[0] );
77+
iR = 0.8 * ( iR + fb * fb * fb * prior[1] );
78+
79+
auto [L, R] = hilbert.stepToPair(iL, iR);
80+
81+
auto [re, im] = L;
82+
83+
auto [reR, imR] = R;
84+
85+
prior[0] = (re * qo.v - im * qo.u);
86+
prior[1] = (reR * qo.v - imR * qo.u);
87+
outputs[OUTPUT_0+0].setVoltage(prior[0] * 5.f);
88+
outputs[OUTPUT_0+1].setVoltage(prior[1] * 5.f);
89+
}
4790
};
4891

4992
struct BaconTestWidget : bp::BaconModuleWidget

0 commit comments

Comments
 (0)