147 lines
4.0 KiB
C++
147 lines
4.0 KiB
C++
/*
|
|
Chassis reverb plugin
|
|
|
|
Copyright 2024 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.
|
|
*/
|
|
|
|
#include "chassis.hpp"
|
|
|
|
|
|
SVF::SVF(float cutoff = 0, float q = 0, float samplerate = 0) {
|
|
z1 = z2 = 0;
|
|
setFreq(cutoff, q, samplerate);
|
|
}
|
|
|
|
void SVF::setFreq(float cutoff, float q, float samplerate) {
|
|
z1 = z2 = 0;
|
|
|
|
printf("called with %f %f %f\n", cutoff, q, samplerate);
|
|
w = 2 * tan(3.14159 * (cutoff / samplerate));
|
|
a = w / q;
|
|
b = w * w;
|
|
|
|
// corrected SVF params, per Fons Adriaensen
|
|
c1 = (a + b) / (1 + a / 2 + b / 4);
|
|
c2 = b / (a + b);
|
|
|
|
d0 = c1 * c2 / 4;
|
|
|
|
printf("c1 %f c2 %f d0 %f\n", c1, c2, d0);
|
|
}
|
|
|
|
inline float SVF::lpStep(float in) {
|
|
x = in - z1 - z2;
|
|
z2 += c2 * z1;
|
|
z1 += c1 * x;
|
|
return d0 * x + z2;
|
|
}
|
|
|
|
START_NAMESPACE_DISTRHO
|
|
|
|
Chassis::Chassis() : Plugin(kParameterCount, 0, 0) { // one parameter, no programs, no states
|
|
//lowpass = new float[getBufferSize()];
|
|
//ram = new int16_t[16384];
|
|
|
|
//bzero(lowpass, sizeof(float) * getBufferSize());
|
|
//bzero(ram, sizeof(int16_t) * 16384);
|
|
|
|
//f1.setFreq(5916, .6572, getSampleRate());
|
|
// f2.setFreq(9458, 2.536, getSampleRate());
|
|
}
|
|
|
|
// Initialisation functions
|
|
|
|
void Chassis::initParameter(uint32_t index, Parameter ¶meter) {
|
|
if (index == p_saw) {
|
|
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
|
parameter.name = "Saw";
|
|
parameter.symbol = "saw";
|
|
parameter.ranges.max = 1.0f;
|
|
}
|
|
if (index == p_sqr) {
|
|
parameter.hints = kParameterIsAutomatable | kParameterIsInteger;
|
|
parameter.name = "Square";
|
|
parameter.symbol = "sqr";
|
|
parameter.ranges.max = 4.0f;
|
|
}
|
|
|
|
if (index == p_sublev) {
|
|
parameter.hints = kParameterIsAutomatable;
|
|
parameter.name = "Sub";
|
|
parameter.symbol = "sub";
|
|
parameter.ranges.def = 20.0f;
|
|
parameter.ranges.min = 1.0f;
|
|
parameter.ranges.max = 64.0f;
|
|
}
|
|
if (index == paramProgram) {
|
|
parameter.hints = kParameterIsAutomatable;
|
|
parameter.name = "prog";
|
|
parameter.symbol = "prog";
|
|
parameter.ranges.def = 1.0f;
|
|
parameter.ranges.min = 0.0f;
|
|
parameter.ranges.max = 1.0f;
|
|
}
|
|
}
|
|
|
|
void Chassis::setParameterValue(uint32_t index, float value) {
|
|
|
|
|
|
}
|
|
|
|
float Chassis::getParameterValue(uint32_t index) const {
|
|
|
|
return 0;
|
|
}
|
|
|
|
void Chassis::initAudioPort(bool input, uint32_t index, AudioPort &port) {
|
|
port.groupId = kPortGroupStereo;
|
|
Plugin::initAudioPort(input, index, port);
|
|
|
|
if (!input && index == 0) port.name = "Left Out";
|
|
if (!input && index == 1) port.name = "Right Out";
|
|
}
|
|
/*
|
|
void Chassis::initProgramName(uint32_t index, String &programName) {
|
|
programName = "init";
|
|
}
|
|
|
|
void Chassis::loadProgram(uint32_t index) {
|
|
prog_offset = (index & 0x3f) << 7;
|
|
program = index + 1;
|
|
}
|
|
*/
|
|
// Processing functions
|
|
|
|
void Chassis::activate() {
|
|
// calculate filter coefficients
|
|
printf("called activate()\n");
|
|
}
|
|
|
|
void Chassis::deactivate() {
|
|
// zero out the outputs, maybe
|
|
printf("called deactivate()\n");
|
|
}
|
|
|
|
void Chassis::run(const float **, float **outputs, uint32_t frames, const MidiEvent *MidiEvents, uint32_t midiEventCount) {
|
|
// actual effects here
|
|
|
|
|
|
}
|
|
|
|
// create the plugin
|
|
Plugin *createPlugin() { return new Chassis(); }
|
|
|
|
END_NAMESPACE_DISTRHO
|