[repo] rename and test FM

This commit is contained in:
thibaud keller 2024-10-06 23:26:13 +01:00
parent 8d48c93931
commit abd170d77a
6 changed files with 54 additions and 36 deletions

View file

@ -8,26 +8,26 @@ if(NOT TARGET score_plugin_avnd)
return() return()
endif() endif()
project(score_addon_ottobit LANGUAGES CXX) project(score_avnd_senior LANGUAGES CXX)
avnd_score_plugin_init( avnd_score_plugin_init(
BASE_TARGET score_addon_ottobit BASE_TARGET score_avnd_senior
) )
avnd_score_plugin_add( avnd_score_plugin_add(
BASE_TARGET score_addon_ottobit BASE_TARGET score_avnd_senior
SOURCES SOURCES
Ottobit/Ottobit.hpp Senior/Senior.hpp
Ottobit/OttobitModel.hpp Senior/SeniorModel.hpp
Ottobit/OttobitModel.cpp Senior/SeniorModel.cpp
Ottobit/OttobitUi.hpp Senior/SeniorUi.hpp
TARGET ottobit TARGET senior
MAIN_CLASS Ottobit MAIN_CLASS Senior
NAMESPACE Meris NAMESPACE Ottobit
) )
avnd_score_plugin_finalize( avnd_score_plugin_finalize(
BASE_TARGET score_addon_ottobit BASE_TARGET score_avnd_senior
PLUGIN_VERSION 1 PLUGIN_VERSION 1
PLUGIN_UUID "eab41987-98a5-40ac-9c38-a792eae12148" PLUGIN_UUID "eab41987-98a5-40ac-9c38-a792eae12148"
) )

View file

@ -1,4 +0,0 @@
#pragma once
#include <Ottobit/OttobitModel.hpp>
#include <Ottobit/OttobitUi.hpp>

4
Senior/Senior.hpp Normal file
View file

@ -0,0 +1,4 @@
#pragma once
#include <Senior/SeniorModel.hpp>
#include <Senior/SeniorUi.hpp>

View file

@ -1,10 +1,10 @@
#include <Gamma/scl.h> #include <Gamma/scl.h>
#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 // Only compute bit_factor when the control changes
if (inputs.bits != previous_bits) if (inputs.bits != previous_bits)
@ -24,10 +24,10 @@ void Ottobit::operator()(tick t)
for(int i{0}; i < inputs.audio.channels; i++) for(int i{0}; i < inputs.audio.channels; i++)
{ {
auto* in = inputs.audio[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 // 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++) for(int j{0}; j < t.frames; j++)
{ {
@ -39,26 +39,25 @@ void Ottobit::operator()(tick t)
current_frame = crush_frame(in[j]); 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; 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) if (inputs.bits == BITS)
return f; return f;
else else
{
// Rounding using static_cast // Rounding using static_cast
// return static_cast<double>(static_cast<int>(f * bit_factor)) / bit_factor; // return static_cast<double>(static_cast<int>(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<double>(f * bit_factor) / bit_factor; return gam::scl::round<double>(f * bit_factor) / bit_factor;
}
} }
} }

View file

@ -1,24 +1,28 @@
#pragma once #pragma once
#include <cmath> #include <cmath>
#include <ranges>
#include <Gamma/Oscillator.h>
#include <Gamma/Delay.h>
#include <halp/compat/gamma.hpp>
#include <halp/audio.hpp> #include <halp/audio.hpp>
#include <halp/controls.hpp> #include <halp/controls.hpp>
#include <halp/mappers.hpp> #include <halp/mappers.hpp>
#include <halp/meta.hpp> #include <halp/meta.hpp>
namespace Meris namespace Ottobit
{ {
class Senior
class Ottobit
{ {
#define BITS 16 #define BITS 16
#define RATE 64 #define RATE 64
public: public:
halp_meta(name, "Ottobit") halp_meta(name, "Senior")
halp_meta(category, "Audio") halp_meta(category, "Audio")
halp_meta(c_name, "ottobit") halp_meta(c_name, "senior")
halp_meta(uuid, "fe8425d7-64d3-4b8b-a652-1d80026edc8b") halp_meta(uuid, "fe8425d7-64d3-4b8b-a652-1d80026edc8b")
// Define inputs and outputs ports. // Define inputs and outputs ports.
@ -44,6 +48,16 @@ public:
// Initialization, this method will be called with buffer size, etc. // Initialization, this method will be called with buffer size, etc.
set_bit_factor(); set_bit_factor();
skipped_frames.resize(info.input_channels); 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 // Do our processing for N samples
@ -56,13 +70,18 @@ public:
struct ui; struct ui;
private: private:
// Local variables
int bit_factor, step_size{0}; int bit_factor, step_size{0};
std::vector<int> skipped_frames; std::vector<int> skipped_frames;
double previous_bits{BITS}, previous_rate{1}; double previous_bits{BITS}, previous_rate{1};
std::vector<gam::LFO<gam::phsInc::Loop,
halp::compat::gamma_domain>> lfos;
std::vector<gam::Delay<double,
gam::ipl::Linear,
halp::compat::gamma_domain>> fms;
void set_bit_factor(); void set_bit_factor();
double crush_frame(const double& f); double crush_frame(const double& f);
}; };

View file

@ -1,15 +1,15 @@
#pragma once #pragma once
#include <Ottobit/OttobitModel.hpp> #include <Senior/SeniorModel.hpp>
#include <halp/layout.hpp> #include <halp/layout.hpp>
namespace Meris namespace Ottobit
{ {
struct Ottobit::ui struct Senior::ui
{ {
using enum halp::colors; using enum halp::colors;
using enum halp::layouts; using enum halp::layouts;
halp_meta(name, "Ottobit") halp_meta(name, "Senior")
halp_meta(layout, hbox) halp_meta(layout, hbox)
halp_meta(background, dark) halp_meta(background, dark)