diff --git a/src/Makefile b/src/Makefile index 8a1801f..035162c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -66,7 +66,7 @@ $(BUNDLE): manifest.ttl Dexed.ttl dexed.so dexed.so: $(OBJ) dexed.o $(CXX) $(CXXFLAGS) -shared dexed.o $(OBJ) $(LDFLAGS) -o dexed.so -dexed.o: Makefile dexed.cpp dexed.peg +dexed.o: Makefile dexed.cpp dexed.h dexed.peg $(CXX) $(CXXFLAGS) -Wall -c dexed.cpp trace.o: Makefile trace.c trace.h @@ -109,5 +109,6 @@ PluginFx.o: Makefile PluginFx.cpp $(CXX) $(CXXFLAGS) -Wall -c PluginFx.cpp dexed.peg: Dexed.ttl - lv2peg Dexed.ttl dexed.peg + #lv2peg Dexed.ttl dexed.peg + ttl2c Dexed.ttl dexed.peg diff --git a/src/dexed.cpp b/src/dexed.cpp index 9272d97..4402c87 100644 --- a/src/dexed.cpp +++ b/src/dexed.cpp @@ -10,58 +10,19 @@ #include "msfa/freqlut.h" #include "msfa/controllers.h" #include "PluginFx.h" +#include Dexed::Dexed(double rate) : lvtk::Synth(p_n_ports, p_midi_in) { TRACE("Hi"); - bufsize_=256; - outbuf_=new float[bufsize_]; - - Exp2::init(); - Tanh::init(); - Sin::init(); - - normalizeDxVelocity = false; - - memset(&voiceStatus, 0, sizeof(VoiceStatus)); - - Freqlut::init(rate); - Lfo::init(rate); - PitchEnv::init(rate); - Env::init_sr(rate); - fx.init(rate); - - for (uint8_t note = 0; note < MAX_ACTIVE_NOTES; ++note) { - voices[note].dx7_note = new Dx7Note; - voices[note].keydown = false; - voices[note].sustained = false; - voices[note].live = false; - } - - refreshVoice=true; - - currentNote = 0; - controllers.values_[kControllerPitch] = 0x2000; - controllers.modwheel_cc = 0; - controllers.foot_cc = 0; - controllers.breath_cc = 0; - controllers.aftertouch_cc = 0; - - setEngineType(DEXED_ENGINE_MARKI); - setMonoMode(false); - - sustain = false; - - lfo.reset(data + 137); - - extra_buf_size_ = 0; - add_voices(new DexedVoice(rate)); //add_voices(new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate),new DexedVoice(rate)); add_audio_outputs(p_audio_out); + init(rate); + TRACE("Bye"); } @@ -362,7 +323,7 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer) if ( voices[i].live ) voices[i].dx7_note->update(data, voices[i].midi_note, feedback_bitdepth); } - lfo.reset(data + 137); + lfo.reset(data+137); refreshVoice = false; } @@ -667,6 +628,54 @@ void Dexed::panic(void) { } } +void Dexed::init(double rate) +{ + TRACE("Hi"); + + bufsize_=256; + outbuf_=new float[bufsize_]; + + Exp2::init(); + Tanh::init(); + Sin::init(); + + normalizeDxVelocity = false; + + memset(&voiceStatus, 0, sizeof(VoiceStatus)); + + Freqlut::init(rate); + Lfo::init(rate); + PitchEnv::init(rate); + Env::init_sr(rate); + fx.init(rate); + + for (uint8_t note = 0; note < MAX_ACTIVE_NOTES; ++note) { + voices[note].dx7_note = new Dx7Note; + voices[note].keydown = false; + voices[note].sustained = false; + voices[note].live = false; + } + + refreshVoice=true; + + currentNote = 0; + controllers.values_[kControllerPitch] = 0x2000; + controllers.modwheel_cc = 0; + controllers.foot_cc = 0; + controllers.breath_cc = 0; + controllers.aftertouch_cc = 0; + + setEngineType(DEXED_ENGINE_MARKI); + setMonoMode(false); + + sustain = false; + + lfo.reset(data+137); + + extra_buf_size_ = 0; + +} + //============================================================================== DexedVoice::DexedVoice(double rate) : m_key(lvtk::INVALID_KEY), m_rate(rate) diff --git a/src/dexed.h b/src/dexed.h index 795792e..87cdfdf 100644 --- a/src/dexed.h +++ b/src/dexed.h @@ -85,7 +85,6 @@ class Dexed : public lvtk::Synth void set_params(void); void GetSamples(uint32_t n_samples, float *buffer); - uint8_t data[161]; Controllers controllers; VoiceStatus voiceStatus; @@ -95,6 +94,7 @@ class Dexed : public lvtk::Synth void keyup(uint8_t pitch); void keydown(uint8_t pitch, uint8_t velo); void panic(void); + void init(double rate); static const uint8_t MAX_ACTIVE_NOTES = 16; ProcessorVoice voices[MAX_ACTIVE_NOTES]; @@ -117,6 +117,20 @@ class Dexed : public lvtk::Synth private: uint8_t _param_counter; + uint8_t data[156]; +/* uint8_t data[156]={ + 95, 29, 20, 50, 99, 95, 00, 00, 41, 00, 19, 00, 00, 03, 00, 06, 79, 00, 01, 00, 14, + 95, 20, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 00, 99, 00, 01, 00, 00, + 95, 29, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 06, 89, 00, 01, 00, 07, + 95, 20, 20, 50, 99, 95, 00, 00, 00, 00, 00, 00, 00, 03, 00, 02, 99, 00, 01, 00, 07, + 95, 50, 35, 78, 99, 75, 00, 00, 00, 00, 00, 00, 00, 03, 00, 07, 58, 00, 14, 00, 07, + 96, 25, 25, 67, 99, 75, 00, 00, 00, 00, 00, 00, 00, 03, 00, 02, 99, 00, 01, 00, 10, + 94, 67, 95, 60, 50, 50, 50, 50, + 04, 06, 00, + 34, 33, 00, 00, 00, 04, + 03, 24, + 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, + 63 }; */ }; #endif // PLUGINPROCESSOR_H_INCLUDED