From f40bfc9267b13b54e6379dfe7539447662879d24 Mon Sep 17 00:00:00 2001 From: Sean Bartell Date: Sat, 25 Jun 2011 21:32:25 -0400 Subject: Add codecs to librbcodec. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97 Reviewed-on: http://gerrit.rockbox.org/137 Reviewed-by: Nils Wallménius Tested-by: Nils Wallménius --- lib/rbcodec/codecs/libgme/resampler.h | 75 +++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 lib/rbcodec/codecs/libgme/resampler.h (limited to 'lib/rbcodec/codecs/libgme/resampler.h') diff --git a/lib/rbcodec/codecs/libgme/resampler.h b/lib/rbcodec/codecs/libgme/resampler.h new file mode 100644 index 0000000000..3f3710a54a --- /dev/null +++ b/lib/rbcodec/codecs/libgme/resampler.h @@ -0,0 +1,75 @@ +// Combination of Downsampler and Blip_Buffer mixing. Used by Sega FM emulators. + +// Game_Music_Emu 0.5.5 +#ifndef RESAMPLER_H +#define RESAMPLER_H + +#include "blargg_common.h" +#include "multi_buffer.h" + +typedef short dsample_t; + +enum { max_buf_size = 3960 }; +enum { max_resampler_size = 5942 }; +enum { write_offset = 8 * stereo }; +enum { gain_bits = 14 }; + +struct Resampler { + int (*callback)( void*, blip_time_t, int, dsample_t* ); + void* callback_data; + + int sample_buffer_size; + int sample_buf_size; + int oversamples_per_frame; + int buf_pos; + int resampler_size; + int gain_; + + int buffer_size; + int write_pos; + + int pos; + int step; + + int rate_; + + dsample_t sample_buf [max_buf_size]; + dsample_t buf [max_resampler_size]; // Internal resampler +}; + +static inline void Resampler_init( struct Resampler* this ) +{ + this->pos = 0; + this->write_pos = 0; + this->rate_ = 0; + this->sample_buf_size = 0; + this->sample_buffer_size = 0; + this->oversamples_per_frame = 0; +} + +blargg_err_t Resampler_reset( struct Resampler* this, int max_pairs ); +void Resampler_resize( struct Resampler* this, int pairs_per_frame ); +void Resampler_play( struct Resampler* this, int count, dsample_t* out, struct Blip_Buffer* ); + +static inline void Resampler_set_callback(struct Resampler* this, int (*func)( void*, blip_time_t, int, dsample_t* ), void* user_data ) +{ + this->callback = func; + this->callback_data = user_data; +} + +blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain ); + +static inline void Resampler_clear( struct Resampler* this ) +{ + this->buf_pos = this->sample_buf_size; + + this->pos = 0; + this->write_pos = 0; +} + +static inline int Resampler_rate( struct Resampler* this ) +{ + return this->rate_; +} + +#endif -- cgit v1.2.3