| 1 | // Band-limited sound synthesis buffercxx . . $ `<file>/mednafen/include/blip/Blip_Buffer.h`/ |
| 2 | // Various changes and hacks for use in Mednafen. |
| 3 | |
| 4 | #ifdef __GNUC__cxx . . $ `<built-in>:8:9`! |
| 5 | #define blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! inline __attribute__((always_inline)) |
| 6 | #else |
| 7 | #define blip_inline inline |
| 8 | #endif |
| 9 | |
| 10 | #include <limits.h> |
| 11 | #include <stdint.h> |
| 12 | |
| 13 | // Blip_Buffer 0.4.1 |
| 14 | #ifndef BLIP_BUFFER_H |
| 15 | #define BLIP_BUFFER_Hcxx . . $ `mednafen/include/blip/Blip_Buffer.h:15:9`! |
| 16 | |
| 17 | // Internal |
| 18 | typedef int32_tcxx . . $ int32_t# blip_longcxx . . $ blip_long#; |
| 19 | typedef uint32_tcxx . . $ uint32_t# blip_ulongcxx . . $ blip_ulong#; |
| 20 | typedef int64_tcxx . . $ int64_t# blip_s64cxx . . $ blip_s64#; |
| 21 | typedef uint64_tcxx . . $ uint64_t# blip_u64cxx . . $ blip_u64#; |
| 22 | |
| 23 | // Time unit at source clock rate |
| 24 | typedef blip_longcxx . . $ blip_long# blip_time_tcxx . . $ blip_time_t#; |
| 25 | |
| 26 | // Output samples are 16-bit signed, with a range of -32768 to 32767 |
| 27 | typedef short blip_sample_tcxx . . $ blip_sample_t#; |
| 28 | enumcxx . . $ $anonymous_type_9fbbe4a08064f381_0# { blip_sample_maxcxx . . $ blip_sample_max. = 32767 }; |
| 29 | |
| 30 | class Blip_Buffercxx . . $ Blip_Buffer# { |
| 31 | public: |
| 32 | typedef const char* blargg_err_tcxx . . $ Blip_Buffer#blargg_err_t#; |
| 33 | |
| 34 | // Set output sample rate and buffer length in milliseconds (1/1000 sec, defaults |
| 35 | // to 1/4 second), then clear buffer. Returns NULL on success, otherwise if there |
| 36 | // isn't enough memory, returns error without affecting current buffer setup. |
| 37 | blargg_err_tcxx . . $ Blip_Buffer#blargg_err_t# set_sample_ratecxx . . $ Blip_Buffer#set_sample_rate(ee827314cdea73de).( long samples_per_sec, int msec_length = 1000 / 4 ); |
| 38 | |
| 39 | // Set number of source time units per second |
| 40 | void clock_ratecxx . . $ Blip_Buffer#clock_rate(1624ee8275b10bda).( long ); |
| 41 | |
| 42 | // End current time frame of specified duration and make its samples available |
| 43 | // (along with any still-unread samples) for reading with read_samples(). Begins |
| 44 | // a new time frame at the end of the current frame. |
| 45 | void end_framecxx . . $ Blip_Buffer#end_frame(d4f767463ce0a6b3).( blip_time_tcxx . . $ blip_time_t# time ); |
| 46 | |
| 47 | // Read at most 'max_samples' out of buffer into 'dest', removing them from from |
| 48 | // the buffer. Returns number of samples actually read and removed. If stereo is |
| 49 | // true, increments 'dest' one extra time after writing each sample, to allow |
| 50 | // easy interleving of two channels into a stereo output buffer. |
| 51 | long read_samplescxx . . $ Blip_Buffer#read_samples(44cf187bb4d07f06).( blip_sample_tcxx . . $ blip_sample_t#* dest, long max_samples, int stereo = 0 ); |
| 52 | |
| 53 | // Additional optional features |
| 54 | |
| 55 | // Current output sample rate |
| 56 | long sample_ratecxx . . $ Blip_Buffer#sample_rate(57a65ae535d7db84).() const; |
| 57 | |
| 58 | // Length of buffer, in milliseconds |
| 59 | int lengthcxx . . $ Blip_Buffer#length(455f465bc33b4cdf).() const; |
| 60 | |
| 61 | // Number of source time units per second |
| 62 | long clock_ratecxx . . $ Blip_Buffer#clock_rate(57a65ae535d7db84).() const; |
| 63 | |
| 64 | // Set frequency high-pass filter frequency, where higher values reduce bass more |
| 65 | void bass_freqcxx . . $ Blip_Buffer#bass_freq(d4f767463ce0a6b3).( int frequency ); |
| 66 | |
| 67 | // Number of samples delay from synthesis to samples read out |
| 68 | int output_latencycxx . . $ Blip_Buffer#output_latency(455f465bc33b4cdf).() const; |
| 69 | |
| 70 | // Remove all available samples and clear buffer to silence. If 'entire_buffer' is |
| 71 | // false, just clears out any samples waiting rather than the entire buffer. |
| 72 | void clearcxx . . $ Blip_Buffer#clear(d4f767463ce0a6b3).( int entire_buffer = 1 ); |
| 73 | |
| 74 | // Number of samples available for reading with read_samples() |
| 75 | long samples_availcxx . . $ Blip_Buffer#samples_avail(57a65ae535d7db84).() const; |
| 76 | |
| 77 | // Remove 'count' samples from those waiting to be read |
| 78 | void remove_samplescxx . . $ Blip_Buffer#remove_samples(1624ee8275b10bda).( long count ); |
| 79 | |
| 80 | // Experimental features |
| 81 | |
| 82 | // Count number of clocks needed until 'count' samples will be available. |
| 83 | // If buffer can't even hold 'count' samples, returns number of clocks until |
| 84 | // buffer becomes full. |
| 85 | blip_time_tcxx . . $ blip_time_t# count_clockscxx . . $ Blip_Buffer#count_clocks(54963ccf8c7a5971).( long count ) const; |
| 86 | |
| 87 | // Number of raw samples that can be mixed within frame of specified duration. |
| 88 | long count_samplescxx . . $ Blip_Buffer#count_samples(9ebf7bebeea16932).( blip_time_tcxx . . $ blip_time_t# duration ) const; |
| 89 | |
| 90 | // Mix 'count' samples from 'buf' into buffer. |
| 91 | void mix_samplescxx . . $ Blip_Buffer#mix_samples(16750f554da1093d).( blip_sample_tcxx . . $ blip_sample_t# const* buf, long count ); |
| 92 | |
| 93 | // not documented yet |
| 94 | void set_modifiedcxx . . $ Blip_Buffer#set_modified(49f6e7a06ebc5aa8).() { modified_cxx . . $ Blip_Buffer#modified_. = 1; } |
| 95 | int clear_modifiedcxx . . $ Blip_Buffer#clear_modified(b126dc7c1de90089).() { int b = modified_cxx . . $ Blip_Buffer#modified_.; modified_cxx . . $ Blip_Buffer#modified_. = 0; return b; } |
| 96 | typedef blip_u64cxx . . $ blip_u64# blip_resampled_time_tcxx . . $ Blip_Buffer#blip_resampled_time_t#; |
| 97 | void remove_silencecxx . . $ Blip_Buffer#remove_silence(1624ee8275b10bda).( long count ); |
| 98 | blip_resampled_time_tcxx . . $ Blip_Buffer#blip_resampled_time_t# resampled_durationcxx . . $ Blip_Buffer#resampled_duration(79dc3568750208f6).( int t ) const { return t * factor_cxx . . $ Blip_Buffer#factor_.; } |
| 99 | blip_resampled_time_tcxx . . $ Blip_Buffer#blip_resampled_time_t# resampled_timecxx . . $ Blip_Buffer#resampled_time(79dc3568750208f6).( blip_time_tcxx . . $ blip_time_t# t ) const { return t * factor_cxx . . $ Blip_Buffer#factor_. + offset_cxx . . $ Blip_Buffer#offset_.; } |
| 100 | blip_resampled_time_tcxx . . $ Blip_Buffer#blip_resampled_time_t# clock_rate_factorcxx . . $ Blip_Buffer#clock_rate_factor(2867b430557b1c2e).( long clock_rate ) const; |
| 101 | public: |
| 102 | Blip_Buffercxx . . $ Blip_Buffer#Blip_Buffer(49f6e7a06ebc5aa8).(); |
| 103 | ~cxx . . $ Blip_Buffer#`~Blip_Buffer`(ced63f7c635d850d).Blip_Buffercxx . . $ Blip_Buffer#(); |
| 104 | |
| 105 | // Deprecated |
| 106 | typedef blip_resampled_time_tcxx . . $ Blip_Buffer#blip_resampled_time_t# resampled_time_tcxx . . $ Blip_Buffer#resampled_time_t#; |
| 107 | blargg_err_tcxx . . $ Blip_Buffer#blargg_err_t# sample_ratecxx . . $ Blip_Buffer#sample_rate(595caefabb192cea).( long r ) { return set_sample_ratecxx . . $ Blip_Buffer#set_sample_rate(ee827314cdea73de).( r ); } |
| 108 | blargg_err_tcxx . . $ Blip_Buffer#blargg_err_t# sample_ratecxx . . $ Blip_Buffer#sample_rate(ee827314cdea73de).( long r, int msec ) { return set_sample_ratecxx . . $ Blip_Buffer#set_sample_rate(ee827314cdea73de).( r, msec ); } |
| 109 | private: |
| 110 | // noncopyable |
| 111 | Blip_Buffercxx . . $ Blip_Buffer#Blip_Buffer(69a6568f39ecd3db).( const Blip_Buffercxx . . $ Blip_Buffer#& ); |
| 112 | Blip_Buffercxx . . $ Blip_Buffer#& operatorcxx . . $ Blip_Buffer#`operator=`(8df10b6e15a20347). = ( const Blip_Buffercxx . . $ Blip_Buffer#& ); |
| 113 | public: |
| 114 | typedef blip_time_tcxx . . $ blip_time_t# buf_t_cxx . . $ Blip_Buffer#buf_t_#; |
| 115 | blip_u64cxx . . $ blip_u64# factor_cxx . . $ Blip_Buffer#factor_.; |
| 116 | blip_resampled_time_tcxx . . $ Blip_Buffer#blip_resampled_time_t# offset_cxx . . $ Blip_Buffer#offset_.; |
| 117 | buf_t_cxx . . $ Blip_Buffer#buf_t_#* buffer_cxx . . $ Blip_Buffer#buffer_.; |
| 118 | blip_longcxx . . $ blip_long# buffer_size_cxx . . $ Blip_Buffer#buffer_size_.; |
| 119 | blip_longcxx . . $ blip_long# reader_accum_cxx . . $ Blip_Buffer#reader_accum_.; |
| 120 | int bass_shift_cxx . . $ Blip_Buffer#bass_shift_.; |
| 121 | private: |
| 122 | long sample_rate_cxx . . $ Blip_Buffer#sample_rate_.; |
| 123 | long clock_rate_cxx . . $ Blip_Buffer#clock_rate_.; |
| 124 | int bass_freq_cxx . . $ Blip_Buffer#bass_freq_.; |
| 125 | int length_cxx . . $ Blip_Buffer#length_.; |
| 126 | int modified_cxx . . $ Blip_Buffer#modified_.; |
| 127 | friend class Blip_Readercxx . . $ Blip_Reader#; |
| 128 | }; |
| 129 | |
| 130 | #ifdef HAVE_CONFIG_H |
| 131 | #include "config.h" |
| 132 | #endif |
| 133 | |
| 134 | #define BLIP_BUFFER_ACCURACYcxx . . $ `mednafen/include/blip/Blip_Buffer.h:134:9`! 32 |
| 135 | #define BLIP_PHASE_BITScxx . . $ `mednafen/include/blip/Blip_Buffer.h:135:9`! 8 |
| 136 | |
| 137 | // Number of bits in resample ratio fraction. Higher values give a more accurate ratio |
| 138 | // but reduce maximum buffer size. |
| 139 | //#ifndef BLIP_BUFFER_ACCURACY |
| 140 | // #define BLIP_BUFFER_ACCURACY 16 |
| 141 | //#endif |
| 142 | |
| 143 | // Number bits in phase offset. Fewer than 6 bits (64 phase offsets) results in |
| 144 | // noticeable broadband noise when synthesizing high frequency square waves. |
| 145 | // Affects size of Blip_Synth objects since they store the waveform directly. |
| 146 | //#ifndef BLIP_PHASE_BITS |
| 147 | // #if BLIP_BUFFER_FAST |
| 148 | // #define BLIP_PHASE_BITS 8 |
| 149 | // #else |
| 150 | // #define BLIP_PHASE_BITS 6 |
| 151 | // #endif |
| 152 | //#endif |
| 153 | |
| 154 | // Internal |
| 155 | typedef blip_u64cxx . . $ blip_u64# blip_resampled_time_tcxx . . $ blip_resampled_time_t#; |
| 156 | int const blip_widest_impulse_cxx . . $ blip_widest_impulse_. = 16; |
| 157 | int const blip_buffer_extra_cxx . . $ blip_buffer_extra_. = blip_widest_impulse_cxx . . $ blip_widest_impulse_. + 2; |
| 158 | int const blip_rescxx . . $ blip_res. = 1 << BLIP_PHASE_BITScxx . . $ `mednafen/include/blip/Blip_Buffer.h:135:9`!; |
| 159 | class blip_eq_tcxx . . $ blip_eq_t#; |
| 160 | |
| 161 | class Blip_Synth_Fast_cxx . . $ Blip_Synth_Fast_# { |
| 162 | public: |
| 163 | Blip_Buffercxx . . $ Blip_Buffer#* bufcxx . . $ Blip_Synth_Fast_#buf.; |
| 164 | int last_ampcxx . . $ Blip_Synth_Fast_#last_amp.; |
| 165 | int delta_factorcxx . . $ Blip_Synth_Fast_#delta_factor.; |
| 166 | |
| 167 | void volume_unitcxx . . $ Blip_Synth_Fast_#volume_unit(ba8836b59fb42830).( double ); |
| 168 | Blip_Synth_Fast_cxx . . $ Blip_Synth_Fast_#Blip_Synth_Fast_(49f6e7a06ebc5aa8).(); |
| 169 | void treble_eqcxx . . $ Blip_Synth_Fast_#treble_eq(a728e5f0d25ddc61).( blip_eq_tcxx . . $ blip_eq_t# const& ) { } |
| 170 | }; |
| 171 | |
| 172 | class Blip_Synth_cxx . . $ Blip_Synth_# { |
| 173 | public: |
| 174 | Blip_Buffercxx . . $ Blip_Buffer#* bufcxx . . $ Blip_Synth_#buf.; |
| 175 | int last_ampcxx . . $ Blip_Synth_#last_amp.; |
| 176 | int delta_factorcxx . . $ Blip_Synth_#delta_factor.; |
| 177 | |
| 178 | void volume_unitcxx . . $ Blip_Synth_#volume_unit(ba8836b59fb42830).( double ); |
| 179 | Blip_Synth_cxx . . $ Blip_Synth_#Blip_Synth_(4683f455c3e046d4).( short* impulses, int width ); |
| 180 | void treble_eqcxx . . $ Blip_Synth_#treble_eq(a728e5f0d25ddc61).( blip_eq_tcxx . . $ blip_eq_t# const& ); |
| 181 | private: |
| 182 | double volume_unit_cxx . . $ Blip_Synth_#volume_unit_.; |
| 183 | short* const impulsescxx . . $ Blip_Synth_#impulses.; |
| 184 | int const widthcxx . . $ Blip_Synth_#width.; |
| 185 | blip_longcxx . . $ blip_long# kernel_unitcxx . . $ Blip_Synth_#kernel_unit.; |
| 186 | int impulses_sizecxx . . $ Blip_Synth_#impulses_size(455f465bc33b4cdf).() const { return blip_rescxx . . $ blip_res. / 2 * widthcxx . . $ Blip_Synth_#width. + 1; } |
| 187 | void adjust_impulsecxx . . $ Blip_Synth_#adjust_impulse(49f6e7a06ebc5aa8).(); |
| 188 | }; |
| 189 | |
| 190 | // Quality level. Start with blip_good_quality. |
| 191 | const int blip_med_qualitycxx . . $ blip_med_quality. = 8; |
| 192 | const int blip_good_qualitycxx . . $ blip_good_quality. = 12; |
| 193 | const int blip_high_qualitycxx . . $ blip_high_quality. = 16; |
| 194 | |
| 195 | // Range specifies the greatest expected change in amplitude. Calculate it |
| 196 | // by finding the difference between the maximum and minimum expected |
| 197 | // amplitudes (max - min). |
| 198 | template<int quality,int range> |
| 199 | class Blip_Synthcxx . . $ Blip_Synth# { |
| 200 | public: |
| 201 | // Set overall volume of waveform |
| 202 | void volumecxx . . $ Blip_Synth#volume(ba8836b59fb42830).( double v ) { implcxx . . $ Blip_Synth#impl..volume_unitcxx . . $ Blip_Synth_Fast_#volume_unit(ba8836b59fb42830).( v * (1.0 / (range < 0 ? -range : range)) ); } |
| 203 | |
| 204 | // Configure low-pass filter (see blip_buffer.txt) |
| 205 | void treble_eqcxx . . $ Blip_Synth#treble_eq(a728e5f0d25ddc61).( blip_eq_tcxx . . $ blip_eq_t# const& eq ) { implcxx . . $ Blip_Synth#impl..treble_eqcxx . . $ Blip_Synth_Fast_#treble_eq(a728e5f0d25ddc61).( eq ); } |
| 206 | |
| 207 | // Get/set Blip_Buffer used for output |
| 208 | Blip_Buffercxx . . $ Blip_Buffer#* outputcxx . . $ Blip_Synth#output(80d8c0660567c34).() const { return implcxx . . $ Blip_Synth#impl..bufcxx . . $ Blip_Synth_Fast_#buf.; } |
| 209 | void outputcxx . . $ Blip_Synth#output(1a991b1b0165523b).( Blip_Buffercxx . . $ Blip_Buffer#* b ) { implcxx . . $ Blip_Synth#impl..bufcxx . . $ Blip_Synth_Fast_#buf. = b; implcxx . . $ Blip_Synth#impl..last_ampcxx . . $ Blip_Synth_Fast_#last_amp. = 0; } |
| 210 | |
| 211 | // Update amplitude of waveform at given time. Using this requires a separate |
| 212 | // Blip_Synth for each waveform. |
| 213 | void updatecxx . . $ Blip_Synth#update(3e454b8ccf442868).( blip_time_tcxx . . $ blip_time_t# time, int amplitude ); |
| 214 | |
| 215 | // Low-level interface |
| 216 | |
| 217 | // Add an amplitude transition of specified delta, optionally into specified buffer |
| 218 | // rather than the one set with output(). Delta can be positive or negative. |
| 219 | // The actual change in amplitude is delta * (volume / range) |
| 220 | void offsetcxx . . $ Blip_Synth#offset(90077ce6337795eb).( blip_time_tcxx . . $ blip_time_t#, int delta, Blip_Buffercxx . . $ Blip_Buffer#* ) const; |
| 221 | void offsetcxx . . $ Blip_Synth#offset(db7b78144a373e11).( blip_time_tcxx . . $ blip_time_t# t, int delta ) const { offsetcxx . . $ Blip_Synth#offset(db7b78144a373e11).( t, delta, implcxx . . $ Blip_Synth#impl..bufcxx . . $ Blip_Synth_Fast_#buf. ); } |
| 222 | |
| 223 | // Works directly in terms of fractional output samples. Contact author for more info. |
| 224 | void offset_resampledcxx . . $ Blip_Synth#offset_resampled(86a249e3a5814d7b).( blip_resampled_time_tcxx . . $ blip_resampled_time_t#, int delta, Blip_Buffercxx . . $ Blip_Buffer#* ) const; |
| 225 | |
| 226 | // Same as offset(), except code is inlined for higher performance |
| 227 | void offset_inlinecxx . . $ Blip_Synth#offset_inline(90077ce6337795eb).( blip_time_tcxx . . $ blip_time_t# t, int delta, Blip_Buffercxx . . $ Blip_Buffer#* buf ) const { |
| 228 | offset_resampledcxx . . $ Blip_Synth#offset_resampled(86a249e3a5814d7b).( t * buf->factor_cxx . . $ Blip_Buffer#factor_. + buf->offset_cxx . . $ Blip_Buffer#offset_., delta, buf ); |
| 229 | } |
| 230 | void offset_inlinecxx . . $ Blip_Synth#offset_inline(db7b78144a373e11).( blip_time_tcxx . . $ blip_time_t# t, int delta ) const { |
| 231 | offset_resampledcxx . . $ Blip_Synth#offset_resampled(86a249e3a5814d7b).( t * implcxx . . $ Blip_Synth#impl..bufcxx . . $ Blip_Synth_Fast_#buf.->factor_cxx . . $ Blip_Buffer#factor_. + implcxx . . $ Blip_Synth#impl..bufcxx . . $ Blip_Synth_Fast_#buf.->offset_cxx . . $ Blip_Buffer#offset_., delta, implcxx . . $ Blip_Synth#impl..bufcxx . . $ Blip_Synth_Fast_#buf. ); |
| 232 | } |
| 233 | |
| 234 | private: |
| 235 | Blip_Synth_Fast_cxx . . $ Blip_Synth_Fast_# implcxx . . $ Blip_Synth#impl.; |
| 236 | }; |
| 237 | |
| 238 | // Low-pass equalization parameters |
| 239 | class blip_eq_tcxx . . $ blip_eq_t# { |
| 240 | public: |
| 241 | // Logarithmic rolloff to treble dB at half sampling rate. Negative values reduce |
| 242 | // treble, small positive values (0 to 5.0) increase treble. |
| 243 | blip_eq_tcxx . . $ blip_eq_t#blip_eq_t(ba8836b59fb42830).( double treble_db = 0 ); |
| 244 | |
| 245 | // See blip_buffer.txt |
| 246 | blip_eq_tcxx . . $ blip_eq_t#blip_eq_t(4fde810f210164e8).( double treble, long rolloff_freq, long sample_rate, long cutoff_freq = 0 ); |
| 247 | |
| 248 | private: |
| 249 | double treblecxx . . $ blip_eq_t#treble.; |
| 250 | long rolloff_freqcxx . . $ blip_eq_t#rolloff_freq.; |
| 251 | long sample_ratecxx . . $ blip_eq_t#sample_rate.; |
| 252 | long cutoff_freqcxx . . $ blip_eq_t#cutoff_freq.; |
| 253 | void generatecxx . . $ blip_eq_t#generate(99245bc659b293d5).( float* out, int count ) const; |
| 254 | friend class Blip_Synth_cxx . . $ Blip_Synth_#; |
| 255 | }; |
| 256 | |
| 257 | int const blip_sample_bitscxx . . $ blip_sample_bits. = 30; |
| 258 | |
| 259 | #define BLIP_RESTRICTcxx . . $ `mednafen/include/blip/Blip_Buffer.h:259:9`! |
| 260 | |
| 261 | // Optimized reading from Blip_Buffer, for use in custom sample output |
| 262 | |
| 263 | // Begin reading from buffer. Name should be unique to the current block. |
| 264 | #define BLIP_READER_BEGINcxx . . $ `mednafen/include/blip/Blip_Buffer.h:264:9`!( name, blip_buffer ) \ |
| 265 | const Blip_Buffer::buf_t_* BLIP_RESTRICTcxx . . $ `mednafen/include/blip/Blip_Buffer.h:259:9`! name##_reader_buf = (blip_buffer).buffer_;\ |
| 266 | blip_long name##_reader_accum = (blip_buffer).reader_accum_ |
| 267 | |
| 268 | // Get value to pass to BLIP_READER_NEXT() |
| 269 | #define BLIP_READER_BASScxx . . $ `mednafen/include/blip/Blip_Buffer.h:269:9`!( blip_buffer ) ((blip_buffer).bass_shift_) |
| 270 | |
| 271 | // Constant value to use instead of BLIP_READER_BASS(), for slightly more optimal |
| 272 | // code at the cost of having no bass control |
| 273 | int const blip_reader_default_basscxx . . $ blip_reader_default_bass. = 9; |
| 274 | |
| 275 | // Current sample |
| 276 | #define BLIP_READER_READcxx . . $ `mednafen/include/blip/Blip_Buffer.h:276:9`!( name ) (name##_reader_accum >> (blip_sample_bits - 16)) |
| 277 | |
| 278 | // Current raw sample in full internal resolution |
| 279 | #define BLIP_READER_READ_RAWcxx . . $ `mednafen/include/blip/Blip_Buffer.h:279:9`!( name ) (name##_reader_accum) |
| 280 | |
| 281 | // Advance to next sample |
| 282 | #define BLIP_READER_NEXTcxx . . $ `mednafen/include/blip/Blip_Buffer.h:282:9`!( name, bass ) \ |
| 283 | (void) (name##_reader_accum += *name##_reader_buf++ - (name##_reader_accum >> (bass))) |
| 284 | |
| 285 | // End reading samples from buffer. The number of samples read must now be removed |
| 286 | // using Blip_Buffer::remove_samples(). |
| 287 | #define BLIP_READER_ENDcxx . . $ `mednafen/include/blip/Blip_Buffer.h:287:9`!( name, blip_buffer ) \ |
| 288 | (void) ((blip_buffer).reader_accum_ = name##_reader_accum) |
| 289 | |
| 290 | |
| 291 | // Compatibility with older version |
| 292 | const long blip_unscaledcxx . . $ blip_unscaled. = 65535; |
| 293 | const int blip_low_qualitycxx . . $ blip_low_quality. = blip_med_qualitycxx . . $ blip_med_quality.; |
| 294 | const int blip_best_qualitycxx . . $ blip_best_quality. = blip_high_qualitycxx . . $ blip_high_quality.; |
| 295 | |
| 296 | // Deprecated; use BLIP_READER macros as follows: |
| 297 | // Blip_Reader r; r.begin( buf ); -> BLIP_READER_BEGIN( r, buf ); |
| 298 | // int bass = r.begin( buf ) -> BLIP_READER_BEGIN( r, buf ); int bass = BLIP_READER_BASS( buf ); |
| 299 | // r.read() -> BLIP_READER_READ( r ) |
| 300 | // r.read_raw() -> BLIP_READER_READ_RAW( r ) |
| 301 | // r.next( bass ) -> BLIP_READER_NEXT( r, bass ) |
| 302 | // r.next() -> BLIP_READER_NEXT( r, blip_reader_default_bass ) |
| 303 | // r.end( buf ) -> BLIP_READER_END( r, buf ) |
| 304 | class Blip_Readercxx . . $ Blip_Reader# { |
| 305 | public: |
| 306 | int begincxx . . $ Blip_Reader#begin(bd49e4dbde136ad8).( Blip_Buffercxx . . $ Blip_Buffer#& ); |
| 307 | blip_longcxx . . $ blip_long# readcxx . . $ Blip_Reader#read(455f465bc33b4cdf).() const { return accumcxx . . $ Blip_Reader#accum. >> (blip_sample_bitscxx . . $ blip_sample_bits. - 16); } |
| 308 | blip_longcxx . . $ blip_long# read_rawcxx . . $ Blip_Reader#read_raw(455f465bc33b4cdf).() const { return accumcxx . . $ Blip_Reader#accum.; } |
| 309 | void nextcxx . . $ Blip_Reader#next(d4f767463ce0a6b3).( int bass_shift = 9 ) { accumcxx . . $ Blip_Reader#accum. += *bufcxx . . $ Blip_Reader#buf.++ - (accumcxx . . $ Blip_Reader#accum. >> bass_shift); } |
| 310 | void endcxx . . $ Blip_Reader#end(a2d8fa65957500ee).( Blip_Buffercxx . . $ Blip_Buffer#& b ) { b.reader_accum_cxx . . $ Blip_Buffer#reader_accum_. = accumcxx . . $ Blip_Reader#accum.; } |
| 311 | |
| 312 | private: |
| 313 | const Blip_Buffercxx . . $ Blip_Buffer#::buf_t_cxx . . $ Blip_Buffer#buf_t_#* bufcxx . . $ Blip_Reader#buf.; |
| 314 | blip_longcxx . . $ blip_long# accumcxx . . $ Blip_Reader#accum.; |
| 315 | }; |
| 316 | |
| 317 | // End of public interface |
| 318 | |
| 319 | #include <assert.h> |
| 320 | |
| 321 | template<int quality,int range> |
| 322 | blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! void Blip_Synthcxx . . $ Blip_Synth#<quality,range>::offset_resampledcxx . . $ Blip_Synth#offset_resampled(86a249e3a5814d7b).( blip_resampled_time_tcxx . . $ blip_resampled_time_t# time, |
| 323 | int delta, Blip_Buffercxx . . $ Blip_Buffer#* blip_buf ) const |
| 324 | { |
| 325 | // Fails if time is beyond end of Blip_Buffer, due to a bug in caller code or the |
| 326 | // need for a longer buffer as set by set_sample_rate(). |
| 327 | assertcxx . . $ Blip_Buffer#buffer_size_.( (blip_long) (time >> BLIP_BUFFER_ACCURACYcxx . . $ `mednafen/include/blip/Blip_Buffer.h:134:9`!) < blip_buf->buffer_size_ ); |
| 328 | delta *= implcxx . . $ Blip_Synth#impl..delta_factorcxx . . $ Blip_Synth_Fast_#delta_factor.; |
| 329 | blip_longcxx . . $ blip_long#* BLIP_RESTRICTcxx . . $ `mednafen/include/blip/Blip_Buffer.h:259:9`! buf = blip_buf->buffer_cxx . . $ Blip_Buffer#buffer_. + (time >> BLIP_BUFFER_ACCURACYcxx . . $ `mednafen/include/blip/Blip_Buffer.h:134:9`!); |
| 330 | int phase = (int) (time >> (BLIP_BUFFER_ACCURACYcxx . . $ `mednafen/include/blip/Blip_Buffer.h:134:9`! - BLIP_PHASE_BITScxx . . $ `mednafen/include/blip/Blip_Buffer.h:135:9`!) & (blip_rescxx . . $ blip_res. - 1)); |
| 331 | |
| 332 | blip_longcxx . . $ blip_long# left = buf [0] + delta; |
| 333 | |
| 334 | // Kind of crappy, but doing shift after multiply results in overflow. |
| 335 | // Alternate way of delaying multiply by delta_factor results in worse |
| 336 | // sub-sample resolution. |
| 337 | blip_longcxx . . $ blip_long# right = (delta >> BLIP_PHASE_BITScxx . . $ `mednafen/include/blip/Blip_Buffer.h:135:9`!) * phase; |
| 338 | left -= right; |
| 339 | right += buf [1]; |
| 340 | |
| 341 | buf [0] = left; |
| 342 | buf [1] = right; |
| 343 | } |
| 344 | |
| 345 | #undef BLIP_FWD |
| 346 | #undef BLIP_REV |
| 347 | |
| 348 | template<int quality,int range> |
| 349 | blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! void Blip_Synthcxx . . $ Blip_Synth#<quality,range>::offsetcxx . . $ Blip_Synth#offset(90077ce6337795eb).( blip_time_tcxx . . $ blip_time_t# t, int delta, Blip_Buffercxx . . $ Blip_Buffer#* buf ) const |
| 350 | { |
| 351 | offset_resampledcxx . . $ Blip_Synth#offset_resampled(86a249e3a5814d7b).( t * buf->factor_cxx . . $ Blip_Buffer#factor_. + buf->offset_cxx . . $ Blip_Buffer#offset_., delta, buf ); |
| 352 | } |
| 353 | |
| 354 | template<int quality,int range> |
| 355 | blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! void Blip_Synthcxx . . $ Blip_Synth#<quality,range>::updatecxx . . $ Blip_Synth#update(3e454b8ccf442868).( blip_time_tcxx . . $ blip_time_t# t, int amp ) |
| 356 | { |
| 357 | int delta = amp - implcxx . . $ Blip_Synth#impl..last_ampcxx . . $ Blip_Synth_Fast_#last_amp.; |
| 358 | implcxx . . $ Blip_Synth#impl..last_ampcxx . . $ Blip_Synth_Fast_#last_amp. = amp; |
| 359 | offset_resampledcxx . . $ Blip_Synth#offset_resampled(86a249e3a5814d7b).( t * implcxx . . $ Blip_Synth#impl..bufcxx . . $ Blip_Synth_Fast_#buf.->factor_cxx . . $ Blip_Buffer#factor_. + implcxx . . $ Blip_Synth#impl..bufcxx . . $ Blip_Synth_Fast_#buf.->offset_cxx . . $ Blip_Buffer#offset_., delta, implcxx . . $ Blip_Synth#impl..bufcxx . . $ Blip_Synth_Fast_#buf. ); |
| 360 | } |
| 361 | |
| 362 | blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! blip_eq_tcxx . . $ blip_eq_t#::blip_eq_tcxx . . $ blip_eq_t#blip_eq_t(ba8836b59fb42830).( double t ) : |
| 363 | treblecxx . . $ blip_eq_t#treble.( t ), rolloff_freqcxx . . $ blip_eq_t#rolloff_freq.( 0 ), sample_ratecxx . . $ blip_eq_t#sample_rate.( 44100 ), cutoff_freqcxx . . $ blip_eq_t#cutoff_freq.( 0 ) { } |
| 364 | blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! blip_eq_tcxx . . $ blip_eq_t#::blip_eq_tcxx . . $ blip_eq_t#blip_eq_t(4fde810f210164e8).( double t, long rf, long sr, long cf ) : |
| 365 | treblecxx . . $ blip_eq_t#treble.( t ), rolloff_freqcxx . . $ blip_eq_t#rolloff_freq.( rf ), sample_ratecxx . . $ blip_eq_t#sample_rate.( sr ), cutoff_freqcxx . . $ blip_eq_t#cutoff_freq.( cf ) { } |
| 366 | |
| 367 | blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! int Blip_Buffercxx . . $ Blip_Buffer#::lengthcxx . . $ Blip_Buffer#length(455f465bc33b4cdf).() const { return length_cxx . . $ Blip_Buffer#length_.; } |
| 368 | blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! long Blip_Buffercxx . . $ Blip_Buffer#::samples_availcxx . . $ Blip_Buffer#samples_avail(57a65ae535d7db84).() const { return (long) (offset_cxx . . $ Blip_Buffer#offset_. >> BLIP_BUFFER_ACCURACYcxx . . $ `mednafen/include/blip/Blip_Buffer.h:134:9`!); } |
| 369 | blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! long Blip_Buffercxx . . $ Blip_Buffer#::sample_ratecxx . . $ Blip_Buffer#sample_rate(57a65ae535d7db84).() const { return sample_rate_cxx . . $ Blip_Buffer#sample_rate_.; } |
| 370 | blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! int Blip_Buffercxx . . $ Blip_Buffer#::output_latencycxx . . $ Blip_Buffer#output_latency(455f465bc33b4cdf).() const { return blip_widest_impulse_cxx . . $ blip_widest_impulse_. / 2; } |
| 371 | blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! long Blip_Buffercxx . . $ Blip_Buffer#::clock_ratecxx . . $ Blip_Buffer#clock_rate(57a65ae535d7db84).() const { return clock_rate_cxx . . $ Blip_Buffer#clock_rate_.; } |
| 372 | blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! void Blip_Buffercxx . . $ Blip_Buffer#::clock_ratecxx . . $ Blip_Buffer#clock_rate(1624ee8275b10bda).( long cps ) { factor_cxx . . $ Blip_Buffer#factor_. = clock_rate_factorcxx . . $ Blip_Buffer#clock_rate_factor(2867b430557b1c2e).( clock_rate_cxx . . $ Blip_Buffer#clock_rate_. = cps ); } |
| 373 | |
| 374 | blip_inlinecxx . . $ `mednafen/include/blip/Blip_Buffer.h:5:10`! int Blip_Readercxx . . $ Blip_Reader#::begincxx . . $ Blip_Reader#begin(bd49e4dbde136ad8).( Blip_Buffercxx . . $ Blip_Buffer#& blip_buf ) |
| 375 | { |
| 376 | bufcxx . . $ Blip_Reader#buf. = blip_buf.buffer_cxx . . $ Blip_Buffer#buffer_.; |
| 377 | accumcxx . . $ Blip_Reader#accum. = blip_buf.reader_accum_cxx . . $ Blip_Buffer#reader_accum_.; |
| 378 | return blip_buf.bass_shift_cxx . . $ Blip_Buffer#bass_shift_.; |
| 379 | } |
| 380 | |
| 381 | int const blip_max_lengthcxx . . $ blip_max_length. = 0; |
| 382 | int const blip_default_lengthcxx . . $ blip_default_length. = 250; |
| 383 | |
| 384 | #endif |