Skip to content

Commit

Permalink
Apply clang-tidy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiashienzsch committed May 11, 2024
1 parent f130d52 commit b88cc56
Show file tree
Hide file tree
Showing 20 changed files with 225 additions and 200 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Checks: >
bugprone-*,
-bugprone-macro-parentheses,
-bugprone-chained-comparison,
cert-*,
Expand All @@ -20,10 +21,12 @@ Checks: >
-cppcoreguidelines-avoid-magic-numbers,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-pro-bounds-constant-array-index,
-cppcoreguidelines-pro-bounds-pointer-arithmetic,
hicpp-*,
misc-*,
-misc-include-cleaner,
modernize-*,
Expand Down
8 changes: 4 additions & 4 deletions src/mc/acoustics/absorber/porous_absorber.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ struct PorousAbsorberSpecs
struct PorousAbsorberImpedance
{
// Intermediate term cot(k*ta)
std::complex<double> intermediateTerm{};
std::complex<double> intermediateTerm;

// Impedance at absorber surface (zsa)
std::complex<double> atSurface{};
std::complex<double> atSurface;
};

struct PorousAbsorberProperties
Expand Down Expand Up @@ -66,7 +66,7 @@ struct PorousAbsorberProperties

PorousAbsorberImpedance impedance{};

std::complex<double> reflectionFactorNoAirGap{};
std::complex<double> reflectionFactorNoAirGap;
double absorptionFactorNoAirGap{};

std::complex<double> kAirY{0.0};
Expand All @@ -77,7 +77,7 @@ struct PorousAbsorberProperties
std::complex<double> ki{0};
std::complex<double> zaAir{0};

std::complex<double> reflectionFactorWithAirGap{};
std::complex<double> reflectionFactorWithAirGap;
double absorptionFactorWithAirGap{};
};

Expand Down
2 changes: 1 addition & 1 deletion src/mc/raum_akustik/app/application.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct RaumAkustikApplication : juce::JUCEApplication

private:
juce::AudioDeviceManager _deviceManager;
std::unique_ptr<juce::DocumentWindow> _mainWindow{};
std::unique_ptr<juce::DocumentWindow> _mainWindow;
};

[[nodiscard]] auto raumAkusticApplication() -> RaumAkustikApplication&;
Expand Down
8 changes: 4 additions & 4 deletions src/mc/raum_akustik/app/main_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ struct MainComponent final
auto reloadUI() -> void;
auto toggleFullscreen() -> void;

juce::ApplicationCommandManager _commandManager{};
juce::ApplicationCommandManager _commandManager;
juce::UndoManager _undoManager;
juce::ValueTree _valueTree{"RaumAkustik"};
LookAndFeel _lnf{};
LookAndFeel _lnf;

MenuBar _menuBar{_commandManager};
LevelMeter _levelMeter;
Expand All @@ -47,8 +47,8 @@ struct MainComponent final
juce::TabbedComponent _tabs{juce::TabbedButtonBar::TabsAtTop};
AudioInputView _audioInputView;
GeneratorTab _generatorTab;
std::unique_ptr<FirstReflectionsView> _firstReflectionsView{};
std::unique_ptr<PorousAbsorberSimulationView> _absorberSimulationView{};
std::unique_ptr<FirstReflectionsView> _firstReflectionsView;
std::unique_ptr<PorousAbsorberSimulationView> _absorberSimulationView;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(MainComponent) // NOLINT
};
Expand Down
4 changes: 2 additions & 2 deletions src/mc/raum_akustik/tabs/absorber_simulation_tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace ra {
namespace {
auto positionForFrequency(Hertz<double> const freq) noexcept -> double
{
return (std::log(freq.number() / 20.0) / std::log(2.0)) / 10.0;
return (std::log(freq.number() / 20.0) / std::numbers::ln2) / 10.0;
}

} // namespace
Expand Down Expand Up @@ -85,7 +85,7 @@ PorousAbsorberSimulationView::PorousAbsorberSimulationView(juce::ValueTree vt, j

auto PorousAbsorberSimulationView::paint(juce::Graphics& g) -> void
{
juce::Graphics::ScopedSaveState state{g};
juce::Graphics::ScopedSaveState const state{g};

g.reduceClipRegion(_plotArea);

Expand Down
2 changes: 1 addition & 1 deletion src/mc/raum_akustik/tabs/absorber_simulation_tab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ struct PorousAbsorberSimulationView final
auto updateSimulation() -> void;

juce::TableListBox _table{"Table", this};
juce::PropertyPanel _absorberSpecs{};
juce::PropertyPanel _absorberSpecs;
juce::Rectangle<int> _plotArea;

juce::UndoManager* _undoManager{nullptr};
Expand Down
6 changes: 3 additions & 3 deletions src/mc/raum_akustik/tabs/first_reflections_tab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ struct FirstReflectionsView final
juce::Drawable::createFromImageData(mcbd::insert_emoticon_svg, mcbd::insert_emoticon_svgSize)
};

juce::PropertyPanel _roomProperties{};
juce::PropertyPanel _renderProperties{};
juce::PropertyPanel _roomProperties;
juce::PropertyPanel _renderProperties;

juce::Rectangle<int> _drawArea{};
juce::Rectangle<int> _drawArea;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(FirstReflectionsView) // NOLINT
};
Expand Down
11 changes: 6 additions & 5 deletions src/mc/raum_akustik/tabs/generator_tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ static auto frequencyToX(float minFreq, float maxFreq, float freq, float width)

static auto amplitudeToY(float amplitude, juce::Rectangle<float> const bounds) -> float
{
auto const infinity = -96.0f;
auto const infinity = -96.0F;
auto const dB = juce::Decibels::gainToDecibels(amplitude, infinity);
return juce::jmap(dB, infinity, 0.0f, bounds.getBottom(), bounds.getY());
return juce::jmap(dB, infinity, 0.0F, bounds.getBottom(), bounds.getY());
}

static auto getFrequencyAndAmplitude(std::span<std::complex<float> const> bins, double sampleRate)
Expand All @@ -61,8 +61,9 @@ makePathFromAnalysis(std::span<FrequencyAndAmplitude const> analysis, float fs,
-> juce::Path
{
auto const size = static_cast<int>(analysis.size());
if (size == 0)
if (size == 0) {
return {};
}

auto frequencyLess = [](auto bin, auto target) { return bin.frequency < target; };
auto first = std::lower_bound(begin(analysis), end(analysis), 1.0F, frequencyLess);
Expand All @@ -75,11 +76,11 @@ makePathFromAnalysis(std::span<FrequencyAndAmplitude const> analysis, float fs,

auto const width = bounds.getWidth();
auto const startY = amplitudeToY(first->amplitude, bounds);
p.startNewSubPath(bounds.getX() + frequencyToX(1.0f, fs * 0.5F, first->frequency, width), startY);
p.startNewSubPath(bounds.getX() + frequencyToX(1.0F, fs * 0.5F, first->frequency, width), startY);

for (; first != end(analysis); ++first) {
auto const y = amplitudeToY(first->amplitude, bounds);
p.lineTo(bounds.getX() + frequencyToX(1.0f, fs * 0.5F, first->frequency, width), y);
p.lineTo(bounds.getX() + frequencyToX(1.0F, fs * 0.5F, first->frequency, width), y);
}

return p;
Expand Down
8 changes: 4 additions & 4 deletions src/mc/raum_akustik/tabs/generator_tab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ struct GeneratorTab final
auto valueTreePropertyChanged(juce::ValueTree& tree, juce::Identifier const& property) -> void override;

private:
juce::PropertyPanel _sweepSpecPanel{};
juce::PropertyPanel _sweepSpecPanel;
MeasurementRecorderEditor _recorder;
juce::Rectangle<int> _thumbnailBounds{};
juce::Rectangle<int> _spectrumBounds{};
juce::Rectangle<int> _thumbnailBounds;
juce::Rectangle<int> _spectrumBounds;

juce::UndoManager* _undoManager{nullptr};
juce::ValueTree _valueTree{"SineSweep"};
Expand All @@ -38,7 +38,7 @@ struct GeneratorTab final
juce::CachedValue<double> _sampleRate{_valueTree, "sampleRate", _undoManager};

juce::AudioFormatManager _formatManager;
juce::AudioBuffer<float> _thumbnailBuffer{};
juce::AudioBuffer<float> _thumbnailBuffer;
juce::AudioThumbnailCache _thumbnailCache{1};
juce::AudioThumbnail _thumbnail{32, _formatManager, _thumbnailCache};

Expand Down
Loading

0 comments on commit b88cc56

Please sign in to comment.