From f647d06181114efd7bbd10266b3c9b9b915b0ee0 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 20 Dec 2016 18:14:16 +0000 Subject: [PATCH] Added original Dexed clipping code. Can be disabled by setting "-DNON_DEXED_CLIP" in Makefile. Added switch for enabling pitch-wheel code - but this code seems currently to broken. For enabling add "-DPITCHWHEEL" in Makefile. Renamed method for calculating which operator is a carrier. Smaller optimizations. --- src/Makefile | 9 ++++++--- src/dexed.cpp | 18 ++++++++++++------ src/manifest.ttl | 5 +++-- src/msfa/dx7note.cc | 7 ++++--- src/msfa/fm_core.cc | 2 +- src/msfa/fm_core.h | 2 +- 6 files changed, 27 insertions(+), 16 deletions(-) diff --git a/src/Makefile b/src/Makefile index 736b7c2..4812348 100644 --- a/src/Makefile +++ b/src/Makefile @@ -5,6 +5,9 @@ OBJ=fm_core.o env.o lfo.o dx7note.o sin.o pitchenv.o fm_op_kernel.o freqlut.o ex 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+=-DNON_DEXED_CLIP # enable for non-dexed-cliping code +#CFLAGS_OPTIONS+=-DPITCHWHEEL # enable for adding pitchwheel code + ifeq ($(ARCH),) ARCH := $(shell uname -m) endif @@ -41,13 +44,13 @@ endif ifeq ($(DEBUG), 1) ifeq ($(FILETRACE), 1) - CXXFLAGS += -DDEBUG -DFILETRACE $(CFLAGS) + CXXFLAGS += -DDEBUG -DFILETRACE $(CFLAGS) $(CFLAGS_OPTIONS) else - CXXFLAGS += -DDEBUG $(CFLAGS) + CXXFLAGS += -DDEBUG $(CFLAGS) $(CFLAGS_OPTIONS) endif else #CXXFLAGS += -Ofast $(CFLAGS) $(CPU) $(FPU) - CXXFLAGS += $(CFLAGS) -O3 -mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mvectorize-with-neon-quad + CXXFLAGS += $(CFLAGS) $(CFLAGS_OPTIONS) -O3 -mcpu=cortex-a7 -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard -mvectorize-with-neon-quad endif all: $(BUNDLE) Makefile diff --git a/src/dexed.cpp b/src/dexed.cpp index 89fde5e..887ae4f 100644 --- a/src/dexed.cpp +++ b/src/dexed.cpp @@ -428,11 +428,14 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer) if (voices[note].live) { voices[note].dx7_note->compute(audiobuf.get(), lfovalue, lfodelay, &controllers); for (uint32_t j=0; j < N; ++j) { - /*int32_t val = audiobuf.get()[j]; +#ifndef NON_DEXED_CLIP + int32_t val = audiobuf.get()[j]; val = val >> 4; int32_t clip_val = val < -(1 << 24) ? 0x8000 : val >= (1 << 24) ? 0x7fff : val >> 9; - float f = static_cast(clip_val)/0x8000; */ + float f = static_cast(clip_val)/0x8000; +#else float f=static_cast(audiobuf.get()[j]<<2)/INT_MAX; +#endif if(f>1.0) f=1.0; if(f<-1.0) @@ -457,7 +460,7 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer) if(++_param_counter%32) { - uint8_t op_out=controllers.core->op_out(data[134]); // look for carriers + uint8_t op_carrier=controllers.core->get_carrier_operators(data[134]); // look for carriers for(i=0;i < MAX_ACTIVE_NOTES;i++) { @@ -470,8 +473,10 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer) for(uint8_t op=0;op<6;op++) { - TRACE("op=%d op_out=%d 2^op=%d %d",op,op_out,static_cast(pow(2,op)),op_out&static_cast(pow(2,op))); - if((op_out&static_cast(pow(2,op)))>0) + 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! op_carrier_num++; @@ -484,7 +489,8 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer) } if(op_amp==op_carrier_num) { - voices[i].live=false; // every carrier produces no audio anymore + // all carrier-operators are silent -> disable the voice + voices[i].live=false; TRACE("Shutting down Voice[%2d]",i); } } diff --git a/src/manifest.ttl b/src/manifest.ttl index 1a0f626..46bd940 100644 --- a/src/manifest.ttl +++ b/src/manifest.ttl @@ -8,17 +8,18 @@ @prefix foaf: . - a lv2:Plugin ; + a lv2:Plugin, doap:Project, lv2:SynthPlugin ; doap:name "Dexed" ; doap:description "Synth" ; doap:shortdesc "Dexed" ; - lv2:minorVersion 1; lv2:microVersion 0; doap:homepage ; doap:maintainer [ foaf:name "dcoredump" ; foaf:homepage ; foaf:mbox ; ] ; + rdfs:comment "Dexed.lv2 is a native LV2 port of the famous DX-7 emulator Dexed."; + lv2:microVersion 1 ;lv2:minorVersion 0 ; doap:developer [ a foaf:Person ; foaf:name "Pascal Gauthier" ; diff --git a/src/msfa/dx7note.cc b/src/msfa/dx7note.cc index 7250690..4f88aa2 100644 --- a/src/msfa/dx7note.cc +++ b/src/msfa/dx7note.cc @@ -190,7 +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]; int32_t pb = (pitchbend - 0x2000); if (pb != 0) { @@ -204,8 +204,9 @@ 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"); + +TRACE("pitch_mod=%d pb=%d"); +#endif // ==== AMP MOD ==== uint32_t amod_1 = ((int64_t) ampmoddepth_ * (int64_t) lfo_delay) >> 8; // Q24 :D diff --git a/src/msfa/fm_core.cc b/src/msfa/fm_core.cc index 0d26941..c2fb911 100644 --- a/src/msfa/fm_core.cc +++ b/src/msfa/fm_core.cc @@ -68,7 +68,7 @@ int n_out(const FmAlgorithm &alg) { return count; } -uint8_t FmCore::op_out(uint8_t algorithm) +uint8_t FmCore::get_carrier_operators(uint8_t algorithm) { uint8_t op_out=0; FmAlgorithm alg=algorithms[algorithm]; diff --git a/src/msfa/fm_core.h b/src/msfa/fm_core.h index af134cb..4062244 100644 --- a/src/msfa/fm_core.h +++ b/src/msfa/fm_core.h @@ -48,7 +48,7 @@ class FmCore { public: virtual ~FmCore() {}; static void dump(); - uint8_t op_out(uint8_t algorithm); + uint8_t get_carrier_operators(uint8_t algorithm); virtual void render(int32_t *output, FmOpParams *params, int algorithm, int32_t *fb_buf, int32_t feedback_gain); protected: AlignedBufbuf_[2];