Compare commits
2 Commits
8d987fa5b0
...
8c2263c129
| Author | SHA1 | Date |
|---|---|---|
|
|
8c2263c129 | |
|
|
ffe4026b18 |
|
|
@ -19,9 +19,8 @@
|
|||
#include "chorus.hpp"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
Chorus::Chorus() {
|
||||
lpfOut1 = new float[bufferSize];
|
||||
lpfOut2 = new float[bufferSize];
|
||||
|
|
@ -30,7 +29,8 @@ Chorus::Chorus() {
|
|||
lfoPhase = 1;
|
||||
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
|
||||
// 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;
|
||||
input[i] += (flt * hpGain);
|
||||
|
||||
ram[delayptr] = input[i];
|
||||
flt = ((input[i] - bbdRC) * bbdTC) + bbdRC;
|
||||
bbdRC = flt;
|
||||
|
||||
ram[delayptr] = input[i] - flt;
|
||||
|
||||
// delays in milliseconds
|
||||
#define BASE 0.005
|
||||
#define AMT 0.00175
|
||||
#define BASE 0.0035
|
||||
#define AMT 0.002
|
||||
|
||||
dly1 = (BASE + (AMT * lfoPhase)) * sampleRate;
|
||||
delay = (int)dly1;
|
||||
|
|
@ -103,8 +106,6 @@ void Chorus::run(float* input, float** outputs, uint32_t frames) {
|
|||
delayptr++;
|
||||
delayptr &= 0x3ff;
|
||||
}
|
||||
//printf("dly1 = %f\n", dly1);
|
||||
|
||||
postFilter1l->runSVF(lpfOut1, lpfOut1, frames);
|
||||
postFilter2l->runSVF(lpfOut1, lpfOut1, 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++) {
|
||||
float y = input[i];
|
||||
gainRC = (gain - gainRC) * gainTC + gainRC;
|
||||
|
||||
outputs[0][i] = y + (gainRC * lpfOut1[i]);
|
||||
outputs[1][i] = y + (gainRC * lpfOut2[i]);
|
||||
}
|
||||
|
|
@ -154,11 +154,11 @@ void Chorus::setChorus(uint8_t mode) {
|
|||
break;
|
||||
case 0x40:
|
||||
gain = 1.2;
|
||||
lfoSpeed = 6.283 * 0.3 / sampleRate;
|
||||
lfoSpeed = 6.283 * 0.525 / sampleRate / 2;
|
||||
break;
|
||||
case 0x00:
|
||||
gain = 1.2;
|
||||
lfoSpeed = 6.283 * 0.5 / sampleRate;
|
||||
lfoSpeed = 6.283 * 0.85 / sampleRate / 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,8 @@ class Chorus {
|
|||
float gainRC = 0;
|
||||
float gainTC = 0;
|
||||
|
||||
float bbdRC=0, bbdTC=0;
|
||||
|
||||
|
||||
uint16_t delayptr = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class Module {
|
|||
*/
|
||||
|
||||
struct {
|
||||
uint8_t lfoRate = 0x00;
|
||||
uint8_t lfoRate = 0x1f;
|
||||
uint8_t lfoDelay = 0x00;
|
||||
uint8_t vcoLfo = 0x00;
|
||||
uint8_t pwmLfo = 0x3c;
|
||||
|
|
@ -124,6 +124,7 @@ class Module {
|
|||
|
||||
private:
|
||||
void runLFO();
|
||||
|
||||
// precalculated coefficients for RC networks
|
||||
float pwmTC = 0, subTC = 0, mVcaTC = 0;
|
||||
float pwmRC = 0, subRC = 0, vcaRC = 0;
|
||||
|
|
|
|||
|
|
@ -80,16 +80,14 @@ void Peacock::run(const float**, float** outputs, uint32_t frames, const MidiEve
|
|||
while (framePos < frames) {
|
||||
if (blockLeft == 0) {
|
||||
// no more samples to calculate in this update period
|
||||
blockLeft = sampleRate / 238; // update rate in Hz
|
||||
blockLeft = sampleRate / 233.5; // update rate in Hz, measured
|
||||
runMidi(midiEvents, midiEventCount, framePos + blockLeft);
|
||||
m->run(voice, blockLeft);
|
||||
}
|
||||
|
||||
// how many frames to do? Are we about to run off an update block
|
||||
sizeThisTime = (framesLeft < blockLeft) ? framesLeft : blockLeft;
|
||||
|
||||
// update the module board for this block
|
||||
m->run(voice, sizeThisTime);
|
||||
|
||||
// now run all the voices for this chunk of samples
|
||||
for (uint32_t i = 0; i < NUM_VOICES; i++) {
|
||||
voice[i].run(m, outputs[0], framePos, sizeThisTime);
|
||||
|
|
|
|||
Loading…
Reference in New Issue