From b7dae6a4b62b11b4230f6e3eac537d2043effd2f Mon Sep 17 00:00:00 2001 From: Martmists Date: Wed, 28 Jul 2021 23:50:34 +0200 Subject: [PATCH] work on HighShelf --- CMakeLists.txt | 1 + src/utils/HighShelf.cpp | 31 +++++++++++++++++++++++++++++++ src/utils/HighShelf.h | 25 +++++++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100644 src/utils/HighShelf.cpp create mode 100644 src/utils/HighShelf.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e3be1a8..2d5c2cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ set(FILES src/utils/DepthSurround.cpp src/utils/DynamicBass.cpp src/utils/FixedBiquad.cpp + src/utils/HighShelf.cpp src/utils/IIR_1st.cpp src/utils/IIR_NOrder_BW_BP.cpp src/utils/IIR_NOrder_BW_LH.cpp diff --git a/src/utils/HighShelf.cpp b/src/utils/HighShelf.cpp new file mode 100644 index 0000000..da77538 --- /dev/null +++ b/src/utils/HighShelf.cpp @@ -0,0 +1,31 @@ +// +// Created by mart on 7/28/21. +// + +#include +#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 +} diff --git a/src/utils/HighShelf.h b/src/utils/HighShelf.h new file mode 100644 index 0000000..f804588 --- /dev/null +++ b/src/utils/HighShelf.h @@ -0,0 +1,25 @@ +// +// Created by mart on 7/28/21. +// + +#pragma once +#include + +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; +}; + + +