Compare commits
No commits in common. "8c2263c129cd63c08442d7071dd5b5be1c69a15f" and "8d987fa5b04f8e84a34709c0796613e94331bb6b" have entirely different histories.
8c2263c129
...
8d987fa5b0
|
|
@ -19,8 +19,9 @@
|
|||
#include "chorus.hpp"
|
||||
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <stdio.h>
|
||||
Chorus::Chorus() {
|
||||
lpfOut1 = new float[bufferSize];
|
||||
lpfOut2 = new float[bufferSize];
|
||||
|
|
@ -29,8 +30,7 @@ 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); // 1/10th of a second declick
|
||||
bbdTC = 1 - exp(-6.283 * 30 / sampleRate); // hpf into BBD at 159Hz
|
||||
gainTC = 1 - exp(-6.283 * 10 / sampleRate);
|
||||
|
||||
// not quite Butterworth but you'd never hear the difference
|
||||
// these are calculated from the real-world component values
|
||||
|
|
@ -76,14 +76,11 @@ void Chorus::run(float* input, float** outputs, uint32_t frames) {
|
|||
hpDelay = flt;
|
||||
input[i] += (flt * hpGain);
|
||||
|
||||
flt = ((input[i] - bbdRC) * bbdTC) + bbdRC;
|
||||
bbdRC = flt;
|
||||
|
||||
ram[delayptr] = input[i] - flt;
|
||||
ram[delayptr] = input[i];
|
||||
|
||||
// delays in milliseconds
|
||||
#define BASE 0.0035
|
||||
#define AMT 0.002
|
||||
#define BASE 0.005
|
||||
#define AMT 0.00175
|
||||
|
||||
dly1 = (BASE + (AMT * lfoPhase)) * sampleRate;
|
||||
delay = (int)dly1;
|
||||
|
|
@ -106,6 +103,8 @@ 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);
|
||||
|
|
@ -114,6 +113,7 @@ 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.525 / sampleRate / 2;
|
||||
lfoSpeed = 6.283 * 0.3 / sampleRate;
|
||||
break;
|
||||
case 0x00:
|
||||
gain = 1.2;
|
||||
lfoSpeed = 6.283 * 0.85 / sampleRate / 2;
|
||||
lfoSpeed = 6.283 * 0.5 / sampleRate;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,8 +46,6 @@ class Chorus {
|
|||
float gainRC = 0;
|
||||
float gainTC = 0;
|
||||
|
||||
float bbdRC=0, bbdTC=0;
|
||||
|
||||
|
||||
uint16_t delayptr = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ void Module::runLFO() {
|
|||
else
|
||||
lfo = (lfoPhase & 0x3fff) - 0x1fff;
|
||||
|
||||
pw = 0x3fff - (((0x2000 + lfo) * patchRam.pwmLfo) >> 7);
|
||||
pw = (patchRam.switch2 & 0x01) ? 0x3fff - (patchRam.pwmLfo << 7) : pw;
|
||||
pw = 0x3fff-(((0x2000 + lfo) * patchRam.pwmLfo) >> 7);
|
||||
pw = (patchRam.switch2 & 0x01) ? 0x3fff - (patchRam.pwmLfo << 7 ) : pw;
|
||||
lfo = (lfo * lfoDelay) >> 14;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ class Module {
|
|||
*/
|
||||
|
||||
struct {
|
||||
uint8_t lfoRate = 0x1f;
|
||||
uint8_t lfoRate = 0x00;
|
||||
uint8_t lfoDelay = 0x00;
|
||||
uint8_t vcoLfo = 0x00;
|
||||
uint8_t pwmLfo = 0x3c;
|
||||
|
|
@ -124,7 +124,6 @@ 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,14 +80,16 @@ 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 / 233.5; // update rate in Hz, measured
|
||||
blockLeft = sampleRate / 238; // update rate in Hz
|
||||
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