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