[repo] rename and test FM
This commit is contained in:
parent
8d48c93931
commit
abd170d77a
6 changed files with 54 additions and 36 deletions
|
@ -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"
|
||||
)
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include <Ottobit/OttobitModel.hpp>
|
||||
#include <Ottobit/OttobitUi.hpp>
|
4
Senior/Senior.hpp
Normal file
4
Senior/Senior.hpp
Normal file
|
@ -0,0 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
#include <Senior/SeniorModel.hpp>
|
||||
#include <Senior/SeniorUi.hpp>
|
|
@ -1,10 +1,10 @@
|
|||
#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
|
||||
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<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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,24 +1,28 @@
|
|||
#pragma once
|
||||
|
||||
#include <cmath>
|
||||
#include <ranges>
|
||||
|
||||
#include <Gamma/Oscillator.h>
|
||||
#include <Gamma/Delay.h>
|
||||
|
||||
#include <halp/compat/gamma.hpp>
|
||||
#include <halp/audio.hpp>
|
||||
#include <halp/controls.hpp>
|
||||
#include <halp/mappers.hpp>
|
||||
#include <halp/meta.hpp>
|
||||
|
||||
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<int> skipped_frames;
|
||||
|
||||
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();
|
||||
double crush_frame(const double& f);
|
||||
};
|
|
@ -1,15 +1,15 @@
|
|||
#pragma once
|
||||
#include <Ottobit/OttobitModel.hpp>
|
||||
#include <Senior/SeniorModel.hpp>
|
||||
#include <halp/layout.hpp>
|
||||
|
||||
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)
|
||||
|
Loading…
Add table
Reference in a new issue