libresidfp 1.1.1
ExternalFilter.h
1/*
2 * This file is part of libsidplayfp, a SID player engine.
3 *
4 * Copyright 2011-2025 Leandro Nini <drfiemost@users.sourceforge.net>
5 * Copyright 2007-2010 Antti Lankila
6 * Copyright 2004 Dag Lem <resid@nimrod.no>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23#ifndef EXTERNALFILTER_H
24#define EXTERNALFILTER_H
25
26#include "siddefs-fp.h"
27
28#include <cstdint>
29
30namespace reSIDfp
31{
32
87{
88 friend class State;
89
90private:
92 int32_t Vlp;
93
95 int32_t Vhp;
96
97 int32_t w0lp_1_s7 = 0;
98
99 int32_t w0hp_1_s17 = 0;
100
101public:
108 int32_t clock(int32_t input);
109
114
120 void setClockFrequency(double frequency);
121
125 void reset();
126};
127
128} // namespace reSIDfp
129
130#if RESIDFP_INLINING || defined(EXTERNALFILTER_CPP)
131
132namespace reSIDfp
133{
134
135RESIDFP_INLINE
136int32_t ExternalFilter::clock(int32_t input)
137{
138 const int32_t Vi = input << 11;
139 const int32_t dVlp = (w0lp_1_s7 * (Vi - Vlp) >> 7);
140 const int32_t dVhp = (w0hp_1_s17 * (Vlp - Vhp) >> 17);
141 Vlp += dVlp;
142 Vhp += dVhp;
143 return (Vlp - Vhp) >> 11;
144}
145
146} // namespace reSIDfp
147
148#endif
149
150#endif
Definition ExternalFilter.h:87
void reset()
Definition ExternalFilter.cpp:59
void setClockFrequency(double frequency)
Definition ExternalFilter.cpp:46
int32_t clock(int32_t input)
Definition ExternalFilter.h:136
ExternalFilter()
Definition ExternalFilter.cpp:41
Definition State.h:47