From 2d7a4b6f5f568d7e5cce60acef676e737e440b4a Mon Sep 17 00:00:00 2001 From: tildearrow Date: Sat, 11 Feb 2023 18:51:35 -0500 Subject: [PATCH] is this optimization, or DE-optimization?! --- .../vgsound_emu/src/es550x/es550x.hpp | 2 -- .../vgsound_emu/src/es550x/es550x_filter.cpp | 29 +++++++------------ 2 files changed, 11 insertions(+), 20 deletions(-) diff --git a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es550x.hpp b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es550x.hpp index 75f45a3b..0a9780fc 100644 --- a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es550x.hpp +++ b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es550x.hpp @@ -429,8 +429,6 @@ class es550x_shared_core : public vgsound_emu_core inline s32 o4_1() { return m_o[4][0]; } private: - void lp_exec(s32 coeff, const s32 in, const s32 out); - void hp_exec(s32 coeff, const s32 in, const s32 out); // Registers u8 m_lp = 0; // Filter mode diff --git a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es550x_filter.cpp b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es550x_filter.cpp index afff686d..4bed2214 100644 --- a/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es550x_filter.cpp +++ b/extern/vgsound_emu-modified/vgsound_emu/src/es550x/es550x_filter.cpp @@ -8,6 +8,17 @@ #include "es550x.hpp" + +// Yn = K*(Xn - Yn-1) + Yn-1 +#define lp_exec(coeff,in,out) \ + m_o[out][1] = m_o[out][0]; \ + m_o[out][0] = ((coeff * (m_o[in][0] - m_o[out][0])) / 4096) + m_o[out][0]; + +// Yn = Xn - Xn-1 + K*Yn-1 +#define hp_exec(coeff,in,out) \ + m_o[out][1] = m_o[out][0]; \ + m_o[out][0] = m_o[in][0] - m_o[in][1] + ((coeff * m_o[out][0]) / 8192) + (m_o[out][0] / 2); + // Filter functions void es550x_shared_core::es550x_voice_t::es550x_filter_t::reset() { @@ -49,21 +60,3 @@ void es550x_shared_core::es550x_voice_t::es550x_filter_t::tick(s32 in) break; } } - -void es550x_shared_core::es550x_voice_t::es550x_filter_t::lp_exec(s32 coeff, const s32 in, const s32 out) -{ - // Store previous filter data - m_o[out][1] = m_o[out][0]; - - // Yn = K*(Xn - Yn-1) + Yn-1 - m_o[out][0] = ((coeff * (m_o[in][0] - m_o[out][0])) / 4096) + m_o[out][0]; -} - -void es550x_shared_core::es550x_voice_t::es550x_filter_t::hp_exec(s32 coeff, const s32 in, const s32 out) -{ - // Store previous filter data - m_o[out][1] = m_o[out][0]; - - // Yn = Xn - Xn-1 + K*Yn-1 - m_o[out][0] = m_o[in][0] - m_o[in][1] + ((coeff * m_o[out][0]) / 8192) + (m_o[out][0] / 2); -}