summaryrefslogtreecommitdiff
path: root/apps/codecs/libgme/resampler.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libgme/resampler.h')
-rw-r--r--apps/codecs/libgme/resampler.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/apps/codecs/libgme/resampler.h b/apps/codecs/libgme/resampler.h
new file mode 100644
index 0000000000..f5e8c55119
--- /dev/null
+++ b/apps/codecs/libgme/resampler.h
@@ -0,0 +1,68 @@
1// Combination of Downsampler and Blip_Buffer mixing. Used by Sega FM emulators.
2
3// Game_Music_Emu 0.5.5
4#ifndef RESAMPLER_H
5#define RESAMPLER_H
6
7#include "blargg_config.h"
8#include "multi_buffer.h"
9
10typedef short dsample_t;
11
12enum { stereo = 2 };
13enum { max_buf_size = 3960 };
14enum { max_resampler_size = 5942 };
15enum { write_offset = 8 * stereo };
16enum { gain_bits = 14 };
17
18struct Resampler {
19 int (*callback)( void*, blip_time_t, int, dsample_t* );
20 void* callback_data;
21
22 dsample_t sample_buf [max_buf_size];
23 int sample_buf_size;
24 int oversamples_per_frame;
25 int buf_pos;
26 int resampler_size;
27 int gain_;
28
29 // Internal resampler
30 dsample_t buf [max_resampler_size];
31 int buffer_size;
32
33 int write_pos;
34 double rate_;
35
36 int pos;
37 int step;
38};
39
40static inline void Resampler_init( struct Resampler* this )
41{
42 this->pos = 0;
43 this->write_pos = 0;
44 this->rate_ = 0;
45}
46
47blargg_err_t Resampler_reset( struct Resampler* this, int max_pairs );
48void Resampler_resize( struct Resampler* this, int pairs_per_frame );
49
50void Resampler_play( struct Resampler* this, long count, dsample_t* out, struct Stereo_Buffer* ) ICODE_ATTR;
51
52static inline void Resampler_set_callback(struct Resampler* this, int (*func)( void*, blip_time_t, int, dsample_t* ), void* user_data )
53{
54 this->callback = func;
55 this->callback_data = user_data;
56}
57
58blargg_err_t Resampler_setup( struct Resampler* this, double oversample, double rolloff, double gain );
59
60static inline void Resampler_clear( struct Resampler* this )
61{
62 this->buf_pos = this->sample_buf_size;
63
64 this->pos = 0;
65 this->write_pos = 0;
66}
67
68#endif