score-avnd-senior/Ottobit/OttobitModel.hpp

64 lines
1.2 KiB
C++

#pragma once
#include <cmath>
#include <halp/audio.hpp>
#include <halp/controls.hpp>
#include <halp/mappers.hpp>
#include <halp/meta.hpp>
namespace Example
{
class Ottobit
{
#define BITS 16
public:
halp_meta(name, "Ottobit")
halp_meta(category, "Audio")
halp_meta(c_name, "ottobit")
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;
struct : halp::knob_f32<"Bits", halp::range{.min = 3, .max = BITS, .init = BITS}>
{
using mapper = halp::log_mapper<std::ratio<95, 100>>;
} bits;
} inputs;
struct
{
halp::dynamic_audio_bus<"Output", double> audio;
} outputs;
// Local variables
double previous_bits;
int bit_factor;
double current_frame;
void set_bit_factor();
using setup = halp::setup;
void prepare(setup info)
{
// Initialization, this method will be called with buffer size, etc.
previous_bits = BITS;
set_bit_factor();
}
// Do our processing for N samples
using tick = halp::tick;
// Defined in the .cpp
void operator()(tick t);
// UI is defined in another file to keep things clear.
struct ui;
};
}