Skip to content

Commit

Permalink
Merge pull request #27 from mike919192/clangtidy
Browse files Browse the repository at this point in the history
Clangtidy
  • Loading branch information
mike919192 authored Dec 5, 2024
2 parents cebb2fb + e9a51a9 commit 4387000
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 68 deletions.
107 changes: 107 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@

---
FormatStyle: 'file'
SystemHeaders: false
WarningsAsErrors: 'readability-identifier-naming'
HeaderFilterRegex: '.*'
HeaderFileExtensions:
- ''
- h
- hh
- hpp
- hxx
ImplementationFileExtensions:
- c
- cc
- cpp
- cxx
- ipp
Checks: "clang-diagnostic-*,
clang-analyzer-*,
*,
-altera-id-dependent-backward-branch,
-altera-unroll-loops,
-bugprone-easily-swappable-parameters,
-cppcoreguidelines-avoid-magic-numbers,
-fuchsia-default-arguments-calls,
-fuchsia-default-arguments-declarations,
-google-readability-braces-around-statements,
-google-readability-namespace-comments,
-hicpp-braces-around-statements,
-llvmlibc-callee-namespace,
-llvmlibc-implementation-in-namespace,
-llvmlibc-inline-function-decl,
-llvmlibc-restrict-system-libc-headers,
-llvm-header-guard,
-llvm-namespace-comment,
-modernize-use-trailing-return-type,
-readability-braces-around-statements,
-readability-identifier-length,
-readability-magic-numbers
"
CheckOptions:
cppcoreguidelines-pro-type-const-cast.StrictMode: true
misc-include-cleaner.IgnoreHeaders: '^.*(?:pch|stdafx)\.h\w*$'
modernize-use-default-member-init.UseAssignment: true
performance-for-range-copy.WarnOnAllAutoCopies: true
readability-identifier-naming.AbstractClassCase: 'lower_case'
readability-identifier-naming.ClassCase: 'lower_case'
readability-identifier-naming.ClassConstantCase: 'lower_case'
readability-identifier-naming.ClassMemberCase: 'lower_case'
readability-identifier-naming.ClassMethodCase: 'lower_case'
readability-identifier-naming.ConceptCase: 'lower_case'
readability-identifier-naming.ConstantCase: 'lower_case'
readability-identifier-naming.ConstantMemberCase: 'lower_case'
readability-identifier-naming.ConstantParameterCase: 'lower_case'
readability-identifier-naming.ConstantPointerParameterCase: 'lower_case'
readability-identifier-naming.ConstexprFunctionCase: 'lower_case'
readability-identifier-naming.ConstexprMethodCase: 'lower_case'
readability-identifier-naming.ConstexprVariableCase: 'lower_case'
readability-identifier-naming.EnumCase: 'lower_case'
readability-identifier-naming.EnumConstantCase: 'lower_case'
readability-identifier-naming.FunctionCase: 'lower_case'
readability-identifier-naming.GlobalConstantCase: 'lower_case'
readability-identifier-naming.GlobalConstantPointerCase: 'lower_case'
readability-identifier-naming.GlobalFunctionCase: 'lower_case'
readability-identifier-naming.GlobalPointerCase: 'lower_case'
readability-identifier-naming.GlobalVariableCase: 'lower_case'
readability-identifier-naming.InlineNamespaceCase: 'lower_case'
readability-identifier-naming.LocalConstantCase: 'lower_case'
readability-identifier-naming.LocalConstantPointerCase: 'lower_case'
readability-identifier-naming.LocalPointerCase: 'lower_case'
readability-identifier-naming.LocalVariableCase: 'lower_case'
readability-identifier-naming.MacroDefinitionCase: 'UPPER_CASE'
readability-identifier-naming.MemberCase: 'lower_case'
readability-identifier-naming.MethodCase: 'lower_case'
readability-identifier-naming.NamespaceCase: 'lower_case'
readability-identifier-naming.ParameterCase: 'lower_case'
readability-identifier-naming.ParameterPackCase: 'lower_case'
readability-identifier-naming.PointerParameterCase: 'lower_case'
readability-identifier-naming.PrivateMemberCase: 'lower_case'
readability-identifier-naming.PrivateMemberPrefix: 'm_'
readability-identifier-naming.PrivateMethodCase: 'lower_case'
readability-identifier-naming.ProtectedMemberCase: 'lower_case'
readability-identifier-naming.ProtectedMemberPrefix: 'm_'
readability-identifier-naming.ProtectedMethodCase: 'lower_case'
readability-identifier-naming.PublicMemberCase: 'lower_case'
readability-identifier-naming.PublicMethodCase: 'lower_case'
readability-identifier-naming.ScopedEnumConstantCase: 'lower_case'
readability-identifier-naming.StaticConstantCase: 'lower_case'
readability-identifier-naming.StaticVariableCase: 'lower_case'
readability-identifier-naming.StructCase: 'lower_case'
readability-identifier-naming.TemplateParameterCase: 'lower_case'
readability-identifier-naming.TemplateParameterSuffix: '_t'
readability-identifier-naming.TemplateTemplateParameterCase: 'lower_case'
readability-identifier-naming.TemplateTemplateParameterSuffix: '_t'
readability-identifier-naming.TypeAliasCase: 'lower_case'
readability-identifier-naming.TypeAliasSuffix: '_t'
readability-identifier-naming.TypedefCase: 'lower_case'
readability-identifier-naming.TypedefSuffix: '_t'
readability-identifier-naming.TypeTemplateParameterCase: 'lower_case'
readability-identifier-naming.TypeTemplateParameterSuffix: '_t'
readability-identifier-naming.UnionCase: 'lower_case'
readability-identifier-naming.ValueTemplateParameterCase: 'lower_case'
readability-identifier-naming.ValueTemplateParameterSuffix: '_t'
readability-identifier-naming.VariableCase: 'lower_case'
readability-identifier-naming.VirtualMethodCase: 'lower_case'
readability-redundant-inline-specifier.StrictMode: true
7 changes: 0 additions & 7 deletions include/sdsp/FilterType.h

This file was deleted.

44 changes: 22 additions & 22 deletions include/sdsp/casc2orderIIR.h → include/sdsp/casc_2o_iir.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once
#include "FilterType.h"
#include "filter_type.h"
#include <array>
#include <cmath>

namespace sdsp
{
template <size_t M>
class casc_2o_IIR {
class casc_2o_iir {
private:
int pos{ 0 };

Expand All @@ -17,15 +17,15 @@ class casc_2o_IIR {
std::array<std::array<double, 3>, M> bCoeff{ 0 };
std::array<std::array<double, 3>, M> aCoeff{ 0 };

FilterType fType{ FilterType::None };
filter_type fType{ filter_type::none };

public:
casc_2o_IIR()
casc_2o_iir()
{
static_assert(M % 2 == 0, "M must be even!");
}

void copy_coeff_from(const casc_2o_IIR<M> &otherFilter)
void copy_coeff_from(const casc_2o_iir<M> &otherFilter)
{
gain = otherFilter.gain;
bCoeff = otherFilter.bCoeff;
Expand Down Expand Up @@ -83,7 +83,7 @@ class casc_2o_IIR {
{
gain = gainIn;
double q2{ 2 * Q };
fType = FilterType::BandPass;
fType = filter_type::band_pass;

double e0{ 2 * M_PI * f0 / fs };
double dnm{ std::sin(e0) };
Expand Down Expand Up @@ -140,7 +140,7 @@ class casc_2o_IIR {
void set_hp_coeff(double f0, double fs, double gainIn = 1.0)
{
gain = gainIn;
fType = FilterType::HighPass;
fType = filter_type::high_pass;

double e0{ 2 * M_PI * f0 / fs };
for (unsigned int k = 0; k < M; k++) {
Expand Down Expand Up @@ -168,7 +168,7 @@ class casc_2o_IIR {
void set_lp_coeff(double f0, double fs, double gainIn = 1.0)
{
gain = gainIn;
fType = FilterType::LowPass;
fType = filter_type::low_pass;

double e0{ 2 * M_PI * f0 / fs };
for (unsigned int k = 0; k < M; k++) {
Expand Down Expand Up @@ -201,7 +201,7 @@ class casc_2o_IIR {
for (int i = 0; i < 3; i++) {
memVals.at(0).at(i) = preload_value;
}
if (fType == FilterType::LowPass) {
if (fType == filter_type::low_pass) {
for (uint j = 1; j < M + 1; j++) {
preload_value /= 1 + aCoeff.at(j - 1).at(1) + aCoeff.at(j - 1).at(2);
preload_value *= bCoeff.at(j - 1).at(0) + bCoeff.at(j - 1).at(1) + bCoeff.at(j - 1).at(2);
Expand All @@ -215,7 +215,7 @@ class casc_2o_IIR {
};

template <size_t M>
class casc_2o_IIR_base {
class casc_2o_iir_base {
protected:
int pos{ 0 };

Expand Down Expand Up @@ -264,14 +264,14 @@ class casc_2o_IIR_base {
};

template <size_t M>
class casc_2o_IIR_lp : casc_2o_IIR_base<M> {
class casc_2o_iir_lp : casc_2o_iir_base<M> {
public:
casc_2o_IIR_lp()
casc_2o_iir_lp()
{
static_assert(M % 2 == 0, "M must be even!");
}

void copy_coeff_from(const casc_2o_IIR_lp<M> &otherFilter)
void copy_coeff_from(const casc_2o_iir_lp<M> &otherFilter)
{
this->gain = otherFilter.gain;
this->aCoeff = otherFilter.aCoeff;
Expand All @@ -280,7 +280,7 @@ class casc_2o_IIR_lp : casc_2o_IIR_base<M> {
template <typename Iter>
void process(Iter begin, Iter end)
{
this->template process_base<casc_2o_IIR_lp<M>>(begin, end);
this->template process_base<casc_2o_iir_lp<M>>(begin, end);
}

static void process_spec(std::array<std::array<double, 3>, M + 1> &y, const std::array<std::array<double, 3>, M> &a,
Expand Down Expand Up @@ -322,14 +322,14 @@ class casc_2o_IIR_lp : casc_2o_IIR_base<M> {
};

template <size_t M>
class casc_2o_IIR_hp : casc_2o_IIR_base<M> {
class casc_2o_iir_hp : casc_2o_iir_base<M> {
public:
casc_2o_IIR_hp()
casc_2o_iir_hp()
{
static_assert(M % 2 == 0, "M must be even!");
}

void copy_coeff_from(const casc_2o_IIR_hp<M> &otherFilter)
void copy_coeff_from(const casc_2o_iir_hp<M> &otherFilter)
{
this->gain = otherFilter.gain;
this->aCoeff = otherFilter.aCoeff;
Expand All @@ -338,7 +338,7 @@ class casc_2o_IIR_hp : casc_2o_IIR_base<M> {
template <typename Iter>
void process(Iter begin, Iter end)
{
this->template process_base<casc_2o_IIR_hp<M>>(begin, end);
this->template process_base<casc_2o_iir_hp<M>>(begin, end);
}

static void process_spec(std::array<std::array<double, 3>, M + 1> &y, const std::array<std::array<double, 3>, M> &a,
Expand Down Expand Up @@ -380,14 +380,14 @@ class casc_2o_IIR_hp : casc_2o_IIR_base<M> {
};

template <size_t M>
class casc_2o_IIR_bp : casc_2o_IIR_base<M> {
class casc_2o_iir_bp : casc_2o_iir_base<M> {
public:
casc_2o_IIR_bp()
casc_2o_iir_bp()
{
static_assert(M % 2 == 0, "M must be even!");
}

void copy_coeff_from(const casc_2o_IIR_bp<M> &otherFilter)
void copy_coeff_from(const casc_2o_iir_bp<M> &otherFilter)
{
this->gain = otherFilter.gain;
this->aCoeff = otherFilter.aCoeff;
Expand All @@ -396,7 +396,7 @@ class casc_2o_IIR_bp : casc_2o_IIR_base<M> {
template <typename Iter>
void process(Iter begin, Iter end)
{
this->template process_base<casc_2o_IIR_bp<M>>(begin, end);
this->template process_base<casc_2o_iir_bp<M>>(begin, end);
}

static void process_spec(std::array<std::array<double, 3>, M + 1> &y, const std::array<std::array<double, 3>, M> &a,
Expand Down
7 changes: 7 additions & 0 deletions include/sdsp/filter_type.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

#pragma once

namespace sdsp
{
enum class filter_type { none = 0, low_pass = 1, high_pass = 2, band_pass = 3 };
}
Loading

0 comments on commit 4387000

Please sign in to comment.