Compare commits
No commits in common. "8c2263c129cd63c08442d7071dd5b5be1c69a15f" and "8d987fa5b04f8e84a34709c0796613e94331bb6b" have entirely different histories.
8c2263c129
...
8d987fa5b0
|
|
@ -19,8 +19,9 @@
|
||||||
#include "chorus.hpp"
|
#include "chorus.hpp"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
Chorus::Chorus() {
|
Chorus::Chorus() {
|
||||||
lpfOut1 = new float[bufferSize];
|
lpfOut1 = new float[bufferSize];
|
||||||
lpfOut2 = new float[bufferSize];
|
lpfOut2 = new float[bufferSize];
|
||||||
|
|
@ -29,8 +30,7 @@ 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); // 1/10th of a second declick
|
gainTC = 1 - exp(-6.283 * 10 / sampleRate);
|
||||||
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,14 +76,11 @@ void Chorus::run(float* input, float** outputs, uint32_t frames) {
|
||||||
hpDelay = flt;
|
hpDelay = flt;
|
||||||
input[i] += (flt * hpGain);
|
input[i] += (flt * hpGain);
|
||||||
|
|
||||||
flt = ((input[i] - bbdRC) * bbdTC) + bbdRC;
|
ram[delayptr] = input[i];
|
||||||
bbdRC = flt;
|
|
||||||
|
|
||||||
ram[delayptr] = input[i] - flt;
|
|
||||||
|
|
||||||
// delays in milliseconds
|
// delays in milliseconds
|
||||||
#define BASE 0.0035
|
#define BASE 0.005
|
||||||
#define AMT 0.002
|
#define AMT 0.00175
|
||||||
|
|
||||||
dly1 = (BASE + (AMT * lfoPhase)) * sampleRate;
|
dly1 = (BASE + (AMT * lfoPhase)) * sampleRate;
|
||||||
delay = (int)dly1;
|
delay = (int)dly1;
|
||||||
|
|
@ -106,6 +103,8 @@ 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);
|
||||||
|
|
@ -114,6 +113,7 @@ 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.525 / sampleRate / 2;
|
lfoSpeed = 6.283 * 0.3 / sampleRate;
|
||||||
break;
|
break;
|
||||||
case 0x00:
|
case 0x00:
|
||||||
gain = 1.2;
|
gain = 1.2;
|
||||||
lfoSpeed = 6.283 * 0.85 / sampleRate / 2;
|
lfoSpeed = 6.283 * 0.5 / sampleRate;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,6 @@ 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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ class Module {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
uint8_t lfoRate = 0x1f;
|
uint8_t lfoRate = 0x00;
|
||||||
uint8_t lfoDelay = 0x00;
|
uint8_t lfoDelay = 0x00;
|
||||||
uint8_t vcoLfo = 0x00;
|
uint8_t vcoLfo = 0x00;
|
||||||
uint8_t pwmLfo = 0x3c;
|
uint8_t pwmLfo = 0x3c;
|
||||||
|
|
@ -124,7 +124,6 @@ class Module {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void runLFO();
|
void runLFO();
|
||||||
|
|
||||||
// precalculated coefficients for RC networks
|
// precalculated coefficients for RC networks
|
||||||
float pwmTC = 0, subTC = 0, mVcaTC = 0;
|
float pwmTC = 0, subTC = 0, mVcaTC = 0;
|
||||||
float pwmRC = 0, subRC = 0, vcaRC = 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) {
|
while (framePos < frames) {
|
||||||
if (blockLeft == 0) {
|
if (blockLeft == 0) {
|
||||||
// no more samples to calculate in this update period
|
// 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);
|
runMidi(midiEvents, midiEventCount, framePos + blockLeft);
|
||||||
m->run(voice, blockLeft);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// how many frames to do? Are we about to run off an update block
|
// how many frames to do? Are we about to run off an update block
|
||||||
sizeThisTime = (framesLeft < blockLeft) ? framesLeft : blockLeft;
|
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
|
// now run all the voices for this chunk of samples
|
||||||
for (uint32_t i = 0; i < NUM_VOICES; i++) {
|
for (uint32_t i = 0; i < NUM_VOICES; i++) {
|
||||||
voice[i].run(m, outputs[0], framePos, sizeThisTime);
|
voice[i].run(m, outputs[0], framePos, sizeThisTime);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue