From 3f9790f594693aeeccd22c2f7f9f6a8e29616924 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Mon, 19 Dec 2016 14:08:20 +0000 Subject: [PATCH] Fixing pitchbend code for using with LV2 --- src/Dexed.ttl | 24 ++++++++++++++++++++++-- src/dexed.cpp | 2 +- src/dexed.h | 7 ++++--- src/manifest.ttl | 2 +- src/msfa/dx7note.cc | 26 +++++++++++++++++++++----- 5 files changed, 49 insertions(+), 12 deletions(-) diff --git a/src/Dexed.ttl b/src/Dexed.ttl index 1fb1df3..3057e3b 100644 --- a/src/Dexed.ttl +++ b/src/Dexed.ttl @@ -1832,7 +1832,7 @@ lv2:index 152 ; lv2:symbol "pitch_bend_range" ; lv2:name "PITCH BEND RANGE" ; - lv2:default 1 ; + lv2:default 12 ; lv2:minimum 0 ; lv2:maximum 12 ; lv2:portProperty lv2:integer ; @@ -1842,7 +1842,27 @@ lv2:index 153 ; lv2:symbol "pitch_bend_step" ; lv2:name "PITCH BEND STEP" ; - lv2:default 0 ; + lv2:default 12 ; + lv2:minimum 0 ; + lv2:maximum 12 ; + lv2:portProperty lv2:integer ; + ] , + [ + a lv2:InputPort, lv2:ControlPort ; + lv2:index 154 ; + lv2:symbol "mod_wheel_range" ; + lv2:name "MOD WHEEL RANGE" ; + lv2:default 12 ; + lv2:minimum 0 ; + lv2:maximum 12 ; + lv2:portProperty lv2:integer ; + ] , + [ + a lv2:InputPort, lv2:ControlPort ; + lv2:index 155 ; + lv2:symbol "mod_wheel_step" ; + lv2:name "MOD WHEEL STEP" ; + lv2:default 12 ; lv2:minimum 0 ; lv2:maximum 12 ; lv2:portProperty lv2:integer ; diff --git a/src/dexed.cpp b/src/dexed.cpp index bc6dab2..1d13b42 100644 --- a/src/dexed.cpp +++ b/src/dexed.cpp @@ -41,7 +41,7 @@ Dexed::Dexed(double rate) : lvtk::Synth(p_n_ports, p_midi_in) voices[i].live = false; } - for(i=0;i<156;++i) + for(i=0;i<156+4;++i) data_float[i]=static_cast(data[i]); currentNote = 0; diff --git a/src/dexed.h b/src/dexed.h index 56c5f2e..47977cb 100644 --- a/src/dexed.h +++ b/src/dexed.h @@ -117,9 +117,9 @@ class Dexed : public lvtk::Synth private: double _rate; uint8_t _param_counter; - float data_float[156]; + float data_float[156+4]; //uint8_t data[156]; - uint8_t data[156]={ + uint8_t data[156+4]={ 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, @@ -131,7 +131,8 @@ class Dexed : public lvtk::Synth 34, 33, 00, 00, 00, 04, 03, 24, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, - 63 }; + 63, + 12, 12, 12, 12}; }; #endif // PLUGINPROCESSOR_H_INCLUDED diff --git a/src/manifest.ttl b/src/manifest.ttl index 9cf343a..5fc39fa 100644 --- a/src/manifest.ttl +++ b/src/manifest.ttl @@ -11,7 +11,7 @@ a lv2:Plugin ; doap:name "Dexed is a LV2 port of the famous DX-7 simulation which is based on MSFA." ; doap:description "Synth" ; - doap:shortdesc "An LV2 port of the Dexed plugin" ; + doap:shortdesc "Dexed" ; lv2:minorVersion 1; lv2:microVersion 0; doap:homepage ; doap:maintainer [ diff --git a/src/msfa/dx7note.cc b/src/msfa/dx7note.cc index d44ec1b..5e32eb1 100644 --- a/src/msfa/dx7note.cc +++ b/src/msfa/dx7note.cc @@ -190,12 +190,26 @@ void Dx7Note::compute(int32_t *buf, int32_t lfo_val, int32_t lfo_delay, const Co int32_t pitch_mod = max(pmod_1, pmod_2); pitch_mod = pitchenv_.getsample() + (pitch_mod * (senslfo < 0 ? -1 : 1)); -/* // ---- PITCH BEND ---- - int pitchbend = ctrls->values_[kControllerPitch]; +#ifdef DEBUG + // ---- PITCH BEND ---- + // hardcodes a pitchbend range of 3 semitones, TODO make configurable + int pitchbend = ctrls->values_[kControllerPitch]; + int32_t pb = (pitchbend - 0x2000) << 9; + pitch_mod += pb; + for (int op = 0; op < 6; op++) { + params_[op].level_in = params_[op].gain_out; + int32_t level = env_[op].getsample(); + int32_t gain = Exp2::lookup(level - (14 * (1 << 24))); + // int32_t gain = pow(2, 10 + level * (1.0 / (1 << 24))); + params_[op].freq = Freqlut::lookup(basepitch_[op] + pitch_mod); + params_[op].gain_out = gain; + } + +/* int pitchbend = ctrls->values_[kControllerPitch]; int32_t pb = (pitchbend - 0x2000); if (pb != 0) { if (ctrls->values_[kControllerPitchStep] == 0) { - pb = ((float) (pb << 11)) * ((float) ctrls->values_[kControllerPitchRange]) / 12.0; + pb = ((float) (pb << 11)) * ((float)ctrls->values_[kControllerPitchRange]) / 12.0; } else { int stp = 12 / ctrls->values_[kControllerPitchStep]; pb = pb * stp / 8191; @@ -203,8 +217,10 @@ void Dx7Note::compute(int32_t *buf, int32_t lfo_val, int32_t lfo_delay, const Co } } pitch_mod += pb; - pitch_mod += ctrls->masterTune; -*/ + pitch_mod += ctrls->masterTune; */ +TRACE("pitch_mod=%d pb=%d"); +#endif + // ==== AMP MOD ==== uint32_t amod_1 = ((int64_t) ampmoddepth_ * (int64_t) lfo_delay) >> 8; // Q24 :D amod_1 = ((int64_t) amod_1 * (int64_t) lfo_val) >> 24;