From ddec7f1023645f75f01696507b0064f4ac2cf2b5 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Fri, 6 Jan 2017 17:56:24 +0000 Subject: [PATCH] Fixed pitchwheel code. Added (fixed) master tune. Changed some initial parameters. --- src/Dexed.ttl | 8 ++++---- src/Makefile | 4 ++-- src/dexed.cpp | 22 ++++++++++------------ src/dexed.h | 2 +- src/dexed.mh | 7 +++++++ src/msfa/controllers.h | 2 +- src/msfa/dx7note.cc | 6 +----- 7 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/Dexed.ttl b/src/Dexed.ttl index a1379d8..b3d5abd 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 12 ; + lv2:default 1 ; lv2:minimum 0 ; lv2:maximum 12 ; lv2:portProperty lv2:integer ; @@ -1872,9 +1872,9 @@ lv2:index 156 ; lv2:symbol "master_tune" ; lv2:name "MASTER TUNE" ; - lv2:default 0 ; - lv2:minimum -100.0 ; - lv2:maximum 100.0 ; + lv2:default 0.0 ; + lv2:minimum -1.0 ; + lv2:maximum 1.0 ; ] ; doap:name "Dexed" ; diff --git a/src/Makefile b/src/Makefile index 450d48e..d079d94 100644 --- a/src/Makefile +++ b/src/Makefile @@ -4,8 +4,8 @@ TARGET=dexed.so OBJ=fm_core.o env.o lfo.o dx7note.o sin.o pitchenv.o fm_op_kernel.o freqlut.o exp2.o EngineMkI.o EngineOpl.o PluginFx.o trace.o CFLAGS=-fPIC -DPIC -std=c++11 -I. -I/usr/local/include/lvtk-2 -DLVTK_DEBUG=false LDFLAGS=-L/usr/local/lib -llvtk_plugin2 - -#CFLAGS_OPTIONS+=-DPITCHWHEEL # enable for adding pitchwheel code +#DEBUG=1 +#FILETRACE=1 ifeq ($(ARCH),) ARCH := $(shell uname -m) diff --git a/src/dexed.cpp b/src/dexed.cpp index 0fcac91..30e6ae1 100644 --- a/src/dexed.cpp +++ b/src/dexed.cpp @@ -46,6 +46,7 @@ Dexed::Dexed(double rate) : lvtk::Synth(p_n_ports, p_midi_in) currentNote = 0; controllers.values_[kControllerPitch] = 0x2000; + controllers.values_[kControllerPitchRange] = 12; controllers.modwheel_cc = 0; controllers.foot_cc = 0; controllers.breath_cc = 0; @@ -107,10 +108,6 @@ void Dexed::activate(void) set_params(); -#ifdef DEBUG - TRACE("Algorithm %d outputs: %d",data[134],controllers.core->op_out(data[134])); -#endif - Plugin::activate(); TRACE("Bye"); @@ -473,7 +470,6 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer) { uint8_t op_bit=static_cast(pow(2,op)); - TRACE("op=%d op_out=%d 2^op=%d %d",op,op_out,op_bit,op_out&op_bit); if((op_carrier&op_bit)>0) { // this voice is a carrier! @@ -548,21 +544,23 @@ void Dexed::ProcessMidiMessage(const uint8_t *buf, uint32_t buf_size) { } break; } -/* - case 0xc0 : - //setCurrentProgram(buf[1]); - break; + +// case 0xc0 : +// setCurrentProgram(buf[1]); +// break; + // aftertouch case 0xd0 : TRACE("MIDI aftertouch 0xd0 event: %d %d",buf[1]); controllers.aftertouch_cc = buf[1]; controllers.refresh(); break; + // pitchbend case 0xe0 : TRACE("MIDI pitchbend 0xe0 event: %d %d",buf[1],buf[2]); controllers.values_[kControllerPitch] = buf[1] | (buf[2] << 7); break; -*/ + default: TRACE("MIDI event unknown: cmd=%d, val1=%d, val2=%d",buf[0],buf[1],buf[2]); break; @@ -682,8 +680,8 @@ void Dexed::onParam(uint8_t param_num,float param_val) if(param_num==160) { - controllers.masterTune=param_val; - return; + int32_t tune=param_val*0x4000; + controllers.masterTune=(tune<<11)*(1.0/12); } if(param_num==144 || param_num==134) diff --git a/src/dexed.h b/src/dexed.h index fb97097..5785f5e 100644 --- a/src/dexed.h +++ b/src/dexed.h @@ -136,7 +136,7 @@ class Dexed : public lvtk::Synth 03, 24, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 63, - 12, 12, 12, 12, 00}; + 01, 12, 12, 12, 00}; }; #endif // PLUGINPROCESSOR_H_INCLUDED diff --git a/src/dexed.mh b/src/dexed.mh index b561bb4..4c0fa64 100644 --- a/src/dexed.mh +++ b/src/dexed.mh @@ -25,3 +25,10 @@ add https://github.com/dcoredump/dexed.lv2 0 connect system:midi_capture_1 effect_0:midi_in connect effect_0:audio_out system:playback_1 connect effect_0:audio_out system:playback_2 + +dexed.lv2 triggered from Kawai MP5 (Variant) +-------------------------------------------- +add https://github.com/dcoredump/dexed.lv2 0 +connect ttymidi:MIDI_in effect_0:midi_in +connect effect_0:audio_out system:playback_1 +connect effect_0:audio_out system:playback_2 diff --git a/src/msfa/controllers.h b/src/msfa/controllers.h index 96143fe..7de904e 100755 --- a/src/msfa/controllers.h +++ b/src/msfa/controllers.h @@ -77,7 +77,7 @@ class Controllers { } public: - int values_[3]; + int32_t values_[3]; char opSwitch[7]; diff --git a/src/msfa/dx7note.cc b/src/msfa/dx7note.cc index 4f88aa2..70ce45b 100644 --- a/src/msfa/dx7note.cc +++ b/src/msfa/dx7note.cc @@ -190,8 +190,7 @@ 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)); -#ifdef PITCHWHEEL - int pitchbend = ctrls->values_[kControllerPitch]; + uint32_t pitchbend = ctrls->values_[kControllerPitch]; int32_t pb = (pitchbend - 0x2000); if (pb != 0) { if (ctrls->values_[kControllerPitchStep] == 0) { @@ -205,9 +204,6 @@ void Dx7Note::compute(int32_t *buf, int32_t lfo_val, int32_t lfo_delay, const Co pitch_mod += pb; 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;