commit 981c44523e7da6af525054ce38be096b2c9ea426
parent 7533091a6558a49e6d347eb9b4ec01e607505f21
Author: jatinchowdhury18 <[email protected]>
Date: Sat, 6 Mar 2021 06:02:15 -0800
Attempt to fix (most) compiler warnings (#150)
* Attempt to fix (most) compiler warnings
* Adjust warning flags for GCC and VS2019
* More warning flag adjustments
* More warning flag adjustments
Diffstat:
13 files changed, 78 insertions(+), 38 deletions(-)
diff --git a/Plugin/Source/GUI/MyLNF.cpp b/Plugin/Source/GUI/MyLNF.cpp
@@ -194,7 +194,7 @@ void MyLNF::drawLinearSlider (Graphics& g, int x, int y, int width, int height,
g.strokePath (backgroundTrack, { trackWidth, PathStrokeType::curved, PathStrokeType::rounded });
Path valueTrack;
- Point<float> minPoint, maxPoint, thumbPoint;
+ Point<float> minPoint, maxPoint;
{
auto kx = slider.isHorizontal() ? sliderPos : ((float) x + (float) width * 0.5f);
diff --git a/Plugin/Source/GUI/TapeScope.cpp b/Plugin/Source/GUI/TapeScope.cpp
@@ -8,14 +8,18 @@ constexpr int rmsMS = 5000; // rms window milliseconds
constexpr float xPad = 3.0f;
} // namespace
-void TapeScope::prepareToPlay (int numChannels, double newSampleRate, int samplesPerBlockExpected)
+TapeScope::TapeScope (int numChannels) : numChannels (numChannels)
+{
+}
+
+void TapeScope::prepareToPlay (double newSampleRate, int samplesPerBlockExpected)
{
MagicOscilloscope::prepareToPlay (newSampleRate, samplesPerBlockExpected);
inputSource.setupSource (numChannels, newSampleRate, rmsMS, rmsMS);
outputSource.setupSource (numChannels, newSampleRate, rmsMS, rmsMS);
}
-void TapeScope::pushSamples (const AudioBuffer<float>& buffer, AudioType type)
+void TapeScope::pushSamplesIO (const AudioBuffer<float>& buffer, AudioType type)
{
switch (type)
{
diff --git a/Plugin/Source/GUI/TapeScope.h b/Plugin/Source/GUI/TapeScope.h
@@ -6,7 +6,7 @@
class TapeScope : public foleys::MagicOscilloscope
{
public:
- TapeScope() = default;
+ TapeScope (int numChannels);
~TapeScope() = default;
enum AudioType
@@ -15,8 +15,8 @@ public:
Output,
};
- void prepareToPlay (int numChannels, double sampleRate, int samplesPerBlockExpected);
- void pushSamples (const AudioBuffer<float>& buffer, AudioType type);
+ void prepareToPlay (double sampleRate, int samplesPerBlockExpected) override;
+ void pushSamplesIO (const AudioBuffer<float>& buffer, AudioType type);
void createPlotPaths (Path& path, Path& filledPath, Rectangle<float> bounds, foleys::MagicPlotComponent& component) override;
@@ -24,6 +24,8 @@ private:
foleys::MagicLevelSource inputSource;
foleys::MagicLevelSource outputSource;
+ const int numChannels;
+
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TapeScope)
};
diff --git a/Plugin/Source/MixGroups/MixGroupsSharedData.cpp b/Plugin/Source/MixGroups/MixGroupsSharedData.cpp
@@ -43,7 +43,7 @@ int MixGroupsSharedData::getNumPluginsInGroup (int mixGroup) const
void MixGroupsSharedData::copyPluginState (int mixGroup, AudioProcessorValueTreeState& vts)
{
- auto paramMap = paramMaps[mixGroup - 1].get();
+ auto paramMap = paramMaps[(size_t) mixGroup - 1].get();
auto mapIter = paramMap->begin();
while (mapIter.next())
{
@@ -54,11 +54,11 @@ void MixGroupsSharedData::copyPluginState (int mixGroup, AudioProcessorValueTree
void MixGroupsSharedData::setParameter (const String& paramID, int mixGroup, float value, String uuid)
{
- paramMaps[mixGroup - 1]->set (paramID, value);
+ paramMaps[(size_t) mixGroup - 1]->set (paramID, value);
listeners.call (&Listener::mixGroupParamChanged, paramID, mixGroup, value, uuid);
}
float MixGroupsSharedData::getParameter (const String& paramID, int mixGroup) const
{
- return paramMaps[mixGroup - 1]->operator[] (paramID);
+ return paramMaps[(size_t) mixGroup - 1]->operator[] (paramID);
}
diff --git a/Plugin/Source/PluginProcessor.cpp b/Plugin/Source/PluginProcessor.cpp
@@ -42,7 +42,7 @@ ChowtapeModelAudioProcessor::ChowtapeModelAudioProcessor()
onOffManager (vts, this),
mixGroupsController (vts, this)
{
- scope = magicState.createAndAddObject<TapeScope> ("scope");
+ scope = magicState.createAndAddObject<TapeScope> ("scope", getMainBusNumInputChannels());
flutter.initialisePlots (magicState);
LookAndFeel::setDefaultLookAndFeel (&myLNF);
@@ -173,7 +173,7 @@ void ChowtapeModelAudioProcessor::prepareToPlay (double sampleRate, int samplesP
flutter.prepareToPlay (sampleRate, samplesPerBlock);
outGain.prepareToPlay (sampleRate, samplesPerBlock);
- scope->prepareToPlay (getMainBusNumInputChannels(), sampleRate, samplesPerBlock);
+ scope->prepareToPlay (sampleRate, samplesPerBlock);
dryWet.setDryWet (*vts.getRawParameterValue ("drywet") / 100.0f);
dryWet.reset();
@@ -237,7 +237,7 @@ void ChowtapeModelAudioProcessor::processBlock (AudioBuffer<float>& buffer, Midi
inGain.processBlock (buffer, midiMessages);
inputFilters.processBlock (buffer);
- scope->pushSamples (buffer, TapeScope::AudioType::Input);
+ scope->pushSamplesIO (buffer, TapeScope::AudioType::Input);
toneControl.processBlockIn (buffer);
hysteresis.processBlock (buffer, midiMessages);
@@ -253,7 +253,7 @@ void ChowtapeModelAudioProcessor::processBlock (AudioBuffer<float>& buffer, Midi
outGain.processBlock (buffer, midiMessages);
dryWet.processBlock (dryBuffer, buffer);
- scope->pushSamples (buffer, TapeScope::AudioType::Output);
+ scope->pushSamplesIO (buffer, TapeScope::AudioType::Output);
}
void ChowtapeModelAudioProcessor::latencyCompensation()
diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp b/Plugin/Source/Processors/Hysteresis/HysteresisProcessor.cpp
@@ -147,7 +147,7 @@ void HysteresisProcessor::prepareToPlay (double sampleRate, int samplesPerBlock)
}
for (int i = 0; i < 5; ++i)
- overSample[i]->initProcessing (samplesPerBlock);
+ overSample[i]->initProcessing ((size_t) samplesPerBlock);
prevOS = curOS;
for (int ch = 0; ch < 2; ++ch)
@@ -225,10 +225,10 @@ void HysteresisProcessor::processBlock (AudioBuffer<float>& buffer, MidiBuffer&
void HysteresisProcessor::process (dsp::AudioBlock<float>& block)
{
- for (int channel = 0; channel < block.getNumChannels(); ++channel)
+ for (size_t channel = 0; channel < block.getNumChannels(); ++channel)
{
auto* x = block.getChannelPointer (channel);
- for (int samp = 0; samp < block.getNumSamples(); samp++)
+ for (size_t samp = 0; samp < block.getNumSamples(); samp++)
{
x[samp] = (float) hProcs[channel].process ((double) x[samp]) * makeup[channel].getNextValue();
}
@@ -237,10 +237,10 @@ void HysteresisProcessor::process (dsp::AudioBlock<float>& block)
void HysteresisProcessor::processSmooth (dsp::AudioBlock<float>& block)
{
- for (int channel = 0; channel < block.getNumChannels(); ++channel)
+ for (size_t channel = 0; channel < block.getNumChannels(); ++channel)
{
auto* x = block.getChannelPointer (channel);
- for (int samp = 0; samp < block.getNumSamples(); samp++)
+ for (size_t samp = 0; samp < block.getNumSamples(); samp++)
{
hProcs[channel].cook (drive[channel].getNextValue(), width[channel].getNextValue(), sat[channel].getNextValue(), false);
@@ -253,10 +253,10 @@ void HysteresisProcessor::processV1 (dsp::AudioBlock<float>& block)
{
const auto angleDelta = MathConstants<float>::twoPi * biasFreq / (fs * overSamplingFactor);
- for (int channel = 0; channel < block.getNumChannels(); ++channel)
+ for (size_t channel = 0; channel < block.getNumChannels(); ++channel)
{
auto* x = block.getChannelPointer (channel);
- for (int samp = 0; samp < block.getNumSamples(); samp++)
+ for (size_t samp = 0; samp < block.getNumSamples(); samp++)
{
float bias = biasGain * (1.0f - width[channel].getCurrentValue()) * std::sin (biasAngle[channel]);
biasAngle[channel] += angleDelta;
@@ -273,10 +273,10 @@ void HysteresisProcessor::processSmoothV1 (dsp::AudioBlock<float>& block)
{
const auto angleDelta = MathConstants<float>::twoPi * biasFreq / (fs * overSamplingFactor);
- for (int channel = 0; channel < block.getNumChannels(); ++channel)
+ for (size_t channel = 0; channel < block.getNumChannels(); ++channel)
{
auto* x = block.getChannelPointer (channel);
- for (int samp = 0; samp < block.getNumSamples(); samp++)
+ for (size_t samp = 0; samp < block.getNumSamples(); samp++)
{
hProcs[channel].cook (drive[channel].getNextValue(), width[channel].getNextValue(), sat[channel].getNextValue(), true);
diff --git a/Plugin/Source/Processors/Hysteresis/HysteresisSTN.cpp b/Plugin/Source/Processors/Hysteresis/HysteresisSTN.cpp
@@ -15,12 +15,12 @@ static std::array<String, HysteresisSTN::numSatModels> satTags { "0", "5", "10",
constexpr size_t getSatIdx (float satParam)
{
- return std::clamp (static_cast<int> (satIdxMult * satParam), 0, HysteresisSTN::numSatModels - 1);
+ return (size_t) std::clamp (static_cast<int> (satIdxMult * satParam), 0, HysteresisSTN::numSatModels - 1);
}
constexpr size_t getWidthIdx (float widthParam)
{
- return std::clamp (static_cast<int> (widthIdxMult * widthParam), 0, HysteresisSTN::numWidthModels - 1);
+ return (size_t) std::clamp (static_cast<int> (widthIdxMult * widthParam), 0, HysteresisSTN::numWidthModels - 1);
}
std::unique_ptr<MemoryInputStream> getModelFileStream (const String& modelFile)
diff --git a/Plugin/Source/Processors/Input_Filters/InputFilters.cpp b/Plugin/Source/Processors/Input_Filters/InputFilters.cpp
@@ -78,8 +78,8 @@ void InputFilters::processBlock (AudioBuffer<float>& buffer)
for (int n = 0; n < buffer.getNumSamples(); ++n)
{
- lowCutFilter.processSample (ch, data[n], cutLowSignal[n], data[n]);
- highCutFilter.processSample (ch, data[n], data[n], cutHighSignal[n]);
+ lowCutFilter.processSample ((size_t) ch, data[n], cutLowSignal[n], data[n]);
+ highCutFilter.processSample ((size_t) ch, data[n], data[n], cutHighSignal[n]);
}
}
diff --git a/Plugin/Source/Processors/Loss_Effects/LossFilter.cpp b/Plugin/Source/Processors/Loss_Effects/LossFilter.cpp
@@ -121,7 +121,7 @@ void LossFilter::calcCoefs (StereoIIR& filter)
auto h = currentCoefs.getRawDataPointer();
for (int n = 0; n < curOrder / 2; n++)
{
- const size_t idx = curOrder / 2 + n;
+ const size_t idx = size_t (curOrder / 2 + 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/Timing_Effects/FlutterProcess.cpp b/Plugin/Source/Processors/Timing_Effects/FlutterProcess.cpp
@@ -2,7 +2,7 @@
void FlutterProcess::prepare (double sampleRate, int samplesPerBlock)
{
- fs = fs;
+ fs = (float) sampleRate;
for (int ch = 0; ch < 2; ++ch)
{
diff --git a/Plugin/Source/Processors/Timing_Effects/WowFlutterProcessor.cpp b/Plugin/Source/Processors/Timing_Effects/WowFlutterProcessor.cpp
@@ -1,11 +1,6 @@
#include "WowFlutterProcessor.h"
#include "../../GUI/LightMeter.h"
-namespace
-{
-constexpr float depthSlewMin = 0.001f;
-}
-
WowFlutterProcessor::WowFlutterProcessor (AudioProcessorValueTreeState& vts)
{
flutterRate = vts.getRawParameterValue ("rate");
diff --git a/Plugin/modules/CMakeLists.txt b/Plugin/modules/CMakeLists.txt
@@ -6,6 +6,7 @@ else()
endif()
juce_add_modules(foleys_gui_magic)
juce_add_modules(chowdsp_utils)
+include(WarningFlags.cmake)
# Using RTNeural with XSimd backend
set(RTNEURAL_XSIMD ON CACHE BOOL "Use RTNeural with XSimd backend" FORCE)
@@ -23,7 +24,7 @@ target_link_libraries(juce_plugin_modules
PUBLIC
juce::juce_recommended_config_flags
juce::juce_recommended_lto_flags
- juce::juce_recommended_warning_flags
+ warning_flags
)
target_compile_definitions(juce_plugin_modules
@@ -43,10 +44,6 @@ target_compile_definitions(juce_plugin_modules
$<TARGET_PROPERTY:juce_plugin_modules,COMPILE_DEFINITIONS>
)
-if(MSVC)
- target_compile_options(juce_plugin_modules PRIVATE /wd4458) # supress "declaration hides class member" for Foley's
-endif()
-
target_include_directories(juce_plugin_modules
INTERFACE
$<TARGET_PROPERTY:juce_plugin_modules,INCLUDE_DIRECTORIES>
diff --git a/Plugin/modules/WarningFlags.cmake b/Plugin/modules/WarningFlags.cmake
@@ -0,0 +1,42 @@
+add_library(warning_flags INTERFACE)
+
+if((CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") OR (CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC"))
+ target_compile_options(warning_flags INTERFACE
+ /W4 # base warning level
+ /wd4458 # declaration hides class member (from Foley's GUI Magic)
+ /wd4505 # since VS2019 doesn't handle [[ maybe_unused ]] for static functions (RTNeural::debug_print)
+ )
+elseif((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang"))
+ target_compile_options(warning_flags INTERFACE
+ -Wall -Wshadow-all -Wshorten-64-to-32 -Wstrict-aliasing -Wuninitialized
+ -Wunused-parameter -Wconversion -Wsign-compare -Wint-conversion
+ -Wconditional-uninitialized -Woverloaded-virtual -Wreorder
+ -Wconstant-conversion -Wsign-conversion -Wunused-private-field
+ -Wbool-conversion -Wno-extra-semi -Wunreachable-code
+ -Wzero-as-null-pointer-constant -Wcast-align
+ -Wno-inconsistent-missing-destructor-override -Wshift-sign-overflow
+ -Wnullable-to-nonnull-conversion -Wno-missing-field-initializers
+ -Wno-ignored-qualifiers -Wpedantic -Wno-pessimizing-move
+ # These lines suppress some warnings from Foley's GUI Magic and RTNeural.
+ # Comment them out to be more strict.
+ -Wno-shadow-field-in-constructor -Wno-shadow-field -Wno-sign-conversion
+ -Wno-float-conversion -Wno-implicit-float-conversion -Wno-switch-enum
+ )
+elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
+ target_compile_options(warning_flags INTERFACE
+ -Wall -Wextra -Wstrict-aliasing -Wuninitialized -Wunused-parameter
+ -Wsign-compare -Woverloaded-virtual -Wreorder -Wunreachable-code
+ -Wzero-as-null-pointer-constant -Wcast-align -Wno-implicit-fallthrough
+ -Wno-maybe-uninitialized -Wno-missing-field-initializers -Wno-pedantic
+ -Wno-ignored-qualifiers -Wno-unused-function -Wno-pessimizing-move
+ # These lines suppress some warnings from Foley's GUI Magic and RTNeural.
+ # Comment them out to be more strict.
+ -Wno-sign-conversion -Wno-switch-enum -Wno-overloaded-virtual
+ # From LV2 Wrapper
+ -Wno-parentheses -Wno-deprecated-declarations -Wno-redundant-decls
+ )
+
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "7.0.0")
+ target_compile_options(warning_flags INTERFACE "-Wno-strict-overflow")
+ endif()
+endif()