score-avnd-senior/Senior/SeniorModel.hpp

94 lines
2.3 KiB
C++
Raw Normal View History

2024-09-30 18:50:58 +01:00
#pragma once
2024-09-30 22:30:26 +01:00
#include <cmath>
2024-10-06 23:26:13 +01:00
#include <ranges>
2024-09-30 22:30:26 +01:00
2024-10-06 23:26:13 +01:00
#include <Gamma/Oscillator.h>
#include <Gamma/Delay.h>
2024-10-30 19:51:40 +00:00
#include <Gamma/Filter.h>
2024-10-06 23:26:13 +01:00
#include <halp/compat/gamma.hpp>
2024-09-30 18:50:58 +01:00
#include <halp/audio.hpp>
#include <halp/controls.hpp>
2024-09-30 22:30:26 +01:00
#include <halp/mappers.hpp>
2024-09-30 18:50:58 +01:00
#include <halp/meta.hpp>
2024-10-06 23:26:13 +01:00
namespace Ottobit
2024-09-30 18:50:58 +01:00
{
2024-10-06 23:26:13 +01:00
class Senior
2024-09-30 18:50:58 +01:00
{
public:
2024-10-06 23:26:13 +01:00
halp_meta(name, "Senior")
2024-09-30 18:50:58 +01:00
halp_meta(category, "Audio")
2024-10-06 23:26:13 +01:00
halp_meta(c_name, "senior")
2024-09-30 18:50:58 +01:00
halp_meta(uuid, "fe8425d7-64d3-4b8b-a652-1d80026edc8b")
// Define inputs and outputs ports.
// See the docs at https://github.com/celtera/avendish
struct ins
{
halp::dynamic_audio_bus<"Input", double> audio;
2024-10-07 22:53:11 +01:00
halp::knob_f32<"SAMPLE RATE", halp::range{.min = .1, .max = 1., .init = 1.}> s_rate;
halp::knob_f32<"FILTER", halp::range{.min = .001, .max = 1., .init = 1.}> filter;
2024-10-07 22:53:11 +01:00
using log_map = halp::log_mapper<std::ratio<95, 100>>;
struct : halp::knob_f32<"BITS", halp::range{.min = .1, .max = 1., .init = 1.}>
2024-09-30 22:30:26 +01:00
{
2024-10-07 22:53:11 +01:00
using mapper = log_map;
2024-09-30 22:30:26 +01:00
} bits;
2024-10-07 22:53:11 +01:00
struct : halp::knob_f32<"FREQ", halp::range{.min = .4, .max = 200., .init = 5.}>
{
using mapper = log_map;
} freq;
halp::knob_f32<"DEPTH", halp::range{.min = 0., .max = 1., .init = 0.}> depth;
halp::knob_f32<"AM/RING/FM", halp::range{.min = 0., .max = 2., .init = 0.}> am_fm;
2024-09-30 18:50:58 +01:00
} inputs;
struct
{
halp::dynamic_audio_bus<"Output", double> audio;
} outputs;
using setup = halp::setup;
2024-10-21 16:38:25 +01:00
void prepare(setup info);
2024-09-30 18:50:58 +01:00
// Do our processing for N samples
using tick = halp::tick;
// Defined in the .cpp
2024-09-30 22:30:26 +01:00
void operator()(tick t);
2024-09-30 18:50:58 +01:00
// UI is defined in another file to keep things clear.
struct ui;
private:
int bit_factor, step_size{0};
2024-10-20 23:37:37 +01:00
double
previous_rate{1},
previous_bits{1},
2024-10-20 23:37:37 +01:00
previous_depth{0},
previous_am_fm{0},
am_amp{0},
fm_amp{0};
2024-10-07 22:53:11 +01:00
std::vector<int> skipped_frames;
2024-10-21 16:38:25 +01:00
std::vector<float> phases;
gam::LFO<gam::phsInc::Loop, halp::compat::gamma_domain> lfo{5.};
2024-10-06 23:26:13 +01:00
std::vector<gam::Delay<double,
gam::ipl::Linear,
halp::compat::gamma_domain>> fms;
2024-10-30 19:51:40 +00:00
std::vector<gam::OnePole<double,
double,
halp::compat::gamma_domain>> lpfs;
void set_bit_factor();
2024-10-07 22:53:11 +01:00
double crush(const double& f);
2024-09-30 18:50:58 +01:00
};
2024-10-07 22:53:11 +01:00
} // namespace Ottobit