diff --git a/plugin/generator.cpp b/plugin/generator.cpp index 294fac4..516800a 100644 --- a/plugin/generator.cpp +++ b/plugin/generator.cpp @@ -24,17 +24,9 @@ #include "DistrhoPluginInfo.h" -Generator::Generator(uint32_t bufferSize) { +Generator::Generator(uint32_t bufferSize, float sampleRate) { output = new float[bufferSize]; - -} - -Generator::~Generator() { - delete output; -} - -void Generator::setupGenerator(double sampleRate) { - // create the phase increments for each semitone + // create the phase increments for each semitone for (uint8_t i = 0; i < 12; i++) { phase[i] = 0; uint32_t f; @@ -43,6 +35,10 @@ void Generator::setupGenerator(double sampleRate) { } } +Generator::~Generator() { + delete output; +} + void Generator::runBlock(uint8_t *noteTable, uint32_t frames) { Voice *v; uint32_t i; @@ -69,23 +65,20 @@ void Generator::runBlock(uint8_t *noteTable, uint32_t frames) { v->vc78 = ((n - v->vc78) * v->c78) + v->vc78; v->vc107 = ((v->vc78 - v->vc107) * v->c107) + v->vc107; - - d = (phase[n1] & (0x80000000 >> n2)) != 0; n = d ? 0.25 : -0.25; v->vc33 = ((n - v->vc33) * v->c33) + v->vc33; n -= v->vc33; n *= d ? 1 : 0; v->vc22 = ((n - v->vc22) * v->c22) + v->vc22; - v->vc31 = ((v->vc31 - v->vc31) * v->c31) + v->vc31; - + v->vc31 = ((v->vc22 - v->vc31) * v->c31) + v->vc31; v->vca = ((v->gate - v->vca) * v->vcatc) + v->vca; float v4 = (v->vc78 - v->vc107); float v8 = (v->vc22 - v->vc31); - output[i] += (v4 + v8) * v->vca; //((noteTable[k]&0x80)?0:1); + output[i] += 0.25* (v4 + v8) * v->vca; //((noteTable[k]&0x80)?0:1); } } } @@ -95,18 +88,17 @@ void Voice::startNote(uint8_t key, double sampleRate) { // violin and viola filter params float fc = 88.4 * powf(2, 0.083334 * (key - 24)); c34 = 1 - exp(-6.283 * fc / sampleRate); - c33 = 1 - exp(-6.283 * fc /2 / sampleRate); + c33 = 1 - exp(-6.283 * fc / 2 / sampleRate); // violin register - fc = 4000 * powf(2, 0.06 * (key - 24)); + fc = 4000 + 65.8 * powf(2, 0.08 * (key - 24)); c78 = 1 - exp(-6.283 * fc / sampleRate); c107 = 1 - exp(-6.283 * 154.0 / sampleRate); // viola register - fc = 6000 * powf(2, 0.07 * (key - 24)); + fc = 3000 + 65.8 * powf(2, 0.07 * (key - 24)); c22 = 1 - exp(-6.283 * fc / sampleRate); - c31 = 1 - exp(-6.283 * 54.0 / sampleRate); - + c31 = 1 - exp(-6.283 * 150.0 / sampleRate); gate = 1; vcatc = 0.0001; diff --git a/plugin/generator.hpp b/plugin/generator.hpp index 04232a8..37ce2d8 100644 --- a/plugin/generator.hpp +++ b/plugin/generator.hpp @@ -45,9 +45,8 @@ class Voice { class Generator { public: - Generator(uint32_t bufferSize); + Generator(uint32_t bufferSize, float sampleRate); ~Generator(); - void setupGenerator(double sampleRate); void runBlock(uint8_t *noteTable, uint32_t frames); Voice voices[NUM_VOICES]; float *output; diff --git a/plugin/parameters.cpp b/plugin/parameters.cpp index 8fbdd4c..57bc2a2 100644 --- a/plugin/parameters.cpp +++ b/plugin/parameters.cpp @@ -21,6 +21,20 @@ void Sonnenlicht::initParameter(uint32_t index, Parameter& parameter) { // define all the different control input parameters switch (index) { + case pContraBass: + parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; + parameter.name = "Contrabass"; + parameter.symbol = "s_contra"; + parameter.ranges.def = 1; + break; + + case pCello: + parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; + parameter.name = "Cello"; + parameter.symbol = "s_cello"; + parameter.ranges.def = 0; + break; + case pViola: parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; parameter.name = "Viola"; @@ -35,6 +49,26 @@ void Sonnenlicht::initParameter(uint32_t index, Parameter& parameter) { parameter.ranges.def = 1; break; + case pTrumpet: + parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; + parameter.name = "Trumpet"; + parameter.symbol = "s_trumpet"; + parameter.ranges.def = 0; + break; + case pHorn: + parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; + parameter.name = "Horn"; + parameter.symbol = "s_horn"; + parameter.ranges.def = 0; + break; + + case pChorale: + parameter.hints = kParameterIsAutomatable | kParameterIsBoolean; + parameter.name = "Chorale"; + parameter.symbol = "s_chorale"; + parameter.ranges.def = 1; + break; + case pBassVolume: parameter.hints = kParameterIsAutomatable; parameter.name = "Bass Volume"; @@ -43,6 +77,22 @@ void Sonnenlicht::initParameter(uint32_t index, Parameter& parameter) { parameter.ranges.max = 1.0f; parameter.ranges.def = 0.7f; break; + case pAttack: + parameter.hints = kParameterIsAutomatable; + parameter.name = "Attack"; + parameter.symbol = "s_attack"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 1.0f; + parameter.ranges.def = 0.7f; + break; + case pSustain: + parameter.hints = kParameterIsAutomatable; + parameter.name = "Sustain"; + parameter.symbol = "s_sustain"; + parameter.ranges.min = 0.0f; + parameter.ranges.max = 1.0f; + parameter.ranges.def = 0.7f; + break; } } diff --git a/plugin/sonnenlicht.cpp b/plugin/sonnenlicht.cpp index 4f0cdd8..33453de 100644 --- a/plugin/sonnenlicht.cpp +++ b/plugin/sonnenlicht.cpp @@ -21,9 +21,8 @@ START_NAMESPACE_DISTRHO Sonnenlicht::Sonnenlicht() : Plugin(kParameterCount, 0, 0), fSampleRate(getSampleRate()) { - genny = new Generator(getBufferSize()); - genny->setupGenerator(fSampleRate); - + genny = new Generator(getBufferSize(), fSampleRate); + assigner = new Assigner(genny->voices); chorus = new Chorus(getBufferSize(), fSampleRate); diff --git a/plugin/sonnenlicht.hpp b/plugin/sonnenlicht.hpp index af5913a..8b6f3a9 100644 --- a/plugin/sonnenlicht.hpp +++ b/plugin/sonnenlicht.hpp @@ -29,9 +29,16 @@ START_NAMESPACE_DISTRHO class Sonnenlicht : public Plugin { public: enum Parameters { + pContraBass, + pCello, + pBassVolume, + pAttack, + pSustain, pViola, pViolin, - pBassVolume, + pTrumpet, + pHorn, + pChorale, kParameterCount };