diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-11 21:06:16 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-11 21:06:16 +0000 |
commit | 1b9f9fb4651c9af36ca0bf21746c211afd90a916 (patch) | |
tree | c8124b38421bbe5eefbabfbc0335f091dcfc3b44 | |
parent | b1279498609808cf65a7054ae7085b4885a33e66 (diff) | |
download | rockbox-1b9f9fb4651c9af36ca0bf21746c211afd90a916.tar.gz rockbox-1b9f9fb4651c9af36ca0bf21746c211afd90a916.zip |
5th part of FS#12176. Further fixed point migration. Only two emulators (ym2413, ym2612) still use floating point.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30281 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/codecs/libgme/hes_apu_adpcm.c | 8 | ||||
-rw-r--r-- | apps/codecs/libgme/hes_apu_adpcm.h | 2 | ||||
-rw-r--r-- | apps/codecs/libgme/nes_apu.c | 2 | ||||
-rw-r--r-- | apps/codecs/libgme/nes_vrc7_apu.c | 2 | ||||
-rw-r--r-- | apps/codecs/libgme/nes_vrc7_apu.h | 2 | ||||
-rw-r--r-- | apps/codecs/libgme/nsf_emu.c | 8 | ||||
-rw-r--r-- | apps/codecs/libgme/nsf_emu.h | 1 | ||||
-rw-r--r-- | apps/codecs/libgme/resampler.c | 18 | ||||
-rw-r--r-- | apps/codecs/libgme/resampler.h | 4 | ||||
-rw-r--r-- | apps/codecs/libgme/sms_fm_apu.c | 4 | ||||
-rw-r--r-- | apps/codecs/libgme/sms_fm_apu.h | 2 | ||||
-rw-r--r-- | apps/codecs/libgme/vgm_emu.c | 14 | ||||
-rw-r--r-- | apps/codecs/libgme/vgm_emu.h | 2 | ||||
-rw-r--r-- | apps/codecs/libgme/ym2413_emu.c | 2 | ||||
-rw-r--r-- | apps/codecs/libgme/ym2413_emu.h | 2 | ||||
-rw-r--r-- | apps/codecs/libgme/ym2612_emu.c | 6 | ||||
-rw-r--r-- | apps/codecs/libgme/ym2612_emu.h | 2 |
17 files changed, 38 insertions, 43 deletions
diff --git a/apps/codecs/libgme/hes_apu_adpcm.c b/apps/codecs/libgme/hes_apu_adpcm.c index b2f78ff71f..66512dc702 100644 --- a/apps/codecs/libgme/hes_apu_adpcm.c +++ b/apps/codecs/libgme/hes_apu_adpcm.c | |||
@@ -107,7 +107,7 @@ static void Adpcm_run_until( struct Hes_Apu_Adpcm* this, blip_time_t end_time ) | |||
107 | int fadetimer = state->fadetimer; | 107 | int fadetimer = state->fadetimer; |
108 | int fadecount = state->fadecount; | 108 | int fadecount = state->fadecount; |
109 | int last_time = this->last_time; | 109 | int last_time = this->last_time; |
110 | double next_timer = this->next_timer; | 110 | int next_timer = this->next_timer; |
111 | int last_amp = this->last_amp; | 111 | int last_amp = this->last_amp; |
112 | 112 | ||
113 | struct Blip_Buffer* output = this->output; // cache often-used values | 113 | struct Blip_Buffer* output = this->output; // cache often-used values |
@@ -129,7 +129,7 @@ static void Adpcm_run_until( struct Hes_Apu_Adpcm* this, blip_time_t end_time ) | |||
129 | volume = 0xFF - ( 0xFF * fadecount / fadetimer ); | 129 | volume = 0xFF - ( 0xFF * fadecount / fadetimer ); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | next_timer += 7159.091; | 132 | next_timer += 7159; // 7159091/1000; |
133 | } | 133 | } |
134 | int amp; | 134 | int amp; |
135 | if ( state->ad_low_nibble ) | 135 | if ( state->ad_low_nibble ) |
@@ -160,7 +160,7 @@ static void Adpcm_run_until( struct Hes_Apu_Adpcm* this, blip_time_t end_time ) | |||
160 | 160 | ||
161 | if ( !state->playflag ) | 161 | if ( !state->playflag ) |
162 | { | 162 | { |
163 | while ( next_timer <= end_time ) next_timer += 7159.091; | 163 | while ( next_timer <= end_time ) next_timer += 7159; // 7159091/1000 |
164 | last_time = end_time; | 164 | last_time = end_time; |
165 | } | 165 | } |
166 | 166 | ||
@@ -290,7 +290,7 @@ void Adpcm_end_frame( struct Hes_Apu_Adpcm* this, blip_time_t end_time ) | |||
290 | { | 290 | { |
291 | Adpcm_run_until( this, end_time ); | 291 | Adpcm_run_until( this, end_time ); |
292 | this->last_time -= end_time; | 292 | this->last_time -= end_time; |
293 | this->next_timer -= (double)end_time; | 293 | this->next_timer -= end_time; |
294 | check( last_time >= 0 ); | 294 | check( last_time >= 0 ); |
295 | if ( this->output ) | 295 | if ( this->output ) |
296 | Blip_set_modified( this->output ); | 296 | Blip_set_modified( this->output ); |
diff --git a/apps/codecs/libgme/hes_apu_adpcm.h b/apps/codecs/libgme/hes_apu_adpcm.h index 38b8839276..d8d024ee34 100644 --- a/apps/codecs/libgme/hes_apu_adpcm.h +++ b/apps/codecs/libgme/hes_apu_adpcm.h | |||
@@ -43,7 +43,7 @@ struct Hes_Apu_Adpcm { | |||
43 | 43 | ||
44 | struct Blip_Buffer* output; | 44 | struct Blip_Buffer* output; |
45 | blip_time_t last_time; | 45 | blip_time_t last_time; |
46 | double next_timer; | 46 | int next_timer; |
47 | int last_amp; | 47 | int last_amp; |
48 | }; | 48 | }; |
49 | 49 | ||
diff --git a/apps/codecs/libgme/nes_apu.c b/apps/codecs/libgme/nes_apu.c index fae799d8d6..d4e6e8df4d 100644 --- a/apps/codecs/libgme/nes_apu.c +++ b/apps/codecs/libgme/nes_apu.c | |||
@@ -46,7 +46,7 @@ void Apu_init( struct Nes_Apu* this ) | |||
46 | void Apu_enable_nonlinear( struct Nes_Apu* this, int v ) | 46 | void Apu_enable_nonlinear( struct Nes_Apu* this, int v ) |
47 | { | 47 | { |
48 | this->dmc.nonlinear = true; | 48 | this->dmc.nonlinear = true; |
49 | Synth_volume( &this->square_synth, (int)((1.3 * 0.25751258 / 0.742467605 * 0.25 * FP_ONE_VOLUME) / amp_range * v) ); | 49 | Synth_volume( &this->square_synth, (int)((long long)(1.3 * 0.25751258 / 0.742467605 * 0.25 * FP_ONE_VOLUME) / amp_range * v) ); |
50 | 50 | ||
51 | const int tnd = (int)(0.48 / 202 * 0.75 * FP_ONE_VOLUME); | 51 | const int tnd = (int)(0.48 / 202 * 0.75 * FP_ONE_VOLUME); |
52 | Synth_volume( &this->triangle.synth, 3 * tnd ); | 52 | Synth_volume( &this->triangle.synth, 3 * tnd ); |
diff --git a/apps/codecs/libgme/nes_vrc7_apu.c b/apps/codecs/libgme/nes_vrc7_apu.c index 6148a6b90f..c9e638e3d8 100644 --- a/apps/codecs/libgme/nes_vrc7_apu.c +++ b/apps/codecs/libgme/nes_vrc7_apu.c | |||
@@ -29,7 +29,7 @@ void Vrc7_reset( struct Nes_Vrc7_Apu* this ) | |||
29 | OPLL_setMask(&this->opll, this->mask); | 29 | OPLL_setMask(&this->opll, this->mask); |
30 | } | 30 | } |
31 | 31 | ||
32 | void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, double r ) | 32 | void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, int r ) |
33 | { | 33 | { |
34 | OPLL_set_quality( &this->opll, r < 44100 ? 0 : 1 ); | 34 | OPLL_set_quality( &this->opll, r < 44100 ? 0 : 1 ); |
35 | OPLL_set_rate( &this->opll, (e_uint32)r ); | 35 | OPLL_set_rate( &this->opll, (e_uint32)r ); |
diff --git a/apps/codecs/libgme/nes_vrc7_apu.h b/apps/codecs/libgme/nes_vrc7_apu.h index aa8bb7648c..b37dfd63b0 100644 --- a/apps/codecs/libgme/nes_vrc7_apu.h +++ b/apps/codecs/libgme/nes_vrc7_apu.h | |||
@@ -27,7 +27,7 @@ struct Nes_Vrc7_Apu { | |||
27 | // See Nes_Apu.h for reference | 27 | // See Nes_Apu.h for reference |
28 | void Vrc7_init( struct Nes_Vrc7_Apu* this ); | 28 | void Vrc7_init( struct Nes_Vrc7_Apu* this ); |
29 | void Vrc7_reset( struct Nes_Vrc7_Apu* this ); | 29 | void Vrc7_reset( struct Nes_Vrc7_Apu* this ); |
30 | void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, double r ); | 30 | void Vrc7_set_rate( struct Nes_Vrc7_Apu* this, int r ); |
31 | void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t ) ICODE_ATTR; | 31 | void Vrc7_end_frame( struct Nes_Vrc7_Apu* this, blip_time_t ) ICODE_ATTR; |
32 | 32 | ||
33 | void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int reg ) ICODE_ATTR; | 33 | void Vrc7_write_reg( struct Nes_Vrc7_Apu* this, int reg ) ICODE_ATTR; |
diff --git a/apps/codecs/libgme/nsf_emu.c b/apps/codecs/libgme/nsf_emu.c index 1b8d98e51a..79a15e21f2 100644 --- a/apps/codecs/libgme/nsf_emu.c +++ b/apps/codecs/libgme/nsf_emu.c | |||
@@ -179,9 +179,9 @@ static bool pal_only( struct header_t* this ) | |||
179 | return (this->speed_flags & 3) == 1; | 179 | return (this->speed_flags & 3) == 1; |
180 | } | 180 | } |
181 | 181 | ||
182 | static double clock_rate( struct header_t* this ) | 182 | static long clock_rate( struct header_t* this ) |
183 | { | 183 | { |
184 | return pal_only( this ) ? 1662607.125 : 1789772.727272727; | 184 | return pal_only( this ) ? (long)1662607.125 : (long)1789772.727272727; |
185 | } | 185 | } |
186 | 186 | ||
187 | static int play_period( struct header_t* this ) | 187 | static int play_period( struct header_t* this ) |
@@ -206,7 +206,7 @@ static int play_period( struct header_t* this ) | |||
206 | 206 | ||
207 | // Custom rate | 207 | // Custom rate |
208 | if ( rate != value ) | 208 | if ( rate != value ) |
209 | clocks = (int) (rate * clock_rate( this ) * (1.0/1000000.0)); | 209 | clocks = (int) ((1LL * rate * clock_rate( this )) / 1000000); |
210 | 210 | ||
211 | return clocks; | 211 | return clocks; |
212 | } | 212 | } |
@@ -285,7 +285,7 @@ blargg_err_t Nsf_post_load( struct Nsf_Emu* this ) | |||
285 | this->track_count = this->header.track_count; | 285 | this->track_count = this->header.track_count; |
286 | 286 | ||
287 | // Change clock rate & setup buffer | 287 | // Change clock rate & setup buffer |
288 | this->clock_rate__ = (long) (clock_rate( &this->header ) + 0.5); | 288 | this->clock_rate__ = (long) clock_rate( &this->header ); |
289 | Buffer_clock_rate( &this->stereo_buf, this->clock_rate__ ); | 289 | Buffer_clock_rate( &this->stereo_buf, this->clock_rate__ ); |
290 | this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); | 290 | this->buf_changed_count = Buffer_channels_changed_count( &this->stereo_buf ); |
291 | return 0; | 291 | return 0; |
diff --git a/apps/codecs/libgme/nsf_emu.h b/apps/codecs/libgme/nsf_emu.h index 05b5e5a920..513443226c 100644 --- a/apps/codecs/libgme/nsf_emu.h +++ b/apps/codecs/libgme/nsf_emu.h | |||
@@ -112,7 +112,6 @@ struct Nsf_Emu { | |||
112 | long silence_count; // number of samples of silence to play before using buf | 112 | long silence_count; // number of samples of silence to play before using buf |
113 | long buf_remain; // number of samples left in silence buffer | 113 | long buf_remain; // number of samples left in silence buffer |
114 | 114 | ||
115 | double clock_rate_; | ||
116 | long clock_rate__; | 115 | long clock_rate__; |
117 | unsigned buf_changed_count; | 116 | unsigned buf_changed_count; |
118 | 117 | ||
diff --git a/apps/codecs/libgme/resampler.c b/apps/codecs/libgme/resampler.c index d9dcea02c6..a69a92cc53 100644 --- a/apps/codecs/libgme/resampler.c +++ b/apps/codecs/libgme/resampler.c | |||
@@ -24,15 +24,13 @@ unsigned const resampler_extra = 34; | |||
24 | enum { shift = 14 }; | 24 | enum { shift = 14 }; |
25 | int const unit = 1 << shift; | 25 | int const unit = 1 << shift; |
26 | 26 | ||
27 | blargg_err_t Resampler_setup( struct Resampler* this, double oversample, double rolloff, double gain ) | 27 | blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain ) |
28 | { | 28 | { |
29 | (void) rolloff; | 29 | this->gain_ = (int)( ((1LL << gain_bits) * fm_gain * gain) / FP_ONE_GAIN ); |
30 | 30 | this->step = (int)( ((1LL << shift) * fm_rate) / rate + 1); | |
31 | this->gain_ = (int)((1 << gain_bits) * gain); | 31 | this->rate_ = this->step; |
32 | this->step = (int) ( oversample * unit + 0.5); | 32 | return 0; |
33 | this->rate_ = 1.0 / unit * this->step; | 33 | } |
34 | return 0; | ||
35 | } | ||
36 | 34 | ||
37 | blargg_err_t Resampler_reset( struct Resampler* this, int pairs ) | 35 | blargg_err_t Resampler_reset( struct Resampler* this, int pairs ) |
38 | { | 36 | { |
@@ -52,7 +50,7 @@ void Resampler_resize( struct Resampler* this, int pairs ) | |||
52 | if ( this->sample_buf_size != new_sample_buf_size ) | 50 | if ( this->sample_buf_size != new_sample_buf_size ) |
53 | { | 51 | { |
54 | this->sample_buf_size = new_sample_buf_size; | 52 | this->sample_buf_size = new_sample_buf_size; |
55 | this->oversamples_per_frame = (int) (pairs * this->rate_) * 2 + 2; | 53 | this->oversamples_per_frame = (int) ((pairs * this->rate_ * 2LL) / unit) + 2; |
56 | Resampler_clear( this ); | 54 | Resampler_clear( this ); |
57 | } | 55 | } |
58 | } | 56 | } |
diff --git a/apps/codecs/libgme/resampler.h b/apps/codecs/libgme/resampler.h index f5e8c55119..741bdb50a4 100644 --- a/apps/codecs/libgme/resampler.h +++ b/apps/codecs/libgme/resampler.h | |||
@@ -31,7 +31,7 @@ struct Resampler { | |||
31 | int buffer_size; | 31 | int buffer_size; |
32 | 32 | ||
33 | int write_pos; | 33 | int write_pos; |
34 | double rate_; | 34 | int rate_; |
35 | 35 | ||
36 | int pos; | 36 | int pos; |
37 | int step; | 37 | int step; |
@@ -55,7 +55,7 @@ static inline void Resampler_set_callback(struct Resampler* this, int (*func)( v | |||
55 | this->callback_data = user_data; | 55 | this->callback_data = user_data; |
56 | } | 56 | } |
57 | 57 | ||
58 | blargg_err_t Resampler_setup( struct Resampler* this, double oversample, double rolloff, double gain ); | 58 | blargg_err_t Resampler_setup( struct Resampler* this, int fm_rate, int fm_gain, int rate, int gain ); |
59 | 59 | ||
60 | static inline void Resampler_clear( struct Resampler* this ) | 60 | static inline void Resampler_clear( struct Resampler* this ) |
61 | { | 61 | { |
diff --git a/apps/codecs/libgme/sms_fm_apu.c b/apps/codecs/libgme/sms_fm_apu.c index 93689cd811..5240405ad1 100644 --- a/apps/codecs/libgme/sms_fm_apu.c +++ b/apps/codecs/libgme/sms_fm_apu.c | |||
@@ -8,9 +8,9 @@ void Fm_apu_create( struct Sms_Fm_Apu* this ) | |||
8 | Ym2413_init( &this->apu ); | 8 | Ym2413_init( &this->apu ); |
9 | } | 9 | } |
10 | 10 | ||
11 | blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, double clock_rate, double sample_rate ) | 11 | blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, int clock_rate, int sample_rate ) |
12 | { | 12 | { |
13 | this->period_ = (blip_time_t) (clock_rate / sample_rate + 0.5); | 13 | this->period_ = (blip_time_t) (clock_rate / sample_rate); |
14 | CHECK_ALLOC( !Ym2413_set_rate( &this->apu, sample_rate, clock_rate ) ); | 14 | CHECK_ALLOC( !Ym2413_set_rate( &this->apu, sample_rate, clock_rate ) ); |
15 | 15 | ||
16 | Fm_apu_set_output( this, 0 ); | 16 | Fm_apu_set_output( this, 0 ); |
diff --git a/apps/codecs/libgme/sms_fm_apu.h b/apps/codecs/libgme/sms_fm_apu.h index f78af3065e..0dd882b0f4 100644 --- a/apps/codecs/libgme/sms_fm_apu.h +++ b/apps/codecs/libgme/sms_fm_apu.h | |||
@@ -24,7 +24,7 @@ struct Sms_Fm_Apu { | |||
24 | void Fm_apu_create( struct Sms_Fm_Apu* this ); | 24 | void Fm_apu_create( struct Sms_Fm_Apu* this ); |
25 | 25 | ||
26 | static inline bool Fm_apu_supported( void ) { return Ym2413_supported(); } | 26 | static inline bool Fm_apu_supported( void ) { return Ym2413_supported(); } |
27 | blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, double clock_rate, double sample_rate ); | 27 | blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, int clock_rate, int sample_rate ); |
28 | 28 | ||
29 | static inline void Fm_apu_set_output( struct Sms_Fm_Apu* this, struct Blip_Buffer* b ) | 29 | static inline void Fm_apu_set_output( struct Sms_Fm_Apu* this, struct Blip_Buffer* b ) |
30 | { | 30 | { |
diff --git a/apps/codecs/libgme/vgm_emu.c b/apps/codecs/libgme/vgm_emu.c index 82e30c0b0f..b442b3e84b 100644 --- a/apps/codecs/libgme/vgm_emu.c +++ b/apps/codecs/libgme/vgm_emu.c | |||
@@ -22,8 +22,6 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ | |||
22 | const char* const gme_wrong_file_type = "Wrong file type for this emulator"; | 22 | const char* const gme_wrong_file_type = "Wrong file type for this emulator"; |
23 | 23 | ||
24 | int const fm_gain = 3; // FM emulators are internally quieter to avoid 16-bit overflow | 24 | int const fm_gain = 3; // FM emulators are internally quieter to avoid 16-bit overflow |
25 | double const rolloff = 0.990; | ||
26 | double const oversample_factor = 1.5; | ||
27 | 25 | ||
28 | int const silence_max = 6; // seconds | 26 | int const silence_max = 6; // seconds |
29 | int const silence_threshold = 0x10; | 27 | int const silence_threshold = 0x10; |
@@ -310,7 +308,7 @@ blargg_err_t Vgm_load_mem( struct Vgm_Emu* this, byte const* new_data, long new_ | |||
310 | } | 308 | } |
311 | 309 | ||
312 | void update_fm_rates( struct Vgm_Emu* this, int* ym2413_rate, int* ym2612_rate ); | 310 | void update_fm_rates( struct Vgm_Emu* this, int* ym2413_rate, int* ym2612_rate ); |
313 | static blargg_err_t init_fm( struct Vgm_Emu* this, double* rate ) | 311 | static blargg_err_t init_fm( struct Vgm_Emu* this, int* rate ) |
314 | { | 312 | { |
315 | int ym2612_rate = get_le32( header( this )->ym2612_rate ); | 313 | int ym2612_rate = get_le32( header( this )->ym2612_rate ); |
316 | int ym2413_rate = get_le32( header( this )->ym2413_rate ); | 314 | int ym2413_rate = get_le32( header( this )->ym2413_rate ); |
@@ -320,14 +318,14 @@ static blargg_err_t init_fm( struct Vgm_Emu* this, double* rate ) | |||
320 | if ( ym2612_rate ) | 318 | if ( ym2612_rate ) |
321 | { | 319 | { |
322 | if ( !*rate ) | 320 | if ( !*rate ) |
323 | *rate = ym2612_rate / 144.0; | 321 | *rate = ym2612_rate / 144; |
324 | RETURN_ERR( Ym2612_set_rate( &this->ym2612, *rate, ym2612_rate ) ); | 322 | RETURN_ERR( Ym2612_set_rate( &this->ym2612, *rate, ym2612_rate ) ); |
325 | Ym2612_enable( &this->ym2612, true ); | 323 | Ym2612_enable( &this->ym2612, true ); |
326 | } | 324 | } |
327 | else if ( ym2413_rate ) | 325 | else if ( ym2413_rate ) |
328 | { | 326 | { |
329 | if ( !*rate ) | 327 | if ( !*rate ) |
330 | *rate = ym2413_rate / 72.0; | 328 | *rate = ym2413_rate / 72; |
331 | int result = Ym2413_set_rate( &this->ym2413, *rate, ym2413_rate ); | 329 | int result = Ym2413_set_rate( &this->ym2413, *rate, ym2413_rate ); |
332 | if ( result == 2 ) | 330 | if ( result == 2 ) |
333 | return "YM2413 FM sound not supported"; | 331 | return "YM2413 FM sound not supported"; |
@@ -342,15 +340,15 @@ static blargg_err_t init_fm( struct Vgm_Emu* this, double* rate ) | |||
342 | 340 | ||
343 | blargg_err_t setup_fm( struct Vgm_Emu* this ) | 341 | blargg_err_t setup_fm( struct Vgm_Emu* this ) |
344 | { | 342 | { |
345 | double fm_rate = 0.0; | 343 | int fm_rate = 0; |
346 | if ( !this->disable_oversampling ) | 344 | if ( !this->disable_oversampling ) |
347 | this->fm_rate = this->sample_rate * oversample_factor; | 345 | this->fm_rate = (this->sample_rate * 3) / 2; // oversample factor = 1.5 |
348 | RETURN_ERR( init_fm( this, &fm_rate ) ); | 346 | RETURN_ERR( init_fm( this, &fm_rate ) ); |
349 | 347 | ||
350 | if ( uses_fm( this ) ) | 348 | if ( uses_fm( this ) ) |
351 | { | 349 | { |
352 | this->voice_count = 8; | 350 | this->voice_count = 8; |
353 | RETURN_ERR( Resampler_setup( &this->resampler, fm_rate / this->sample_rate, rolloff, fm_gain * (double)(this->gain)/FP_ONE_GAIN ) ); | 351 | RETURN_ERR( Resampler_setup( &this->resampler, fm_rate, fm_gain, this->sample_rate, this->gain ) ); |
354 | RETURN_ERR( Resampler_reset( &this->resampler, Buffer_length( &this->stereo_buf ) * this->sample_rate / 1000 ) ); | 352 | RETURN_ERR( Resampler_reset( &this->resampler, Buffer_length( &this->stereo_buf ) * this->sample_rate / 1000 ) ); |
355 | Sms_apu_volume( &this->psg, ((this->gain/5)-(this->gain*5)/1000) * fm_gain ); | 353 | Sms_apu_volume( &this->psg, ((this->gain/5)-(this->gain*5)/1000) * fm_gain ); |
356 | } | 354 | } |
diff --git a/apps/codecs/libgme/vgm_emu.h b/apps/codecs/libgme/vgm_emu.h index 5a0f1e5fa5..65993dbd5d 100644 --- a/apps/codecs/libgme/vgm_emu.h +++ b/apps/codecs/libgme/vgm_emu.h | |||
@@ -63,7 +63,7 @@ struct track_info_t | |||
63 | // aliasing on high notes. Currently YM2413 support requires that you supply a | 63 | // aliasing on high notes. Currently YM2413 support requires that you supply a |
64 | // YM2413 sound chip emulator. I can provide one I've modified to work with the library. | 64 | // YM2413 sound chip emulator. I can provide one I've modified to work with the library. |
65 | struct Vgm_Emu { | 65 | struct Vgm_Emu { |
66 | double fm_rate; | 66 | int fm_rate; |
67 | long psg_rate; | 67 | long psg_rate; |
68 | long vgm_rate; | 68 | long vgm_rate; |
69 | bool disable_oversampling; | 69 | bool disable_oversampling; |
diff --git a/apps/codecs/libgme/ym2413_emu.c b/apps/codecs/libgme/ym2413_emu.c index 67870f31dc..9efd3dcc3d 100644 --- a/apps/codecs/libgme/ym2413_emu.c +++ b/apps/codecs/libgme/ym2413_emu.c | |||
@@ -7,7 +7,7 @@ void Ym2413_init( struct Ym2413_Emu* this ) | |||
7 | this->last_time = disabled_time; this->out = 0; | 7 | this->last_time = disabled_time; this->out = 0; |
8 | } | 8 | } |
9 | 9 | ||
10 | int Ym2413_set_rate( struct Ym2413_Emu* this, double sample_rate, double clock_rate ) | 10 | int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate ) |
11 | { | 11 | { |
12 | OPLL_new ( &this->opll, clock_rate, sample_rate ); | 12 | OPLL_new ( &this->opll, clock_rate, sample_rate ); |
13 | OPLL_reset_patch( &this->opll, OPLL_2413_TONE ); | 13 | OPLL_reset_patch( &this->opll, OPLL_2413_TONE ); |
diff --git a/apps/codecs/libgme/ym2413_emu.h b/apps/codecs/libgme/ym2413_emu.h index 71369e9c88..7efb8e2fab 100644 --- a/apps/codecs/libgme/ym2413_emu.h +++ b/apps/codecs/libgme/ym2413_emu.h | |||
@@ -25,7 +25,7 @@ static inline bool Ym2413_supported( void ) { return true; } | |||
25 | 25 | ||
26 | // Sets output sample rate and chip clock rates, in Hz. Returns non-zero | 26 | // Sets output sample rate and chip clock rates, in Hz. Returns non-zero |
27 | // if error. | 27 | // if error. |
28 | int Ym2413_set_rate( struct Ym2413_Emu* this, double sample_rate, double clock_rate ); | 28 | int Ym2413_set_rate( struct Ym2413_Emu* this, int sample_rate, int clock_rate ); |
29 | 29 | ||
30 | // Resets to power-up state | 30 | // Resets to power-up state |
31 | void Ym2413_reset( struct Ym2413_Emu* this ); | 31 | void Ym2413_reset( struct Ym2413_Emu* this ); |
diff --git a/apps/codecs/libgme/ym2612_emu.c b/apps/codecs/libgme/ym2612_emu.c index 54930298c9..2162d73850 100644 --- a/apps/codecs/libgme/ym2612_emu.c +++ b/apps/codecs/libgme/ym2612_emu.c | |||
@@ -682,15 +682,15 @@ static void impl_set_rate( struct Ym2612_Impl* impl, double sample_rate, double | |||
682 | impl_reset( impl ); | 682 | impl_reset( impl ); |
683 | } | 683 | } |
684 | 684 | ||
685 | const char* Ym2612_set_rate( struct Ym2612_Emu* this, double sample_rate, double clock_rate ) | 685 | const char* Ym2612_set_rate( struct Ym2612_Emu* this, int sample_rate, int clock_rate ) |
686 | { | 686 | { |
687 | // Only set rates if necessary | 687 | // Only set rates if necessary |
688 | #if defined(ROCKBOX) | 688 | #if defined(ROCKBOX) |
689 | static double last_sample_rate = 0.0, last_clock_rate = 0.0; | 689 | static int last_sample_rate = 0, last_clock_rate = 0; |
690 | if (last_sample_rate == sample_rate && last_clock_rate == clock_rate) return 0; | 690 | if (last_sample_rate == sample_rate && last_clock_rate == clock_rate) return 0; |
691 | #endif | 691 | #endif |
692 | memset( &this->impl.YM2612, 0, sizeof this->impl.YM2612 ); | 692 | memset( &this->impl.YM2612, 0, sizeof this->impl.YM2612 ); |
693 | impl_set_rate( &this->impl, sample_rate, clock_rate ); | 693 | impl_set_rate( &this->impl, (double)sample_rate, (double)clock_rate ); |
694 | 694 | ||
695 | return 0; | 695 | return 0; |
696 | } | 696 | } |
diff --git a/apps/codecs/libgme/ym2612_emu.h b/apps/codecs/libgme/ym2612_emu.h index 19f0903d61..9ca1989ced 100644 --- a/apps/codecs/libgme/ym2612_emu.h +++ b/apps/codecs/libgme/ym2612_emu.h | |||
@@ -199,7 +199,7 @@ static inline void Ym2612_init( struct Ym2612_Emu* this_ ) | |||
199 | 199 | ||
200 | // Sets sample rate and chip clock rate, in Hz. Returns non-zero | 200 | // Sets sample rate and chip clock rate, in Hz. Returns non-zero |
201 | // if error. If clock_rate=0, uses sample_rate*144 | 201 | // if error. If clock_rate=0, uses sample_rate*144 |
202 | const char* Ym2612_set_rate( struct Ym2612_Emu* this_, double sample_rate, double clock_rate ); | 202 | const char* Ym2612_set_rate( struct Ym2612_Emu* this_, int sample_rate, int clock_rate ); |
203 | 203 | ||
204 | // Resets to power-up state | 204 | // Resets to power-up state |
205 | void Ym2612_reset( struct Ym2612_Emu* this_ ); | 205 | void Ym2612_reset( struct Ym2612_Emu* this_ ); |