globals for samplerate and buffersize
This commit is contained in:
parent
8f604d10c2
commit
23d99e92f2
|
|
@ -23,12 +23,7 @@
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
//extern double sampleRate;
|
Chorus::Chorus() {
|
||||||
//extern uint32_t bufferSize;
|
|
||||||
|
|
||||||
double sampleRate = 48000;
|
|
||||||
uint32_t bufferSize = 1024;
|
|
||||||
Chorus::Chorus() { // no parameters, programs, or states
|
|
||||||
|
|
||||||
lpfOut1 = new float[bufferSize];
|
lpfOut1 = new float[bufferSize];
|
||||||
lpfOut2 = new float[bufferSize];
|
lpfOut2 = new float[bufferSize];
|
||||||
|
|
@ -53,6 +48,7 @@ Chorus::Chorus() { // no parameters, programs, or states
|
||||||
}
|
}
|
||||||
|
|
||||||
Chorus::~Chorus() {
|
Chorus::~Chorus() {
|
||||||
|
printf("called chorus destructor\n");
|
||||||
delete lpfOut1;
|
delete lpfOut1;
|
||||||
delete lpfOut2;
|
delete lpfOut2;
|
||||||
delete ram;
|
delete ram;
|
||||||
|
|
@ -62,7 +58,7 @@ Chorus::~Chorus() {
|
||||||
delete postFilter2r;
|
delete postFilter2r;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Chorus::run(const float *input, float **outputs, uint32_t frames) {
|
void Chorus::run(const float* input, float** outputs, uint32_t frames) {
|
||||||
// actual effects here
|
// actual effects here
|
||||||
|
|
||||||
// now run the DSP
|
// now run the DSP
|
||||||
|
|
@ -70,6 +66,8 @@ void Chorus::run(const float *input, float **outputs, uint32_t frames) {
|
||||||
float lfoMod, dly1, frac;
|
float lfoMod, dly1, frac;
|
||||||
uint16_t tap, delay;
|
uint16_t tap, delay;
|
||||||
|
|
||||||
|
fastOmega = sampleRate*4;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < frames; i++) {
|
for (uint32_t i = 0; i < frames; i++) {
|
||||||
// run a step of LFO
|
// run a step of LFO
|
||||||
fastPhase += fastOmega;
|
fastPhase += fastOmega;
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,14 @@
|
||||||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef Chorus_HPP
|
#ifndef __CHORUS_HPP
|
||||||
#define Chorus_HPP
|
#define __CHORUS_HPP
|
||||||
|
|
||||||
#include "svf.hpp"
|
#include "svf.hpp"
|
||||||
|
|
||||||
|
extern uint32_t bufferSize;
|
||||||
|
extern double sampleRate;
|
||||||
|
|
||||||
// total size of delay line buffer
|
// total size of delay line buffer
|
||||||
#define DELAYSIZE 1028
|
#define DELAYSIZE 1028
|
||||||
|
|
||||||
|
|
@ -30,7 +33,7 @@ class Chorus {
|
||||||
public:
|
public:
|
||||||
Chorus();
|
Chorus();
|
||||||
~Chorus();
|
~Chorus();
|
||||||
void run(const float *input, float **outputs, uint32_t frames);
|
void run(const float* input, float** outputs, uint32_t frames);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
double fastPhase, fastOmega;
|
double fastPhase, fastOmega;
|
||||||
|
|
@ -39,8 +42,8 @@ class Chorus {
|
||||||
|
|
||||||
uint16_t delayptr;
|
uint16_t delayptr;
|
||||||
|
|
||||||
float *ram;
|
float* ram;
|
||||||
float *lpfIn;
|
float* lpfIn;
|
||||||
float *lpfOut1, *lpfOut2;
|
float *lpfOut1, *lpfOut2;
|
||||||
|
|
||||||
SVF *postFilter1l, *postFilter2l, *postFilter1r, *postFilter2r;
|
SVF *postFilter1l, *postFilter2l, *postFilter1r, *postFilter2r;
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ void Module::run(Voice* voice) {
|
||||||
|
|
||||||
px *= (patchRam.switch1 & 0x07);
|
px *= (patchRam.switch1 & 0x07);
|
||||||
|
|
||||||
v->omega = px / 192000.0f; // fixme use proper scaler
|
v->omega = px / (sampleRate * 4.0f); // fixme use proper scaler
|
||||||
|
|
||||||
// per voice we need to calculate the key follow amount and envelope amount
|
// per voice we need to calculate the key follow amount and envelope amount
|
||||||
v->vcfCut = (patchRam.vcfFreq << 7) + ((vcf * v->env) >> 16);
|
v->vcfCut = (patchRam.vcfFreq << 7) + ((vcf * v->env) >> 16);
|
||||||
|
|
|
||||||
|
|
@ -23,15 +23,16 @@
|
||||||
|
|
||||||
#include "DistrhoPluginInfo.h"
|
#include "DistrhoPluginInfo.h"
|
||||||
|
|
||||||
|
extern double sampleRate;
|
||||||
|
|
||||||
class Voice;
|
class Voice;
|
||||||
|
|
||||||
class Module {
|
class Module {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Module();
|
Module();
|
||||||
|
|
||||||
void run(Voice* voice);
|
void run(Voice* voice);
|
||||||
// Voice voices[NUM_VOICES];
|
|
||||||
float res = 0;
|
float res = 0;
|
||||||
// precomputed values for all voices
|
// precomputed values for all voices
|
||||||
float pw; //, saw, square, sub;
|
float pw; //, saw, square, sub;
|
||||||
|
|
@ -49,9 +50,9 @@ class Module {
|
||||||
uint8_t vcoLfo = 0x00;
|
uint8_t vcoLfo = 0x00;
|
||||||
uint8_t pwmLfo = 0x60;
|
uint8_t pwmLfo = 0x60;
|
||||||
uint8_t noise = 0x00;
|
uint8_t noise = 0x00;
|
||||||
uint8_t vcfFreq = 0x30;//1c; // 0x3f80
|
uint8_t vcfFreq = 0x30; // 1c; // 0x3f80
|
||||||
uint8_t vcfReso = 0x00;
|
uint8_t vcfReso = 0x00;
|
||||||
uint8_t vcfEnv = 0x40;//4e;
|
uint8_t vcfEnv = 0x40; // 4e;
|
||||||
uint8_t vcfLfo = 0;
|
uint8_t vcfLfo = 0;
|
||||||
uint8_t vcfKey = 0x7f; // 47;
|
uint8_t vcfKey = 0x7f; // 47;
|
||||||
uint8_t vca = 0x28;
|
uint8_t vca = 0x28;
|
||||||
|
|
@ -66,11 +67,11 @@ class Module {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// controls
|
// controls
|
||||||
float subRC = 0, outRC = 0, pwmRC = 0, resRC = 0, noiseRC = 0;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Voice {
|
class Voice {
|
||||||
friend Module;
|
friend Module;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Voice();
|
Voice();
|
||||||
void on(uint8_t midiNote);
|
void on(uint8_t midiNote);
|
||||||
|
|
|
||||||
|
|
@ -18,22 +18,27 @@
|
||||||
|
|
||||||
#include "peacock.hpp"
|
#include "peacock.hpp"
|
||||||
|
|
||||||
|
double sampleRate;
|
||||||
|
uint32_t bufferSize;
|
||||||
|
|
||||||
START_NAMESPACE_DISTRHO
|
START_NAMESPACE_DISTRHO
|
||||||
|
|
||||||
Peacock::Peacock() : Plugin(parameterCount, 0, 0) {
|
Peacock::Peacock() : Plugin(parameterCount, 0, 0) {
|
||||||
d_debug("peacock constructor\n");
|
d_debug("peacock constructor\n");
|
||||||
|
|
||||||
sampleRate = getSampleRate();
|
sampleRate = getSampleRate();
|
||||||
m = new Module;
|
bufferSize = getBufferSize();
|
||||||
|
m = new Module();
|
||||||
ic1 = new Assigner;
|
ic1 = new Assigner;
|
||||||
ic1->voice = voice;
|
ic1->voice = voice;
|
||||||
chorus = new Chorus;
|
chorus = new Chorus();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Peacock::~Peacock() {
|
Peacock::~Peacock() {
|
||||||
free(m);
|
printf("peacock destructor\n");
|
||||||
free(ic1);
|
|
||||||
free(chorus);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Peacock::initAudioPort(bool input, uint32_t index, AudioPort& port) {
|
void Peacock::initAudioPort(bool input, uint32_t index, AudioPort& port) {
|
||||||
|
|
@ -99,7 +104,7 @@ void Peacock::run(const float**, float** outputs, uint32_t frames, const MidiEve
|
||||||
//memcpy(outputs[1], outputs[0], sizeof(float) * frames);
|
//memcpy(outputs[1], outputs[0], sizeof(float) * frames);
|
||||||
chorus->run(outputs[0], outputs, frames);
|
chorus->run(outputs[0], outputs, frames);
|
||||||
|
|
||||||
//outputs[0][0]=1;
|
// outputs[0][0]=1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Plugin* createPlugin() { return new Peacock(); }
|
Plugin* createPlugin() { return new Peacock(); }
|
||||||
|
|
|
||||||
|
|
@ -21,8 +21,11 @@
|
||||||
|
|
||||||
#include "DistrhoPlugin.hpp"
|
#include "DistrhoPlugin.hpp"
|
||||||
#include "assigner.hpp"
|
#include "assigner.hpp"
|
||||||
#include "module.hpp"
|
|
||||||
#include "chorus.hpp"
|
#include "chorus.hpp"
|
||||||
|
#include "module.hpp"
|
||||||
|
|
||||||
|
extern double sampleRate;
|
||||||
|
extern uint32_t bufferSize;
|
||||||
|
|
||||||
START_NAMESPACE_DISTRHO
|
START_NAMESPACE_DISTRHO
|
||||||
|
|
||||||
|
|
@ -31,7 +34,6 @@ class Peacock : public Plugin {
|
||||||
Peacock();
|
Peacock();
|
||||||
~Peacock();
|
~Peacock();
|
||||||
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const char* getLabel() const override { return "peacock-8"; }
|
const char* getLabel() const override { return "peacock-8"; }
|
||||||
const char* getDescription() const override {
|
const char* getDescription() const override {
|
||||||
|
|
@ -59,8 +61,6 @@ class Peacock : public Plugin {
|
||||||
Module* m;
|
Module* m;
|
||||||
Chorus* chorus;
|
Chorus* chorus;
|
||||||
|
|
||||||
uint32_t sampleRate;
|
|
||||||
|
|
||||||
// variables for breaking up the 4.3 millisecond module board ticks
|
// variables for breaking up the 4.3 millisecond module board ticks
|
||||||
uint32_t lastEvent = 0; // event number of last MIDI event processed in a chunk
|
uint32_t lastEvent = 0; // event number of last MIDI event processed in a chunk
|
||||||
uint32_t framesLeft = 0, blockLeft = 0;
|
uint32_t framesLeft = 0, blockLeft = 0;
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SVF_HPP
|
#ifndef __SVF_HPP
|
||||||
#define SVF_HPP
|
#define __SVF_HPP
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue