Index: apps/codecs/libgme/nes_apu.h =================================================================== --- apps/codecs/libgme/nes_apu.h (Revision 30276) +++ apps/codecs/libgme/nes_apu.h (Arbeitskopie) @@ -77,7 +77,7 @@ void Apu_set_tempo( struct Nes_Apu* this, int ); // Set overall volume (default is 1.0) -void Apu_volume( struct Nes_Apu* this, double ); +void Apu_volume( struct Nes_Apu* this, int ); // Run DMC until specified time, so that any DMC memory reads can be // accounted for (i.e. inserting cpu wait states). Index: apps/codecs/libgme/nes_vrc7_apu.h =================================================================== --- apps/codecs/libgme/nes_vrc7_apu.h (Revision 30276) +++ apps/codecs/libgme/nes_vrc7_apu.h (Arbeitskopie) @@ -47,6 +47,6 @@ } // DB2LIN_AMP_BITS == 11, * 2 -static inline void Vrc7_volume( struct Nes_Vrc7_Apu* this, double v ) { Synth_volume( &this->synth, 1.0 / 3 / 4096 * v ); } +static inline void Vrc7_volume( struct Nes_Vrc7_Apu* this, int v ) { Synth_volume( &this->synth, v / 3 / 4096 ); } #endif Index: apps/codecs/libgme/gb_apu.h =================================================================== --- apps/codecs/libgme/gb_apu.h (Revision 30276) +++ apps/codecs/libgme/gb_apu.h (Arbeitskopie) @@ -27,7 +27,7 @@ struct Gb_Osc* oscs [osc_count]; blip_time_t last_time; // time sound emulator has been run to blip_time_t frame_period; // clocks between each frame sequencer step - double volume_; + int volume_; bool reduce_clicks_; struct Gb_Square square1; @@ -69,7 +69,7 @@ struct Blip_Buffer* left, struct Blip_Buffer* right ); // Sets overall volume, where 1.0 is normal -void Apu_volume( struct Gb_Apu* this, double v ); +void Apu_volume( struct Gb_Apu* this, int v ); // If true, reduces clicking by disabling DAC biasing. Note that this reduces // emulation accuracy, since the clicks are authentic. Index: apps/codecs/libgme/sms_apu.c =================================================================== --- apps/codecs/libgme/sms_apu.c (Revision 30276) +++ apps/codecs/libgme/sms_apu.c (Arbeitskopie) @@ -17,9 +17,9 @@ int const noise_osc = 3; -void Sms_apu_volume( struct Sms_Apu* this, double vol ) +void Sms_apu_volume( struct Sms_Apu* this, int vol ) { - vol *= 0.85 / sms_osc_count / 64; + vol = (vol - (vol*3)/20) / sms_osc_count / 64; Synth_volume( &this->synth, vol ); } @@ -116,7 +116,7 @@ for ( i = sms_osc_count; --i >= 0; ) Sms_apu_set_output( this, i, NULL, NULL, NULL ); - Sms_apu_volume( this, 1.0 ); + Sms_apu_volume( this, (int)FP_ONE_VOLUME ); Sms_apu_reset( this, 0, 0 ); } Index: apps/codecs/libgme/nes_namco_apu.c =================================================================== --- apps/codecs/libgme/nes_namco_apu.c (Revision 30276) +++ apps/codecs/libgme/nes_namco_apu.c (Arbeitskopie) @@ -20,7 +20,7 @@ Synth_init( &this->synth ); Namco_output( this, NULL ); - Namco_volume( this, 1.0 ); + Namco_volume( this, (int)FP_ONE_VOLUME ); Namco_reset( this ); } Index: apps/codecs/libgme/sms_apu.h =================================================================== --- apps/codecs/libgme/sms_apu.h (Revision 30276) +++ apps/codecs/libgme/sms_apu.h (Arbeitskopie) @@ -58,6 +58,6 @@ void Sms_apu_reset( struct Sms_Apu* this, unsigned noise_feedback, int noise_width ); // Sets overall volume, where 1.0 is normal -void Sms_apu_volume( struct Sms_Apu* this, double vol ); +void Sms_apu_volume( struct Sms_Apu* this, int vol ); #endif Index: apps/codecs/libgme/nes_namco_apu.h =================================================================== --- apps/codecs/libgme/nes_namco_apu.h (Revision 30276) +++ apps/codecs/libgme/nes_namco_apu.h (Arbeitskopie) @@ -47,7 +47,7 @@ return &this->reg [addr]; } -static inline void Namco_volume( struct Nes_Namco_Apu* this, double v ) { Synth_volume( &this->synth, 0.10 / namco_osc_count * v / 15.0 ); } +static inline void Namco_volume( struct Nes_Namco_Apu* this, int v ) { Synth_volume( &this->synth, v / 10 / namco_osc_count / 15 ); } // Write-only address register is at 0xF800 static inline void Namco_write_addr( struct Nes_Namco_Apu* this, int v ) { this->addr_reg = v; } Index: apps/codecs/libgme/ay_apu.c =================================================================== --- apps/codecs/libgme/ay_apu.c (Revision 30276) +++ apps/codecs/libgme/ay_apu.c (Arbeitskopie) @@ -100,7 +100,7 @@ } set_output( this, NULL ); - Ay_apu_volume( this, 1.0 ); + Ay_apu_volume( this, (int)FP_ONE_VOLUME ); Ay_apu_reset( this ); } Index: apps/codecs/libgme/sgc_emu.c =================================================================== --- apps/codecs/libgme/sgc_emu.c (Revision 30277) +++ apps/codecs/libgme/sgc_emu.c (Arbeitskopie) @@ -96,8 +96,8 @@ this->track_count = this->header.song_count; this->voice_count = sega_mapping( this ) ? osc_count : sms_osc_count; - Sms_apu_volume( &this->apu, (double)(this->gain)/FP_ONE_GAIN ); - Fm_apu_volume( &this->fm_apu, (double)(this->gain)/FP_ONE_GAIN ); + Sms_apu_volume( &this->apu, this->gain ); + Fm_apu_volume( &this->fm_apu, this->gain ); // Setup buffer this->clock_rate_ = clock_rate( this ); Index: apps/codecs/libgme/ay_apu.h =================================================================== --- apps/codecs/libgme/ay_apu.h (Revision 30276) +++ apps/codecs/libgme/ay_apu.h (Arbeitskopie) @@ -57,7 +57,7 @@ void Ay_apu_reset( struct Ay_Apu* this ); // Sets overall volume, where 1.0 is normal -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 ); } +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 ); } static inline void Ay_apu_set_output( struct Ay_Apu* this, int i, struct Blip_Buffer* out ) { Index: apps/codecs/libgme/kss_scc_apu.c =================================================================== --- apps/codecs/libgme/kss_scc_apu.c (Revision 30276) +++ apps/codecs/libgme/kss_scc_apu.c (Arbeitskopie) @@ -28,9 +28,9 @@ Scc_set_output( this, i, buf ); } -void Scc_volume( struct Scc_Apu* this, double v ) +void Scc_volume( struct Scc_Apu* this, int v ) { - Synth_volume( &this->synth, 0.43 / scc_osc_count / scc_amp_range * v ); + Synth_volume( &this->synth, (v/2 - (v*7)/100) / scc_osc_count / scc_amp_range ); } void Scc_reset( struct Scc_Apu* this ) @@ -49,7 +49,7 @@ Synth_init( &this->synth); set_output( this, NULL ); - Scc_volume( this, 1.0 ); + Scc_volume( this, (int)FP_ONE_VOLUME ); Scc_reset( this ); } Index: apps/codecs/libgme/vgm_emu.c =================================================================== --- apps/codecs/libgme/vgm_emu.c (Revision 30277) +++ apps/codecs/libgme/vgm_emu.c (Arbeitskopie) @@ -21,7 +21,7 @@ const char* const gme_wrong_file_type = "Wrong file type for this emulator"; -double const fm_gain = 3.0; // FM emulators are internally quieter to avoid 16-bit overflow +int const fm_gain = 3; // FM emulators are internally quieter to avoid 16-bit overflow double const rolloff = 0.990; double const oversample_factor = 1.5; @@ -352,11 +352,11 @@ this->voice_count = 8; RETURN_ERR( Resampler_setup( &this->resampler, fm_rate / this->sample_rate, rolloff, fm_gain * (double)(this->gain)/FP_ONE_GAIN ) ); RETURN_ERR( Resampler_reset( &this->resampler, Buffer_length( &this->stereo_buf ) * this->sample_rate / 1000 ) ); - Sms_apu_volume( &this->psg, 0.195 * fm_gain * (double)(this->gain)/FP_ONE_GAIN ); + Sms_apu_volume( &this->psg, ((this->gain/5)-(this->gain*5)/1000) * fm_gain ); } else { - Sms_apu_volume( &this->psg, (double)(this->gain)/FP_ONE_GAIN ); + Sms_apu_volume( &this->psg, this->gain ); } return 0; @@ -717,7 +717,7 @@ Sms_apu_set_output( &this->psg, i, ( mask & 0x80 ) ? 0 : &this->stereo_buf.bufs [0], NULL, NULL ); if ( Ym2612_enabled( &this->ym2612 ) ) { - Synth_volume( &this->pcm, (mask & 0x40) ? 0.0 : 0.1115 / 256 * fm_gain * (double)(this->gain)/FP_ONE_GAIN ); + Synth_volume( &this->pcm, (mask & 0x40) ? 0 : (int)((long long)(0.1115*FP_ONE_VOLUME) / 256 * fm_gain * this->gain / FP_ONE_VOLUME) ); Ym2612_mute_voices( &this->ym2612, mask ); } Index: apps/codecs/libgme/kss_scc_apu.h =================================================================== --- apps/codecs/libgme/kss_scc_apu.h (Revision 30276) +++ apps/codecs/libgme/kss_scc_apu.h (Arbeitskopie) @@ -33,7 +33,7 @@ void Scc_reset( struct Scc_Apu* this ); // Set overall volume, where 1.0 is normal -void Scc_volume( struct Scc_Apu* this, double v ); +void Scc_volume( struct Scc_Apu* this, int v ); static inline void Scc_set_output( struct Scc_Apu* this, int index, struct Blip_Buffer* b ) { Index: apps/codecs/libgme/kss_emu.c =================================================================== --- apps/codecs/libgme/kss_emu.c (Revision 30277) +++ apps/codecs/libgme/kss_emu.c (Arbeitskopie) @@ -110,12 +110,12 @@ g = (g*6) / 5; //g *= 1.2; } - if ( sms_psg_enabled( this ) ) Sms_apu_volume( &this->sms.psg, (double)(g)/FP_ONE_GAIN ); - if ( sms_fm_enabled( this ) ) Opl_volume( &this->sms.fm, (double)(g)/FP_ONE_GAIN ); - if ( msx_psg_enabled( this ) ) Ay_apu_volume( &this->msx.psg, (double)(g)/FP_ONE_GAIN ); - if ( msx_scc_enabled( this ) ) Scc_volume( &this->msx.scc, (double)(g)/FP_ONE_GAIN ); - if ( msx_music_enabled( this ) ) Opl_volume( &this->msx.music, (double)(g)/FP_ONE_GAIN ); - if ( msx_audio_enabled( this ) ) Opl_volume( &this->msx.audio, (double)(g)/FP_ONE_GAIN ); + if ( sms_psg_enabled( this ) ) Sms_apu_volume( &this->sms.psg, g ); + if ( sms_fm_enabled( this ) ) Opl_volume( &this->sms.fm, g ); + if ( msx_psg_enabled( this ) ) Ay_apu_volume( &this->msx.psg, g ); + if ( msx_scc_enabled( this ) ) Scc_volume( &this->msx.scc, g ); + if ( msx_music_enabled( this ) ) Opl_volume( &this->msx.music, g ); + if ( msx_audio_enabled( this ) ) Opl_volume( &this->msx.audio, g ); } blargg_err_t Kss_load_mem( struct Kss_Emu* this, const void* data, long size ) Index: apps/codecs/libgme/nes_fme7_apu.c =================================================================== --- apps/codecs/libgme/nes_fme7_apu.c (Revision 30276) +++ apps/codecs/libgme/nes_fme7_apu.c (Arbeitskopie) @@ -22,7 +22,7 @@ Synth_init( &this->synth ); Fme7_output( this, NULL ); - Fme7_volume( this, 1.0 ); + Fme7_volume( this, (int)FP_ONE_VOLUME ); Fme7_reset( this ); } Index: apps/codecs/libgme/blargg_common.h =================================================================== --- apps/codecs/libgme/blargg_common.h (Revision 30277) +++ apps/codecs/libgme/blargg_common.h (Arbeitskopie) @@ -21,8 +21,9 @@ #endif // common defines -#define FP_ONE_TEMPO (1LL <<24) -#define FP_ONE_GAIN (1LL <<24) +#define FP_ONE_TEMPO (1LL << 24) +#define FP_ONE_GAIN (1LL << 24) +#define FP_ONE_VOLUME FP_ONE_GAIN #if 1 /* IRAM configuration is not yet active for all libGME codecs. */ #undef ICODE_ATTR Index: apps/codecs/libgme/nes_fme7_apu.h =================================================================== --- apps/codecs/libgme/nes_fme7_apu.h (Revision 30276) +++ apps/codecs/libgme/nes_fme7_apu.h (Arbeitskopie) @@ -41,9 +41,9 @@ void Fme7_init( struct Nes_Fme7_Apu* this ); void Fme7_reset( struct Nes_Fme7_Apu* this ); -static inline void Fme7_volume( struct Nes_Fme7_Apu* this, double v ) +static inline void Fme7_volume( struct Nes_Fme7_Apu* this, int v ) { - Synth_volume( &this->synth, 0.38 / amp_range * v ); // to do: fine-tune + Synth_volume( &this->synth, (v/2 - (v*3)/25) / amp_range ); // to do: fine-tune } static inline void Fme7_osc_output( struct Nes_Fme7_Apu* this, int i, struct Blip_Buffer* buf ) Index: apps/codecs/libgme/blip_buffer.c =================================================================== --- apps/codecs/libgme/blip_buffer.c (Revision 30276) +++ apps/codecs/libgme/blip_buffer.c (Arbeitskopie) @@ -279,7 +279,7 @@ } // Set overall volume of waveform -void Synth_volume( struct Blip_Synth* this, double v ) +void Synth_volume( struct Blip_Synth* this, int v ) { - this->delta_factor = (int) (v * (1L << blip_sample_bits) + 0.5); + this->delta_factor = (int) (v * (1LL << blip_sample_bits) / FP_ONE_VOLUME); } Index: apps/codecs/libgme/gbs_emu.c =================================================================== --- apps/codecs/libgme/gbs_emu.c (Revision 30277) +++ apps/codecs/libgme/gbs_emu.c (Arbeitskopie) @@ -112,7 +112,7 @@ Rom_set_addr( &this->rom, load_addr ); this->voice_count_ = osc_count; - Apu_volume( &this->apu, (double)(this->gain_)/FP_ONE_GAIN ); + Apu_volume( &this->apu, this->gain_ ); // Change clock rate & setup buffer this->clock_rate_ = 4194304; Index: apps/codecs/libgme/blip_buffer.h =================================================================== --- apps/codecs/libgme/blip_buffer.h (Revision 30276) +++ apps/codecs/libgme/blip_buffer.h (Arbeitskopie) @@ -170,7 +170,7 @@ void Synth_init( struct Blip_Synth* this ); // Set overall volume of waveform -void Synth_volume( struct Blip_Synth* this, double v ) ICODE_ATTR; +void Synth_volume( struct Blip_Synth* this, int v ) ICODE_ATTR; // Get/set Blip_Buffer used for output const struct Blip_Buffer* Synth_output( struct Blip_Synth* this ) ICODE_ATTR; Index: apps/codecs/libgme/nes_fds_apu.c =================================================================== --- apps/codecs/libgme/nes_fds_apu.c (Revision 30276) +++ apps/codecs/libgme/nes_fds_apu.c (Arbeitskopie) @@ -23,7 +23,7 @@ this->lfo_tempo = lfo_base_tempo; Fds_set_output( this, 0, NULL ); - Fds_volume( this, 1.0 ); + Fds_volume( this, (int)FP_ONE_VOLUME ); Fds_reset( this ); } Index: apps/codecs/libgme/nes_vrc6_apu.c =================================================================== --- apps/codecs/libgme/nes_vrc6_apu.c (Revision 30276) +++ apps/codecs/libgme/nes_vrc6_apu.c (Arbeitskopie) @@ -21,7 +21,7 @@ Synth_init( &this->square_synth ); Vrc6_output( this, NULL ); - Vrc6_volume( this, 1.0 ); + Vrc6_volume( this, (int)FP_ONE_VOLUME ); Vrc6_reset( this ); } Index: apps/codecs/libgme/nes_fds_apu.h =================================================================== --- apps/codecs/libgme/nes_fds_apu.h (Revision 30276) +++ apps/codecs/libgme/nes_fds_apu.h (Arbeitskopie) @@ -53,9 +53,9 @@ // emulation void Fds_reset( struct Nes_Fds_Apu* this ); -static inline void Fds_volume( struct Nes_Fds_Apu* this, double v ) +static inline void Fds_volume( struct Nes_Fds_Apu* this, int v ) { - Synth_volume( &this->synth, 0.14 / fds_master_vol_max / fds_vol_max / fds_wave_sample_max * v ); + Synth_volume( &this->synth, (v*14) / 100 / fds_master_vol_max / fds_vol_max / fds_wave_sample_max ); } static inline void Fds_set_output( struct Nes_Fds_Apu* this, int i, struct Blip_Buffer* b ) Index: apps/codecs/libgme/nes_vrc6_apu.h =================================================================== --- apps/codecs/libgme/nes_vrc6_apu.h (Revision 30276) +++ apps/codecs/libgme/nes_vrc6_apu.h (Arbeitskopie) @@ -52,11 +52,11 @@ this->oscs [i].output = buf; } -static inline void Vrc6_volume( struct Nes_Vrc6_Apu* this, double v ) +static inline void Vrc6_volume( struct Nes_Vrc6_Apu* this, int v ) { - double const factor = 0.0967 * 2; - Synth_volume( &this->saw_synth, factor / 31 * v ); - Synth_volume( &this->square_synth, factor * 0.5 / 15 * v ); + long long const factor = (long long)(FP_ONE_VOLUME * 0.0967 * 2); + Synth_volume( &this->saw_synth, (int)(v * factor / 31 / FP_ONE_VOLUME) ); + Synth_volume( &this->square_synth, (int)(v * factor / 2 / 15 / FP_ONE_VOLUME) ); } #endif Index: apps/codecs/libgme/hes_emu.c =================================================================== --- apps/codecs/libgme/hes_emu.c (Revision 30277) +++ apps/codecs/libgme/hes_emu.c (Arbeitskopie) @@ -131,8 +131,8 @@ this->voice_count_ = osc_count + adpcm_osc_count; - Apu_volume( &this->apu, (double)(this->gain_)/FP_ONE_GAIN ); - Adpcm_volume( &this->adpcm, (double)(this->gain_)/FP_ONE_GAIN ); + Apu_volume( &this->apu, this->gain_ ); + Adpcm_volume( &this->adpcm, this->gain_ ); // Setup buffer this->clock_rate_ = 7159091; Index: apps/codecs/libgme/sms_fm_apu.c =================================================================== --- apps/codecs/libgme/sms_fm_apu.c (Revision 30276) +++ apps/codecs/libgme/sms_fm_apu.c (Arbeitskopie) @@ -14,7 +14,7 @@ CHECK_ALLOC( !Ym2413_set_rate( &this->apu, sample_rate, clock_rate ) ); Fm_apu_set_output( this, 0 ); - Fm_apu_volume( this, 1.0 ); + Fm_apu_volume( this, (int)FP_ONE_VOLUME ); Fm_apu_reset( this ); return 0; } Index: apps/codecs/libgme/nsf_emu.c =================================================================== --- apps/codecs/libgme/nsf_emu.c (Revision 30277) +++ apps/codecs/libgme/nsf_emu.c (Arbeitskopie) @@ -150,19 +150,19 @@ this->voice_count += vrc7_osc_count; } - if ( vrc7_enabled( this ) ) Vrc7_volume( &this->vrc7, (double)adjusted_gain/FP_ONE_GAIN ); - if ( namco_enabled( this ) ) Namco_volume( &this->namco, (double)adjusted_gain/FP_ONE_GAIN ); - if ( vrc6_enabled( this ) ) Vrc6_volume( &this->vrc6, (double)adjusted_gain/FP_ONE_GAIN ); - if ( fme7_enabled( this ) ) Fme7_volume( &this->fme7, (double)adjusted_gain/FP_ONE_GAIN ); - if ( mmc5_enabled( this ) ) Apu_volume( &this->mmc5.apu, (double)adjusted_gain/FP_ONE_GAIN ); - if ( fds_enabled( this ) ) Fds_volume( &this->fds, (double)adjusted_gain/FP_ONE_GAIN ); + if ( vrc7_enabled( this ) ) Vrc7_volume( &this->vrc7, adjusted_gain ); + if ( namco_enabled( this ) ) Namco_volume( &this->namco, adjusted_gain ); + if ( vrc6_enabled( this ) ) Vrc6_volume( &this->vrc6, adjusted_gain ); + if ( fme7_enabled( this ) ) Fme7_volume( &this->fme7, adjusted_gain ); + if ( mmc5_enabled( this ) ) Apu_volume( &this->mmc5.apu, adjusted_gain ); + if ( fds_enabled( this ) ) Fds_volume( &this->fds, adjusted_gain ); } #endif if ( adjusted_gain > this->gain ) adjusted_gain = this->gain; - Apu_volume( &this->apu, (double)adjusted_gain/FP_ONE_GAIN ); + Apu_volume( &this->apu, adjusted_gain ); return 0; } Index: apps/codecs/libgme/hes_apu_adpcm.h =================================================================== --- apps/codecs/libgme/hes_apu_adpcm.h (Revision 30276) +++ apps/codecs/libgme/hes_apu_adpcm.h (Arbeitskopie) @@ -85,5 +85,5 @@ void Adpcm_end_frame( struct Hes_Apu_Adpcm* this,blip_time_t t ) ICODE_ATTR; // Sets overall volume, where 1.0 is normal -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 ); } +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 ); } #endif Index: apps/codecs/libgme/sms_fm_apu.h =================================================================== --- apps/codecs/libgme/sms_fm_apu.h (Revision 30276) +++ apps/codecs/libgme/sms_fm_apu.h (Arbeitskopie) @@ -31,7 +31,7 @@ this->output_ = b; } -static inline void Fm_apu_volume( struct Sms_Fm_Apu* this, double v ) { Synth_volume( &this->synth, 0.4 / 4096 * v ); } +static inline void Fm_apu_volume( struct Sms_Fm_Apu* this, int v ) { Synth_volume( &this->synth, (v*2) / 5 / 4096 ); } void Fm_apu_reset( struct Sms_Fm_Apu* this ); Index: apps/codecs/libgme/opl_apu.c =================================================================== --- apps/codecs/libgme/opl_apu.c (Revision 30276) +++ apps/codecs/libgme/opl_apu.c (Arbeitskopie) @@ -13,7 +13,7 @@ this->rate_ = rate; this->period_ = period; Opl_set_output( this, 0 ); - Opl_volume( this, 1.0 ); + Opl_volume( this, (int)FP_ONE_VOLUME ); switch (type) { Index: apps/codecs/libgme/opl_apu.h =================================================================== --- apps/codecs/libgme/opl_apu.h (Revision 30276) +++ apps/codecs/libgme/opl_apu.h (Arbeitskopie) @@ -38,7 +38,7 @@ blargg_err_t Opl_init( struct Opl_Apu* this, long clock, long rate, blip_time_t period, enum opl_type_t type ); void Opl_reset( struct Opl_Apu* this ); -static inline void Opl_volume( struct Opl_Apu* this, double v ) { Synth_volume( &this->synth, 1.0 / (4096 * 6) * v ); } +static inline void Opl_volume( struct Opl_Apu* this, int v ) { Synth_volume( &this->synth, v / (4096 * 6) ); } static inline void Opl_osc_output( struct Opl_Apu* this, int i, struct Blip_Buffer* buf ) { Index: apps/codecs/libgme/ay_emu.c =================================================================== --- apps/codecs/libgme/ay_emu.c (Revision 30277) +++ apps/codecs/libgme/ay_emu.c (Arbeitskopie) @@ -144,7 +144,7 @@ warning( "Unknown file version" ); */ this->voice_count = ay_osc_count + 1; // +1 for beeper - Ay_apu_volume( &this->apu, ((double)this->gain)/FP_ONE_GAIN); + Ay_apu_volume( &this->apu, this->gain); // Setup buffer change_clock_rate( this, spectrum_clock ); Index: apps/codecs/libgme/hes_apu.h =================================================================== --- apps/codecs/libgme/hes_apu.h (Revision 30276) +++ apps/codecs/libgme/hes_apu.h (Arbeitskopie) @@ -51,5 +51,5 @@ void Apu_write_data( struct Hes_Apu* this, blip_time_t, int addr, int data ) ICODE_ATTR; void Apu_end_frame( struct Hes_Apu* this, blip_time_t ) ICODE_ATTR; -static inline void Apu_volume( struct Hes_Apu* this, double v ) { Synth_volume( &this->synth, 1.8 / osc_count / amp_range * v ); } +static inline void Apu_volume( struct Hes_Apu* this, int v ) { Synth_volume( &this->synth, (v*9)/5 / osc_count / amp_range ); } #endif Index: apps/codecs/libgme/nes_apu.c =================================================================== --- apps/codecs/libgme/nes_apu.c (Revision 30276) +++ apps/codecs/libgme/nes_apu.c (Arbeitskopie) @@ -39,19 +39,18 @@ this->oscs [4] = &this->dmc.osc; Apu_output( this, NULL ); - Apu_volume( this, 1.0 ); + Apu_volume( this, (int)FP_ONE_VOLUME ); Apu_reset( this, false, 0 ); } -static double nonlinear_tnd_gain( void ) { return 0.75; } -void Apu_enable_nonlinear( struct Nes_Apu* this, double v ) +void Apu_enable_nonlinear( struct Nes_Apu* this, int v ) { this->dmc.nonlinear = true; - Synth_volume( &this->square_synth, 1.3 * 0.25751258 / 0.742467605 * 0.25 / amp_range * v ); + Synth_volume( &this->square_synth, (int)((1.3 * 0.25751258 / 0.742467605 * 0.25 * FP_ONE_VOLUME) / amp_range * v) ); - const double tnd = 0.48 / 202 * nonlinear_tnd_gain(); - Synth_volume( &this->triangle.synth, 3.0 * tnd ); - Synth_volume( &this->noise.synth, 2.0 * tnd ); + const int tnd = (int)(0.48 / 202 * 0.75 * FP_ONE_VOLUME); + Synth_volume( &this->triangle.synth, 3 * tnd ); + Synth_volume( &this->noise.synth, 2 * tnd ); Synth_volume( &this->dmc.synth, tnd ); this->square1 .osc.last_amp = 0; @@ -61,13 +60,13 @@ this->dmc .osc.last_amp = 0; } -void Apu_volume( struct Nes_Apu* this, double v ) +void Apu_volume( struct Nes_Apu* this, int v ) { this->dmc.nonlinear = false; - Synth_volume( &this->square_synth, 0.1128 / amp_range * v ); - Synth_volume( &this->triangle.synth,0.12765 / amp_range * v ); - Synth_volume( &this->noise.synth, 0.0741 / amp_range * v ); - Synth_volume( &this->dmc.synth, 0.42545 / 127 * v ); + Synth_volume( &this->square_synth, (int)((long long)(0.1128 *FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); + Synth_volume( &this->triangle.synth,(int)((long long)(0.12765*FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); + Synth_volume( &this->noise.synth, (int)((long long)(0.0741 *FP_ONE_VOLUME) * v / amp_range / FP_ONE_VOLUME) ); + Synth_volume( &this->dmc.synth, (int)((long long)(0.42545*FP_ONE_VOLUME) * v / 127 / FP_ONE_VOLUME) ); } void Apu_output( struct Nes_Apu* this, struct Blip_Buffer* buffer ) Index: apps/codecs/libgme/nes_vrc7_apu.c =================================================================== --- apps/codecs/libgme/nes_vrc7_apu.c (Revision 30276) +++ apps/codecs/libgme/nes_vrc7_apu.c (Arbeitskopie) @@ -15,7 +15,7 @@ this->osc.last_amp = 0; this->mask = 0; - Vrc7_volume( this, 1.0 ); + Vrc7_volume( this, (int)FP_ONE_VOLUME ); Vrc7_reset( this ); } Index: apps/codecs/libgme/gb_apu.c =================================================================== --- apps/codecs/libgme/gb_apu.c (Revision 30276) +++ apps/codecs/libgme/gb_apu.c (Arbeitskopie) @@ -51,7 +51,7 @@ void synth_volume( struct Gb_Apu* this, int iv ) { - double v = this->volume_ * 0.60 / osc_count / 15 /*steps*/ / 8 /*master vol range*/ * iv; + int v = (this->volume_ * 6) / 10 / osc_count / 15 /*steps*/ / 8 /*master vol range*/ * iv; Synth_volume( &this->synth, v ); } @@ -67,7 +67,7 @@ synth_volume( this, max( left, right ) + 1 ); } -void Apu_volume( struct Gb_Apu* this, double v ) +void Apu_volume( struct Gb_Apu* this, int v ) { if ( this->volume_ != v ) { @@ -185,7 +185,7 @@ this->reduce_clicks_ = false; Apu_set_tempo( this, (int)FP_ONE_TEMPO ); - this->volume_ = 1.0; + this->volume_ = (int)FP_ONE_VOLUME; Apu_reset( this, mode_cgb, false ); }