diff options
author | Sean Bartell <wingedtachikoma@gmail.com> | 2011-06-25 21:32:25 -0400 |
---|---|---|
committer | Nils Wallménius <nils@rockbox.org> | 2012-04-25 22:13:20 +0200 |
commit | f40bfc9267b13b54e6379dfe7539447662879d24 (patch) | |
tree | 9b20069d5e62809ff434061ad730096836f916f2 /lib/rbcodec/codecs/libgme/resampler.h | |
parent | a0009907de7a0107d49040d8a180f140e2eff299 (diff) | |
download | rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.tar.gz rockbox-f40bfc9267b13b54e6379dfe7539447662879d24.zip |
Add codecs to librbcodec.
Change-Id: Id7f4717d51ed02d67cb9f9cb3c0ada4a81843f97
Reviewed-on: http://gerrit.rockbox.org/137
Reviewed-by: Nils Wallménius <nils@rockbox.org>
Tested-by: Nils Wallménius <nils@rockbox.org>
Diffstat (limited to 'lib/rbcodec/codecs/libgme/resampler.h')
-rw-r--r-- | lib/rbcodec/codecs/libgme/resampler.h | 75 |
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 | |||
10 | typedef short dsample_t; | ||
11 | |||
12 | enum { max_buf_size = 3960 }; | ||
13 | enum { max_resampler_size = 5942 }; | ||
14 | enum { write_offset = 8 * stereo }; | ||
15 | enum { gain_bits = 14 }; | ||
16 | |||
17 | struct 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 | |||
40 | static 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 | |||
50 | blargg_err_t Resampler_reset( struct Resampler* this, int max_pairs ); | ||
51 | void Resampler_resize( struct Resampler* this, int pairs_per_frame ); | ||
52 | void Resampler_play( struct Resampler* this, int count, dsample_t* out, struct Blip_Buffer* ); | ||
53 | |||
54 | static 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 | |||
60 | blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain ); | ||
61 | |||
62 | static 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 | |||
70 | static inline int Resampler_rate( struct Resampler* this ) | ||
71 | { | ||
72 | return this->rate_; | ||
73 | } | ||
74 | |||
75 | #endif | ||