view snes_spc/SPC_Filter.h @ 9:477c36226481 tip

added old scripts for historical interest.
author Robert McIntyre <rlm@mit.edu>
date Fri, 21 Oct 2011 07:46:18 -0700
parents e38dacceb958
children
line wrap: on
line source
1 // Simple low-pass and high-pass filter to better match sound output of a SNES
3 // snes_spc 0.9.0
4 #ifndef SPC_FILTER_H
5 #define SPC_FILTER_H
7 #include "blargg_common.h"
9 struct SPC_Filter {
10 public:
12 // Filters count samples of stereo sound in place. Count must be a multiple of 2.
13 typedef short sample_t;
14 void run( sample_t* io, int count );
16 // Optional features
18 // Clears filter to silence
19 void clear();
21 // Sets gain (volume), where gain_unit is normal. Gains greater than gain_unit
22 // are fine, since output is clamped to 16-bit sample range.
23 enum { gain_unit = 0x100 };
24 void set_gain( int gain );
26 // Sets amount of bass (logarithmic scale)
27 enum { bass_none = 0 };
28 enum { bass_norm = 8 }; // normal amount
29 enum { bass_max = 31 };
30 void set_bass( int bass );
32 public:
33 SPC_Filter();
34 BLARGG_DISABLE_NOTHROW
35 private:
36 enum { gain_bits = 8 };
37 int gain;
38 int bass;
39 struct chan_t { int p1, pp1, sum; };
40 chan_t ch [2];
41 };
43 inline void SPC_Filter::set_gain( int g ) { gain = g; }
45 inline void SPC_Filter::set_bass( int b ) { bass = b; }
47 #endif