diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..18c5ad0 --- /dev/null +++ b/notes.txt @@ -0,0 +1,41 @@ +highest A violin 1760 + +c0 from divider = 4186 +c1 = top output of divider chain = midi C7 = 2093Hz +c5 = bottom of divider chain = midi C3 = 130.81Hz + +RC networks = capacitor and effectively 10k because of the diode and 27.6k resistor network + +c1=2842 +c6 = + +Each key drives two sets of gates, for 4' (violin) and 8' (viola/trumpet/horn) +Five sets of gates apiece + +C6 is the *lowest* note +C1 is the *highest* note + +Viola filters +C5 to G#4 = D43 10k/18n/5k6 180n/22k/10k +A4 to F#3 = D41 10k/12n/8k2 + +G3 to E2 = D39 10k/10n/10k 270n/22k/10k +F2 to D1 = D37 10k/4n7/12k +D#1 to C1 = D35 10k/2n2/18k + +Violin filters +C5 to G#4 = D105 10k/68n/5k6 47n/22k 4n7/10k +A4 to F#3 = D103 10k/47n/8k2 47n/22k 4n7/10k + +G3 to E2 = D101 10k/22n/5k6 47n/22k 1n/18k +F2 to D1 = D99 10k/10n/8k2 +D#1 to C1 = D97 10k/5n6/10k + +Cello filter = 6n8/50k +Bass filter = 10n/50k + +bass lowpass filter = 2-pole 208Hz / Q=1.4 + +prechorus lpf = 12600 Q=1.3 + + diff --git a/plugin/Makefile b/plugin/Makefile index f12ecfc..1ec96ea 100644 --- a/plugin/Makefile +++ b/plugin/Makefile @@ -9,7 +9,7 @@ NAME = sonnenlicht -FILES_DSP = assigner.cpp sonnenlicht.cpp +FILES_DSP = assigner.cpp generator.cpp sonnenlicht.cpp include ../dpf/Makefile.plugins.mk TARGETS += vst2 vst3 jack lv2_dsp diff --git a/plugin/assigner.cpp b/plugin/assigner.cpp index 0a8b63f..e542a36 100644 --- a/plugin/assigner.cpp +++ b/plugin/assigner.cpp @@ -1,7 +1,7 @@ /* sonnenlicht poly ensemble - Copyright 2025 Gordon JC Pearce + Copyright 2024 Gordon JC Pearce Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above @@ -18,7 +18,7 @@ #include "assigner.hpp" -#define DEBUG +// #define DEBUG void Assigner::dumpTables() { #ifdef DEBUG diff --git a/plugin/assigner.hpp b/plugin/assigner.hpp index 6e921d9..3078c61 100644 --- a/plugin/assigner.hpp +++ b/plugin/assigner.hpp @@ -25,12 +25,12 @@ class Assigner { public: Assigner(); void handleMidi(MidiEvent *ev); + uint8_t noteTbl[NUM_VOICES]; // note played by voice private: void noteOn(uint8_t note); // incoming note on (or off, if velocity = 0) void noteOff(uint8_t note); // incoming note off uint8_t voiceTbl[NUM_VOICES]; // voices in order of use - uint8_t noteTbl[NUM_VOICES]; // note played by voice void dumpTables(); }; diff --git a/plugin/generator.cpp b/plugin/generator.cpp new file mode 100644 index 0000000..5129ceb --- /dev/null +++ b/plugin/generator.cpp @@ -0,0 +1,59 @@ +#include "generator.hpp" +/* + sonnenlicht poly ensemble + + Copyright 2024 Gordon JC Pearce + + 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 +#include + +#include + +#include "DistrhoPluginInfo.h" + +Generator::Generator() { +} + +void Generator::setupGenerator(double sampleRate) { + // create the phase increments for each semitone + for (uint8_t i = 0; i < 12; i++) { + phase[i] = 0; + uint32_t f; + f = (1 << 31) * (65.406 * powf(2, 0.083334 * (i + 12)) / sampleRate); + omega[i] = f; + } +} + +void Generator::runBlock(float *output, uint8_t *noteTable, uint32_t frames) { + + memset(output, 0, frames * sizeof(float)); + + for (uint32_t i = 0; i < frames; i++) { + for (uint8_t p = 0; p < 12; p++) { + phase[p] += omega[p]; + } + + for (uint8_t k=0; k> n2)) ? 0.1 : -0.1) * (noteTable[k]&0x80?0:1); + } + + + + } + + +} diff --git a/plugin/generator.hpp b/plugin/generator.hpp new file mode 100644 index 0000000..9fa362a --- /dev/null +++ b/plugin/generator.hpp @@ -0,0 +1,36 @@ +/* + sonnenlicht poly ensemble + + Copyright 2024 Gordon JC Pearce + + 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 GENERATOR_HPP +#define GENERATOR_HPP + +#include + +class Generator { + public: + Generator(); + + void setupGenerator(double sampleRate); + + void runBlock(float *output, uint8_t *noteTable, uint32_t frames); + + uint32_t phase[12]; + uint32_t omega[12]; +}; + +#endif \ No newline at end of file diff --git a/plugin/sonnenlicht.cpp b/plugin/sonnenlicht.cpp index 2e67ac9..f16b627 100644 --- a/plugin/sonnenlicht.cpp +++ b/plugin/sonnenlicht.cpp @@ -24,9 +24,8 @@ START_NAMESPACE_DISTRHO Sonnenlicht::Sonnenlicht() : Plugin(kParameterCount, 0, 0), fSampleRate(getSampleRate()) { printf("initialiser called\n"); - w = 440.0 / fSampleRate; - phase = 0; assigner = new Assigner; + genny.setupGenerator(fSampleRate); } Sonnenlicht::~Sonnenlicht() { @@ -52,15 +51,17 @@ void Sonnenlicht::deactivate() { } void Sonnenlicht::initParameter(uint32_t index, Parameter& parameter) { + (void) index; (void) ¶meter; // pretend these aren't here return; } void Sonnenlicht::run(const float**, float** outputs, uint32_t frames, const MidiEvent* ev, uint32_t evCount) { for (uint32_t i = 0; i < evCount; i++) { - //printf("%3d: %02x %02x\n", i, midiEvents[i].data[0], midiEvents[i].data[1]); - assigner->handleMidi((MidiEvent *)&ev[i]); + assigner->handleMidi((MidiEvent*)&ev[i]); } + + genny.runBlock(outputs[0], assigner->noteTbl, frames); } Plugin* createPlugin() { return new Sonnenlicht(); } diff --git a/plugin/sonnenlicht.hpp b/plugin/sonnenlicht.hpp index c32e61e..0ea5176 100644 --- a/plugin/sonnenlicht.hpp +++ b/plugin/sonnenlicht.hpp @@ -21,6 +21,7 @@ #include "DistrhoPlugin.hpp" #include "assigner.hpp" +#include "generator.hpp" START_NAMESPACE_DISTRHO @@ -59,8 +60,7 @@ class Sonnenlicht : public Plugin { private: Assigner *assigner; double fSampleRate; - float phase; - float w; + Generator genny; DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Sonnenlicht); };