forked from klang-modular/synthapp
parent
2ca29337c3
commit
5389e811eb
19 changed files with 152 additions and 141 deletions
@ -1,44 +0,0 @@ |
||||
#include <cstdio> |
||||
#include <cmath> |
||||
|
||||
#include "synth/dsp/filter.h" |
||||
#include "synth/dsp/util.h" |
||||
|
||||
void dumpLUT(const char * filename, const char * identifier, float *lut, size_t size) { |
||||
FILE * f = fopen(filename, "w"); |
||||
fprintf(f, "float %s[] = {\n", identifier); |
||||
for(size_t i = 0; i < size; ++i) { |
||||
if(i % 8 == 0) { |
||||
fputs(" ", f); |
||||
} |
||||
fprintf(f, "%13.7ff", (double) lut[i]); |
||||
if(i < size - 1) { |
||||
fputs(", ", f); |
||||
} |
||||
if(i % 8 == 7) { |
||||
putc('\n', f); |
||||
} |
||||
} |
||||
fputs("};\n", f); |
||||
fclose(f); |
||||
} |
||||
|
||||
int main(int argc, char** argv) { |
||||
float kLUT[K_LUT_SIZE]; |
||||
for(int i = 0; i < K_LUT_SIZE; ++i) { |
||||
kLUT[i] = tan(std::max(M_PI_4, M_PI_2 * FILTER_K_SCALE * exp2(FILTER_CV_MAX * i / (K_LUT_SIZE - 1.0)))); |
||||
} |
||||
dumpLUT("src/synth/dsp/filterlut.cpp", "kLUT", kLUT, K_LUT_SIZE); |
||||
|
||||
float noteLUT[NOTE_LUT_SIZE]; |
||||
for(int i = 0; i < NOTE_LUT_SIZE; ++i) { |
||||
noteLUT[i] = 440 * powf(2.f, (i - 69.f) / 12.0f); |
||||
} |
||||
dumpLUT("src/synth/dsp/notelut.cpp", "noteLUT", noteLUT, NOTE_LUT_SIZE); |
||||
|
||||
float centLUT[CENT_LUT_SIZE]; |
||||
for(int i = 0; i < CENT_LUT_SIZE; ++i) { |
||||
centLUT[i] = pow(2.f, i / ((CENT_LUT_SIZE - 1) * 12.0f)); |
||||
} |
||||
dumpLUT("src/synth/dsp/centlut.cpp", "centLUT", centLUT, CENT_LUT_SIZE); |
||||
} |
Loading…
Reference in new issue