diff options
author | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-11 06:18:39 +0000 |
---|---|---|
committer | Andree Buschmann <AndreeBuschmann@t-online.de> | 2011-08-11 06:18:39 +0000 |
commit | 631d22b8e55f695a43d0e8ecc353f79688f32507 (patch) | |
tree | b11a9209680eb888253bd5355d71d80fde200a99 | |
parent | 4ca2367e34e095419fa7e4de240dd7416575398a (diff) | |
download | rockbox-631d22b8e55f695a43d0e8ecc353f79688f32507.tar.gz rockbox-631d22b8e55f695a43d0e8ecc353f79688f32507.zip |
4th part of FS#12176. Volume settings migrated to fixed point for libgme.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30278 a1c6a512-1295-4272-9138-f99709370657
36 files changed, 79 insertions, 88 deletions
diff --git a/apps/codecs/libgme/ay_apu.c b/apps/codecs/libgme/ay_apu.c index a2ec299167..8906c987c1 100644 --- a/apps/codecs/libgme/ay_apu.c +++ b/apps/codecs/libgme/ay_apu.c | |||
@@ -100,7 +100,7 @@ void Ay_apu_init( struct Ay_Apu* this ) | |||
100 | } | 100 | } |
101 | 101 | ||
102 | set_output( this, NULL ); | 102 | set_output( this, NULL ); |
103 | Ay_apu_volume( this, 1.0 ); | 103 | Ay_apu_volume( this, (int)FP_ONE_VOLUME ); |
104 | Ay_apu_reset( this ); | 104 | Ay_apu_reset( this ); |
105 | } | 105 | } |
106 | 106 | ||
diff --git a/apps/codecs/libgme/ay_apu.h b/apps/codecs/libgme/ay_apu.h index ccdd204c46..a18e3e7860 100644 --- a/apps/codecs/libgme/ay_apu.h +++ b/apps/codecs/libgme/ay_apu.h | |||
@@ -57,7 +57,7 @@ int Ay_apu_read( struct Ay_Apu* this ); | |||
57 | void Ay_apu_reset( struct Ay_Apu* this ); | 57 | void Ay_apu_reset( struct Ay_Apu* this ); |
58 | 58 | ||
59 | // Sets overall volume, where 1.0 is normal | 59 | // Sets overall volume, where 1.0 is normal |
60 | static inline void Ay_apu_volume( struct Ay_Apu* this, double v ) { Synth_volume( &this->synth_, 0.7/ay_osc_count/ay_amp_range * v ); } | 60 | static inline void Ay_apu_volume( struct Ay_Apu* this, int v ) { Synth_volume( &this->synth_, (v*7)/10 /ay_osc_count/ay_amp_range ); } |
61 | 61 | ||
62 | static inline void Ay_apu_set_output( struct Ay_Apu* this, int i, struct Blip_Buffer* out ) | 62 | static inline void Ay_apu_set_output( struct Ay_Apu* this, int i, struct Blip_Buffer* out ) |
63 | { | 63 | { |
diff --git a/apps/codecs/libgme/ay_emu.c b/apps/codecs/libgme/ay_emu.c index 3c4398471c..06946a9766 100644 --- a/apps/codecs/libgme/ay_emu.c +++ b/apps/codecs/libgme/ay_emu.c | |||
@@ -144,7 +144,7 @@ blargg_err_t Ay_load_mem( struct Ay_Emu *this, byte const in [], int size ) | |||
144 | warning( "Unknown file version" ); */ | 144 | warning( "Unknown file version" ); */ |
145 | 145 | ||
146 | this->voice_count = ay_osc_count + 1; // +1 for beeper | 146 | this->voice_count = ay_osc_count + 1; // +1 for beeper |
147 | Ay_apu_volume( &this->apu, ((double)this->gain)/FP_ONE_GAIN); | 147 | Ay_apu_volume( &this->apu, this->gain); |
148 | 148 | ||
149 | // Setup buffer | 149 | // Setup buffer |
150 | change_clock_rate( this, spectrum_clock ); | 150 | change_clock_rate( this, spectrum_clock ); |
@@ -483,7 +483,7 @@ blargg_err_t Ay_start_track( struct Ay_Emu *this, int track ) | |||
483 | Z80_map_mem( &this->cpu, 0, mem_size, this->mem.ram, this->mem.ram ); | 483 | Z80_map_mem( &this->cpu, 0, mem_size, this->mem.ram, this->mem.ram ); |
484 | this->cpu.r = r; | 484 | this->cpu.r = r; |
485 | 485 | ||
486 | this->beeper_delta = (int) (ay_amp_range * 0.8); | 486 | this->beeper_delta = (int) ((ay_amp_range*4)/5); |
487 | this->last_beeper = 0; | 487 | this->last_beeper = 0; |
488 | this->next_play = this->play_period; | 488 | this->next_play = this->play_period; |
489 | this->spectrum_mode = false; | 489 | this->spectrum_mode = false; |
diff --git a/apps/codecs/libgme/blargg_common.h b/apps/codecs/libgme/blargg_common.h index 190af65f23..0f955e5151 100644 --- a/apps/codecs/libgme/blargg_common.h +++ b/apps/codecs/libgme/blargg_common.h | |||
@@ -21,8 +21,9 @@ | |||
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | // common defines | 23 | // common defines |
24 | #define FP_ONE_TEMPO (1LL <<24) | 24 | #define FP_ONE_TEMPO (1LL << 24) |
25 | #define FP_ONE_GAIN (1LL <<24) | 25 | #define FP_ONE_GAIN (1LL << 24) |
26 | #define FP_ONE_VOLUME FP_ONE_GAIN | ||
26 | 27 | ||
27 | #if 1 /* IRAM configuration is not yet active for all libGME codecs. */ | 28 | #if 1 /* IRAM configuration is not yet active for all libGME codecs. */ |
28 | #undef ICODE_ATTR | 29 | #undef ICODE_ATTR |
diff --git a/apps/codecs/libgme/blip_buffer.c b/apps/codecs/libgme/blip_buffer.c index 2a015d75c4..d8ecbb8bb2 100644 --- a/apps/codecs/libgme/blip_buffer.c +++ b/apps/codecs/libgme/blip_buffer.c | |||
@@ -106,18 +106,9 @@ blargg_err_t Blip_set_sample_rate( struct Blip_Buffer* this, long new_rate, int | |||
106 | return 0; // success | 106 | return 0; // success |
107 | } | 107 | } |
108 | 108 | ||
109 | /* Not sure if this affects sound quality */ | ||
110 | #if defined(ROCKBOX) | ||
111 | double floor(double x) { | ||
112 | if ( x > 0 ) return (int)x; | ||
113 | return (int)(x-0.9999999999999999); | ||
114 | } | ||
115 | #endif | ||
116 | |||
117 | blip_resampled_time_t Blip_clock_rate_factor( struct Blip_Buffer* this, long rate ) | 109 | blip_resampled_time_t Blip_clock_rate_factor( struct Blip_Buffer* this, long rate ) |
118 | { | 110 | { |
119 | double ratio = (double) this->sample_rate_ / rate; | 111 | blip_long factor = (blip_long) ( this->sample_rate_ * (1LL << BLIP_BUFFER_ACCURACY) / rate); |
120 | blip_long factor = (blip_long) floor( ratio * (1L << BLIP_BUFFER_ACCURACY) + 0.5 ); | ||
121 | assert( factor > 0 || !this->sample_rate_ ); // fails if clock/output ratio is too large | 112 | assert( factor > 0 || !this->sample_rate_ ); // fails if clock/output ratio is too large |
122 | return (blip_resampled_time_t) factor; | 113 | return (blip_resampled_time_t) factor; |
123 | } | 114 | } |
@@ -279,7 +270,7 @@ void Synth_init( struct Blip_Synth* this ) | |||
279 | } | 270 | } |
280 | 271 | ||
281 | // Set overall volume of waveform | 272 | // Set overall volume of waveform |
282 | void Synth_volume( struct Blip_Synth* this, double v ) | 273 | void Synth_volume( struct Blip_Synth* this, int v ) |
283 | { | 274 | { |
284 | this->delta_factor = (int) (v * (1L << blip_sample_bits) + 0.5); | 275 | this->delta_factor = (int) (v * (1LL << blip_sample_bits) / FP_ONE_VOLUME); |
285 | } | 276 | } |
diff --git a/apps/codecs/libgme/blip_buffer.h b/apps/codecs/libgme/blip_buffer.h index 84ed6e6690..d03e1c0998 100644 --- a/apps/codecs/libgme/blip_buffer.h +++ b/apps/codecs/libgme/blip_buffer.h | |||
@@ -170,7 +170,7 @@ struct Blip_Synth { | |||
170 | void Synth_init( struct Blip_Synth* this ); | 170 | void Synth_init( struct Blip_Synth* this ); |
171 | 171 | ||
172 | // Set overall volume of waveform | 172 | // Set overall volume of waveform |
173 | void Synth_volume( struct Blip_Synth* this, double v ) ICODE_ATTR; | 173 | void Synth_volume( struct Blip_Synth* this, int v ) ICODE_ATTR; |
174 | 174 | ||
175 | // Get/set Blip_Buffer used for output | 175 | // Get/set Blip_Buffer used for output |
176 | const struct Blip_Buffer* Synth_output( struct Blip_Synth* this ) ICODE_ATTR; | 176 | const struct Blip_Buffer* Synth_output( struct Blip_Synth* this ) ICODE_ATTR; |
diff --git a/apps/codecs/libgme/gb_apu.c b/apps/codecs/libgme/gb_apu.c index adc307156c..f6da1b034a 100644 --- a/apps/codecs/libgme/gb_apu.c +++ b/apps/codecs/libgme/gb_apu.c | |||
@@ -51,7 +51,7 @@ void Apu_set_output( struct Gb_Apu* this, int i, struct Blip_Buffer* center, str | |||
51 | 51 | ||
52 | void synth_volume( struct Gb_Apu* this, int iv ) | 52 | void synth_volume( struct Gb_Apu* this, int iv ) |
53 | { | 53 | { |
54 | double v = this->volume_ * 0.60 / osc_count / 15 /*steps*/ / 8 /*master vol range*/ * iv; | 54 | int v = (this->volume_ * 6) / 10 / osc_count / 15 /*steps*/ / 8 /*master vol range*/ * iv; |
55 | Synth_volume( &this->synth, v ); | 55 | Synth_volume( &this->synth, v ); |
56 | } | 56 | } |
57 | 57 | ||
@@ -67,7 +67,7 @@ void apply_volume( struct Gb_Apu* this ) | |||
67 | synth_volume( this, max( left, right ) + 1 ); | 67 | synth_volume( this, max( left, right ) + 1 ); |
68 | } | 68 | } |
69 | 69 | ||
70 | void Apu_volume( struct Gb_Apu* this, double v ) | 70 | void Apu_volume( struct Gb_Apu* this, int v ) |
71 | { | 71 | { |
72 | if ( this->volume_ != v ) | 72 | if ( this->volume_ != v ) |
73 | { | 73 | { |
@@ -185,7 +185,7 @@ void Apu_init( struct Gb_Apu* this ) | |||
185 | 185 | ||
186 | this->reduce_clicks_ = false; | 186 | this->reduce_clicks_ = false; |
187 | Apu_set_tempo( this, (int)FP_ONE_TEMPO ); | 187 | Apu_set_tempo( this, (int)FP_ONE_TEMPO ); |
188 | this->volume_ = 1.0; | 188 | this->volume_ = (int)FP_ONE_VOLUME; |
189 | Apu_reset( this, mode_cgb, false ); | 189 | Apu_reset( this, mode_cgb, false ); |
190 | } | 190 | } |
191 | 191 | ||
diff --git a/apps/codecs/libgme/gb_apu.h b/apps/codecs/libgme/gb_apu.h index 028be29d7c..642db8f32f 100644 --- a/apps/codecs/libgme/gb_apu.h +++ b/apps/codecs/libgme/gb_apu.h | |||
@@ -27,7 +27,7 @@ struct Gb_Apu { | |||
27 | struct Gb_Osc* oscs [osc_count]; | 27 | struct Gb_Osc* oscs [osc_count]; |
28 | blip_time_t last_time; // time sound emulator has been run to | 28 | blip_time_t last_time; // time sound emulator has been run to |
29 | blip_time_t frame_period; // clocks between each frame sequencer step | 29 | blip_time_t frame_period; // clocks between each frame sequencer step |
30 | double volume_; | 30 | int volume_; |
31 | bool reduce_clicks_; | 31 | bool reduce_clicks_; |
32 | 32 | ||
33 | struct Gb_Square square1; | 33 | struct Gb_Square square1; |
@@ -69,7 +69,7 @@ void Apu_set_output( struct Gb_Apu* this, int chan, struct Blip_Buffer* center, | |||
69 | struct Blip_Buffer* left, struct Blip_Buffer* right ); | 69 | struct Blip_Buffer* left, struct Blip_Buffer* right ); |
70 | 70 | ||
71 | // Sets overall volume, where 1.0 is normal | 71 | // Sets overall volume, where 1.0 is normal |
72 | void Apu_volume( struct Gb_Apu* this, double v ); | 72 | void Apu_volume( struct Gb_Apu* this, int v ); |
73 | 73 | ||
74 | // If true, reduces clicking by disabling DAC biasing. Note that this reduces | 74 | // If true, reduces clicking by disabling DAC biasing. Note that this reduces |
75 | // emulation accuracy, since the clicks are authentic. | 75 | // emulation accuracy, since the clicks are authentic. |
diff --git a/apps/codecs/libgme/gbs_emu.c b/apps/codecs/libgme/gbs_emu.c index 664510d5fa..a0e7f184c7 100644 --- a/apps/codecs/libgme/gbs_emu.c +++ b/apps/codecs/libgme/gbs_emu.c | |||
@@ -112,7 +112,7 @@ blargg_err_t Gbs_load( struct Gbs_Emu* this, void* data, long size ) | |||
112 | Rom_set_addr( &this->rom, load_addr ); | 112 | Rom_set_addr( &this->rom, load_addr ); |
113 | 113 | ||
114 | this->voice_count_ = osc_count; | 114 | this->voice_count_ = osc_count; |
115 | Apu_volume( &this->apu, (double)(this->gain_)/FP_ONE_GAIN ); | 115 | Apu_volume( &this->apu, this->gain_ ); |
116 | 116 | ||
117 | // Change clock rate & setup buffer | 117 | // Change clock rate & setup buffer |
118 | this->clock_rate_ = 4194304; | 118 | this->clock_rate_ = 4194304; |
diff --git a/apps/codecs/libgme/hes_apu.h b/apps/codecs/libgme/hes_apu.h index 8a49a5afc7..fcdcbab786 100644 --- a/apps/codecs/libgme/hes_apu.h +++ b/apps/codecs/libgme/hes_apu.h | |||
@@ -51,5 +51,5 @@ void Apu_osc_output( struct Hes_Apu* this, int index, struct Blip_Buffer* center | |||
51 | void Apu_write_data( struct Hes_Apu* this, blip_time_t, int addr, int data ) ICODE_ATTR; | 51 | void Apu_write_data( struct Hes_Apu* this, blip_time_t, int addr, int data ) ICODE_ATTR; |
52 | void Apu_end_frame( struct Hes_Apu* this, blip_time_t ) ICODE_ATTR; | 52 | void Apu_end_frame( struct Hes_Apu* this, blip_time_t ) ICODE_ATTR; |
53 | 53 | ||
54 | static inline void Apu_volume( struct Hes_Apu* this, double v ) { Synth_volume( &this->synth, 1.8 / osc_count / amp_range * v ); } | 54 | static inline void Apu_volume( struct Hes_Apu* this, int v ) { Synth_volume( &this->synth, (v*9)/5 / osc_count / amp_range ); } |
55 | #endif | 55 | #endif |
diff --git a/apps/codecs/libgme/hes_apu_adpcm.h b/apps/codecs/libgme/hes_apu_adpcm.h index 5478f2b360..38b8839276 100644 --- a/apps/codecs/libgme/hes_apu_adpcm.h +++ b/apps/codecs/libgme/hes_apu_adpcm.h | |||
@@ -85,5 +85,5 @@ int Adpcm_read_data( struct Hes_Apu_Adpcm* this, blip_time_t t, int addr ) ICODE | |||
85 | void Adpcm_end_frame( struct Hes_Apu_Adpcm* this,blip_time_t t ) ICODE_ATTR; | 85 | void Adpcm_end_frame( struct Hes_Apu_Adpcm* this,blip_time_t t ) ICODE_ATTR; |
86 | 86 | ||
87 | // Sets overall volume, where 1.0 is normal | 87 | // Sets overall volume, where 1.0 is normal |
88 | static inline void Adpcm_volume( struct Hes_Apu_Adpcm* this, double v ) { Synth_volume( &this->synth, 0.6 / adpcm_osc_count / adpcm_amp_range * v ); } | 88 | static inline void Adpcm_volume( struct Hes_Apu_Adpcm* this, int v ) { Synth_volume( &this->synth, (v*3)/5 / adpcm_osc_count / adpcm_amp_range ); } |
89 | #endif | 89 | #endif |
diff --git a/apps/codecs/libgme/hes_emu.c b/apps/codecs/libgme/hes_emu.c index ae4e68e48e..10ec9a2128 100644 --- a/apps/codecs/libgme/hes_emu.c +++ b/apps/codecs/libgme/hes_emu.c | |||
@@ -131,8 +131,8 @@ blargg_err_t Hes_load( struct Hes_Emu* this, void* data, long size ) | |||
131 | 131 | ||
132 | this->voice_count_ = osc_count + adpcm_osc_count; | 132 | this->voice_count_ = osc_count + adpcm_osc_count; |
133 | 133 | ||
134 | Apu_volume( &this->apu, (double)(this->gain_)/FP_ONE_GAIN ); | 134 | Apu_volume( &this->apu, this->gain_ ); |
135 | Adpcm_volume( &this->adpcm, (double)(this->gain_)/FP_ONE_GAIN ); | 135 | Adpcm_volume( &this->adpcm, this->gain_ ); |
136 | 136 | ||
137 | // Setup buffer | 137 | // Setup buffer |
138 | this->clock_rate_ = 7159091; | 138 | this->clock_rate_ = 7159091; |
diff --git a/apps/codecs/libgme/kss_emu.c b/apps/codecs/libgme/kss_emu.c index 00991be8b5..102fbf926d 100644 --- a/apps/codecs/libgme/kss_emu.c +++ b/apps/codecs/libgme/kss_emu.c | |||
@@ -110,12 +110,12 @@ void update_gain( struct Kss_Emu* this ) | |||
110 | g = (g*6) / 5; //g *= 1.2; | 110 | g = (g*6) / 5; //g *= 1.2; |
111 | } | 111 | } |
112 | 112 | ||
113 | if ( sms_psg_enabled( this ) ) Sms_apu_volume( &this->sms.psg, (double)(g)/FP_ONE_GAIN ); | 113 | if ( sms_psg_enabled( this ) ) Sms_apu_volume( &this->sms.psg, g ); |
114 | if ( sms_fm_enabled( this ) ) Opl_volume( &this->sms.fm, (double)(g)/FP_ONE_GAIN ); | 114 | if ( sms_fm_enabled( this ) ) Opl_volume( &this->sms.fm, g ); |
115 | if ( msx_psg_enabled( this ) ) Ay_apu_volume( &this->msx.psg, (double)(g)/FP_ONE_GAIN ); | 115 | if ( msx_psg_enabled( this ) ) Ay_apu_volume( &this->msx.psg, g ); |
116 | if ( msx_scc_enabled( this ) ) Scc_volume( &this->msx.scc, (double)(g)/FP_ONE_GAIN ); | 116 | if ( msx_scc_enabled( this ) ) Scc_volume( &this->msx.scc, g ); |
117 | if ( msx_music_enabled( this ) ) Opl_volume( &this->msx.music, (double)(g)/FP_ONE_GAIN ); | 117 | if ( msx_music_enabled( this ) ) Opl_volume( &this->msx.music, g ); |
118 | if ( msx_audio_enabled( this ) ) Opl_volume( &this->msx.audio, (double)(g)/FP_ONE_GAIN ); | 118 | if ( msx_audio_enabled( this ) ) Opl_volume( &this->msx.audio, g ); |
119 | } | 119 | } |
120 | 120 | ||
121 | blargg_err_t Kss_load_mem( struct Kss_Emu* this, const void* data, long size ) | 121 | blargg_err_t Kss_load_mem( struct Kss_Emu* this, const void* data, long size ) |
diff --git a/apps/codecs/libgme/kss_scc_apu.c b/apps/codecs/libgme/kss_scc_apu.c index 0e71b1ce3b..1bec9b7f0e 100644 --- a/apps/codecs/libgme/kss_scc_apu.c +++ b/apps/codecs/libgme/kss_scc_apu.c | |||
@@ -28,9 +28,9 @@ static void set_output( struct Scc_Apu* this, struct Blip_Buffer* buf ) | |||
28 | Scc_set_output( this, i, buf ); | 28 | Scc_set_output( this, i, buf ); |
29 | } | 29 | } |
30 | 30 | ||
31 | void Scc_volume( struct Scc_Apu* this, double v ) | 31 | void Scc_volume( struct Scc_Apu* this, int v ) |
32 | { | 32 | { |
33 | Synth_volume( &this->synth, 0.43 / scc_osc_count / scc_amp_range * v ); | 33 | Synth_volume( &this->synth, (v/2 - (v*7)/100) / scc_osc_count / scc_amp_range ); |
34 | } | 34 | } |
35 | 35 | ||
36 | void Scc_reset( struct Scc_Apu* this ) | 36 | void Scc_reset( struct Scc_Apu* this ) |
@@ -49,7 +49,7 @@ void Scc_init( struct Scc_Apu* this ) | |||
49 | Synth_init( &this->synth); | 49 | Synth_init( &this->synth); |
50 | 50 | ||
51 | set_output( this, NULL ); | 51 | set_output( this, NULL ); |
52 | Scc_volume( this, 1.0 ); | 52 | Scc_volume( this, (int)FP_ONE_VOLUME ); |
53 | Scc_reset( this ); | 53 | Scc_reset( this ); |
54 | } | 54 | } |
55 | 55 | ||
diff --git a/apps/codecs/libgme/kss_scc_apu.h b/apps/codecs/libgme/kss_scc_apu.h index f31228a39d..26425b38c7 100644 --- a/apps/codecs/libgme/kss_scc_apu.h +++ b/apps/codecs/libgme/kss_scc_apu.h | |||
@@ -33,7 +33,7 @@ void Scc_init( struct Scc_Apu* this ); | |||
33 | void Scc_reset( struct Scc_Apu* this ); | 33 | void Scc_reset( struct Scc_Apu* this ); |
34 | 34 | ||
35 | // Set overall volume, where 1.0 is normal | 35 | // Set overall volume, where 1.0 is normal |
36 | void Scc_volume( struct Scc_Apu* this, double v ); | 36 | void Scc_volume( struct Scc_Apu* this, int v ); |
37 | 37 | ||
38 | static inline void Scc_set_output( struct Scc_Apu* this, int index, struct Blip_Buffer* b ) | 38 | static inline void Scc_set_output( struct Scc_Apu* this, int index, struct Blip_Buffer* b ) |
39 | { | 39 | { |
diff --git a/apps/codecs/libgme/nes_apu.c b/apps/codecs/libgme/nes_apu.c index 826c768770..2e304325c2 100644 --- a/apps/codecs/libgme/nes_apu.c +++ b/apps/codecs/libgme/nes_apu.c | |||
@@ -39,19 +39,18 @@ void Apu_init( struct Nes_Apu* this ) | |||
39 | this->oscs [4] = &this->dmc.osc; | 39 | this->oscs [4] = &this->dmc.osc; |
40 | 40 | ||
41 | Apu_output( this, NULL ); | 41 | Apu_output( this, NULL ); |
42 | Apu_volume( this, 1.0 ); | 42 | Apu_volume( this, (int)FP_ONE_VOLUME ); |
43 | Apu_reset( this, false, 0 ); | 43 | Apu_reset( this, false, 0 ); |
44 | } | 44 | } |
45 | 45 | ||
46 | static double nonlinear_tnd_gain( void ) { return 0.75; } | 46 | void Apu_enable_nonlinear( struct Nes_Apu* this, int v ) |
47 | void Apu_enable_nonlinear( struct Nes_Apu* this, double v ) | ||
48 | { | 47 | { |
49 | this->dmc.nonlinear = true; | 48 | this->dmc.nonlinear = true; |
50 | Synth_volume( &this->square_synth, 1.3 * 0.25751258 / 0.742467605 * 0.25 / amp_range * v ); | 49 | Synth_volume( &this->square_synth, (int)((1.3 * 0.25751258 / 0.742467605 * 0.25 * FP_ONE_VOLUME) / amp_range * v) ); |
51 | 50 | ||
52 | const double tnd = 0.48 / 202 * nonlinear_tnd_gain(); | 51 | const int tnd = (int)(0.48 / 202 * 0.75 * FP_ONE_VOLUME); |
53 | Synth_volume( &this->triangle.synth, 3.0 * tnd ); | 52 | Synth_volume( &this->triangle.synth, 3 * tnd ); |
54 | Synth_volume( &this->noise.synth, 2.0 * tnd ); | 53 | Synth_volume( &this->noise.synth, 2 * tnd ); |
55 | Synth_volume( &this->dmc.synth, tnd ); | 54 | Synth_volume( &this->dmc.synth, tnd ); |
56 | 55 | ||
57 | this->square1 .osc.last_amp = 0; | 56 | this->square1 .osc.last_amp = 0; |
@@ -61,13 +60,13 @@ void Apu_enable_nonlinear( struct Nes_Apu* this, double v ) | |||
61 | this->dmc .osc.last_amp = 0; | 60 | this->dmc .osc.last_amp = 0; |
62 | } | 61 | } |
63 | 62 | ||
64 | void Apu_volume( struct Nes_Apu* this, double v ) | 63 | void Apu_volume( struct Nes_Apu* this, int v ) |
65 | { | 64 | { |
66 | this->dmc.nonlinear = false; | 65 | this->dmc.nonlinear = false; |
67 | Synth_volume( &this->square_synth, 0.1128 / amp_range * v ); | 66 | Synth_volume( &this->square_synth, (int)((long long)(0.1128 *FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); |
68 | Synth_volume( &this->triangle.synth,0.12765 / amp_range * v ); | 67 | Synth_volume( &this->triangle.synth,(int)((long long)(0.12765*FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); |
69 | Synth_volume( &this->noise.synth, 0.0741 / amp_range * v ); | 68 | Synth_volume( &this->noise.synth, (int)((long long)(0.0741 *FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); |
70 | Synth_volume( &this->dmc.synth, 0.42545 / 127 * v ); | 69 | Synth_volume( &this->dmc.synth, (int)((long long)(0.42545*FP_ONE_VOLUME) * v / 127 / FP_ONE_VOLUME) ); |
71 | } | 70 | } |
72 | 71 | ||
73 | void Apu_output( struct Nes_Apu* this, struct Blip_Buffer* buffer ) | 72 | void Apu_output( struct Nes_Apu* this, struct Blip_Buffer* buffer ) |
diff --git a/apps/codecs/libgme/nes_apu.h b/apps/codecs/libgme/nes_apu.h index 8653afc41d..eb85a03f13 100644 --- a/apps/codecs/libgme/nes_apu.h +++ b/apps/codecs/libgme/nes_apu.h | |||
@@ -77,7 +77,7 @@ void Apu_reset( struct Nes_Apu* this, bool pal_mode, int initial_dmc_dac ); | |||
77 | void Apu_set_tempo( struct Nes_Apu* this, int ); | 77 | void Apu_set_tempo( struct Nes_Apu* this, int ); |
78 | 78 | ||
79 | // Set overall volume (default is 1.0) | 79 | // Set overall volume (default is 1.0) |
80 | void Apu_volume( struct Nes_Apu* this, double ); | 80 | void Apu_volume( struct Nes_Apu* this, int ); |
81 | 81 | ||
82 | // Run DMC until specified time, so that any DMC memory reads can be | 82 | // Run DMC until specified time, so that any DMC memory reads can be |
83 | // accounted for (i.e. inserting cpu wait states). | 83 | // accounted for (i.e. inserting cpu wait states). |
diff --git a/apps/codecs/libgme/nes_fds_apu.c b/apps/codecs/libgme/nes_fds_apu.c index f78e962455..d021cfd289 100644 --- a/apps/codecs/libgme/nes_fds_apu.c +++ b/apps/codecs/libgme/nes_fds_apu.c | |||
@@ -23,7 +23,7 @@ void Fds_init( struct Nes_Fds_Apu* this ) | |||
23 | 23 | ||
24 | this->lfo_tempo = lfo_base_tempo; | 24 | this->lfo_tempo = lfo_base_tempo; |
25 | Fds_set_output( this, 0, NULL ); | 25 | Fds_set_output( this, 0, NULL ); |
26 | Fds_volume( this, 1.0 ); | 26 | Fds_volume( this, (int)FP_ONE_VOLUME ); |
27 | Fds_reset( this ); | 27 | Fds_reset( this ); |
28 | } | 28 | } |
29 | 29 | ||
diff --git a/apps/codecs/libgme/nes_fds_apu.h b/apps/codecs/libgme/nes_fds_apu.h index 47b17eb754..951aff0ee9 100644 --- a/apps/codecs/libgme/nes_fds_apu.h +++ b/apps/codecs/libgme/nes_fds_apu.h | |||
@@ -53,9 +53,9 @@ void Fds_set_tempo( struct Nes_Fds_Apu* this, int t ); | |||
53 | // emulation | 53 | // emulation |
54 | void Fds_reset( struct Nes_Fds_Apu* this ); | 54 | void Fds_reset( struct Nes_Fds_Apu* this ); |
55 | 55 | ||
56 | static inline void Fds_volume( struct Nes_Fds_Apu* this, double v ) | 56 | static inline void Fds_volume( struct Nes_Fds_Apu* this, int v ) |
57 | { | 57 | { |
58 | Synth_volume( &this->synth, 0.14 / fds_master_vol_max / fds_vol_max / fds_wave_sample_max * v ); | 58 | Synth_volume( &this->synth, (v*14) / 100 / fds_master_vol_max / fds_vol_max / fds_wave_sample_max ); |
59 | } | 59 | } |
60 | 60 | ||
61 | static inline void Fds_set_output( struct Nes_Fds_Apu* this, int i, struct Blip_Buffer* b ) | 61 | static inline void Fds_set_output( struct Nes_Fds_Apu* this, int i, struct Blip_Buffer* b ) |
diff --git a/apps/codecs/libgme/nes_fme7_apu.c b/apps/codecs/libgme/nes_fme7_apu.c index cb5ed93be5..068a21f1bf 100644 --- a/apps/codecs/libgme/nes_fme7_apu.c +++ b/apps/codecs/libgme/nes_fme7_apu.c | |||
@@ -22,7 +22,7 @@ void Fme7_init( struct Nes_Fme7_Apu* this ) | |||
22 | Synth_init( &this->synth ); | 22 | Synth_init( &this->synth ); |
23 | 23 | ||
24 | Fme7_output( this, NULL ); | 24 | Fme7_output( this, NULL ); |
25 | Fme7_volume( this, 1.0 ); | 25 | Fme7_volume( this, (int)FP_ONE_VOLUME ); |
26 | Fme7_reset( this ); | 26 | Fme7_reset( this ); |
27 | } | 27 | } |
28 | 28 | ||
diff --git a/apps/codecs/libgme/nes_fme7_apu.h b/apps/codecs/libgme/nes_fme7_apu.h index 47b93e5cfe..0d6bef0f3e 100644 --- a/apps/codecs/libgme/nes_fme7_apu.h +++ b/apps/codecs/libgme/nes_fme7_apu.h | |||
@@ -41,9 +41,9 @@ struct Nes_Fme7_Apu { | |||
41 | void Fme7_init( struct Nes_Fme7_Apu* this ); | 41 | void Fme7_init( struct Nes_Fme7_Apu* this ); |
42 | void Fme7_reset( struct Nes_Fme7_Apu* this ); | 42 | void Fme7_reset( struct Nes_Fme7_Apu* this ); |
43 | 43 | ||
44 | static inline void Fme7_volume( struct Nes_Fme7_Apu* this, double v ) | 44 | static inline void Fme7_volume( struct Nes_Fme7_Apu* this, int v ) |
45 | { | 45 | { |
46 | Synth_volume( &this->synth, 0.38 / amp_range * v ); // to do: fine-tune | 46 | Synth_volume( &this->synth, (v/2 - (v*3)/25) / amp_range ); // to do: fine-tune |
47 | } | 47 | } |
48 | 48 | ||
49 | static inline void Fme7_osc_output( struct Nes_Fme7_Apu* this, int i, struct Blip_Buffer* buf ) | 49 | static inline void Fme7_osc_output( struct Nes_Fme7_Apu* this, int i, struct Blip_Buffer* buf ) |
diff --git a/apps/codecs/libgme/nes_namco_apu.c b/apps/codecs/libgme/nes_namco_apu.c index 0fca501eff..0f64d3c84f 100644 --- a/apps/codecs/libgme/nes_namco_apu.c +++ b/apps/codecs/libgme/nes_namco_apu.c | |||
@@ -20,7 +20,7 @@ void Namco_init( struct Nes_Namco_Apu* this ) | |||
20 | Synth_init( &this->synth ); | 20 | Synth_init( &this->synth ); |
21 | 21 | ||
22 | Namco_output( this, NULL ); | 22 | Namco_output( this, NULL ); |
23 | Namco_volume( this, 1.0 ); | 23 | Namco_volume( this, (int)FP_ONE_VOLUME ); |
24 | Namco_reset( this ); | 24 | Namco_reset( this ); |
25 | } | 25 | } |
26 | 26 | ||
diff --git a/apps/codecs/libgme/nes_namco_apu.h b/apps/codecs/libgme/nes_namco_apu.h index b53b69808b..5f9f1c84a0 100644 --- a/apps/codecs/libgme/nes_namco_apu.h +++ b/apps/codecs/libgme/nes_namco_apu.h | |||
@@ -47,7 +47,7 @@ static inline uint8_t* namco_access( struct Nes_Namco_Apu* this ) | |||
47 | return &this->reg [addr]; | 47 | return &this->reg [addr]; |
48 | } | 48 | } |
49 | 49 | ||
50 | static inline void Namco_volume( struct Nes_Namco_Apu* this, double v ) { Synth_volume( &this->synth, 0.10 / namco_osc_count * v / 15.0 ); } | 50 | static inline void Namco_volume( struct Nes_Namco_Apu* this, int v ) { Synth_volume( &this->synth, v / 10 / namco_osc_count / 15 ); } |
51 | 51 | ||
52 | // Write-only address register is at 0xF800 | 52 | // Write-only address register is at 0xF800 |
53 | static inline void Namco_write_addr( struct Nes_Namco_Apu* this, int v ) { this->addr_reg = v; } | 53 | static inline void Namco_write_addr( struct Nes_Namco_Apu* this, int v ) { this->addr_reg = v; } |
diff --git a/apps/codecs/libgme/nes_vrc6_apu.c b/apps/codecs/libgme/nes_vrc6_apu.c index 0aba81e57f..25b0cc48b1 100644 --- a/apps/codecs/libgme/nes_vrc6_apu.c +++ b/apps/codecs/libgme/nes_vrc6_apu.c | |||
@@ -21,7 +21,7 @@ void Vrc6_init( struct Nes_Vrc6_Apu* this ) | |||
21 | Synth_init( &this->square_synth ); | 21 | Synth_init( &this->square_synth ); |
22 | 22 | ||
23 | Vrc6_output( this, NULL ); | 23 | Vrc6_output( this, NULL ); |
24 | Vrc6_volume( this, 1.0 ); | 24 | Vrc6_volume( this, (int)FP_ONE_VOLUME ); |
25 | Vrc6_reset( this ); | 25 | Vrc6_reset( this ); |
26 | } | 26 | } |
27 | 27 | ||
diff --git a/apps/codecs/libgme/nes_vrc6_apu.h b/apps/codecs/libgme/nes_vrc6_apu.h index 540438f4a2..39ed006100 100644 --- a/apps/codecs/libgme/nes_vrc6_apu.h +++ b/apps/codecs/libgme/nes_vrc6_apu.h | |||
@@ -52,11 +52,11 @@ static inline void Vrc6_osc_output( struct Nes_Vrc6_Apu* this, int i, struct Bli | |||
52 | this->oscs [i].output = buf; | 52 | this->oscs [i].output = buf; |
53 | } | 53 | } |
54 | 54 | ||
55 | static inline void Vrc6_volume( struct Nes_Vrc6_Apu* this, double v ) | 55 | static inline void Vrc6_volume( struct Nes_Vrc6_Apu* this, int v ) |
56 | { | 56 | { |
57 | double const factor = 0.0967 * 2; | 57 | long long const factor = (long long)(FP_ONE_VOLUME * 0.0967 * 2); |
58 | Synth_volume( &this->saw_synth, factor / 31 * v ); | 58 | Synth_volume( &this->saw_synth, (int)(v * factor / 31 / FP_ONE_VOLUME) ); |
59 | Synth_volume( &this->square_synth, factor * 0.5 / 15 * v ); | 59 | Synth_volume( &this->square_synth, (int)(v * factor / 2 / 15 / FP_ONE_VOLUME) ); |
60 | } | 60 | } |
61 | 61 | ||
62 | #endif | 62 | #endif |
diff --git a/apps/codecs/libgme/nes_vrc7_apu.c b/apps/codecs/libgme/nes_vrc7_apu.c index d8768bfc7e..6148a6b90f 100644 --- a/apps/codecs/libgme/nes_vrc7_apu.c +++ b/apps/codecs/libgme/nes_vrc7_apu.c | |||
@@ -15,7 +15,7 @@ void Vrc7_init( struct Nes_Vrc7_Apu* this ) | |||
15 | this->osc.last_amp = 0; | 15 | this->osc.last_amp = 0; |
16 | this->mask = 0; | 16 | this->mask = 0; |
17 | 17 | ||
18 | Vrc7_volume( this, 1.0 ); | 18 | Vrc7_volume( this, (int)FP_ONE_VOLUME ); |
19 | Vrc7_reset( this ); | 19 | Vrc7_reset( this ); |
20 | } | 20 | } |
21 | 21 | ||
diff --git a/apps/codecs/libgme/nes_vrc7_apu.h b/apps/codecs/libgme/nes_vrc7_apu.h index 5453e6b403..aa8bb7648c 100644 --- a/apps/codecs/libgme/nes_vrc7_apu.h +++ b/apps/codecs/libgme/nes_vrc7_apu.h | |||
@@ -47,6 +47,6 @@ static inline void Vrc7_set_output( struct Nes_Vrc7_Apu* this, int i, struct Bli | |||
47 | } | 47 | } |
48 | 48 | ||
49 | // DB2LIN_AMP_BITS == 11, * 2 | 49 | // DB2LIN_AMP_BITS == 11, * 2 |
50 | static inline void Vrc7_volume( struct Nes_Vrc7_Apu* this, double v ) { Synth_volume( &this->synth, 1.0 / 3 / 4096 * v ); } | 50 | static inline void Vrc7_volume( struct Nes_Vrc7_Apu* this, int v ) { Synth_volume( &this->synth, v / 3 / 4096 ); } |
51 | 51 | ||
52 | #endif | 52 | #endif |
diff --git a/apps/codecs/libgme/nsf_emu.c b/apps/codecs/libgme/nsf_emu.c index f3e1db773b..ec32ef3595 100644 --- a/apps/codecs/libgme/nsf_emu.c +++ b/apps/codecs/libgme/nsf_emu.c | |||
@@ -150,19 +150,19 @@ blargg_err_t init_sound( struct Nsf_Emu* this ) | |||
150 | this->voice_count += vrc7_osc_count; | 150 | this->voice_count += vrc7_osc_count; |
151 | } | 151 | } |
152 | 152 | ||
153 | if ( vrc7_enabled( this ) ) Vrc7_volume( &this->vrc7, (double)adjusted_gain/FP_ONE_GAIN ); | 153 | if ( vrc7_enabled( this ) ) Vrc7_volume( &this->vrc7, adjusted_gain ); |
154 | if ( namco_enabled( this ) ) Namco_volume( &this->namco, (double)adjusted_gain/FP_ONE_GAIN ); | 154 | if ( namco_enabled( this ) ) Namco_volume( &this->namco, adjusted_gain ); |
155 | if ( vrc6_enabled( this ) ) Vrc6_volume( &this->vrc6, (double)adjusted_gain/FP_ONE_GAIN ); | 155 | if ( vrc6_enabled( this ) ) Vrc6_volume( &this->vrc6, adjusted_gain ); |
156 | if ( fme7_enabled( this ) ) Fme7_volume( &this->fme7, (double)adjusted_gain/FP_ONE_GAIN ); | 156 | if ( fme7_enabled( this ) ) Fme7_volume( &this->fme7, adjusted_gain ); |
157 | if ( mmc5_enabled( this ) ) Apu_volume( &this->mmc5.apu, (double)adjusted_gain/FP_ONE_GAIN ); | 157 | if ( mmc5_enabled( this ) ) Apu_volume( &this->mmc5.apu, adjusted_gain ); |
158 | if ( fds_enabled( this ) ) Fds_volume( &this->fds, (double)adjusted_gain/FP_ONE_GAIN ); | 158 | if ( fds_enabled( this ) ) Fds_volume( &this->fds, adjusted_gain ); |
159 | } | 159 | } |
160 | #endif | 160 | #endif |
161 | 161 | ||
162 | if ( adjusted_gain > this->gain ) | 162 | if ( adjusted_gain > this->gain ) |
163 | adjusted_gain = this->gain; | 163 | adjusted_gain = this->gain; |
164 | 164 | ||
165 | Apu_volume( &this->apu, (double)adjusted_gain/FP_ONE_GAIN ); | 165 | Apu_volume( &this->apu, adjusted_gain ); |
166 | 166 | ||
167 | return 0; | 167 | return 0; |
168 | } | 168 | } |
diff --git a/apps/codecs/libgme/opl_apu.c b/apps/codecs/libgme/opl_apu.c index bde5e9e26e..64b2714b81 100644 --- a/apps/codecs/libgme/opl_apu.c +++ b/apps/codecs/libgme/opl_apu.c | |||
@@ -13,7 +13,7 @@ blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t | |||
13 | this->rate_ = rate; | 13 | this->rate_ = rate; |
14 | this->period_ = period; | 14 | this->period_ = period; |
15 | Opl_set_output( this, 0 ); | 15 | Opl_set_output( this, 0 ); |
16 | Opl_volume( this, 1.0 ); | 16 | Opl_volume( this, (int)FP_ONE_VOLUME ); |
17 | 17 | ||
18 | switch (type) | 18 | switch (type) |
19 | { | 19 | { |
diff --git a/apps/codecs/libgme/opl_apu.h b/apps/codecs/libgme/opl_apu.h index 3f5a751976..6185a99208 100644 --- a/apps/codecs/libgme/opl_apu.h +++ b/apps/codecs/libgme/opl_apu.h | |||
@@ -38,7 +38,7 @@ struct Opl_Apu { | |||
38 | blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t period, enum opl_type_t type ); | 38 | blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t period, enum opl_type_t type ); |
39 | 39 | ||
40 | void Opl_reset( struct Opl_Apu* this ); | 40 | void Opl_reset( struct Opl_Apu* this ); |
41 | static inline void Opl_volume( struct Opl_Apu* this, double v ) { Synth_volume( &this->synth, 1.0 / (4096 * 6) * v ); } | 41 | static inline void Opl_volume( struct Opl_Apu* this, int v ) { Synth_volume( &this->synth, v / (4096 * 6) ); } |
42 | 42 | ||
43 | static inline void Opl_osc_output( struct Opl_Apu* this, int i, struct Blip_Buffer* buf ) | 43 | static inline void Opl_osc_output( struct Opl_Apu* this, int i, struct Blip_Buffer* buf ) |
44 | { | 44 | { |
diff --git a/apps/codecs/libgme/sgc_emu.c b/apps/codecs/libgme/sgc_emu.c index 10866836d6..ff8db0be9e 100644 --- a/apps/codecs/libgme/sgc_emu.c +++ b/apps/codecs/libgme/sgc_emu.c | |||
@@ -96,8 +96,8 @@ blargg_err_t Sgc_load_mem( struct Sgc_Emu* this, const void* data, long size ) | |||
96 | this->track_count = this->header.song_count; | 96 | this->track_count = this->header.song_count; |
97 | this->voice_count = sega_mapping( this ) ? osc_count : sms_osc_count; | 97 | this->voice_count = sega_mapping( this ) ? osc_count : sms_osc_count; |
98 | 98 | ||
99 | Sms_apu_volume( &this->apu, (double)(this->gain)/FP_ONE_GAIN ); | 99 | Sms_apu_volume( &this->apu, this->gain ); |
100 | Fm_apu_volume( &this->fm_apu, (double)(this->gain)/FP_ONE_GAIN ); | 100 | Fm_apu_volume( &this->fm_apu, this->gain ); |
101 | 101 | ||
102 | // Setup buffer | 102 | // Setup buffer |
103 | this->clock_rate_ = clock_rate( this ); | 103 | this->clock_rate_ = clock_rate( this ); |
diff --git a/apps/codecs/libgme/sms_apu.c b/apps/codecs/libgme/sms_apu.c index 4be63db073..09506592fd 100644 --- a/apps/codecs/libgme/sms_apu.c +++ b/apps/codecs/libgme/sms_apu.c | |||
@@ -17,9 +17,9 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ | |||
17 | 17 | ||
18 | int const noise_osc = 3; | 18 | int const noise_osc = 3; |
19 | 19 | ||
20 | void Sms_apu_volume( struct Sms_Apu* this, double vol ) | 20 | void Sms_apu_volume( struct Sms_Apu* this, int vol ) |
21 | { | 21 | { |
22 | vol *= 0.85 / sms_osc_count / 64; | 22 | vol = (vol - (vol*3)/20) / sms_osc_count / 64; |
23 | Synth_volume( &this->synth, vol ); | 23 | Synth_volume( &this->synth, vol ); |
24 | } | 24 | } |
25 | 25 | ||
@@ -116,7 +116,7 @@ void Sms_apu_init( struct Sms_Apu* this ) | |||
116 | for ( i = sms_osc_count; --i >= 0; ) | 116 | for ( i = sms_osc_count; --i >= 0; ) |
117 | Sms_apu_set_output( this, i, NULL, NULL, NULL ); | 117 | Sms_apu_set_output( this, i, NULL, NULL, NULL ); |
118 | 118 | ||
119 | Sms_apu_volume( this, 1.0 ); | 119 | Sms_apu_volume( this, (int)FP_ONE_VOLUME ); |
120 | Sms_apu_reset( this, 0, 0 ); | 120 | Sms_apu_reset( this, 0, 0 ); |
121 | } | 121 | } |
122 | 122 | ||
diff --git a/apps/codecs/libgme/sms_apu.h b/apps/codecs/libgme/sms_apu.h index 25f4e74ae5..e0225138e5 100644 --- a/apps/codecs/libgme/sms_apu.h +++ b/apps/codecs/libgme/sms_apu.h | |||
@@ -58,6 +58,6 @@ void Sms_apu_end_frame( struct Sms_Apu* this, blip_time_t t ) ICODE_ATTR; | |||
58 | void Sms_apu_reset( struct Sms_Apu* this, unsigned noise_feedback, int noise_width ); | 58 | void Sms_apu_reset( struct Sms_Apu* this, unsigned noise_feedback, int noise_width ); |
59 | 59 | ||
60 | // Sets overall volume, where 1.0 is normal | 60 | // Sets overall volume, where 1.0 is normal |
61 | void Sms_apu_volume( struct Sms_Apu* this, double vol ); | 61 | void Sms_apu_volume( struct Sms_Apu* this, int vol ); |
62 | 62 | ||
63 | #endif | 63 | #endif |
diff --git a/apps/codecs/libgme/sms_fm_apu.c b/apps/codecs/libgme/sms_fm_apu.c index b15fc56680..93689cd811 100644 --- a/apps/codecs/libgme/sms_fm_apu.c +++ b/apps/codecs/libgme/sms_fm_apu.c | |||
@@ -14,7 +14,7 @@ blargg_err_t Fm_apu_init( struct Sms_Fm_Apu* this, double clock_rate, double sam | |||
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 ); |
17 | Fm_apu_volume( this, 1.0 ); | 17 | Fm_apu_volume( this, (int)FP_ONE_VOLUME ); |
18 | Fm_apu_reset( this ); | 18 | Fm_apu_reset( this ); |
19 | return 0; | 19 | return 0; |
20 | } | 20 | } |
diff --git a/apps/codecs/libgme/sms_fm_apu.h b/apps/codecs/libgme/sms_fm_apu.h index 95e1f95e62..f78af3065e 100644 --- a/apps/codecs/libgme/sms_fm_apu.h +++ b/apps/codecs/libgme/sms_fm_apu.h | |||
@@ -31,7 +31,7 @@ static inline void Fm_apu_set_output( struct Sms_Fm_Apu* this, struct Blip_Buffe | |||
31 | this->output_ = b; | 31 | this->output_ = b; |
32 | } | 32 | } |
33 | 33 | ||
34 | static inline void Fm_apu_volume( struct Sms_Fm_Apu* this, double v ) { Synth_volume( &this->synth, 0.4 / 4096 * v ); } | 34 | static inline void Fm_apu_volume( struct Sms_Fm_Apu* this, int v ) { Synth_volume( &this->synth, (v*2) / 5 / 4096 ); } |
35 | 35 | ||
36 | void Fm_apu_reset( struct Sms_Fm_Apu* this ); | 36 | void Fm_apu_reset( struct Sms_Fm_Apu* this ); |
37 | 37 | ||
diff --git a/apps/codecs/libgme/vgm_emu.c b/apps/codecs/libgme/vgm_emu.c index 9c4e1fe6b7..5d230ed9b5 100644 --- a/apps/codecs/libgme/vgm_emu.c +++ b/apps/codecs/libgme/vgm_emu.c | |||
@@ -21,7 +21,7 @@ Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ | |||
21 | 21 | ||
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 | double const fm_gain = 3.0; // 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; | 25 | double const rolloff = 0.990; |
26 | double const oversample_factor = 1.5; | 26 | double const oversample_factor = 1.5; |
27 | 27 | ||
@@ -352,11 +352,11 @@ blargg_err_t setup_fm( struct Vgm_Emu* this ) | |||
352 | this->voice_count = 8; | 352 | 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 ) ); | 353 | RETURN_ERR( Resampler_setup( &this->resampler, fm_rate / this->sample_rate, rolloff, fm_gain * (double)(this->gain)/FP_ONE_GAIN ) ); |
354 | RETURN_ERR( Resampler_reset( &this->resampler, Buffer_length( &this->stereo_buf ) * this->sample_rate / 1000 ) ); | 354 | RETURN_ERR( Resampler_reset( &this->resampler, Buffer_length( &this->stereo_buf ) * this->sample_rate / 1000 ) ); |
355 | Sms_apu_volume( &this->psg, 0.195 * fm_gain * (double)(this->gain)/FP_ONE_GAIN ); | 355 | Sms_apu_volume( &this->psg, ((this->gain/5)-(this->gain*5)/1000) * fm_gain ); |
356 | } | 356 | } |
357 | else | 357 | else |
358 | { | 358 | { |
359 | Sms_apu_volume( &this->psg, (double)(this->gain)/FP_ONE_GAIN ); | 359 | Sms_apu_volume( &this->psg, this->gain ); |
360 | } | 360 | } |
361 | 361 | ||
362 | return 0; | 362 | return 0; |
@@ -717,7 +717,7 @@ void Sound_mute_voices( struct Vgm_Emu* this, int mask ) | |||
717 | Sms_apu_set_output( &this->psg, i, ( mask & 0x80 ) ? 0 : &this->stereo_buf.bufs [0], NULL, NULL ); | 717 | Sms_apu_set_output( &this->psg, i, ( mask & 0x80 ) ? 0 : &this->stereo_buf.bufs [0], NULL, NULL ); |
718 | if ( Ym2612_enabled( &this->ym2612 ) ) | 718 | if ( Ym2612_enabled( &this->ym2612 ) ) |
719 | { | 719 | { |
720 | Synth_volume( &this->pcm, (mask & 0x40) ? 0.0 : 0.1115 / 256 * fm_gain * (double)(this->gain)/FP_ONE_GAIN ); | 720 | Synth_volume( &this->pcm, (mask & 0x40) ? 0 : (int)((long long)(0.1115*FP_ONE_VOLUME) / 256 * fm_gain * this->gain / FP_ONE_VOLUME) ); |
721 | Ym2612_mute_voices( &this->ym2612, mask ); | 721 | Ym2612_mute_voices( &this->ym2612, mask ); |
722 | } | 722 | } |
723 | 723 | ||