76 lines
2.2 KiB
C++
76 lines
2.2 KiB
C++
/*
|
|
sonnenlicht poly ensemble
|
|
|
|
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 "sonnenlicht.hpp"
|
|
|
|
double sampleRate;
|
|
uint32_t bufferSize;
|
|
START_NAMESPACE_DISTRHO
|
|
|
|
Sonnenlicht::Sonnenlicht() : Plugin(kParameterCount, 0, 0) {
|
|
// genny = new Generator(getBufferSize(), fSampleRate);
|
|
|
|
sampleRate = getSampleRate();
|
|
bufferSize = getBufferSize();
|
|
genny = new Generator();
|
|
|
|
assigner = new Assigner(genny->voices);
|
|
|
|
chorus = new Chorus(getBufferSize(), sampleRate);
|
|
}
|
|
|
|
Sonnenlicht::~Sonnenlicht() {
|
|
delete assigner;
|
|
delete genny;
|
|
delete chorus;
|
|
}
|
|
|
|
void Sonnenlicht::initAudioPort(bool input, uint32_t index, AudioPort& port) {
|
|
port.groupId = kPortGroupStereo;
|
|
Plugin::initAudioPort(input, index, port);
|
|
|
|
if (!input && index == 0) port.symbol = "Left";
|
|
if (!input && index == 1) port.symbol = "Right";
|
|
}
|
|
|
|
void Sonnenlicht::activate() {
|
|
}
|
|
|
|
void Sonnenlicht::deactivate() {
|
|
}
|
|
|
|
void Sonnenlicht::run(const float**, float** outputs, uint32_t frames,
|
|
const MidiEvent* ev, uint32_t evCount) {
|
|
for (uint32_t i = 0; i < evCount; i++) {
|
|
assigner->handleMidi((MidiEvent*)&ev[i]);
|
|
}
|
|
|
|
genny->runBlock(frames);
|
|
|
|
if (prog.enableChorus) {
|
|
chorus->run(genny->output, outputs, frames);
|
|
} else {
|
|
memcpy(outputs[0], genny->output, frames * sizeof(float));
|
|
memcpy(outputs[1], genny->output, frames * sizeof(float));
|
|
}
|
|
}
|
|
|
|
Plugin* createPlugin() { return new Sonnenlicht(); }
|
|
|
|
END_NAMESPACE_DISTRHO
|