wip: private method naming conventions

This commit is contained in:
2023-09-10 01:28:48 +04:00
parent d7dd36ccd1
commit 3af5c344f2
10 changed files with 25 additions and 25 deletions

View File

@@ -3,7 +3,7 @@
class BandPassFilter : public Filter { class BandPassFilter : public Filter {
private: private:
void calculate_coefficients() override; void CalculateCoefficients() override;
public: public:
BandPassFilter(Filter* filter); BandPassFilter(Filter* filter);

View File

@@ -17,8 +17,8 @@ class Filter : public Effect {
float m_a0, m_a1, m_a2, m_b1, m_b2; float m_a0, m_a1, m_a2, m_b1, m_b2;
float m_z1, m_z2; float m_z1, m_z2;
void calculate_normals(); void CalculateNormals();
virtual void calculate_coefficients(){}; virtual void CalculateCoefficients(){};
public: public:
Filter(/* args */); Filter(/* args */);

View File

@@ -5,22 +5,22 @@
#include "HighPassFilter.h" #include "HighPassFilter.h"
struct FilterFactory { struct FilterFactory {
static Filter* CreateFilter(Filter* oldFilter, FilterType newType) { static Filter* CreateFilter(Filter* old_filter, FilterType new_type) {
Filter* newFilter; Filter* new_filter;
switch (newType) { switch (new_type) {
case LowPass: case LowPass:
newFilter = new LowPassFilter(oldFilter); new_filter = new LowPassFilter(old_filter);
break; break;
case BandPass: case BandPass:
newFilter = new BandPassFilter(oldFilter); new_filter = new BandPassFilter(old_filter);
break; break;
case HighPass: case HighPass:
newFilter = new HighPassFilter(oldFilter); new_filter = new HighPassFilter(old_filter);
break; break;
default: default:
break; break;
} }
return newFilter; return new_filter;
} }
static Filter* GetDefaultFilter() { static Filter* GetDefaultFilter() {

View File

@@ -3,7 +3,7 @@
class HighPassFilter : public Filter { class HighPassFilter : public Filter {
private: private:
void calculate_coefficients() override; void CalculateCoefficients() override;
public: public:
HighPassFilter(); HighPassFilter();

View File

@@ -4,7 +4,7 @@
class LowPassFilter : public Filter { class LowPassFilter : public Filter {
protected: protected:
void calculate_coefficients() override; void CalculateCoefficients() override;
public: public:
LowPassFilter(); LowPassFilter();

View File

@@ -12,8 +12,8 @@ BandPassFilter::BandPassFilter(float freq, float res, float q) {}
BandPassFilter::~BandPassFilter() {} BandPassFilter::~BandPassFilter() {}
void BandPassFilter::calculate_coefficients() { void BandPassFilter::CalculateCoefficients() {
calculate_normals(); CalculateNormals();
m_norm = 1 / (1 + m_k / m_q + m_k * m_k); m_norm = 1 / (1 + m_k / m_q + m_k * m_k);
m_a0 = m_k / m_q * m_norm; m_a0 = m_k / m_q * m_norm;
m_a1 = 0; m_a1 = 0;

View File

@@ -5,7 +5,7 @@ Filter::Filter(/* args */) {}
Filter::~Filter() {} Filter::~Filter() {}
void Filter::calculate_normals() { void Filter::CalculateNormals() {
m_v = powf(10, fabs(m_order) / 20.0); m_v = powf(10, fabs(m_order) / 20.0);
m_k = tanf(M_PI * m_freq); m_k = tanf(M_PI * m_freq);
} }
@@ -16,7 +16,7 @@ void Filter::Release() {}
float Filter::Process(float in) { float Filter::Process(float in) {
// may move to a compile-time dictionary calculation, if needed // may move to a compile-time dictionary calculation, if needed
calculate_coefficients(); CalculateCoefficients();
float out = in * m_a0 + m_z1; float out = in * m_a0 + m_z1;
m_z1 = in * m_a1 + m_z2 - m_b1 * out; m_z1 = in * m_a1 + m_z2 - m_b1 * out;
m_z2 = in * m_a2 - m_b2 * out; m_z2 = in * m_a2 - m_b2 * out;

View File

@@ -12,8 +12,8 @@ HighPassFilter::HighPassFilter(float freq, float res, float q) {}
HighPassFilter::~HighPassFilter() {} HighPassFilter::~HighPassFilter() {}
void HighPassFilter::calculate_coefficients() { void HighPassFilter::CalculateCoefficients() {
calculate_normals(); CalculateNormals();
m_norm = 1 / (1 + m_k / m_q + m_k * m_k); m_norm = 1 / (1 + m_k / m_q + m_k * m_k);
m_a0 = 1 * m_norm; m_a0 = 1 * m_norm;
m_a1 = -2 * m_a0; m_a1 = -2 * m_a0;

View File

@@ -22,8 +22,8 @@ LowPassFilter::LowPassFilter(Filter* filter) {
LowPassFilter::~LowPassFilter() {} LowPassFilter::~LowPassFilter() {}
void LowPassFilter::calculate_coefficients() { void LowPassFilter::CalculateCoefficients() {
calculate_normals(); CalculateNormals();
m_norm = 1 / (1 + m_k / m_q + m_k * m_k); m_norm = 1 / (1 + m_k / m_q + m_k * m_k);
m_a0 = m_k * m_k * m_norm; m_a0 = m_k * m_k * m_norm;
m_a1 = 2 * m_a0; m_a1 = 2 * m_a0;

View File

@@ -96,10 +96,10 @@ void Synth::Release() {
void Synth::AddEffect(Effect* fx) { m_effects.push_back(fx); } void Synth::AddEffect(Effect* fx) { m_effects.push_back(fx); }
void Synth::SetFilter(FilterType type) { void Synth::SetFilter(FilterType type) {
Filter* oldFilter = this->GetFilter(); Filter* old_filter = this->GetFilter();
if (!oldFilter->IsSameFilterType(type)) { if (!old_filter->IsSameFilterType(type)) {
Filter* newFilter = FilterFactory::CreateFilter(oldFilter, type); Filter* new_filter = FilterFactory::CreateFilter(old_filter, type);
delete oldFilter; delete old_filter;
m_effects[1] = newFilter; m_effects[1] = new_filter;
} }
} }