55 lines
1.8 KiB
C++
55 lines
1.8 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"
|
|
|
|
START_NAMESPACE_DISTRHO
|
|
|
|
Sonnenlicht::Sonnenlicht() : Plugin(kParameterCount, 0, 0), fSampleRate(getSampleRate()) {
|
|
printf("initialiser called\n");
|
|
w = 440.0 / fSampleRate;
|
|
phase = 0;
|
|
}
|
|
|
|
void Sonnenlicht::run(const float**, float** outputs, uint32_t frames,
|
|
const MidiEvent* midiEvents, uint32_t midiEventCount) {
|
|
|
|
if (midiEventCount > 0) {
|
|
for (uint32_t i=0; i < midiEventCount; i++ ) {
|
|
const uint8_t *data = midiEvents[i].data;
|
|
const uint8_t status = data[0] & 0xf0;
|
|
|
|
|
|
if (status == 0x90) {
|
|
w = (261.6 * (powf(2, (data[1]-60)/12.0f)))/fSampleRate;
|
|
printf("set w to %f\n", w);
|
|
}
|
|
}
|
|
}
|
|
for (uint32_t i = 0; i < frames; i++) {
|
|
phase += w;
|
|
if (phase > 1) phase -= 1;
|
|
outputs[0][i] = phase - 0.5;
|
|
outputs[1][i] = phase - 0.5;
|
|
}
|
|
}
|
|
|
|
Plugin* createPlugin() { return new Sonnenlicht(); }
|
|
|
|
END_NAMESPACE_DISTRHO
|