44 lines
783 B
C
44 lines
783 B
C
#pragma once
|
|
|
|
#include <stdbool.h>
|
|
#include <stdint.h>
|
|
#include <math.h>
|
|
|
|
#include "input.h"
|
|
#include "vco.h"
|
|
|
|
typedef struct {
|
|
float clock_bpm;
|
|
|
|
float vco_freq;
|
|
float vco_volume;
|
|
vco_mode_t vco_mode;
|
|
|
|
float filter_freq;
|
|
float filter_resonance;
|
|
|
|
float env1_attack;
|
|
float env1_release;
|
|
float env2_attack;
|
|
float env2_release;
|
|
|
|
float reverb_amount;
|
|
bool quant_enabled;
|
|
bool amen_enabled;
|
|
} state_t;
|
|
|
|
static inline float map_linear(float v, float min, float max) {
|
|
return min + v * (max - min);
|
|
}
|
|
|
|
static inline float map_exponential(float v, float min, float max) {
|
|
return min + powf(max / min, v);
|
|
}
|
|
|
|
static inline float map_squared(float v, float min, float max) {
|
|
return min + (v * v) * (max - min);
|
|
}
|
|
|
|
void update_state(state_t* state, input_t* input);
|
|
|