From d73bcfdfd829fd50cc1d3e31e89fb2fe557bac42 Mon Sep 17 00:00:00 2001 From: Paul Date: Sat, 13 Jan 2024 08:41:14 -0500 Subject: [PATCH] Integrate Superparasites Clouds Firmware (off by default) (#7436) This commit implements the superparasites firmware as an option for clouds. The firmware comes from patrick dowling at https://github.com/patrickdowling/superparasites In this commit, the firmware is activatable at build time but is still off by default, so the synth is unchanged unless you opt in in libs/eurorack/CMakeLists with the option. Closes https://github.com/patrickdowling/superparasites/issues/6 Addresses #7359 --- libs/eurorack/CMakeLists.txt | 26 +++++++++++++++++++++-- libs/eurorack/eurorack | 2 +- src/common/Parameter.cpp | 23 +++++++++++++++++++- src/common/dsp/effects/NimbusEffect.cpp | 22 +++++++++++++++++-- src/surge-xt/gui/overlays/AboutScreen.cpp | 9 ++++++++ 5 files changed, 76 insertions(+), 6 deletions(-) diff --git a/libs/eurorack/CMakeLists.txt b/libs/eurorack/CMakeLists.txt index cf5fda04775..63d441ed081 100644 --- a/libs/eurorack/CMakeLists.txt +++ b/libs/eurorack/CMakeLists.txt @@ -1,14 +1,36 @@ project(eurorack VERSION 0.0.0 LANGUAGES CXX) -add_library(${PROJECT_NAME} +add_library(${PROJECT_NAME}) + +option(EURORACK_CLOUDS_IS_CLOUDS "Use the clouds (as opposed to superparasites) firmware for clouds" TRUE) + +if (EURORACK_CLOUDS_IS_CLOUDS) + target_sources(${PROJECT_NAME} PRIVATE eurorack/clouds/dsp/correlator.cc eurorack/clouds/dsp/granular_processor.cc eurorack/clouds/dsp/mu_law.cc eurorack/clouds/dsp/pvoc/frame_transformation.cc eurorack/clouds/dsp/pvoc/phase_vocoder.cc eurorack/clouds/dsp/pvoc/stft.cc - eurorack/clouds/resources.cc + eurorack/clouds/resources.cc) + target_compile_definitions(${PROJECT_NAME} PUBLIC EURORACK_CLOUDS_IS_CLOUDS=1) +else() + target_sources(${PROJECT_NAME} PRIVATE + eurorack/supercell/resources.cc + eurorack/supercell/dsp/kammerl_player.cc + eurorack/supercell/dsp/pvoc/stft.cc + eurorack/supercell/dsp/pvoc/spectral_clouds_transformation.cc + eurorack/supercell/dsp/pvoc/phase_vocoder.cc + eurorack/supercell/dsp/pvoc/frame_transformation.cc + eurorack/supercell/dsp/granular_processor.cc + eurorack/supercell/dsp/mu_law.cc + eurorack/supercell/dsp/correlator.cc +) + target_compile_definitions(${PROJECT_NAME} PUBLIC EURORACK_CLOUDS_IS_SUPERPARASITES=1) +endif() + +target_sources(${PROJECT_NAME} PRIVATE eurorack/plaits/dsp/voice.cc eurorack/plaits/dsp/speech/lpc_speech_synth_phonemes.cc eurorack/plaits/dsp/speech/lpc_speech_synth_controller.cc diff --git a/libs/eurorack/eurorack b/libs/eurorack/eurorack index 23d0bd2f88d..f7614460cd3 160000 --- a/libs/eurorack/eurorack +++ b/libs/eurorack/eurorack @@ -1 +1 @@ -Subproject commit 23d0bd2f88d53b888bff94312626bd24fd566f06 +Subproject commit f7614460cd3e295f6f6132f9052984c7bca9a69d diff --git a/src/common/Parameter.cpp b/src/common/Parameter.cpp index 65aeeeb45f5..fcb464bcf27 100644 --- a/src/common/Parameter.cpp +++ b/src/common/Parameter.cpp @@ -1272,7 +1272,11 @@ void Parameter::set_type(int ctrltype) case ct_nimbusmode: valtype = vt_int; val_min.i = 0; - val_max.i = 3; // sin, tri, saw, s&h +#if EURORACK_CLOUDS_IS_SUPERPARASITES + val_max.i = 7; +#else + val_max.i = 3; +#endif val_default.i = 0; break; @@ -4050,6 +4054,23 @@ std::string Parameter::get_display(bool external, float ef) const case 3: txt = "Spectral Madness"; break; +#if EURORACK_CLOUDS_IS_SUPERPARASITES + case 4: + txt = "Oliverb"; + break; + case 5: + txt = "Reonestor"; + break; + case 6: + txt = "Kammerl"; + break; + case 7: + txt = "Spectral Cloud"; + break; +#endif + default: + txt = "Unknown Model"; + break; } } break; diff --git a/src/common/dsp/effects/NimbusEffect.cpp b/src/common/dsp/effects/NimbusEffect.cpp index 3f29ffc6d30..cb69d14c4d8 100644 --- a/src/common/dsp/effects/NimbusEffect.cpp +++ b/src/common/dsp/effects/NimbusEffect.cpp @@ -30,7 +30,11 @@ #endif #define TEST // remember this is how you tell the eurorack code to use dsp not hardware +#if EURORACK_CLOUDS_IS_SUPERPARASITES +#include "supercell/dsp/granular_processor.h" +#else #include "clouds/dsp/granular_processor.h" +#endif NimbusEffect::NimbusEffect(SurgeStorage *storage, FxStorage *fxdata, pdata *pd) : Effect(storage, fxdata, pd) @@ -40,7 +44,10 @@ NimbusEffect::NimbusEffect(SurgeStorage *storage, FxStorage *fxdata, pdata *pd) block_mem = new uint8_t[memLen](); block_ccm = new uint8_t[ccmLen](); processor = new clouds::GranularProcessor(); +#if EURORACK_CLOUDS_IS_SUPERPARASITES +#else memset(processor, 0, sizeof(*processor)); +#endif processor->Init(block_mem, memLen, block_ccm, ccmLen); mix.set_blocksize(BLOCK_SIZE); @@ -122,8 +129,15 @@ void NimbusEffect::process(float *dataL, float *dataR) int frames_to_go = sdata.output_frames_gen; int outpos = 0; + auto modeInt = *pd_int[nmb_mode]; + // Just make sure we are safe if we swap between superparasites and not +#if EURORACK_CLOUDS_IS_SUPERPARASITES + modeInt = std::clamp(modeInt, 0, 7); +#else + modeInt = std::clamp(modeInt, 0, 3); +#endif processor->set_playback_mode( - (clouds::PlaybackMode)((int)clouds::PLAYBACK_MODE_GRANULAR + *pd_int[nmb_mode])); + (clouds::PlaybackMode)((int)clouds::PLAYBACK_MODE_GRANULAR + modeInt)); processor->set_quality(*pd_int[nmb_quality]); int consume_ptr = 0; @@ -165,8 +179,12 @@ void NimbusEffect::process(float *dataL, float *dataR) parm->reverb = clamp01(*pd_float[nmb_reverb]); parm->dry_wet = 1.f; +#if EURORACK_CLOUDS_IS_SUPERPARASITES + parm->capture = nimbusTrigger; +#else parm->trigger = nimbusTrigger; // this is an external granulating source. Skip it - parm->gate = parm->freeze; // This is the CV for the freeze button +#endif + parm->gate = parm->freeze; // This is the CV for the freeze button processor->Prepare(); processor->Process(input, output, inputSz); diff --git a/src/surge-xt/gui/overlays/AboutScreen.cpp b/src/surge-xt/gui/overlays/AboutScreen.cpp index 147b37241c5..79679d48206 100644 --- a/src/surge-xt/gui/overlays/AboutScreen.cpp +++ b/src/surge-xt/gui/overlays/AboutScreen.cpp @@ -417,6 +417,15 @@ void AboutScreen::resized() yp += lblvs; +#if EURORACK_CLOUDS_IS_SUPERPARASITES + addLabel("Nimbus includes the the integrated superparasites firmware by Patrick Dowling, " + "including" + " mqtthiqs/Parasites and jkammerl/Beat Repeat modes.", + 600); + + yp += lblvs; +#endif + addLabel("Oscilloscope code based on s(m)exoscope by Bram @ Smartelectronix, licensed " "under GNU GPL v3 license", 600);