1 // Combination of Downsampler and Blip_Buffer mixing. Used by Sega FM emulators.
3 // Game_Music_Emu 0.5.5
7 #include "blargg_config.h"
8 #include "multi_buffer.h"
10 typedef short dsample_t
;
13 enum { max_buf_size
= 3960 };
14 enum { max_resampler_size
= 5942 };
15 enum { write_offset
= 8 * stereo
};
16 enum { gain_bits
= 14 };
19 int (*callback
)( void*, blip_time_t
, int, dsample_t
* );
22 dsample_t sample_buf
[max_buf_size
];
24 int oversamples_per_frame
;
30 dsample_t buf
[max_resampler_size
];
40 static inline void Resampler_init( struct Resampler
* this )
47 blargg_err_t
Resampler_reset( struct Resampler
* this, int max_pairs
);
48 void Resampler_resize( struct Resampler
* this, int pairs_per_frame
);
50 void Resampler_play( struct Resampler
* this, long count
, dsample_t
* out
, struct Stereo_Buffer
* ) ICODE_ATTR
;
52 static inline void Resampler_set_callback(struct Resampler
* this, int (*func
)( void*, blip_time_t
, int, dsample_t
* ), void* user_data
)
54 this->callback
= func
;
55 this->callback_data
= user_data
;
58 blargg_err_t
Resampler_setup( struct Resampler
* this, double oversample
, double rolloff
, double gain
);
60 static inline void Resampler_clear( struct Resampler
* this )
62 this->buf_pos
= this->sample_buf_size
;