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 {
private:
void calculate_coefficients() override;
void CalculateCoefficients() override;
public:
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_z1, m_z2;
void calculate_normals();
virtual void calculate_coefficients(){};
void CalculateNormals();
virtual void CalculateCoefficients(){};
public:
Filter(/* args */);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -22,8 +22,8 @@ LowPassFilter::LowPassFilter(Filter* filter) {
LowPassFilter::~LowPassFilter() {}
void LowPassFilter::calculate_coefficients() {
calculate_normals();
void LowPassFilter::CalculateCoefficients() {
CalculateNormals();
m_norm = 1 / (1 + m_k / m_q + m_k * m_k);
m_a0 = m_k * m_k * m_norm;
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::SetFilter(FilterType type) {
Filter* oldFilter = this->GetFilter();
if (!oldFilter->IsSameFilterType(type)) {
Filter* newFilter = FilterFactory::CreateFilter(oldFilter, type);
delete oldFilter;
m_effects[1] = newFilter;
Filter* old_filter = this->GetFilter();
if (!old_filter->IsSameFilterType(type)) {
Filter* new_filter = FilterFactory::CreateFilter(old_filter, type);
delete old_filter;
m_effects[1] = new_filter;
}
}