From c758a0a493036157a1f3ac0387081e261e8aeab2 Mon Sep 17 00:00:00 2001 From: Gordon JC Pearce Date: Sat, 12 Oct 2024 23:36:34 +0100 Subject: [PATCH] functional envelopes --- plugin/ic1.cpp | 5 +++++ plugin/ic29.cpp | 34 +++++++++++++++++++++++++--------- plugin/ic29.hpp | 14 +++++++++++--- plugin/peacock.cpp | 2 +- 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/plugin/ic1.cpp b/plugin/ic1.cpp index 2b8c688..7cdd28f 100644 --- a/plugin/ic1.cpp +++ b/plugin/ic1.cpp @@ -17,6 +17,7 @@ */ #include "ic1.hpp" +#include "ic29.hpp" #include "peacock.hpp" @@ -62,6 +63,8 @@ void Assigner::noteOff(uint8_t note) { memmove(keymap + i, keymap + i + 1, NUM_VOICES - i - 1); voicemap[NUM_VOICES - 1] = voice; keymap[NUM_VOICES - 1] = note | 0x80; + s.voiceOff(voice); + } } printMap(); @@ -80,6 +83,7 @@ void Assigner::noteOn(uint8_t note) { memmove(keymap + 1, keymap, i); keymap[0] = note; // show note as on voicemap[0] = voice; + s.voiceOn(voice, note); return; } } @@ -95,6 +99,7 @@ void Assigner::noteOn(uint8_t note) { memmove(keymap + 1, keymap, i); keymap[0] = note; // show note as on voicemap[0] = voice; + s.voiceOn(voice, note); return; } } diff --git a/plugin/ic29.cpp b/plugin/ic29.cpp index b93c461..c1d2185 100644 --- a/plugin/ic29.cpp +++ b/plugin/ic29.cpp @@ -18,24 +18,41 @@ #include "ic29.hpp" -#include "peacock.hpp" + +Synth s; + Synth::Synth() { + printf("initialising synth\n"); + envAtk = 0x007f; + envDcy = envRls = 0xfe90; + envStn = 0x1fff; } void Synth::run() { - printf("called synth::run()\n"); - printf("%d\n", voices[0].env.phase); + //printf("called synth::run()\n"); + //printf("%d\n", voices[0].env.phase); + for (uint8_t i=0; i s.envStn) { level -= s.envStn; - level *= s.envDcy; + level = (level * s.envDcy) >> 16; level += s.envStn; } else { level = s.envStn; } break; case ENV_RLS: - level *= s.envRls; + level = (level * s.envRls) >> 16; break; case ENV_IDLE: default: @@ -65,8 +82,7 @@ void Envelope::run() { } } -void Envelope::gate(uint8_t gate) { -} - Voice::Voice() { } + +extern Synth s; \ No newline at end of file diff --git a/plugin/ic29.hpp b/plugin/ic29.hpp index f62cd0e..e426f7e 100644 --- a/plugin/ic29.hpp +++ b/plugin/ic29.hpp @@ -20,14 +20,22 @@ #include "peacock.hpp" + + class Envelope { public: Envelope(); void run(); - void gate(uint8_t gate); + void on() { + phase = ENV_ATK; + } + + void off() { + phase = ENV_RLS; + } uint16_t level; - //private: + // private: enum { ENV_ATK, ENV_DCY, @@ -42,7 +50,7 @@ class Voice { void run(); uint8_t note; - //private: + // private: Envelope env; // calculated envelope value uint16_t pitch; // calculated pitch value with porta and master pitch etc enum { V_DONE, diff --git a/plugin/peacock.cpp b/plugin/peacock.cpp index bc46825..c556b4a 100644 --- a/plugin/peacock.cpp +++ b/plugin/peacock.cpp @@ -23,7 +23,6 @@ START_NAMESPACE_DISTRHO Assigner ic1; -Synth s; Peacock::Peacock() : Plugin(paramCount, 0, 0), sampleRate(getSampleRate()) { s.run(); @@ -41,6 +40,7 @@ void Peacock::run(const float **, float **outputs, uint32_t frames, const MidiEv } + s.run(); }