From 42316698bf68255cc6c51df8ca742795f3ff7756 Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Sun, 18 Dec 2016 16:30:11 +0000 Subject: [PATCH] Added a function which checks which operators are carriers. This is needed for exclude voices from sound calculation (e.g. voices where all carriers are silent) => more CPU for other things available. --- src/Makefile | 2 +- src/dexed.cpp | 23 +++++++++++++++++------ src/msfa/fm_core.cc | 16 ++++++++++++++++ src/msfa/fm_core.h | 1 + 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/Makefile b/src/Makefile index c8b7971..736b7c2 100644 --- a/src/Makefile +++ b/src/Makefile @@ -41,7 +41,7 @@ endif ifeq ($(DEBUG), 1) ifeq ($(FILETRACE), 1) - CXXFLAGS += -DDEBUG -DFILETRACE $(CFLAGS) -D PATCH_DEBUG + CXXFLAGS += -DDEBUG -DFILETRACE $(CFLAGS) else CXXFLAGS += -DDEBUG $(CFLAGS) endif diff --git a/src/dexed.cpp b/src/dexed.cpp index 4e92ef5..7a0a291 100644 --- a/src/dexed.cpp +++ b/src/dexed.cpp @@ -104,6 +104,10 @@ 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"); @@ -447,18 +451,25 @@ void Dexed::GetSamples(uint32_t n_samples, float* buffer) if(voices[i].live==true && voices[i].keydown==false) { uint8_t op_amp=0; + uint8_t op_out=controllers.core->op_out(data[134]); + uint8_t op_carrier_num=0; voices[i].dx7_note->peekVoiceStatus(voiceStatus); for(uint8_t op=0;op<6;op++) { -// TRACE("Voice[%2d] OP [%d] amp=%ld,amp_step=%d,pitch_step=%d",i,op,voiceStatus.amp[op],voiceStatus.ampStep[op],voiceStatus.pitchStep); - - if(voiceStatus.amp[op]<=1069) - op_amp++; - + if((op_out&op)==1) + { + // this voice is a carrier! + op_carrier_num++; + + TRACE("Voice[%2d] OP [%d] amp=%ld,amp_step=%d,pitch_step=%d",i,op,voiceStatus.amp[op],voiceStatus.ampStep[op],voiceStatus.pitchStep); + + if(voiceStatus.amp[op]<=1069) + op_amp++; + } } - if(op_amp==6) + if(op_amp==op_carrier_num) voices[i].live=false; } // TRACE("Voice[%2d] live=%d keydown=%d",i,voices[i].live,voices[i].keydown); diff --git a/src/msfa/fm_core.cc b/src/msfa/fm_core.cc index a408c55..6001175 100644 --- a/src/msfa/fm_core.cc +++ b/src/msfa/fm_core.cc @@ -68,6 +68,22 @@ int n_out(const FmAlgorithm &alg) { return count; } +uint8_t FmCore::op_out(uint8_t algorithm) +{ + uint8_t op_out=0; + FmAlgorithm alg=algorithms[algorithm]; + + for(uint8_t i=0; i<6;i++) + { + if((alg.ops[i]&OUT_BUS_ADD)==OUT_BUS_ADD) + op_out|=1<buf_[2];