From 37e62dedc6681835ab6282f183a04bf19284424d Mon Sep 17 00:00:00 2001 From: MarcBoule Date: Sun, 15 Oct 2023 15:07:13 -0400 Subject: [PATCH] more minor cleanup, before try move lock from shape to channel --- src/ShapeMaster/Channel.cpp | 12 +++---- src/ShapeMaster/Channel.hpp | 70 ++++++++++++++++++------------------- src/ShapeMaster/Shape.hpp | 2 +- 3 files changed, 41 insertions(+), 43 deletions(-) diff --git a/src/ShapeMaster/Channel.cpp b/src/ShapeMaster/Channel.cpp index 1707bd5..132d05a 100644 --- a/src/ShapeMaster/Channel.cpp +++ b/src/ShapeMaster/Channel.cpp @@ -12,15 +12,8 @@ Channel::Channel(int _chanNum, bool* _running, uint32_t* _sosEosEoc, ClockDetector* _clockDetector, Input* _inputs, Output* _outputs, Param* _params, ParamQuantity* pqReps, PresetAndShapeManager* _presetAndShapeManager) { - // channelSettings.cc1 = 0; - // channelSettings2.cc1 = 0; - // channelSettings3.cc1 = 0; - // channelSettings4.cc1 = 0; - chanNum = _chanNum; running = _running; - hpFilter.setParameters(true, 0.1f); - lpFilter.setParameters(false, 0.4f); if (_inputs) { inInput = &_inputs[IN_INPUTS + chanNum]; scInput = &_inputs[SIDECHAIN_INPUT]; @@ -29,6 +22,9 @@ Channel::Channel(int _chanNum, bool* _running, uint32_t* _sosEosEoc, ClockDetect outOutput = &_outputs[OUT_OUTPUTS + chanNum]; cvOutput = &_outputs[CV_OUTPUTS + chanNum]; } + hpFilter.setParameters(true, 0.1f); + lpFilter.setParameters(false, 0.4f); + paPhase = &_params[PHASE_PARAM + chanNum * NUM_CHAN_PARAMS]; paResponse = &_params[RESPONSE_PARAM + chanNum * NUM_CHAN_PARAMS]; paWarp = &_params[WARP_PARAM + chanNum * NUM_CHAN_PARAMS]; @@ -59,6 +55,7 @@ void Channel::onReset(bool withParams) { paHigh->setValue(DEFAULT_HIGH); paLow->setValue(DEFAULT_LOW); } + slewLimiter.reset(); setHPFCutoffSqFreq(SC_HPF_SQFREQ_DEF); setLPFCutoffSqFreq(SC_LPF_SQFREQ_DEF); sensitivity = DEFAULT_SENSITIVITY; @@ -119,6 +116,7 @@ void Channel::resetNonJson() { warpPhaseResponseAmountCvConnected = false; xoverSlewWithCv = simd::float_4(paCrossover->getValue(), paHigh->getValue(), paLow->getValue(), paSlew->getValue()); xoverSlewCvConnected = false; + nodeTrigPulseGen.reset(); setCrossoverCutoffFreq(); } diff --git a/src/ShapeMaster/Channel.hpp b/src/ShapeMaster/Channel.hpp index 05e3d2d..f8fc58a 100644 --- a/src/ShapeMaster/Channel.hpp +++ b/src/ShapeMaster/Channel.hpp @@ -76,25 +76,25 @@ class Channel { // none // need to save, with reset - Param* paPhase = nullptr; - Param* paResponse = nullptr; - Param* paWarp = nullptr; - Param* paAmount = nullptr; - Param* paSlew = nullptr; - Param* paSmooth = nullptr; - Param* paCrossover = nullptr; - Param* paHigh = nullptr; - Param* paLow = nullptr; - Param* paPrevNextPreSha = nullptr; + Param* paPhase; + Param* paResponse; + Param* paWarp; + Param* paAmount; + Param* paSlew; + Param* paSmooth; + Param* paCrossover; + Param* paHigh; + Param* paLow; + Param* paPrevNextPreSha; SlewLimiterSingle slewLimiter; - float hpfCutoffSqFreq = 0.0f;// always use getter and setter since tied to Biquad - float lpfCutoffSqFreq = 0.0f;// always use getter and setter since tied to Biquad - float sensitivity = 0.0f; - float gainAdjustVca = 0.0f;// this is a gain here (not dB) - float gainAdjustSc = 0.0f;// this is a gain here (not dB) - float nodeTrigDuration = 0.0f; - uint8_t gridX = 0; - int8_t rangeIndex = 0; + float hpfCutoffSqFreq;// always use getter and setter since tied to Biquad + float lpfCutoffSqFreq;// always use getter and setter since tied to Biquad + float sensitivity; + float gainAdjustVca;// this is a gain here (not dB) + float gainAdjustSc;// this is a gain here (not dB) + float nodeTrigDuration; + uint8_t gridX; + int8_t rangeIndex; public: PackedBytes4 channelSettings; PackedBytes4 channelSettings2; @@ -110,35 +110,35 @@ class Channel { // no need to save, with reset - double sampleTime = 0.0f; + double sampleTime; LinkwitzRileyStereo8xCrossover xover; - float lastCrossoverParamWithCv = 0.0f; + float lastCrossoverParamWithCv; ButterworthFourthOrder hpFilter; ButterworthFourthOrder lpFilter; FirstOrderFilter smoothFilter; - float lastSmoothParam = 0.0f; - double lastProcessXt = 0.0; - bool channelActive = false; - int vcaPreSize = 0; - int vcaPostSize = 0; - float scSignal = 0.0f;// implicitly mono - float scEnvelope = 0.0f;// implicitly mono + float lastSmoothParam; + double lastProcessXt; + bool channelActive; + int vcaPreSize; + int vcaPostSize; + float scSignal;// implicitly mono + float scEnvelope;// implicitly mono dsp::SlewLimiter scEnvSlewer; public: simd::float_4 warpPhaseResponseAmountWithCv;// warp = [0] - bool warpPhaseResponseAmountCvConnected = false; + bool warpPhaseResponseAmountCvConnected; simd::float_4 xoverSlewWithCv;// xfreq = [0], xhigh = [1], xlow = [2], slew = [3] (slew unrelated to xvoer) - bool xoverSlewCvConnected = false; + bool xoverSlewCvConnected; private: dsp::PulseGenerator nodeTrigPulseGen; // no need to save, no reset - int chanNum = 0; - bool* running = nullptr; - Input* inInput = nullptr;// use only in process() because of channelDirtyCache and possible nullness - Input* scInput = nullptr;// use only in process() because of channelDirtyCache and possible nullness - Output* outOutput = nullptr;// use only in process() because of channelDirtyCache and possible nullness - Output* cvOutput = nullptr;// use only in process() because of channelDirtyCache and possible nullness + int chanNum; + bool* running; + Input* inInput;// use only in process() because of channelDirtyCache and possible nullness + Input* scInput;// use only in process() because of channelDirtyCache and possible nullness + Output* outOutput;// use only in process() because of channelDirtyCache and possible nullness + Output* cvOutput;// use only in process() because of channelDirtyCache and possible nullness float lengthUnsyncOld = -10.0f;// don't need init nor reset for this, used in caching detection with param that is [-1.0f : 1.0f], used with next line std::string lengthUnsyncTextOld;// used with previous line float vcaPre[16] = {}; diff --git a/src/ShapeMaster/Shape.hpp b/src/ShapeMaster/Shape.hpp index 303bc3d..a0fcca1 100644 --- a/src/ShapeMaster/Shape.hpp +++ b/src/ShapeMaster/Shape.hpp @@ -74,7 +74,7 @@ class Shape { ~Shape() { delete lock_shape; } - + void onReset(); void initMinPts();