Skip to content

Commit

Permalink
Test Module Noodling Continues
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul committed Nov 30, 2023
1 parent 33dcadd commit 985471f
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "libs/midifile"]
path = libs/midifile
url = https://github.com/craigsapp/midifile.git
[submodule "libs/sst/sst-basic-blocks"]
path = libs/sst/sst-basic-blocks
url = https://github.com/surge-synthesizer/sst-basic-blocks
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ include(RackSDK.cmake)
message(STATUS "BaconMusic for Rack Build Process" )
message(STATUS "Installing into '${CMAKE_INSTALL_PREFIX}'")

add_subdirectory(libs/sst/sst-basic-blocks)

file(GLOB SOURCES src/*.cpp libs/midifile/src/*.cpp libs/open303-code/Source/DSPCode/*.cpp)
add_compile_options(-fvisibility=hidden -fvisibility-inlines-hidden)

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

1 change: 1 addition & 0 deletions libs/sst/sst-basic-blocks
Submodule sst-basic-blocks added at 096027
45 changes: 44 additions & 1 deletion src/BaconTestModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#include "BaconModule.hpp"
#include "BaconModuleWidget.h"

#include "sst/basic-blocks/dsp/HilbertTransform.h"
#include "sst/basic-blocks/dsp/QuadratureOscillators.h"

namespace bp = baconpaul::rackplugs;

struct BaconTest : bp::BaconModule
Expand Down Expand Up @@ -30,6 +33,10 @@ struct BaconTest : bp::BaconModule
NUM_LIGHTS
};

sst::basic_blocks::dsp::HilbertTransformMonoFloat hilbertMono;
sst::basic_blocks::dsp::HilbertTransformStereoSSE hilbert;
sst::basic_blocks::dsp::QuadratureOscillator<float> qo;

BaconTest()
{
config(NUM_PARAMS, NUM_INPUTS, NUM_OUTPUTS, NUM_LIGHTS);
Expand All @@ -43,7 +50,43 @@ struct BaconTest : bp::BaconModule
}
}

void process(const ProcessArgs &args) override {}
double theSampleRate{1};
void onSampleRateChange(const SampleRateChangeEvent &e) override
{
qo.setRate(2.0 * M_PI * 50 * e.sampleTime);
hilbert.setSampleRate(e.sampleRate);
hilbertMono.setSampleRate(e.sampleRate);
Module::onSampleRateChange(e);
}
float lrt = -1.f;
float prior[2]{0.f, 0.f};
void process(const ProcessArgs &args) override {
auto iL = inputs[INPUT_0].getVoltage() / 5.0f;
auto iR = inputs[INPUT_0 + 1].getVoltage() / 5.0f;

qo.step();

if (params[PARAM_0].getValue() != lrt)
{
lrt = params[PARAM_0].getValue();
auto rf = lrt * 800 - 200;
qo.setRate(2.0 * M_PI * rf * args.sampleTime);
}
auto fb = params[PARAM_0 + 1].getValue();
iL = 0.8 * ( iL + fb * fb * fb * prior[0] );
iR = 0.8 * ( iR + fb * fb * fb * prior[1] );

auto [L, R] = hilbert.stepToPair(iL, iR);

auto [re, im] = L;

auto [reR, imR] = R;

prior[0] = (re * qo.v - im * qo.u);
prior[1] = (reR * qo.v - imR * qo.u);
outputs[OUTPUT_0+0].setVoltage(prior[0] * 5.f);
outputs[OUTPUT_0+1].setVoltage(prior[1] * 5.f);
}
};

struct BaconTestWidget : bp::BaconModuleWidget
Expand Down

0 comments on commit 985471f

Please sign in to comment.