libresidfp  1.2.3
Filter6581.h
1 /*
2  * This file is part of libsidplayfp, a SID player engine.
3  *
4  * Copyright 2011-2026 Leandro Nini <drfiemost@users.sourceforge.net>
5  * Copyright 2007-2010 Antti Lankila
6  * Copyright 2004,2010 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 FILTER6581_H
24 #define FILTER6581_H
25 
26 #include "Filter.h"
27 #include "FilterModelConfig6581.h"
28 #include "Integrator6581.h"
29 
30 #include "siddefs-fp.h"
31 
32 namespace reSIDfp
33 {
34 
35 class Integrator6581;
36 
320 class Filter6581 final : public Filter
321 {
322  friend class State;
323 
324 private:
326  Integrator6581 hpIntegrator;
327 
329  Integrator6581 bpIntegrator;
330 
331  const uint16_t* f0_dac;
332 
333 protected:
337  void updateCenterFrequency() override;
338 
339  void restartIntegrators() override { hpIntegrator.restart(); bpIntegrator.restart(); }
340 
341  /*
342  * The filter input resistors on the 6581 are slightly bigger than the voice ones,
343  * scale the values accordingly.
344  */
345  int32_t getNormalizedMixerVoice(float v, uint8_t env) const override
346  {
347  return getNormalizedVoice(v * static_cast<float>(FilterModelConfig6581::VF_TR_RATIO), env);
348  }
349 
350 public:
351  Filter6581() :
352  Filter(*FilterModelConfig6581::getInstance(), hpIntegrator, bpIntegrator),
353  hpIntegrator(*FilterModelConfig6581::getInstance()),
354  bpIntegrator(*FilterModelConfig6581::getInstance()),
355  f0_dac(FilterModelConfig6581::getInstance()->getDAC(0.5))
356  {}
357 
358  ~Filter6581() override;
359 
366  void setFilterCurve(double curvePosition);
367 
374  static void setFilterRange(double adjustment)
375  {
376  FilterModelConfig6581::getInstance()->setFilterRange(adjustment);
377  }
378 
384  static void enableOldCaps(bool enable)
385  {
386  FilterModelConfig6581::getInstance()->enableOldCaps(enable);
387  }
388 };
389 
390 } // namespace reSIDfp
391 
392 #endif
Definition: Integrator6581.h:164
Definition: Dac.cpp:27
void updateCenterFrequency() override
Definition: Filter6581.cpp:37
void setFilterCurve(double curvePosition)
Definition: Filter6581.cpp:44
static void setFilterRange(double adjustment)
Definition: Filter6581.h:374
Definition: Filter6581.h:320
void enable(bool enable)
Definition: Filter.cpp:129
static void enableOldCaps(bool enable)
Definition: Filter6581.h:384
Definition: Filter.h:38
Definition: State.h:45