diff --git a/CMakeLists.txt b/CMakeLists.txt index b2195c9..0f68feb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,26 +8,26 @@ if(NOT TARGET score_plugin_avnd) return() endif() -project(score_addon_ottobit LANGUAGES CXX) +project(score_avnd_senior LANGUAGES CXX) avnd_score_plugin_init( - BASE_TARGET score_addon_ottobit + BASE_TARGET score_avnd_senior ) avnd_score_plugin_add( - BASE_TARGET score_addon_ottobit + BASE_TARGET score_avnd_senior SOURCES - Ottobit/Ottobit.hpp - Ottobit/OttobitModel.hpp - Ottobit/OttobitModel.cpp - Ottobit/OttobitUi.hpp - TARGET ottobit - MAIN_CLASS Ottobit - NAMESPACE Meris + Senior/Senior.hpp + Senior/SeniorModel.hpp + Senior/SeniorModel.cpp + Senior/SeniorUi.hpp + TARGET senior + MAIN_CLASS Senior + NAMESPACE Ottobit ) avnd_score_plugin_finalize( - BASE_TARGET score_addon_ottobit + BASE_TARGET score_avnd_senior PLUGIN_VERSION 1 PLUGIN_UUID "eab41987-98a5-40ac-9c38-a792eae12148" ) diff --git a/Ottobit/Ottobit.hpp b/Ottobit/Ottobit.hpp deleted file mode 100644 index a67e3c2..0000000 --- a/Ottobit/Ottobit.hpp +++ /dev/null @@ -1,4 +0,0 @@ -#pragma once - -#include -#include \ No newline at end of file diff --git a/Senior/Senior.hpp b/Senior/Senior.hpp new file mode 100644 index 0000000..6879852 --- /dev/null +++ b/Senior/Senior.hpp @@ -0,0 +1,4 @@ +#pragma once + +#include +#include diff --git a/Ottobit/OttobitModel.cpp b/Senior/SeniorModel.cpp similarity index 71% rename from Ottobit/OttobitModel.cpp rename to Senior/SeniorModel.cpp index b438242..8eb7af4 100644 --- a/Ottobit/OttobitModel.cpp +++ b/Senior/SeniorModel.cpp @@ -1,10 +1,10 @@ #include -#include "Ottobit.hpp" +#include "Senior.hpp" -namespace Meris +namespace Ottobit { -void Ottobit::operator()(tick t) +void Senior::operator()(tick t) { // Only compute bit_factor when the control changes if (inputs.bits != previous_bits) @@ -24,10 +24,10 @@ void Ottobit::operator()(tick t) for(int i{0}; i < inputs.audio.channels; i++) { auto* in = inputs.audio[i]; - auto* out = outputs.audio[i]; + auto* out = outputs.audio[i % outputs.audio.channels]; // Init current_frame for each channel - double current_frame{crush_frame(in[0])}; + double current_frame{crush_frame(in[i])}; for(int j{0}; j < t.frames; j++) { @@ -39,26 +39,25 @@ void Ottobit::operator()(tick t) current_frame = crush_frame(in[j]); } - out[j] = current_frame; + fms[i].delay(lfos[i].cos()*0.0025 + 0.05); + out[j] = fms[i](current_frame); } } } -void Ottobit::set_bit_factor() +void Senior::set_bit_factor() { bit_factor = pow(2, inputs.bits) - 1; } -double Ottobit::crush_frame(const double& f) +double Senior::crush_frame(const double& f) { if (inputs.bits == BITS) return f; else - { // Rounding using static_cast // return static_cast(static_cast(f * bit_factor)) / bit_factor; - // Close, but prefer Lance Putnama's Gama's use of roundMagic + // Close, but prefer the use of roundMagic from Lance Putnam's Gama return gam::scl::round(f * bit_factor) / bit_factor; - } } } diff --git a/Ottobit/OttobitModel.hpp b/Senior/SeniorModel.hpp similarity index 66% rename from Ottobit/OttobitModel.hpp rename to Senior/SeniorModel.hpp index bdd52d6..88869fc 100644 --- a/Ottobit/OttobitModel.hpp +++ b/Senior/SeniorModel.hpp @@ -1,24 +1,28 @@ #pragma once #include +#include +#include +#include + +#include #include #include #include #include -namespace Meris +namespace Ottobit { - -class Ottobit +class Senior { #define BITS 16 #define RATE 64 public: - halp_meta(name, "Ottobit") + halp_meta(name, "Senior") halp_meta(category, "Audio") - halp_meta(c_name, "ottobit") + halp_meta(c_name, "senior") halp_meta(uuid, "fe8425d7-64d3-4b8b-a652-1d80026edc8b") // Define inputs and outputs ports. @@ -44,6 +48,16 @@ public: // Initialization, this method will be called with buffer size, etc. set_bit_factor(); skipped_frames.resize(info.input_channels); + lfos.resize(info.input_channels); + fms.resize(info.input_channels); + + for (auto [lfo, fm] : std::views::zip(lfos, fms)) + { + lfo.set_sample_rate(info.rate); + lfo.set(5, 0, 0); + fm.set_sample_rate(info.rate); + fm.maxDelay(0.1); + } } // Do our processing for N samples @@ -56,13 +70,18 @@ public: struct ui; private: - // Local variables int bit_factor, step_size{0}; std::vector skipped_frames; double previous_bits{BITS}, previous_rate{1}; + std::vector> lfos; + std::vector> fms; + void set_bit_factor(); double crush_frame(const double& f); }; diff --git a/Ottobit/OttobitUi.hpp b/Senior/SeniorUi.hpp similarity index 69% rename from Ottobit/OttobitUi.hpp rename to Senior/SeniorUi.hpp index cc42a4c..69988f8 100644 --- a/Ottobit/OttobitUi.hpp +++ b/Senior/SeniorUi.hpp @@ -1,15 +1,15 @@ #pragma once -#include +#include #include -namespace Meris +namespace Ottobit { -struct Ottobit::ui +struct Senior::ui { using enum halp::colors; using enum halp::layouts; - halp_meta(name, "Ottobit") + halp_meta(name, "Senior") halp_meta(layout, hbox) halp_meta(background, dark)