diff --git a/plugin/Makefile b/plugin/Makefile index 2967e1e..23edd19 100644 --- a/plugin/Makefile +++ b/plugin/Makefile @@ -14,6 +14,7 @@ FILES_DSP = \ controls.cpp \ ic1.cpp \ oscillator.cpp \ + filter.cpp \ ic29.cpp include ../dpf/Makefile.plugins.mk diff --git a/plugin/ic29.cpp b/plugin/ic29.cpp index 978aecb..90bc470 100644 --- a/plugin/ic29.cpp +++ b/plugin/ic29.cpp @@ -35,6 +35,15 @@ void Synth::buildTables(double sampleRate) { // on the real synth the tuning knob is tweaked a little off to pull it in pitchTable[i] = 260.15f * powf(2, (i - 36) / 12.0f) / sampleRate; } + + // precompute a table of values to map the filter value to a filter coefficient + // the ROM preset for adjusting the VCF scale and centre presets cutoff to $31 + // and key scale to $7f, which corresponds to C4 = 248Hz and C6 = 992Hz, B3 and B5 + + for (uint16_t i = 0; i< 256; i++) { + + + } } void Synth::run() { diff --git a/plugin/ic29.hpp b/plugin/ic29.hpp index fd940d3..f21951a 100644 --- a/plugin/ic29.hpp +++ b/plugin/ic29.hpp @@ -73,11 +73,13 @@ class Voice { Voice(); uint8_t note = 0x3c; // middle C void run(float *buffer, uint32_t pos, uint32_t samples); + void filter(float *buffer, uint32_t pos, uint32_t samples); + void update(); void on(uint8_t note); void off(); - private: + // private: Envelope env; // calculated envelope value uint16_t pitch = 0x1818; // calculated pitch value with porta and master pitch etc float delay = 0; // delay slot for polyblep @@ -91,6 +93,8 @@ class Voice { V_ON } voiceState; void calcPitch(); + + float fb=0, b1=0, b2=0, b3=0, b4=0, cut=0.1, reso=4; }; class Synth { @@ -113,6 +117,7 @@ class Synth { int8_t portaCoeff; bool sustained; double pitchTable[104]; + double filterTable[256]; float *noise; diff --git a/plugin/oscillator.cpp b/plugin/oscillator.cpp index a3d7f07..83929b2 100644 --- a/plugin/oscillator.cpp +++ b/plugin/oscillator.cpp @@ -30,8 +30,7 @@ static inline float poly3blep1(float t) { void Voice::run(float *buffer, uint32_t pos, uint32_t samples) { // generate a full block of samples for the oscillator - float y, out, t; - float gain = env.level / 16384.0; + float y, t; if (subosc > 0) subosc = sub; else subosc = -sub; @@ -71,9 +70,8 @@ void Voice::run(float *buffer, uint32_t pos, uint32_t samples) { delay += subosc; delay += ic29.noise[i+pos]; - out = y * 0.15; lastpw = pwrc; - buffer[i + pos] += out * gain; + buffer[i + pos] = y * 0.707; } } diff --git a/plugin/peacock.cpp b/plugin/peacock.cpp index f1e2874..adb776d 100644 --- a/plugin/peacock.cpp +++ b/plugin/peacock.cpp @@ -29,8 +29,6 @@ Peacock::Peacock() : Plugin(paramCount, 0, 0), sampleRate(getSampleRate()) { ic29.bufferSize = getBufferSize(); } - - void Peacock::runMidi(const MidiEvent *ev, uint32_t count, uint32_t timeLimit) { // handle MIDI events, starting at lastEvent and continuing until timeLimit uint32_t i; @@ -52,7 +50,6 @@ void Peacock::initAudioPort(bool input, uint32_t index, AudioPort &port) { if (!input && index == 1) port.name = "Right Out"; } - void Peacock::run(const float **, float **outputs, uint32_t frames, const MidiEvent *midiEvents, uint32_t midiEventCount) { // calculate an entire jack period's worth of samples // harder than it sounds because for short jack periods there may be many @@ -73,7 +70,7 @@ void Peacock::run(const float **, float **outputs, uint32_t frames, const MidiEv runMidi(midiEvents, midiEventCount, blockLeft); // generate a buffer's worth of samples - memset(outputs[0], 0, sizeof(float) * frames); + memset(outputs[1], 0, sizeof(float) * frames); while (framePos < frames) { if (blockLeft == 0) { @@ -88,6 +85,10 @@ void Peacock::run(const float **, float **outputs, uint32_t frames, const MidiEv // run every synth voice into the buffer here FIXME for (uint8_t i = 0; i < NUM_VOICES; i++) { ic29.voices[i].run(outputs[0], framePos, sizeThisTime); + ic29.voices[i].filter(outputs[0], framePos, sizeThisTime); + for (uint8_t j=0; j