better
This commit is contained in:
parent
08712969c7
commit
af2968c23f
1
Makefile
1
Makefile
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
include dpf/Makefile.base.mk
|
include dpf/Makefile.base.mk
|
||||||
|
|
||||||
|
CFLAGS += -ggdb
|
||||||
all: plugins gen
|
all: plugins gen
|
||||||
|
|
||||||
plugins:
|
plugins:
|
||||||
|
@ -21,8 +21,6 @@
|
|||||||
#include "voiceboard.hpp"
|
#include "voiceboard.hpp"
|
||||||
#include "peacock.hpp"
|
#include "peacock.hpp"
|
||||||
|
|
||||||
Assigner ic1;
|
|
||||||
|
|
||||||
void Assigner::printMap() {
|
void Assigner::printMap() {
|
||||||
printf("note memory:\n");
|
printf("note memory:\n");
|
||||||
for (uint8_t i = 0; i < NUM_VOICES; i++) printf("%02x ", voicemap[i]);
|
for (uint8_t i = 0; i < NUM_VOICES; i++) printf("%02x ", voicemap[i]);
|
||||||
@ -52,14 +50,14 @@ void Assigner::handleMidi(const MidiEvent *ev) {
|
|||||||
case 0xb0:
|
case 0xb0:
|
||||||
switch (ev->data[1]) {
|
switch (ev->data[1]) {
|
||||||
case 0x01:
|
case 0x01:
|
||||||
ic29.modWheel = ev->data[2];
|
_ic29->modWheel = ev->data[2];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break; // nothing to do here except in special cases where we don't expect the host to pass on controls
|
break; // nothing to do here except in special cases where we don't expect the host to pass on controls
|
||||||
case 0xe0: // pitch bend;
|
case 0xe0: // pitch bend;
|
||||||
ic29.pitchBend = ev->data[2] << 7 | ev->data[1];
|
_ic29->pitchBend = ev->data[2] << 7 | ev->data[1];
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
d_debug("unhandled MIDI event, status %02x value %02x\n", ev->data[0], ev->data[1]);
|
d_debug("unhandled MIDI event, status %02x value %02x\n", ev->data[0], ev->data[1]);
|
||||||
@ -75,7 +73,7 @@ void Assigner::noteOff(uint8_t note) {
|
|||||||
memmove(keymap + i, keymap + i + 1, NUM_VOICES - i - 1);
|
memmove(keymap + i, keymap + i + 1, NUM_VOICES - i - 1);
|
||||||
voicemap[NUM_VOICES - 1] = voice;
|
voicemap[NUM_VOICES - 1] = voice;
|
||||||
keymap[NUM_VOICES - 1] = note | 0x80;
|
keymap[NUM_VOICES - 1] = note | 0x80;
|
||||||
ic29.voiceOff(voice);
|
_ic29->voiceOff(voice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,7 +89,7 @@ void Assigner::noteOn(uint8_t note) {
|
|||||||
memmove(keymap + 1, keymap, i);
|
memmove(keymap + 1, keymap, i);
|
||||||
keymap[0] = note; // show note as on
|
keymap[0] = note; // show note as on
|
||||||
voicemap[0] = voice;
|
voicemap[0] = voice;
|
||||||
ic29.voiceOn(voice, note);
|
_ic29->voiceOn(voice, note);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,7 +103,7 @@ void Assigner::noteOn(uint8_t note) {
|
|||||||
memmove(keymap + 1, keymap, i);
|
memmove(keymap + 1, keymap, i);
|
||||||
keymap[0] = note; // show note as on
|
keymap[0] = note; // show note as on
|
||||||
voicemap[0] = voice;
|
voicemap[0] = voice;
|
||||||
ic29.voiceOn(voice, note);
|
_ic29->voiceOn(voice, note);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,20 +18,27 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "peacock.hpp"
|
#include "DistrhoPlugin.hpp"
|
||||||
|
#define NUM_VOICES 8
|
||||||
|
|
||||||
|
#include "voiceboard.hpp"
|
||||||
|
|
||||||
class Assigner {
|
class Assigner {
|
||||||
public:
|
public:
|
||||||
Assigner();
|
Assigner();
|
||||||
|
void setVoiceBoard(Synth& s) {
|
||||||
|
_ic29 = &s;
|
||||||
|
}
|
||||||
void handleMidi(const MidiEvent *ev);
|
void handleMidi(const MidiEvent *ev);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void noteOn(uint8_t note);
|
void noteOn(uint8_t note);
|
||||||
void noteOff(uint8_t note);
|
void noteOff(uint8_t note);
|
||||||
void printMap();
|
void printMap();
|
||||||
|
|
||||||
|
Synth* _ic29;
|
||||||
|
|
||||||
uint8_t keymap[NUM_VOICES];
|
uint8_t keymap[NUM_VOICES];
|
||||||
uint8_t voicemap[NUM_VOICES];
|
uint8_t voicemap[NUM_VOICES];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Assigner ic1;
|
|
@ -68,7 +68,7 @@ void Voice::run(float *buffer, uint32_t pos, uint32_t samples) {
|
|||||||
// the DC correction is important because the hardware synth is AC-coupled effectively high-passing
|
// the DC correction is important because the hardware synth is AC-coupled effectively high-passing
|
||||||
// the signal at about 10Hz or so, preventing any PWM rumble from leaking through!
|
// the signal at about 10Hz or so, preventing any PWM rumble from leaking through!
|
||||||
delay += subosc;
|
delay += subosc;
|
||||||
delay += ic29.noise[i+pos];
|
//delay += ic29.noise[i+pos];
|
||||||
|
|
||||||
lastpw = pwrc;
|
lastpw = pwrc;
|
||||||
buffer[i + pos] = y * 0.707;
|
buffer[i + pos] = y * 0.707;
|
||||||
|
@ -25,6 +25,7 @@ START_NAMESPACE_DISTRHO
|
|||||||
|
|
||||||
Peacock::Peacock() : Plugin(paramCount, 0, 0), sampleRate(getSampleRate()) {
|
Peacock::Peacock() : Plugin(paramCount, 0, 0), sampleRate(getSampleRate()) {
|
||||||
printf("peacock constructor\n");
|
printf("peacock constructor\n");
|
||||||
|
ic1.setVoiceBoard(ic29);
|
||||||
ic29.buildTables(getSampleRate());
|
ic29.buildTables(getSampleRate());
|
||||||
ic29.bufferSize = getBufferSize();
|
ic29.bufferSize = getBufferSize();
|
||||||
}
|
}
|
||||||
@ -84,10 +85,10 @@ void Peacock::run(const float **, float **outputs, uint32_t frames, const MidiEv
|
|||||||
|
|
||||||
// run every synth voice into the buffer here FIXME
|
// run every synth voice into the buffer here FIXME
|
||||||
for (uint8_t i = 0; i < NUM_VOICES; i++) {
|
for (uint8_t i = 0; i < NUM_VOICES; i++) {
|
||||||
ic29.voices[i].run(outputs[0], framePos, sizeThisTime);
|
//ic29->voices[i].run(outputs[0], framePos, sizeThisTime);
|
||||||
ic29.voices[i].filter(outputs[0], framePos, sizeThisTime);
|
//ic29->voices[i].filter(outputs[0], framePos, sizeThisTime);
|
||||||
for (uint8_t j=0; j<sizeThisTime; j++) {
|
for (uint8_t j=0; j<sizeThisTime; j++) {
|
||||||
outputs[1][framePos+j] += outputs[0][framePos+j] * ic29.voices[i].env.level/16384.0;
|
// outputs[1][framePos+j] += outputs[0][framePos+j] * ic29->voices[i].env.level/16384.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +23,9 @@
|
|||||||
|
|
||||||
#include "DistrhoPlugin.hpp"
|
#include "DistrhoPlugin.hpp"
|
||||||
|
|
||||||
|
#include "assigner.hpp"
|
||||||
|
#include "voiceboard.hpp"
|
||||||
|
|
||||||
START_NAMESPACE_DISTRHO
|
START_NAMESPACE_DISTRHO
|
||||||
|
|
||||||
class Peacock : public Plugin {
|
class Peacock : public Plugin {
|
||||||
@ -87,6 +90,9 @@ class Peacock : public Plugin {
|
|||||||
uint32_t blockLeft = 0;
|
uint32_t blockLeft = 0;
|
||||||
uint32_t lastEvent = 0;
|
uint32_t lastEvent = 0;
|
||||||
|
|
||||||
|
Assigner ic1;
|
||||||
|
Synth ic29;
|
||||||
|
|
||||||
void runMidi(const MidiEvent *ev, uint32_t count, uint32_t timeLimit);
|
void runMidi(const MidiEvent *ev, uint32_t count, uint32_t timeLimit);
|
||||||
|
|
||||||
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Peacock);
|
DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(Peacock);
|
||||||
|
@ -18,14 +18,15 @@
|
|||||||
|
|
||||||
#include "voiceboard.hpp"
|
#include "voiceboard.hpp"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "DistrhoPlugin.hpp"
|
||||||
#include "ic29tables.hpp"
|
#include "ic29tables.hpp"
|
||||||
|
|
||||||
Synth ic29;
|
#define DEBUG
|
||||||
|
|
||||||
Synth::Synth() {
|
Synth::Synth() {
|
||||||
d_debug("initialising synth\n");
|
printf("Synth constructor\n");
|
||||||
portaCoeff = 0x0;
|
|
||||||
noise = new float [4096];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Synth::buildTables(double sampleRate) {
|
void Synth::buildTables(double sampleRate) {
|
||||||
@ -41,8 +42,6 @@ void Synth::buildTables(double sampleRate) {
|
|||||||
// and key scale to $7f, which corresponds to C4 = 248Hz and C6 = 992Hz, B3 and B5
|
// and key scale to $7f, which corresponds to C4 = 248Hz and C6 = 992Hz, B3 and B5
|
||||||
|
|
||||||
for (uint16_t i = 0; i < 256; i++) {
|
for (uint16_t i = 0; i < 256; i++) {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,10 +49,10 @@ void Synth::run() {
|
|||||||
// handle a "loop" worth of envelopes, pitch calculations, etc
|
// handle a "loop" worth of envelopes, pitch calculations, etc
|
||||||
// callled once every 4.3ms block of samples
|
// callled once every 4.3ms block of samples
|
||||||
|
|
||||||
ic29.lfo.run();
|
lfo.run();
|
||||||
|
|
||||||
masterPitch = 0x1818;
|
masterPitch = 0x1818;
|
||||||
uint16_t vcoLfoDepth = ic29.lfoDepthTable[ic29.patchRam.vcoLfoMod] + ic29.modWheel;
|
uint16_t vcoLfoDepth = lfoDepthTable[patchRam.vcoLfoMod] + modWheel;
|
||||||
vcoLfoDepth = (vcoLfoDepth < 0xff) ? vcoLfoDepth : 0xff;
|
vcoLfoDepth = (vcoLfoDepth < 0xff) ? vcoLfoDepth : 0xff;
|
||||||
masterPitch += (lfo.lfoOut * vcoLfoDepth) >> 11;
|
masterPitch += (lfo.lfoOut * vcoLfoDepth) >> 11;
|
||||||
|
|
||||||
@ -65,31 +64,34 @@ void Synth::run() {
|
|||||||
|
|
||||||
// PWM is bit 0 sw2, 0 = fixed 1 = lfo
|
// PWM is bit 0 sw2, 0 = fixed 1 = lfo
|
||||||
// 0 sets EA to 0x3fff, 1 adds
|
// 0 sets EA to 0x3fff, 1 adds
|
||||||
uint16_t pwmVal = 0x2000 - ic29.lfo.lfoOut;
|
uint16_t pwmVal = 0x2000 - lfo.lfoOut;
|
||||||
if (ic29.patchRam.switch2 & 0x01) pwmVal = 0x3fff;
|
if (patchRam.switch2 & 0x01) pwmVal = 0x3fff;
|
||||||
ic29.pwm = 0.5 - pwmVal / 32768.0f * (ic29.patchRam.pwmLfoMod / 106.0f);
|
pwm = 0.5 - pwmVal / 32768.0f * (patchRam.pwmLfoMod / 106.0f);
|
||||||
|
|
||||||
// generate the voices, then
|
// generate the voices, then
|
||||||
for (uint32_t i = 0; i < bufferSize; i++) {
|
for (uint32_t i = 0; i < bufferSize; i++) {
|
||||||
tr21 = (tr21 * 519) + 3;
|
tr21 = (tr21 * 519) + 3;
|
||||||
noise[i] = (1-(tr21 & 0x00ffffff) / 8388608.0f) * (ic29.patchRam.noiseLevel * 0.0063);
|
noise[i] = (1 - (tr21 & 0x00ffffff) / 8388608.0f) * (patchRam.noiseLevel * 0.0063);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint8_t i = 0; i < NUM_VOICES; i++) {
|
for (uint8_t i = 0; i < NUM_VOICES; i++) {
|
||||||
ic29.voices[i].update();
|
//voices[i].update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Synth::voiceOn(uint8_t voice, uint8_t note) {
|
void Synth::voiceOn(uint8_t voice, uint8_t note) {
|
||||||
// enable synth voice, start it all running
|
// enable synth voice, start it all running
|
||||||
voice &= 0x7f;
|
voice &= 0x7f;
|
||||||
ic29.voices[voice].on(note);
|
|
||||||
|
d_debug("voiceOn %02x %02x", voice, note);
|
||||||
|
|
||||||
|
voices[voice].on(note);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Synth::voiceOff(uint8_t voice) {
|
void Synth::voiceOff(uint8_t voice) {
|
||||||
// enable synth voice, start it all running
|
// enable synth voice, start it all running
|
||||||
voice &= 0x7f;
|
voice &= 0x7f;
|
||||||
ic29.voices[voice].off();
|
voices[voice].off();
|
||||||
}
|
}
|
||||||
|
|
||||||
LFO::LFO() {
|
LFO::LFO() {
|
||||||
@ -126,7 +128,8 @@ Envelope::Envelope() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Envelope::run() {
|
void Envelope::run() {
|
||||||
uint16_t tempStn = ic29.patchRam.sustain << 7;
|
/*
|
||||||
|
uint16_t tempStn = patchRam.sustain << 7;
|
||||||
switch (phase) {
|
switch (phase) {
|
||||||
case ENV_ATK:
|
case ENV_ATK:
|
||||||
level += atkTable[ic29.patchRam.attack];
|
level += atkTable[ic29.patchRam.attack];
|
||||||
@ -148,7 +151,7 @@ void Envelope::run() {
|
|||||||
case ENV_IDLE:
|
case ENV_IDLE:
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
Voice::Voice() {
|
Voice::Voice() {
|
||||||
@ -164,7 +167,7 @@ void Voice::calcPitch() {
|
|||||||
// This is implemented here by adding on a step value until you pass
|
// This is implemented here by adding on a step value until you pass
|
||||||
// the desired final pitch. Once that happens the value is clamped to the
|
// the desired final pitch. Once that happens the value is clamped to the
|
||||||
// desired pitch.
|
// desired pitch.
|
||||||
|
/*
|
||||||
if (ic29.portaCoeff != 0) {
|
if (ic29.portaCoeff != 0) {
|
||||||
// portamento up
|
// portamento up
|
||||||
if (pitch < target) {
|
if (pitch < target) {
|
||||||
@ -207,9 +210,11 @@ void Voice::update() {
|
|||||||
ic29.lfo.rate = ic29.patchRam.lfoRate;
|
ic29.lfo.rate = ic29.patchRam.lfoRate;
|
||||||
|
|
||||||
// do filter values
|
// do filter values
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void Voice::on(uint8_t key) {
|
void Voice::on(uint8_t key) {
|
||||||
|
d_debug("Voice on key %02x\n", key);
|
||||||
voiceState = V_ON;
|
voiceState = V_ON;
|
||||||
if (note != key) {
|
if (note != key) {
|
||||||
phase = 0;
|
phase = 0;
|
||||||
@ -221,9 +226,8 @@ void Voice::on(uint8_t key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Voice::off() {
|
void Voice::off() {
|
||||||
|
d_debug("Voice off\n");
|
||||||
// sustain - I need to rethink this bit FIXME
|
// sustain - I need to rethink this bit FIXME
|
||||||
voiceState = V_OFF;
|
voiceState = V_OFF;
|
||||||
if (!ic29.sustained) {
|
|
||||||
env.off();
|
env.off();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -18,8 +18,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "peacock.hpp"
|
#include <cstdint>
|
||||||
|
|
||||||
|
#define NUM_VOICES 8
|
||||||
class LFO {
|
class LFO {
|
||||||
public:
|
public:
|
||||||
LFO();
|
LFO();
|
||||||
@ -157,6 +158,3 @@ class Synth {
|
|||||||
const static uint8_t lfoDepthTable[128];
|
const static uint8_t lfoDepthTable[128];
|
||||||
const static uint8_t portaTable[128];
|
const static uint8_t portaTable[128];
|
||||||
};
|
};
|
||||||
|
|
||||||
// global
|
|
||||||
extern Synth ic29;
|
|
||||||
|
Loading…
Reference in New Issue
Block a user