From b3d5223a745b40fc3737549eebe693275daf68d6 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Thu, 15 Dec 2016 11:23:22 +0000 Subject: [PATCH] Renamed dexed.pef to dexed_ttl.h. Tried to find the problem with mod-ui. --- src/Makefile | 9 +- src/dexed.cpp | 146 ++++++++++----------- src/dexed.h | 9 +- src/dexed_ttl.h | 333 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 410 insertions(+), 87 deletions(-) create mode 100644 src/dexed_ttl.h diff --git a/src/Makefile b/src/Makefile index d7ce340..a2d4b77 100644 --- a/src/Makefile +++ b/src/Makefile @@ -48,7 +48,7 @@ endif all: $(BUNDLE) Makefile clean: Makefile - rm -f *.o *~ *.bak *.gch dexed.peg *.so *.gch msfa/*.gch + rm -f *.o *~ *.bak *.gch dexed_ttl.h *.so *.gch msfa/*.gch rm -rf $(BUNDLE) install: $(BUNDLE) @@ -66,7 +66,7 @@ $(BUNDLE): manifest.ttl Dexed.ttl modgui.ttl presets.ttl dexed.so dexed.so: $(OBJ) dexed.o $(CXX) $(CXXFLAGS) -shared dexed.o $(OBJ) $(LDFLAGS) -o dexed.so -dexed.o: Makefile dexed.cpp dexed.h dexed.peg +dexed.o: Makefile dexed.cpp dexed.h dexed_ttl.h $(CXX) $(CXXFLAGS) -Wall -c dexed.cpp trace.o: Makefile trace.c trace.h @@ -108,7 +108,6 @@ EngineOpl.o: Makefile EngineOpl.cpp PluginFx.o: Makefile PluginFx.cpp $(CXX) $(CXXFLAGS) -Wall -c PluginFx.cpp -dexed.peg: Dexed.ttl - #lv2peg Dexed.ttl dexed.peg - ttl2c Dexed.ttl dexed.peg +dexed_ttl.h: Dexed.ttl + ttl2c Dexed.ttl dexed_ttl.h diff --git a/src/dexed.cpp b/src/dexed.cpp index fdc8b14..0050ca0 100644 --- a/src/dexed.cpp +++ b/src/dexed.cpp @@ -1,10 +1,11 @@ // from: http://ll-plugins.nongnu.org/lv2pftci/#A_synth #include -#include "dexed.peg" #include "dexed.h" +#include "dexed_ttl.h" #include "EngineMkI.h" #include "EngineOpl.h" +#include "msfa/fm_core.h" #include "msfa/exp2.h" #include "msfa/sin.h" #include "msfa/freqlut.h" @@ -16,11 +17,55 @@ Dexed::Dexed(double rate) : lvtk::Synth(p_n_ports, p_midi_in) { TRACE("Hi"); - //add_voices(new DexedVoice(rate)); + engineMkI=new EngineMkI; + engineOpl=new EngineOpl; + engineMsfa=new FmCore; - add_audio_outputs(p_audio_out); + Exp2::init(); + Tanh::init(); + Sin::init(); + + 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; + } + + currentNote = 0; + controllers.values_[kControllerPitch] = 0x2000; + controllers.modwheel_cc = 0; + controllers.foot_cc = 0; + controllers.breath_cc = 0; + controllers.aftertouch_cc = 0; - _rate=rate; + bufsize_=256; + + outbuf_=new float[bufsize_]; + + lfo.reset(data+137); + + normalizeDxVelocity = false; + + setMonoMode(false); + + sustain = false; + + extra_buf_size_ = 0; + + memset(&voiceStatus, 0, sizeof(VoiceStatus)); + + engineType=0xff; + setEngineType(DEXED_ENGINE_MARKI); + + //add_voices(new DexedVoice(rate)); + add_audio_outputs(p_audio_out); TRACE("Bye"); } @@ -51,7 +96,7 @@ void Dexed::activate(void) TRACE("Hi"); Plugin::activate(); - init(_rate); + set_params(); refreshVoice=true; @@ -71,32 +116,37 @@ void Dexed::set_params(void) { TRACE("Hi"); + bool unisono=bool(*p(p_unisono)); + uint8_t engine=uint8_t(*p(p_engine)); + float f_gain=*p(p_output); + float f_cutoff=*p(p_cutoff); + float f_reso=*p(p_resonance); + // Dexed-Unisono - if(isMonoMode()!=bool(*p(p_unisono))) - setMonoMode(bool(*p(p_unisono))); + if(isMonoMode()!=unisono) + setMonoMode(unisono); // Dexed-Engine - if(controllers.core==NULL || getEngineType()!=uint8_t(*p(p_engine))) + if(controllers.core==NULL || getEngineType()!=engine) { - setEngineType(uint8_t(*p(p_engine))); + setEngineType(engine); refreshVoice=true; } // Dexed-Filter - if(fx.uiCutoff!=*p(p_cutoff)) + if(fx.uiCutoff!=f_cutoff) { - fx.uiCutoff=*p(p_cutoff); + fx.uiCutoff=f_cutoff; refreshVoice=true; } - if(fx.uiReso!=*p(p_resonance)) + if(fx.uiReso!=f_reso) { - fx.uiReso=*p(p_resonance); + fx.uiReso=f_reso; refreshVoice=true; } - fx.uiGain=1.0; - if(fx.uiGain!=*p(p_output)) + if(fx.uiGain!=f_gain) { - fx.uiGain=*p(p_output); + fx.uiGain=f_gain; refreshVoice=true; } @@ -603,17 +653,17 @@ void Dexed::setEngineType(uint8_t tp) { switch (tp) { case DEXED_ENGINE_MARKI: TRACE("DEXED_ENGINE_MARKI:%d",DEXED_ENGINE_MARKI); - controllers.core = &engineMkI; + controllers.core = engineMkI; feedback_bitdepth = 11; break; case DEXED_ENGINE_OPL: TRACE("DEXED_ENGINE_OPL:%d",DEXED_ENGINE_OPL); - controllers.core = &engineOpl; + controllers.core = engineOpl; feedback_bitdepth = 11; break; default: TRACE("DEXED_ENGINE_MODERN:%d",DEXED_ENGINE_MODERN); - controllers.core = &engineMsfa; + controllers.core = engineMsfa; feedback_bitdepth = 8; break; } @@ -641,64 +691,6 @@ void Dexed::panic(void) { } } -void Dexed::init(double rate) -{ - TRACE("Hi"); - - bufsize_=256; - outbuf_=new float[bufsize_]; - - Exp2::init(); - Tanh::init(); - Sin::init(); - - add_voices(new DexedVoice(rate)); - - normalizeDxVelocity = false; - - memset(&voiceStatus, 0, sizeof(VoiceStatus)); - - Freqlut::init(rate); - Lfo::init(rate); - PitchEnv::init(rate); - Env::init_sr(rate); - fx.init(rate); - - fx.uiCutoff=1.0; - fx.uiReso=0.0; - fx.uiGain=1.0; - - 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; - - engineType=0xff; - - setEngineType(DEXED_ENGINE_MARKI); - setMonoMode(false); - - sustain = false; - - lfo.reset(data+137); - - extra_buf_size_ = 0; - - _rate=rate; - -} - //============================================================================== DexedVoice::DexedVoice(double rate) : m_key(lvtk::INVALID_KEY), m_rate(rate) diff --git a/src/dexed.h b/src/dexed.h index 3c36f47..40039dc 100644 --- a/src/dexed.h +++ b/src/dexed.h @@ -29,7 +29,7 @@ #include "PluginFx.h" #include "EngineMkI.h" #include "EngineOpl.h" -#include "dexed.peg" +#include "dexed_ttl.h" #ifdef DEBUG #include "trace.h" #endif @@ -94,7 +94,6 @@ 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]; @@ -107,9 +106,9 @@ class Dexed : public lvtk::Synth uint8_t feedback_bitdepth; PluginFx fx; Lfo lfo; - FmCore engineMsfa; - EngineMkI engineMkI; - EngineOpl engineOpl; + FmCore* engineMsfa; + EngineMkI* engineMkI; + EngineOpl* engineOpl; float* outbuf_; uint32_t bufsize_; float extra_buf_[N]; diff --git a/src/dexed_ttl.h b/src/dexed_ttl.h new file mode 100644 index 0000000..d3aa83b --- /dev/null +++ b/src/dexed_ttl.h @@ -0,0 +1,333 @@ +#ifndef dexed_ttl_h +#define dexed_ttl_h + + +#ifndef PEG_STRUCT +#define PEG_STRUCT +typedef struct { + float min; + float max; + float default_value; + char toggled; + char integer; + char logarithmic; +} peg_data_t; +#endif + +/* */ + +static const char p_uri[] = "https://github.com/dcoredump/dexed.lv2"; + +enum p_port_enum { + p_midi_in, + p_audio_out, + p_cutoff, + p_resonance, + p_output, + p_engine, + p_unisono, + p_algorithm_num, + p_feedback, + p_oscillator_sync, + p_lfo_speed, + p_lfo_delay, + p_lfo_pitch_mod_depth, + p_lfo_amp_mod_depth, + p_lfo_sync, + p_lfo_waveform, + p_transpose, + p_pitch_mod_sensitivity, + p_pitch_eg_rate_1, + p_pitch_eg_rate_2, + p_pitch_eg_rate_3, + p_pitch_eg_rate_4, + p_pitch_eg_level_1, + p_pitch_eg_level_2, + p_pitch_eg_level_3, + p_pitch_eg_level_4, + p_op1_eg_rate_1, + p_op1_eg_rate_2, + p_op1_eg_rate_3, + p_op1_eg_rate_4, + p_op1_eg_level_1, + p_op1_eg_level_2, + p_op1_eg_level_3, + p_op1_eg_level_4, + p_op1_operator_output_level, + p_op1_osc_mode, + p_op1_osc_freq_coarse, + p_op1_osc_freq_fine, + p_op1_osc_detune, + p_op1_kbd_lev_scl_brk_pt, + p_op1_kbd_lev_scl_lft_depth, + p_op1_kbd_lev_scl_rht_depth, + p_op1_kbd_lev_scl_lft_curve, + p_op1_kbd_lev_scl_rht_curve, + p_op1_kbd_rate_scaling, + p_op1_amp_mod_sensitivity, + p_op1_key_vel_sensitivity, + p_op2_eg_rate_1, + p_op2_eg_rate_2, + p_op2_eg_rate_3, + p_op2_eg_rate_4, + p_op2_eg_level_1, + p_op2_eg_level_2, + p_op2_eg_level_3, + p_op2_eg_level_4, + p_op2_operator_output_level, + p_op2_osc_mode, + p_op2_osc_freq_coarse, + p_op2_osc_freq_fine, + p_op2_osc_detune, + p_op2_kbd_lev_scl_brk_pt, + p_op2_kbd_lev_scl_lft_depth, + p_op2_kbd_lev_scl_rht_depth, + p_op2_kbd_lev_scl_lft_curve, + p_op2_kbd_lev_scl_rht_curve, + p_op2_kbd_rate_scaling, + p_op2_amp_mod_sensitivity, + p_op2_key_vel_sensitivity, + p_op3_eg_rate_1, + p_op3_eg_rate_2, + p_op3_eg_rate_3, + p_op3_eg_rate_4, + p_op3_eg_level_1, + p_op3_eg_level_2, + p_op3_eg_level_3, + p_op3_eg_level_4, + p_op3_operator_output_level, + p_op3_osc_mode, + p_op3_osc_freq_coarse, + p_op3_osc_freq_fine, + p_op3_osc_detune, + p_op3_kbd_lev_scl_brk_pt, + p_op3_kbd_lev_scl_lft_depth, + p_op3_kbd_lev_scl_rht_depth, + p_op3_kbd_lev_scl_lft_curve, + p_op3_kbd_lev_scl_rht_curve, + p_op3_kbd_rate_scaling, + p_op3_amp_mod_sensitivity, + p_op3_key_vel_sensitivity, + p_op4_eg_rate_1, + p_op4_eg_rate_2, + p_op4_eg_rate_3, + p_op4_eg_rate_4, + p_op4_eg_level_1, + p_op4_eg_level_2, + p_op4_eg_level_3, + p_op4_eg_level_4, + p_op4_operator_output_level, + p_op4_osc_mode, + p_op4_osc_freq_coarse, + p_op4_osc_freq_fine, + p_op4_osc_detune, + p_op4_kbd_lev_scl_brk_pt, + p_op4_kbd_lev_scl_lft_depth, + p_op4_kbd_lev_scl_rht_depth, + p_op4_kbd_lev_scl_lft_curve, + p_op4_kbd_lev_scl_rht_curve, + p_op4_kbd_rate_scaling, + p_op4_amp_mod_sensitivity, + p_op4_key_vel_sensitivity, + p_op5_eg_rate_1, + p_op5_eg_rate_2, + p_op5_eg_rate_3, + p_op5_eg_rate_4, + p_op5_eg_level_1, + p_op5_eg_level_2, + p_op5_eg_level_3, + p_op5_eg_level_4, + p_op5_operator_output_level, + p_op5_osc_mode, + p_op5_osc_freq_coarse, + p_op5_osc_freq_fine, + p_op5_osc_detune, + p_op5_kbd_lev_scl_brk_pt, + p_op5_kbd_lev_scl_lft_depth, + p_op5_kbd_lev_scl_rht_depth, + p_op5_kbd_lev_scl_lft_curve, + p_op5_kbd_lev_scl_rht_curve, + p_op5_kbd_rate_scaling, + p_op5_amp_mod_sensitivity, + p_op5_key_vel_sensitivity, + p_op6_eg_rate_1, + p_op6_eg_rate_2, + p_op6_eg_rate_3, + p_op6_eg_rate_4, + p_op6_eg_level_1, + p_op6_eg_level_2, + p_op6_eg_level_3, + p_op6_eg_level_4, + p_op6_operator_output_level, + p_op6_osc_mode, + p_op6_osc_freq_coarse, + p_op6_osc_freq_fine, + p_op6_osc_detune, + p_op6_kbd_lev_scl_brk_pt, + p_op6_kbd_lev_scl_lft_depth, + p_op6_kbd_lev_scl_rht_depth, + p_op6_kbd_lev_scl_lft_curve, + p_op6_kbd_lev_scl_rht_curve, + p_op6_kbd_rate_scaling, + p_op6_amp_mod_sensitivity, + p_op6_key_vel_sensitivity, + p_n_ports +}; + +static const peg_data_t p_ports[] = { + { -3.40282e+38, 3.40282e+38, -3.40282e+38, 0, 0, 0 }, + { -3.40282e+38, 3.40282e+38, -3.40282e+38, 0, 0, 0 }, + { 0, 1, 1, 0, 0, 0 }, + { 0, 1, 0, 0, 0, 0 }, + { 0.1, 2, 1, 0, 0, 1 }, + { 0, 2, 1, 0, 1, 0 }, + { 0, 1, 0, 1, 1, 0 }, + { 1, 32, 5, 0, 1, 0 }, + { 0, 7, 6, 0, 1, 0 }, + { 0, 1, 0, 1, 1, 0 }, + { 0, 99, 34, 0, 1, 0 }, + { 0, 99, 33, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 1, 0, 1, 1, 0 }, + { 0, 5, 4, 0, 1, 0 }, + { 0, 48, 24, 0, 1, 0 }, + { 0, 7, 3, 0, 1, 0 }, + { 0, 99, 94, 0, 1, 0 }, + { 0, 99, 67, 0, 1, 0 }, + { 0, 99, 95, 0, 1, 0 }, + { 0, 99, 60, 0, 1, 0 }, + { 0, 99, 50, 0, 1, 0 }, + { 0, 99, 50, 0, 1, 0 }, + { 0, 99, 50, 0, 1, 0 }, + { 0, 99, 50, 0, 1, 0 }, + { 0, 99, 96, 0, 1, 0 }, + { 0, 99, 25, 0, 1, 0 }, + { 0, 99, 25, 0, 1, 0 }, + { 0, 99, 67, 0, 1, 0 }, + { 0, 99, 99, 0, 1, 0 }, + { 0, 99, 75, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 99, 0, 1, 0 }, + { 0, 1, 0, 0, 1, 0 }, + { 0, 31, 1, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { -7, 7, 3, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 7, 3, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 7, 2, 0, 1, 0 }, + { 0, 99, 95, 0, 1, 0 }, + { 0, 99, 50, 0, 1, 0 }, + { 0, 99, 35, 0, 1, 0 }, + { 0, 99, 78, 0, 1, 0 }, + { 0, 99, 99, 0, 1, 0 }, + { 0, 99, 75, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 58, 0, 1, 0 }, + { 0, 1, 0, 0, 1, 0 }, + { 0, 31, 14, 0, 1, 0 }, + { 0, 100, 0, 0, 1, 0 }, + { -7, 7, 0, 0, 1, 0 }, + { 0, 100, 0, 0, 1, 0 }, + { 0, 100, 0, 0, 1, 0 }, + { 0, 100, 0, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 7, 3, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 7, 7, 0, 1, 0 }, + { 0, 99, 95, 0, 1, 0 }, + { 0, 99, 20, 0, 1, 0 }, + { 0, 99, 20, 0, 1, 0 }, + { 0, 99, 50, 0, 1, 0 }, + { 0, 99, 99, 0, 1, 0 }, + { 0, 99, 95, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 99, 0, 1, 0 }, + { 0, 1, 0, 0, 1, 0 }, + { 0, 31, 1, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { -7, 7, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 7, 3, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 7, 2, 0, 1, 0 }, + { 0, 99, 95, 0, 1, 0 }, + { 0, 99, 29, 0, 1, 0 }, + { 0, 99, 20, 0, 1, 0 }, + { 0, 99, 50, 0, 1, 0 }, + { 0, 99, 99, 0, 1, 0 }, + { 0, 99, 95, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 89, 0, 1, 0 }, + { 0, 1, 0, 0, 1, 0 }, + { 0, 31, 1, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { -7, 7, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 7, 3, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 7, 6, 0, 1, 0 }, + { 0, 99, 95, 0, 1, 0 }, + { 0, 99, 20, 0, 1, 0 }, + { 0, 99, 20, 0, 1, 0 }, + { 0, 99, 50, 0, 1, 0 }, + { 0, 99, 99, 0, 1, 0 }, + { 0, 99, 95, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 99, 0, 1, 0 }, + { 0, 1, 0, 0, 1, 0 }, + { 0, 31, 1, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { -7, 7, -7, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 7, 3, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 7, 0, 0, 1, 0 }, + { 0, 99, 95, 0, 1, 0 }, + { 0, 99, 29, 0, 1, 0 }, + { 0, 99, 20, 0, 1, 0 }, + { 0, 99, 50, 0, 1, 0 }, + { 0, 99, 99, 0, 1, 0 }, + { 0, 99, 95, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 79, 0, 1, 0 }, + { 0, 1, 0, 0, 1, 0 }, + { 0, 31, 1, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { -7, 7, 7, 0, 1, 0 }, + { 0, 99, 41, 0, 1, 0 }, + { 0, 99, 0, 0, 1, 0 }, + { 0, 99, 19, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 7, 3, 0, 1, 0 }, + { 0, 3, 0, 0, 1, 0 }, + { 0, 7, 6, 0, 1, 0 }, +}; + + +#endif /* dexed_ttl_h */