2013-09-28 03:24:23 +00:00
|
|
|
// Combination of Fir_Resampler and Stereo_Buffer mixing. Used by Sega FM emulators.
|
2007-10-11 23:11:58 +00:00
|
|
|
|
2013-09-28 03:24:23 +00:00
|
|
|
// Game_Music_Emu $vers
|
2007-10-11 23:11:58 +00:00
|
|
|
#ifndef DUAL_RESAMPLER_H
|
|
|
|
#define DUAL_RESAMPLER_H
|
|
|
|
|
2013-09-28 03:24:23 +00:00
|
|
|
#include "Multi_Buffer.h"
|
|
|
|
|
|
|
|
#if GME_VGM_FAST_RESAMPLER
|
|
|
|
#include "Downsampler.h"
|
|
|
|
typedef Downsampler Dual_Resampler_Downsampler;
|
|
|
|
#else
|
|
|
|
#include "Fir_Resampler.h"
|
|
|
|
typedef Fir_Resampler_Norm Dual_Resampler_Downsampler;
|
|
|
|
#endif
|
2007-10-11 23:11:58 +00:00
|
|
|
|
|
|
|
class Dual_Resampler {
|
|
|
|
public:
|
|
|
|
typedef short dsample_t;
|
|
|
|
|
2013-09-28 03:24:23 +00:00
|
|
|
blargg_err_t setup( double oversample, double rolloff, double gain );
|
|
|
|
double rate() const { return resampler.rate(); }
|
2007-10-11 23:11:58 +00:00
|
|
|
blargg_err_t reset( int max_pairs );
|
|
|
|
void resize( int pairs_per_frame );
|
|
|
|
void clear();
|
|
|
|
|
2013-09-28 03:24:23 +00:00
|
|
|
void dual_play( int count, dsample_t out [], Stereo_Buffer&, Stereo_Buffer** secondary_buf_set = NULL, int secondary_buf_set_count = 0 );
|
2007-10-11 23:11:58 +00:00
|
|
|
|
2013-09-28 03:24:23 +00:00
|
|
|
blargg_callback<int (*)( void*, blip_time_t, int, dsample_t* )> set_callback;
|
|
|
|
|
|
|
|
// Implementation
|
|
|
|
public:
|
|
|
|
Dual_Resampler();
|
|
|
|
~Dual_Resampler();
|
|
|
|
|
2007-10-11 23:11:58 +00:00
|
|
|
private:
|
2013-09-28 03:24:23 +00:00
|
|
|
enum { gain_bits = 14 };
|
2007-10-11 23:11:58 +00:00
|
|
|
blargg_vector<dsample_t> sample_buf;
|
|
|
|
int sample_buf_size;
|
|
|
|
int oversamples_per_frame;
|
|
|
|
int buf_pos;
|
2013-09-28 03:24:23 +00:00
|
|
|
int buffered;
|
2007-10-11 23:11:58 +00:00
|
|
|
int resampler_size;
|
2013-09-28 03:24:23 +00:00
|
|
|
int gain_;
|
2007-10-11 23:11:58 +00:00
|
|
|
|
2013-09-28 03:24:23 +00:00
|
|
|
Dual_Resampler_Downsampler resampler;
|
|
|
|
void mix_samples( Stereo_Buffer&, dsample_t [], int, Stereo_Buffer**, int );
|
|
|
|
void mix_mono( Stereo_Buffer&, dsample_t [], int );
|
|
|
|
void mix_stereo( Stereo_Buffer&, dsample_t [], int );
|
|
|
|
void mix_extra_mono( Stereo_Buffer&, dsample_t [], int );
|
|
|
|
void mix_extra_stereo( Stereo_Buffer&, dsample_t [], int );
|
|
|
|
int play_frame_( Stereo_Buffer&, dsample_t [], Stereo_Buffer**, int );
|
2007-10-11 23:11:58 +00:00
|
|
|
};
|
|
|
|
|
2013-09-28 03:24:23 +00:00
|
|
|
inline blargg_err_t Dual_Resampler::setup( double oversample, double rolloff, double gain )
|
2007-10-11 23:11:58 +00:00
|
|
|
{
|
2013-09-28 03:24:23 +00:00
|
|
|
gain_ = (int) ((1 << gain_bits) * gain);
|
|
|
|
return resampler.set_rate( oversample );
|
2007-10-11 23:11:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|