now builds

This commit is contained in:
Gordon JC Pearce 2024-09-03 15:31:54 +01:00
parent df37350fb4
commit d2c6657594
3 changed files with 27 additions and 4 deletions

View File

@ -10,7 +10,8 @@
NAME = chassis NAME = chassis
FILES_DSP = \ FILES_DSP = \
chassis.cpp chassis.cpp \
voice.cpp
include ../dpf/Makefile.plugins.mk include ../dpf/Makefile.plugins.mk

View File

@ -20,7 +20,25 @@
#include "voice.hpp" #include "voice.hpp"
inline bool Voice::isFree() {
static float blep(float phase, float theta) {
float t;
if (phase < theta) {
t = phase / theta;
return (2 * t) - (t * t) - 1;
}
if (phase > (1 - theta)) {
t = (phase - 1) / theta;
return (2 * t) + (t * t) + 1;
}
return 0;
}
bool Voice::isFree() {
return keyState == K_OFF; return keyState == K_OFF;
} }
@ -40,10 +58,14 @@ void Voice::off() {
} }
void Voice::run(float *buffer, uint32_t samples) { void Voice::run(float *buffer, uint32_t samples) {
float y;
env = ((target - env) * 0.01) + env; env = ((target - env) * 0.01) + env;
for (uint32_t i = 0; i < samples; i++) { for (uint32_t i = 0; i < samples; i++) {
phase += omega; phase += omega;
if (phase > 1) phase -= 1; if (phase > 1) phase -= 1;
buffer[i] += (0.5 - phase) * env; y = (2*phase)-1;
y-=blep(phase,omega);
buffer[i] += y * env;
} }
} }

View File

@ -29,7 +29,7 @@ class Voice {
void off(); void off();
inline bool isFree(); bool isFree();
void run(float *buffer, uint32_t samples); void run(float *buffer, uint32_t samples);