summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libgme/resampler.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rbcodec/codecs/libgme/resampler.h')
-rw-r--r--lib/rbcodec/codecs/libgme/resampler.h75
1 files changed, 75 insertions, 0 deletions
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 @@
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_common.h"
8#include "multi_buffer.h"
9
10typedef short dsample_t;
11
12enum { max_buf_size = 3960 };
13enum { max_resampler_size = 5942 };
14enum { write_offset = 8 * stereo };
15enum { gain_bits = 14 };
16
17struct Resampler {
18 int (*callback)( void*, blip_time_t, int, dsample_t* );
19 void* callback_data;
20
21 int sample_buffer_size;
22 int sample_buf_size;
23 int oversamples_per_frame;
24 int buf_pos;
25 int resampler_size;
26 int gain_;
27
28 int buffer_size;
29 int write_pos;
30
31 int pos;
32 int step;
33
34 int rate_;
35
36 dsample_t sample_buf [max_buf_size];
37 dsample_t buf [max_resampler_size]; // Internal resampler
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 this->sample_buf_size = 0;
46 this->sample_buffer_size = 0;
47 this->oversamples_per_frame = 0;
48}
49
50blargg_err_t Resampler_reset( struct Resampler* this, int max_pairs );
51void Resampler_resize( struct Resampler* this, int pairs_per_frame );
52void Resampler_play( struct Resampler* this, int count, dsample_t* out, struct Blip_Buffer* );
53
54static inline void Resampler_set_callback(struct Resampler* this, int (*func)( void*, blip_time_t, int, dsample_t* ), void* user_data )
55{
56 this->callback = func;
57 this->callback_data = user_data;
58}
59
60blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain );
61
62static inline void Resampler_clear( struct Resampler* this )
63{
64 this->buf_pos = this->sample_buf_size;
65
66 this->pos = 0;
67 this->write_pos = 0;
68}
69
70static inline int Resampler_rate( struct Resampler* this )
71{
72 return this->rate_;
73}
74
75#endif