84 lines
2.3 KiB
C++
84 lines
2.3 KiB
C++
/*
|
|
Peacock-8 VA polysynth
|
|
|
|
Copyright 2025 Gordon JC Pearce <gordonjcp@gjcp.net>
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted, provided that the above
|
|
copyright notice and this permission notice appear in all copies.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
|
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
|
OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
|
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
*/
|
|
|
|
#ifndef _MODULE_HPP
|
|
#define _MODULE_HPP
|
|
|
|
#include <stdint.h>
|
|
|
|
#include "DistrhoPluginInfo.h"
|
|
|
|
class Voice;
|
|
|
|
class Module {
|
|
public:
|
|
Module();
|
|
|
|
void run(Voice* voice);
|
|
// Voice voices[NUM_VOICES];
|
|
float vcfCutoff = 0, vcfReso = 0;
|
|
|
|
// precomputed values for all voices
|
|
float pw, saw, square, sub;
|
|
|
|
struct {
|
|
uint8_t lfoRate = 0x30; // lookup value defaults to 0x0200
|
|
uint8_t lfoDelay = 0x00;
|
|
uint8_t vcoLfo = 0x0a;
|
|
uint8_t pwmLfo = 0x30;
|
|
uint8_t noise = 0x00;
|
|
uint8_t vcfFreq = 0x3c; // 0x3f80
|
|
uint8_t vcfReso = 0x00;
|
|
uint8_t vcfEnv = 0x2e;
|
|
uint8_t vcfLfo = 0;
|
|
uint8_t vcfKey = 0x47;
|
|
uint8_t vca = 0x28;
|
|
uint8_t env_a = 0x1b;
|
|
uint8_t env_d = 0x39;
|
|
uint8_t env_s = 0x39; // 0x3f80
|
|
uint8_t env_r = 0x30;
|
|
uint8_t sub = 0x00;
|
|
uint8_t switch1 = 0x1a;
|
|
uint8_t switch2 = 0x18;
|
|
} patchRam;
|
|
};
|
|
|
|
class Voice {
|
|
public:
|
|
Voice();
|
|
void on(uint8_t note);
|
|
void off();
|
|
void run(Module* m, float* buffer, uint32_t samples);
|
|
uint8_t envPhase = 0;
|
|
float env = 0; // output amplitude
|
|
float envTc = 0;
|
|
float envTarget = 0;
|
|
|
|
|
|
private:
|
|
float omega = 0, theta = 0; // phase increment and angle
|
|
float delay = 0, lastpw = 0; // delay slots for antialiasing
|
|
uint8_t pulseStage = 1; // pulse wave phase
|
|
float subosc = 1; // sub oscillator flipflop output
|
|
|
|
// filter
|
|
float b1=0, b2=0, b3=0, b4=0;
|
|
};
|
|
|
|
|
|
#endif |