work on HighShelf

This commit is contained in:
Martmists 2021-07-28 23:50:34 +02:00
parent 5d83c1356c
commit b7dae6a4b6
3 changed files with 57 additions and 0 deletions

View File

@ -32,6 +32,7 @@ set(FILES
src/utils/DepthSurround.cpp src/utils/DepthSurround.cpp
src/utils/DynamicBass.cpp src/utils/DynamicBass.cpp
src/utils/FixedBiquad.cpp src/utils/FixedBiquad.cpp
src/utils/HighShelf.cpp
src/utils/IIR_1st.cpp src/utils/IIR_1st.cpp
src/utils/IIR_NOrder_BW_BP.cpp src/utils/IIR_NOrder_BW_BP.cpp
src/utils/IIR_NOrder_BW_LH.cpp src/utils/IIR_NOrder_BW_LH.cpp

31
src/utils/HighShelf.cpp Normal file
View File

@ -0,0 +1,31 @@
//
// Created by mart on 7/28/21.
//
#include <cmath>
#include "HighShelf.h"
float HighShelf::Process(float sample) {
float out = sample * this->b0 + this->x_1 * this->b1 + this->x_2 * this->b2 + this->y_1 * this->a1 + this->y_2 * this->a2;
this->y_2 = this->y_1;
this->y_1 = out;
this->x_2 = this->x_1;
this->x_1 = sample;
return out;
}
void HighShelf::SetFrequency(uint32_t freq) {
this->frequency = freq;
}
void HighShelf::SetGain(float gain) {
this->gain = 20.f * log10f(gain);
}
void HighShelf::SetQuality(float q) {
this->quality = q
}
void HighShelf::SetSamplingRate(uint32_t samplerate) {
// TODO
}

25
src/utils/HighShelf.h Normal file
View File

@ -0,0 +1,25 @@
//
// Created by mart on 7/28/21.
//
#pragma once
#include <cstdint>
class HighShelf {
public:
float Process(float sample);
void SetFrequency(uint32_t freq);
void SetGain(float gain);
void SetQuality(float q);
void SetSamplingRate(uint32_t samplerate);
uint32_t frequency, samplerate;
float quality, gain;
float y_2, y_1, x_2, x_1;
float b0, b1, b2, a1, a2;
};