AnalogTapeModel

Physical modelling signal processing for analog tape recording
Log | Files | Refs | Submodules | README | LICENSE

commit 86d27d716c73954b0ead3eda8254c5050a00a578
parent e454b49ce6f8b009bb40b91bde9a31f35b39c8af
Author: jatinchowdhury18 <jatinchowdhury18@gmail.com>
Date:   Mon, 30 Aug 2021 18:09:43 -0700

Fix static analysis issues (#213)

Co-authored-by: jatinchowdhury18 <jatinchowdhury18@users.noreply.github.com>
Diffstat:
MPlugin/Source/GUI/OversamplingMenu.cpp | 2+-
MPlugin/Source/GUI/WowFlutterMenu.cpp | 19+++++++++++++------
MPlugin/Source/PluginProcessor.cpp | 21++++++++++++++-------
MPlugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp | 7+++++--
MPlugin/Source/Processors/Hysteresis/HysteresisProcessor.h | 4++--
MPlugin/Source/Processors/Loss_Effects/LossFilter.cpp | 2+-
MPlugin/Source/Processors/Loss_Effects/LossFilter.h | 10+++++-----
7 files changed, 41 insertions(+), 24 deletions(-)

diff --git a/Plugin/Source/GUI/OversamplingMenu.cpp b/Plugin/Source/GUI/OversamplingMenu.cpp @@ -66,7 +66,7 @@ void OversamplingMenu::generateComboBoxMenu() bool isSelected = ((int) parameter->convertFrom0to1 (parameter->getValue()) == paramVal) && ! forceOff; item.text = choice; item.colour = isSelected ? Colour (0xFFEAA92C) : Colours::white; - item.action = [&, paramVal, disableSame] { + item.action = [this, paramVal, disableSame, &attachment] { if (disableSame) attachments[4]->setValueAsCompleteGesture (0.0f); attachment->setValueAsCompleteGesture (float (paramVal)); diff --git a/Plugin/Source/GUI/WowFlutterMenu.cpp b/Plugin/Source/GUI/WowFlutterMenu.cpp @@ -58,13 +58,20 @@ WowFlutterMenu::WowFlutterMenu (const ChowtapeModelAudioProcessor& proc, const S auto snycToTapeSpeed = [=, &proc] { const auto& vts = proc.getVTS(); - auto speedParam = dynamic_cast<AudioParameterFloat*> (vts.getParameter ("speed")); - auto speedIps = speedParam->get(); + if (auto speedParam = dynamic_cast<AudioParameterFloat*> (vts.getParameter ("speed"))) + { + auto speedIps = speedParam->get(); - auto motorFreq = speedIps / (6.0f * MathConstants<float>::pi); - auto newRate = isFlutter ? flutterFreqToParam (motorFreq) - : wowFreqToParam (std::sqrt (motorFreq)); - setRateValue (newRate); + auto motorFreq = speedIps / (6.0f * MathConstants<float>::pi); + auto newRate = isFlutter ? flutterFreqToParam (motorFreq) + : wowFreqToParam (std::sqrt (motorFreq)); + setRateValue (newRate); + } + else + { + // speedParam was nullptr! + jassertfalse; + } }; auto syncToRhythm = [=, &proc] (float multipleOfQuarterNote) { diff --git a/Plugin/Source/PluginProcessor.cpp b/Plugin/Source/PluginProcessor.cpp @@ -312,14 +312,21 @@ AudioProcessorEditor* ChowtapeModelAudioProcessor::createEditor() builder->registerLookAndFeel ("PresetsLNF", std::make_unique<PresetsLNF>()); builder->registerLookAndFeel ("SpeedButtonLNF", std::make_unique<SpeedButtonLNF>()); - auto* speedHandle = dynamic_cast<AudioParameterFloat*> (vts.getParameter ("speed")); - for (auto speed : { 3.75f, 7.5f, 15.0f, 30.0f }) + if (auto* speedHandle = dynamic_cast<AudioParameterFloat*> (vts.getParameter ("speed"))) { - magicState.addTrigger ("set_speed_" + String (speed, 2, false), [speedHandle, speed] { - speedHandle->beginChangeGesture(); - speedHandle->setValueNotifyingHost (speedHandle->convertTo0to1 (speed)); - speedHandle->endChangeGesture(); - }); + for (auto speed : { 3.75f, 7.5f, 15.0f, 30.0f }) + { + magicState.addTrigger ("set_speed_" + String (speed, 2, false), [speedHandle, speed] { + speedHandle->beginChangeGesture(); + speedHandle->setValueNotifyingHost (speedHandle->convertTo0to1 (speed)); + speedHandle->endChangeGesture(); + }); + } + } + else + { + // speedHandle was nullptr! + jassertfalse; } #if JUCE_IOS diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp b/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp @@ -215,11 +215,14 @@ void HysteresisProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer& // clip input to avoid unstable hysteresis for (int ch = 0; ch < buffer.getNumChannels(); ++ch) - FloatVectorOperations::clip (buffer.getWritePointer (ch), - buffer.getWritePointer (ch), + { + auto* bufferPtr = buffer.getWritePointer (ch); + FloatVectorOperations::clip (bufferPtr, + bufferPtr, -clipLevel, clipLevel, buffer.getNumSamples()); + } doubleBuffer.makeCopyOf (buffer, true); diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.h b/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.h @@ -58,7 +58,7 @@ private: double fs = 44100.0f; HysteresisProcessing hProcs[2]; - SolverType solver; + SolverType solver = SolverType::RK4; OversamplingManager osManager; // needs oversampling to avoid aliasing DCBlocker dcBlocker[2]; @@ -66,7 +66,7 @@ private: double biasGain = 10.0; double biasFreq = 48000.0; - double biasAngle[2]; + double biasAngle[2] = { 0.0, 0.0 }; bool wasV1 = false, useV1 = false; double clipLevel = 20.0; diff --git a/Plugin/Source/Processors/Loss_Effects/LossFilter.cpp b/Plugin/Source/Processors/Loss_Effects/LossFilter.cpp @@ -122,7 +122,7 @@ void LossFilter::calcCoefs (StereoIIR& filter) auto h = currentCoefs.getRawDataPointer(); for (int n = 0; n < curOrder / 2; n++) { - const size_t idx = size_t (curOrder / 2 + n); + const auto idx = (size_t) curOrder / 2 + (size_t) n; for (int k = 0; k < curOrder; k++) h[idx] += Hcoefs[k] * cosf (MathConstants<float>::twoPi * (float) k * (float) n / (float) curOrder); diff --git a/Plugin/Source/Processors/Loss_Effects/LossFilter.h b/Plugin/Source/Processors/Loss_Effects/LossFilter.h @@ -37,17 +37,17 @@ private: std::atomic<float>* gap = nullptr; std::atomic<float>* azimuth = nullptr; - float prevSpeed; - float prevSpacing; - float prevThickness; - float prevGap; + float prevSpeed = 0.5f; + float prevSpacing = 0.5f; + float prevThickness = 0.5f; + float prevGap = 0.5f; float fs = 44100.0f; float fsFactor = 1.0f; float binWidth = fs / 100.0f; const int order; - int curOrder; + int curOrder = order; Array<float> currentCoefs; Array<float> Hcoefs;