Mercurial > spc_convert
diff snes_spc/SPC_Filter.h @ 0:e38dacceb958
initial import
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Fri, 21 Oct 2011 05:53:11 -0700 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/snes_spc/SPC_Filter.h Fri Oct 21 05:53:11 2011 -0700 1.3 @@ -0,0 +1,47 @@ 1.4 +// Simple low-pass and high-pass filter to better match sound output of a SNES 1.5 + 1.6 +// snes_spc 0.9.0 1.7 +#ifndef SPC_FILTER_H 1.8 +#define SPC_FILTER_H 1.9 + 1.10 +#include "blargg_common.h" 1.11 + 1.12 +struct SPC_Filter { 1.13 +public: 1.14 + 1.15 + // Filters count samples of stereo sound in place. Count must be a multiple of 2. 1.16 + typedef short sample_t; 1.17 + void run( sample_t* io, int count ); 1.18 + 1.19 +// Optional features 1.20 + 1.21 + // Clears filter to silence 1.22 + void clear(); 1.23 + 1.24 + // Sets gain (volume), where gain_unit is normal. Gains greater than gain_unit 1.25 + // are fine, since output is clamped to 16-bit sample range. 1.26 + enum { gain_unit = 0x100 }; 1.27 + void set_gain( int gain ); 1.28 + 1.29 + // Sets amount of bass (logarithmic scale) 1.30 + enum { bass_none = 0 }; 1.31 + enum { bass_norm = 8 }; // normal amount 1.32 + enum { bass_max = 31 }; 1.33 + void set_bass( int bass ); 1.34 + 1.35 +public: 1.36 + SPC_Filter(); 1.37 + BLARGG_DISABLE_NOTHROW 1.38 +private: 1.39 + enum { gain_bits = 8 }; 1.40 + int gain; 1.41 + int bass; 1.42 + struct chan_t { int p1, pp1, sum; }; 1.43 + chan_t ch [2]; 1.44 +}; 1.45 + 1.46 +inline void SPC_Filter::set_gain( int g ) { gain = g; } 1.47 + 1.48 +inline void SPC_Filter::set_bass( int b ) { bass = b; } 1.49 + 1.50 +#endif