From 4fd30c5fb0b8853e80c1b964e3b4621543641eab Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sun, 5 Apr 2015 16:11:14 +0300 Subject: [PATCH] Drive sound volume mixer fix. --- driveclick.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/driveclick.cpp b/driveclick.cpp index c6cc3cca..bb397b34 100644 --- a/driveclick.cpp +++ b/driveclick.cpp @@ -263,11 +263,13 @@ static int driveclick_active (void) static uae_s16 getsample (void) { - uae_s32 smp = 0; - int div = 0, i; + uae_s32 total_sample = 0; + int total_div = 0; - for (i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { + int div = 0; if (currprefs.floppyslots[i].dfxclick) { + uae_s32 smp = 0; struct drvsample *ds_start = &drvs[i][DS_START]; struct drvsample *ds_spin = drv_has_disk[i] ? &drvs[i][DS_SPIN] : &drvs[i][DS_SPINND]; struct drvsample *ds_click = &drvs[i][DS_CLICK]; @@ -303,17 +305,20 @@ static uae_s16 getsample (void) div++; ds_click->pos += sample_step; } - int vol; - if (drv_has_disk[i]) - vol = currprefs.dfxclickvolume_disk[i]; - else - vol = currprefs.dfxclickvolume_empty[i]; - smp = smp * (100 - vol) / 100; + if (div) { + int vol; + if (drv_has_disk[i]) + vol = currprefs.dfxclickvolume_disk[i]; + else + vol = currprefs.dfxclickvolume_empty[i]; + total_sample += (smp * (100 - vol) / 100) / div; + total_div++; + } } } - if (!div) + if (!total_div) return 0; - return smp / div; + return total_sample / total_div; } static int clickcnt; -- 2.47.3