2024-01-05 14:35:39 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
2024-01-05 13:45:14 +00:00
|
|
|
typedef struct plugin {
|
|
|
|
float gain;
|
|
|
|
char bypass;
|
|
|
|
} plugin;
|
|
|
|
|
|
|
|
void plugin_init(plugin *instance) {
|
|
|
|
instance->gain = 1.f;
|
|
|
|
instance->bypass = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void plugin_fini(plugin *instance) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void plugin_set_sample_rate(plugin *instance, float sample_rate) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void plugin_reset(plugin *instance) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void plugin_set_parameter(plugin *instance, size_t index, float value) {
|
|
|
|
switch (index) {
|
|
|
|
case 0:
|
|
|
|
instance->gain = value;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
instance->bypass = value >= 0.5f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-09 10:47:25 +00:00
|
|
|
float plugin_get_parameter(plugin *instance, size_t index) {
|
|
|
|
// no output parameters
|
|
|
|
return 0.f;
|
|
|
|
}
|
|
|
|
|
2024-01-05 13:45:14 +00:00
|
|
|
void plugin_process(plugin *instance, const float **inputs, float **outputs, size_t n_samples) {
|
2024-01-05 14:35:39 +00:00
|
|
|
const float g = instance->bypass ? 1.f : powf(10.f, 0.05f * instance->gain);
|
|
|
|
for (size_t i = 0; i < n_samples; i++)
|
|
|
|
outputs[0][i] = g * inputs[0][i];
|
2024-01-05 13:45:14 +00:00
|
|
|
}
|