rlm@0: // Simple low-pass and high-pass filter to better match sound output of a SNES rlm@0: rlm@0: // snes_spc 0.9.0 rlm@0: #ifndef SPC_FILTER_H rlm@0: #define SPC_FILTER_H rlm@0: rlm@0: #include "blargg_common.h" rlm@0: rlm@0: struct SPC_Filter { rlm@0: public: rlm@0: rlm@0: // Filters count samples of stereo sound in place. Count must be a multiple of 2. rlm@0: typedef short sample_t; rlm@0: void run( sample_t* io, int count ); rlm@0: rlm@0: // Optional features rlm@0: rlm@0: // Clears filter to silence rlm@0: void clear(); rlm@0: rlm@0: // Sets gain (volume), where gain_unit is normal. Gains greater than gain_unit rlm@0: // are fine, since output is clamped to 16-bit sample range. rlm@0: enum { gain_unit = 0x100 }; rlm@0: void set_gain( int gain ); rlm@0: rlm@0: // Sets amount of bass (logarithmic scale) rlm@0: enum { bass_none = 0 }; rlm@0: enum { bass_norm = 8 }; // normal amount rlm@0: enum { bass_max = 31 }; rlm@0: void set_bass( int bass ); rlm@0: rlm@0: public: rlm@0: SPC_Filter(); rlm@0: BLARGG_DISABLE_NOTHROW rlm@0: private: rlm@0: enum { gain_bits = 8 }; rlm@0: int gain; rlm@0: int bass; rlm@0: struct chan_t { int p1, pp1, sum; }; rlm@0: chan_t ch [2]; rlm@0: }; rlm@0: rlm@0: inline void SPC_Filter::set_gain( int g ) { gain = g; } rlm@0: rlm@0: inline void SPC_Filter::set_bass( int b ) { bass = b; } rlm@0: rlm@0: #endif