globals for samplerate and buffersize
This commit is contained in:
parent
8f604d10c2
commit
23d99e92f2
|
|
@ -23,12 +23,7 @@
|
|||
|
||||
#include <cstdio>
|
||||
|
||||
//extern double sampleRate;
|
||||
//extern uint32_t bufferSize;
|
||||
|
||||
double sampleRate = 48000;
|
||||
uint32_t bufferSize = 1024;
|
||||
Chorus::Chorus() { // no parameters, programs, or states
|
||||
Chorus::Chorus() {
|
||||
|
||||
lpfOut1 = new float[bufferSize];
|
||||
lpfOut2 = new float[bufferSize];
|
||||
|
|
@ -53,6 +48,7 @@ Chorus::Chorus() { // no parameters, programs, or states
|
|||
}
|
||||
|
||||
Chorus::~Chorus() {
|
||||
printf("called chorus destructor\n");
|
||||
delete lpfOut1;
|
||||
delete lpfOut2;
|
||||
delete ram;
|
||||
|
|
@ -70,6 +66,8 @@ void Chorus::run(const float *input, float **outputs, uint32_t frames) {
|
|||
float lfoMod, dly1, frac;
|
||||
uint16_t tap, delay;
|
||||
|
||||
fastOmega = sampleRate*4;
|
||||
|
||||
for (uint32_t i = 0; i < frames; i++) {
|
||||
// run a step of LFO
|
||||
fastPhase += fastOmega;
|
||||
|
|
|
|||
|
|
@ -16,11 +16,14 @@
|
|||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef Chorus_HPP
|
||||
#define Chorus_HPP
|
||||
#ifndef __CHORUS_HPP
|
||||
#define __CHORUS_HPP
|
||||
|
||||
#include "svf.hpp"
|
||||
|
||||
extern uint32_t bufferSize;
|
||||
extern double sampleRate;
|
||||
|
||||
// total size of delay line buffer
|
||||
#define DELAYSIZE 1028
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ void Module::run(Voice* voice) {
|
|||
|
||||
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
|
||||
v->vcfCut = (patchRam.vcfFreq << 7) + ((vcf * v->env) >> 16);
|
||||
|
|
|
|||
|
|
@ -23,15 +23,16 @@
|
|||
|
||||
#include "DistrhoPluginInfo.h"
|
||||
|
||||
extern double sampleRate;
|
||||
|
||||
class Voice;
|
||||
|
||||
class Module {
|
||||
|
||||
public:
|
||||
Module();
|
||||
|
||||
void run(Voice* voice);
|
||||
// Voice voices[NUM_VOICES];
|
||||
|
||||
float res = 0;
|
||||
// precomputed values for all voices
|
||||
float pw; //, saw, square, sub;
|
||||
|
|
@ -66,11 +67,11 @@ class Module {
|
|||
|
||||
private:
|
||||
// controls
|
||||
float subRC = 0, outRC = 0, pwmRC = 0, resRC = 0, noiseRC = 0;
|
||||
};
|
||||
|
||||
class Voice {
|
||||
friend Module;
|
||||
|
||||
public:
|
||||
Voice();
|
||||
void on(uint8_t midiNote);
|
||||
|
|
|
|||
|
|
@ -18,22 +18,27 @@
|
|||
|
||||
#include "peacock.hpp"
|
||||
|
||||
double sampleRate;
|
||||
uint32_t bufferSize;
|
||||
|
||||
START_NAMESPACE_DISTRHO
|
||||
|
||||
Peacock::Peacock() : Plugin(parameterCount, 0, 0) {
|
||||
d_debug("peacock constructor\n");
|
||||
|
||||
sampleRate = getSampleRate();
|
||||
m = new Module;
|
||||
bufferSize = getBufferSize();
|
||||
m = new Module();
|
||||
ic1 = new Assigner;
|
||||
ic1->voice = voice;
|
||||
chorus = new Chorus;
|
||||
chorus = new Chorus();
|
||||
|
||||
|
||||
}
|
||||
|
||||
Peacock::~Peacock() {
|
||||
free(m);
|
||||
free(ic1);
|
||||
free(chorus);
|
||||
printf("peacock destructor\n");
|
||||
|
||||
}
|
||||
|
||||
void Peacock::initAudioPort(bool input, uint32_t index, AudioPort& port) {
|
||||
|
|
|
|||
|
|
@ -21,8 +21,11 @@
|
|||
|
||||
#include "DistrhoPlugin.hpp"
|
||||
#include "assigner.hpp"
|
||||
#include "module.hpp"
|
||||
#include "chorus.hpp"
|
||||
#include "module.hpp"
|
||||
|
||||
extern double sampleRate;
|
||||
extern uint32_t bufferSize;
|
||||
|
||||
START_NAMESPACE_DISTRHO
|
||||
|
||||
|
|
@ -31,7 +34,6 @@ class Peacock : public Plugin {
|
|||
Peacock();
|
||||
~Peacock();
|
||||
|
||||
|
||||
protected:
|
||||
const char* getLabel() const override { return "peacock-8"; }
|
||||
const char* getDescription() const override {
|
||||
|
|
@ -59,8 +61,6 @@ class Peacock : public Plugin {
|
|||
Module* m;
|
||||
Chorus* chorus;
|
||||
|
||||
uint32_t sampleRate;
|
||||
|
||||
// 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 framesLeft = 0, blockLeft = 0;
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@
|
|||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef SVF_HPP
|
||||
#define SVF_HPP
|
||||
#ifndef __SVF_HPP
|
||||
#define __SVF_HPP
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue