chorus a bit more like the real thing
This commit is contained in:
parent
ffe4026b18
commit
8c2263c129
|
|
@ -19,9 +19,8 @@
|
||||||
#include "chorus.hpp"
|
#include "chorus.hpp"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
Chorus::Chorus() {
|
Chorus::Chorus() {
|
||||||
lpfOut1 = new float[bufferSize];
|
lpfOut1 = new float[bufferSize];
|
||||||
lpfOut2 = new float[bufferSize];
|
lpfOut2 = new float[bufferSize];
|
||||||
|
|
@ -30,7 +29,8 @@ Chorus::Chorus() {
|
||||||
lfoPhase = 1;
|
lfoPhase = 1;
|
||||||
lfoSpeed = 6.283 * 10.7 / sampleRate; // plainly silly value to show if it hasn't been set
|
lfoSpeed = 6.283 * 10.7 / sampleRate; // plainly silly value to show if it hasn't been set
|
||||||
|
|
||||||
gainTC = 1 - exp(-6.283 * 10 / sampleRate);
|
gainTC = 1 - exp(-6.283 * 10 / sampleRate); // 1/10th of a second declick
|
||||||
|
bbdTC = 1 - exp(-6.283 * 30 / sampleRate); // hpf into BBD at 159Hz
|
||||||
|
|
||||||
// not quite Butterworth but you'd never hear the difference
|
// not quite Butterworth but you'd never hear the difference
|
||||||
// these are calculated from the real-world component values
|
// these are calculated from the real-world component values
|
||||||
|
|
@ -76,11 +76,14 @@ void Chorus::run(float* input, float** outputs, uint32_t frames) {
|
||||||
hpDelay = flt;
|
hpDelay = flt;
|
||||||
input[i] += (flt * hpGain);
|
input[i] += (flt * hpGain);
|
||||||
|
|
||||||
ram[delayptr] = input[i];
|
flt = ((input[i] - bbdRC) * bbdTC) + bbdRC;
|
||||||
|
bbdRC = flt;
|
||||||
|
|
||||||
|
ram[delayptr] = input[i] - flt;
|
||||||
|
|
||||||
// delays in milliseconds
|
// delays in milliseconds
|
||||||
#define BASE 0.005
|
#define BASE 0.0035
|
||||||
#define AMT 0.00175
|
#define AMT 0.002
|
||||||
|
|
||||||
dly1 = (BASE + (AMT * lfoPhase)) * sampleRate;
|
dly1 = (BASE + (AMT * lfoPhase)) * sampleRate;
|
||||||
delay = (int)dly1;
|
delay = (int)dly1;
|
||||||
|
|
@ -103,8 +106,6 @@ void Chorus::run(float* input, float** outputs, uint32_t frames) {
|
||||||
delayptr++;
|
delayptr++;
|
||||||
delayptr &= 0x3ff;
|
delayptr &= 0x3ff;
|
||||||
}
|
}
|
||||||
//printf("dly1 = %f\n", dly1);
|
|
||||||
|
|
||||||
postFilter1l->runSVF(lpfOut1, lpfOut1, frames);
|
postFilter1l->runSVF(lpfOut1, lpfOut1, frames);
|
||||||
postFilter2l->runSVF(lpfOut1, lpfOut1, frames);
|
postFilter2l->runSVF(lpfOut1, lpfOut1, frames);
|
||||||
postFilter1r->runSVF(lpfOut2, lpfOut2, frames);
|
postFilter1r->runSVF(lpfOut2, lpfOut2, frames);
|
||||||
|
|
@ -113,7 +114,6 @@ void Chorus::run(float* input, float** outputs, uint32_t frames) {
|
||||||
for (uint32_t i = 0; i < frames; i++) {
|
for (uint32_t i = 0; i < frames; i++) {
|
||||||
float y = input[i];
|
float y = input[i];
|
||||||
gainRC = (gain - gainRC) * gainTC + gainRC;
|
gainRC = (gain - gainRC) * gainTC + gainRC;
|
||||||
|
|
||||||
outputs[0][i] = y + (gainRC * lpfOut1[i]);
|
outputs[0][i] = y + (gainRC * lpfOut1[i]);
|
||||||
outputs[1][i] = y + (gainRC * lpfOut2[i]);
|
outputs[1][i] = y + (gainRC * lpfOut2[i]);
|
||||||
}
|
}
|
||||||
|
|
@ -154,11 +154,11 @@ void Chorus::setChorus(uint8_t mode) {
|
||||||
break;
|
break;
|
||||||
case 0x40:
|
case 0x40:
|
||||||
gain = 1.2;
|
gain = 1.2;
|
||||||
lfoSpeed = 6.283 * 0.3 / sampleRate;
|
lfoSpeed = 6.283 * 0.525 / sampleRate / 2;
|
||||||
break;
|
break;
|
||||||
case 0x00:
|
case 0x00:
|
||||||
gain = 1.2;
|
gain = 1.2;
|
||||||
lfoSpeed = 6.283 * 0.5 / sampleRate;
|
lfoSpeed = 6.283 * 0.85 / sampleRate / 2;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,6 +46,8 @@ class Chorus {
|
||||||
float gainRC = 0;
|
float gainRC = 0;
|
||||||
float gainTC = 0;
|
float gainTC = 0;
|
||||||
|
|
||||||
|
float bbdRC=0, bbdTC=0;
|
||||||
|
|
||||||
|
|
||||||
uint16_t delayptr = 0;
|
uint16_t delayptr = 0;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue