Runs but at wrong speed, very high DSP load

This commit is contained in:
Gordon JC Pearce 2024-07-29 21:56:06 +01:00
parent 02b8622bf6
commit 3c09c94786
3 changed files with 1164 additions and 26 deletions

View File

@ -17,13 +17,15 @@
*/
#include "barrverb.hpp"
#include "rom.h"
START_NAMESPACE_DISTRHO
BarrVerb::BarrVerb() : Plugin(kParameterCount, 1, 0) { // two parameters, one program, no states
lowpass = new float[getBufferSize()];
ram = new int16_t[16384];
/*
/*
// calculate SVF params
// hardcoded values for now
float fc = 5019;
@ -97,7 +99,8 @@ void BarrVerb::deactivate() {
void BarrVerb::run(const float **inputs, float **outputs, uint32_t frames) {
// actual effects here
float x, o;
float x;
uint16_t opcode;
for (uint32_t i = 0; i < frames; i++) {
// smash to mono
@ -113,8 +116,49 @@ void BarrVerb::run(const float **inputs, float **outputs, uint32_t frames) {
in_z12 += c1_2 * x;
lowpass[i] = d0_2 * x + in_z22;
outputs[0][i] = lowpass[i];
outputs[1][i] = lowpass[i];
// run the actual DSP engine for each sample
for (uint8_t step = 0; step < 128; step++) {
opcode = rom[(128*48) + step];
switch (opcode & 0xc000) {
case 0x0000:
ai = ram[ptr];
li = acc + (ai >> 1);
break;
case 0x4000:
ai = ram[ptr];
li = (ai >> 1);
break;
case 0x8000:
ai = acc;
ram[ptr] = ai;
li = acc + (ai >> 1);
break;
case 0xc000:
ai = acc;
ram[ptr] = -ai;
li = -(ai >> 1);
break;
}
if (step == 0x00) {
// load RAM from ADC
ram[ptr] = (int)(lowpass[i] * 4096);
} else if (step == 0x60) {
// output right channel
outputs[1][i] = (float)ai / 4096;
} else if (step == 0x70) {
// output left channel
outputs[0][i] = (float)ai / 4096;
} else {
// everything else
// ADC and DAC operations don't affect the accumulator
// every other step ends with the accumulator latched from the Latch Input reg
acc = li;
}
// 16kW of RAM
ptr += opcode & 0x3fff;
ptr &= 0x3fff;
}
}
}

View File

@ -54,6 +54,10 @@ class BarrVerb : public Plugin {
private:
float c1_1, c2_1, d0_1, c1_2, c2_2, d0_2, in_z1, in_z2, in_z12,in_z22, out_z1, out_z2;
int16_t ai, li, acc;
uint16_t ptr;
int16_t *ram;
float *lowpass;

1090
plugin/rom.h Normal file

File diff suppressed because it is too large Load Diff