diff options
Diffstat (limited to 'muse/synti/organ/organ.h')
-rw-r--r-- | muse/synti/organ/organ.h | 164 |
1 files changed, 44 insertions, 120 deletions
diff --git a/muse/synti/organ/organ.h b/muse/synti/organ/organ.h index ec458f10..92f63114 100644 --- a/muse/synti/organ/organ.h +++ b/muse/synti/organ/organ.h @@ -14,91 +14,41 @@ #define __ORGAN_H__ #include "muse/midictrl.h" -#include "libsynti/mess.h" - -#define RESOLUTION (16384*2) -#define VOICES 128 // max polyphony +#include "libsynti/mess2.h" +static const int NO_VOICES = 128; // max polyphony +static const int NO_KEYS = 97 - 36; class OrganGui; static const int MAX_ATTENUATION = 960; - -enum EnvelopeState { - ATTACK, - DECAY, - SUSTAIN, - RELEASE, - OFF +static const int NO_BUSES = 9; +static const int NO_WHEELS = 91; +static const int NO_ELEMENTS = 194; + +enum { + DRAWBAR0 = CTRL_RPN14_OFFSET, DRAWBAR1, DRAWBAR2, + DRAWBAR3, DRAWBAR4, DRAWBAR5, DRAWBAR6, DRAWBAR7, DRAWBAR8, + ATTACK_LO, DECAY_LO, SUSTAIN_LO, RELEASE_LO, + ATTACK_HI, DECAY_HI, SUSTAIN_HI, RELEASE_HI, + BRASS, FLUTE, REED, VELO }; //--------------------------------------------------------- -// Envelope +// Wheel //--------------------------------------------------------- -struct Envelope { - int ticks; // len of segment - int error, delta, schritt; - int y, yinc; - - void set(int t, int y1, int y2) { - ticks = t; - y = y1; - int dy = y2 - y1; - int dx = t; - error = -dx; - schritt = 2*dx; - if (dy < 0) { - yinc = -1; - delta = -2 * dy; - } - else { - yinc = 1; - delta = 2 * dy; - } - } - - // return false on envelope end - bool step(int* a) { - *a = y; - if (ticks == 0) - return false; - error += delta; - while (error > 0) { - y += yinc; - error -= schritt; - } - --ticks; - return true; - } - }; - -static const int HARM0 = 0 + CTRL_RPN14_OFFSET; -static const int HARM1 = 1 + CTRL_RPN14_OFFSET; -static const int HARM2 = 2 + CTRL_RPN14_OFFSET; -static const int HARM3 = 3 + CTRL_RPN14_OFFSET; -static const int HARM4 = 4 + CTRL_RPN14_OFFSET; -static const int HARM5 = 5 + CTRL_RPN14_OFFSET; -static const int ATTACK_LO = 6 + CTRL_RPN14_OFFSET; -static const int DECAY_LO = 7 + CTRL_RPN14_OFFSET; -static const int SUSTAIN_LO = 8 + CTRL_RPN14_OFFSET; -static const int RELEASE_LO = 9 + CTRL_RPN14_OFFSET; -static const int ATTACK_HI = 10 + CTRL_RPN14_OFFSET; -static const int DECAY_HI = 11 + CTRL_RPN14_OFFSET; -static const int SUSTAIN_HI = 12 + CTRL_RPN14_OFFSET; -static const int RELEASE_HI = 13 + CTRL_RPN14_OFFSET; -static const int BRASS = 14 + CTRL_RPN14_OFFSET; -static const int FLUTE = 15 + CTRL_RPN14_OFFSET; -static const int REED = 16 + CTRL_RPN14_OFFSET; -static const int VELO = 17 + CTRL_RPN14_OFFSET; +struct Wheel { + unsigned freq256; + unsigned accu; -//--------------------------------------------------------- -// SynthCtrl -//--------------------------------------------------------- + int refCount; + bool active; + float gain[NO_BUSES]; -struct SynthCtrl { - const char* name; - int num; - int val; + // envelopes: + float* env[NO_BUSES]; + int envCount[NO_BUSES]; + float deltaGain[NO_BUSES]; }; //--------------------------------------------------------- @@ -108,64 +58,41 @@ struct SynthCtrl { struct Voice { bool isOn; int pitch; - int channel; - - double velocity; - - int state1, state2; - Envelope envL1, envL2, envL3; - Envelope envH1, envH2, envH3; - - unsigned harm0_accum; - unsigned harm1_accum; - unsigned harm2_accum; - unsigned harm3_accum; - unsigned harm4_accum; - unsigned harm5_accum; }; -//--------------------------------------------------------- -// Preset -//--------------------------------------------------------- +struct Elem { + short wheel; + short bus; + float level; -struct Preset { - char* name; - bool brass, flute, reed; - int attack0, attack1; - int release0, release1; - int decay0, decay1; - double harm0, harm1, harm2, harm3, harm4, harm5; - bool velo; + Elem() { bus = -1; } + Elem(short w, short b, float l) : wheel(w), bus(b), level(l) {} }; //--------------------------------------------------------- // Organ //--------------------------------------------------------- -class Organ : public Mess { +class Organ : public Mess2 { static int useCount; + static float* waveTable; static double cb2amp_tab[MAX_ATTENUATION]; - static unsigned freq256[128]; + static unsigned freq256[128][NO_BUSES]; static double cb2amp(int cb); + static Elem routing[NO_KEYS][NO_ELEMENTS]; + static float* attackEnv; + static float* releaseEnv; + static int envSize; + static int resolution; + static int resolution256; - int* idata; // buffer for init data - - bool brass, flute, reed; - int attack0, attack1; - int release0, release1; - int decay0, decay1; // ticks - int sustain0, sustain1; // centibel - bool velo; double volume; - double harm0, harm1, harm2, harm3, harm4, harm5; - - Voice voices[VOICES]; - - static float* sine_table; - static float* g_triangle_table; - static float* g_pulse_table; + float drawBarGain[NO_BUSES]; + Wheel wheels[NO_WHEELS]; + Voice voices[NO_VOICES]; + QList<Wheel*> activeWheels; void noteoff(int channel, int pitch); void setController(int ctrl, int val); @@ -175,9 +102,6 @@ class Organ : public Mess { virtual bool setController(int channel, int ctrl, int val); virtual bool sysex(int, const unsigned char*); - virtual int getControllerInfo(int, const char**, int*, int*, int*); - virtual void getInitData(int*, const unsigned char**); - virtual bool guiVisible() const; virtual void showGui(bool); virtual bool hasGui() const { return true; } @@ -187,7 +111,7 @@ class Organ : public Mess { OrganGui* gui; public: - static SynthCtrl synthCtrl[]; + friend class OrganGui; Organ(int sampleRate); ~Organ(); bool init(const char* name); |