]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Audio master/subvolume update. Toccata Paula mixing.
authorToni Wilen <twilen@winuae.net>
Fri, 23 Jan 2015 17:29:06 +0000 (19:29 +0200)
committerToni Wilen <twilen@winuae.net>
Fri, 23 Jan 2015 17:29:06 +0000 (19:29 +0200)
17 files changed:
audio.cpp
blkdev.cpp
blkdev_cdimage.cpp
cd32_fmv.cpp
cfgfile.cpp
include/audio.h
include/options.h
include/sndboard.h
od-win32/blkdev_win32_ioctl.cpp
od-win32/cda_play.cpp
od-win32/cda_play.h
od-win32/resources/resource.h
od-win32/resources/winuae.rc
od-win32/rp.cpp
od-win32/sounddep/sound.cpp
od-win32/win32gui.cpp
sndboard.cpp

index a825ce0ce7800bd241ce2a81eacf734488330c10..562a6226dac039f1de06e5d9608c59a76c7ce662 100644 (file)
--- a/audio.cpp
+++ b/audio.cpp
@@ -31,6 +31,7 @@
 #include "gui.h"
 #include "xwin.h"
 #include "debug.h"
+#include "sndboard.h"
 #ifdef AVIOUTPUT
 #include "avioutput.h"
 #endif
@@ -306,6 +307,9 @@ static void (*sample_prehandler) (unsigned long best_evtime);
 float sample_evtime;
 float scaled_sample_evtime;
 
+int sound_cd_volume[2];
+int sound_paula_volume[2];
+
 static unsigned long last_cycles;
 static float next_sample_evtime;
 
@@ -313,7 +317,7 @@ typedef uae_s8 sample8_t;
 #define DO_CHANNEL_1(v, c) do { (v) *= audio_channel[c].vol; } while (0)
 #define SBASEVAL16(logn) ((logn) == 1 ? SOUND16_BASE_VAL >> 1 : SOUND16_BASE_VAL)
 
-STATIC_INLINE int FINISH_DATA (int data, int bits)
+STATIC_INLINE int FINISH_DATA (int data, int bits, int ch)
 {
        if (bits == 16) {
                return data;
@@ -323,6 +327,7 @@ STATIC_INLINE int FINISH_DATA (int data, int bits)
                int shift = 16 - bits;
                data <<= shift;
        }
+       data = data * sound_paula_volume[ch] / 32768;
        return data;
 }
 
@@ -645,7 +650,7 @@ static void sample16i_sinc_handler (void)
 
        samplexx_sinc_handler (datas);
        data1 = datas[0] + datas[3] + datas[1] + datas[2];
-       data1 = FINISH_DATA (data1, 18);
+       data1 = FINISH_DATA (data1, 18, 0);
        
        do_filter(&data1, 0);
 
@@ -676,7 +681,7 @@ void sample16_handler (void)
        data0 += data2;
        data0 += data3;
        data = SBASEVAL16(2) + data0;
-       data = FINISH_DATA (data, 16);
+       data = FINISH_DATA (data, 16, 0);
 
        do_filter(&data, 0);
 
@@ -695,7 +700,7 @@ static void sample16i_anti_handler (void)
 
        samplexx_anti_handler (datas);
        data1 = datas[0] + datas[3] + datas[1] + datas[2];
-       data1 = FINISH_DATA (data1, 16);
+       data1 = FINISH_DATA (data1, 16, 0);
 
        do_filter(&data1, 0);
 
@@ -752,7 +757,7 @@ static void sample16i_rh_handler (void)
        ratio = ((audio_channel[3].evtime % delta) << 8) / delta;
        data0 += (data3 * (256 - ratio) + data3p * ratio) >> 8;
        data = SBASEVAL16(2) + data0;
-       data = FINISH_DATA (data, 16);
+       data = FINISH_DATA (data, 16, 0);
 
        do_filter(&data, 0);
 
@@ -829,7 +834,7 @@ static void sample16i_crux_handler (void)
        data0 += data3;
        data0 += data1;
        data = SBASEVAL16(2) + data0;
-       data = FINISH_DATA (data, 16);
+       data = FINISH_DATA (data, 16, 0);
 
        do_filter(&data, 0);
 
@@ -866,10 +871,10 @@ void sample16ss_handler (void)
        data2 &= audio_channel[2].adk_mask;
        data3 &= audio_channel[3].adk_mask;
 
-       data0 = FINISH_DATA (data0, 14);
-       data1 = FINISH_DATA (data1, 14);
-       data2 = FINISH_DATA (data2, 14);
-       data3 = FINISH_DATA (data3, 14);
+       data0 = FINISH_DATA (data0, 14, 0);
+       data1 = FINISH_DATA (data1, 14, 0);
+       data2 = FINISH_DATA (data2, 14, 1);
+       data3 = FINISH_DATA (data3, 14, 1);
 
        do_filter(&data0, 0);
        do_filter(&data1, 1);
@@ -898,10 +903,10 @@ void sample16ss_anti_handler (void)
        int datas[AUDIO_CHANNELS_PAULA];
 
        samplexx_anti_handler (datas);
-       data0 = FINISH_DATA (datas[0], 14);
-       data1 = FINISH_DATA (datas[1], 14);
-       data2 = FINISH_DATA (datas[2], 14);
-       data3 = FINISH_DATA (datas[3], 14);
+       data0 = FINISH_DATA (datas[0], 14, 0);
+       data1 = FINISH_DATA (datas[1], 14, 0);
+       data2 = FINISH_DATA (datas[2], 14, 1);
+       data3 = FINISH_DATA (datas[3], 14, 1);
 
        do_filter(&data0, 0);
        do_filter(&data1, 1);
@@ -928,8 +933,8 @@ static void sample16si_anti_handler (void)
        samplexx_anti_handler (datas);
        data1 = datas[0] + datas[3];
        data2 = datas[1] + datas[2];
-       data1 = FINISH_DATA (data1, 15);
-       data2 = FINISH_DATA (data2, 15);
+       data1 = FINISH_DATA (data1, 15, 0);
+       data2 = FINISH_DATA (data2, 15, 1);
 
        do_filter(&data1, 0);
        do_filter(&data2, 1);
@@ -948,10 +953,10 @@ void sample16ss_sinc_handler (void)
        int datas[AUDIO_CHANNELS_PAULA];
 
        samplexx_sinc_handler (datas);
-       data0 = FINISH_DATA (datas[0], 16);
-       data1 = FINISH_DATA (datas[1], 16);
-       data2 = FINISH_DATA (datas[2], 16);
-       data3 = FINISH_DATA (datas[3], 16);
+       data0 = FINISH_DATA (datas[0], 16, 0);
+       data1 = FINISH_DATA (datas[1], 16, 0);
+       data2 = FINISH_DATA (datas[2], 16, 1);
+       data3 = FINISH_DATA (datas[3], 16, 1);
 
        do_filter(&data0, 0);
        do_filter(&data1, 1);
@@ -978,8 +983,8 @@ static void sample16si_sinc_handler (void)
        samplexx_sinc_handler (datas);
        data1 = datas[0] + datas[3];
        data2 = datas[1] + datas[2];
-       data1 = FINISH_DATA (data1, 17);
-       data2 = FINISH_DATA (data2, 17);
+       data1 = FINISH_DATA (data1, 17, 0);
+       data2 = FINISH_DATA (data2, 17, 1);
 
        do_filter(&data1, 0);
        do_filter(&data2, 1);
@@ -1011,9 +1016,9 @@ void sample16s_handler (void)
        data0 += data3;
        data1 += data2;
        data2 = SBASEVAL16(1) + data0;
-       data2 = FINISH_DATA (data2, 15);
+       data2 = FINISH_DATA (data2, 15, 0);
        data3 = SBASEVAL16(1) + data1;
-       data3 = FINISH_DATA (data3, 15);
+       data3 = FINISH_DATA (data3, 15, 1);
 
        do_filter(&data2, 0);
        do_filter(&data3, 1);
@@ -1090,9 +1095,9 @@ static void sample16si_crux_handler (void)
        data1 += data2;
        data0 += data3;
        data2 = SBASEVAL16(1) + data0;
-       data2 = FINISH_DATA (data2, 15);
+       data2 = FINISH_DATA (data2, 15, 0);
        data3 = SBASEVAL16(1) + data1;
-       data3 = FINISH_DATA (data3, 15);
+       data3 = FINISH_DATA (data3, 15, 1);
 
        do_filter(&data2, 0);
        do_filter(&data3, 1);
@@ -1150,9 +1155,9 @@ static void sample16si_rh_handler (void)
        ratio = ((audio_channel[3].evtime % delta) << 8) / delta;
        data0 += (data3 * (256 - ratio) + data3p * ratio) >> 8;
        data2 = SBASEVAL16(1) + data0;
-       data2 = FINISH_DATA (data2, 15);
+       data2 = FINISH_DATA (data2, 15, 0);
        data3 = SBASEVAL16(1) + data1;
-       data3 = FINISH_DATA (data3, 15);
+       data3 = FINISH_DATA (data3, 15, 1);
 
        do_filter(&data2, 0);
        do_filter(&data3, 1);
@@ -1650,7 +1655,10 @@ static int sound_prefs_changed (void)
        if (changed_prefs.sound_stereo_separation != currprefs.sound_stereo_separation
                || changed_prefs.sound_mixed_stereo_delay != currprefs.sound_mixed_stereo_delay
                || changed_prefs.sound_interpol != currprefs.sound_interpol
-               || changed_prefs.sound_volume != currprefs.sound_volume
+               || changed_prefs.sound_volume_paula != currprefs.sound_volume_paula
+               || changed_prefs.sound_volume_cd != currprefs.sound_volume_cd
+               || changed_prefs.sound_volume_master != currprefs.sound_volume_master
+               || changed_prefs.sound_volume_board != currprefs.sound_volume_board
                || changed_prefs.sound_stereo_swap_paula != currprefs.sound_stereo_swap_paula
                || changed_prefs.sound_stereo_swap_ahi != currprefs.sound_stereo_swap_ahi
                || changed_prefs.sound_cdaudio != currprefs.sound_cdaudio
@@ -1724,11 +1732,18 @@ void set_audio (void)
        currprefs.sound_interpol = changed_prefs.sound_interpol;
        currprefs.sound_filter = changed_prefs.sound_filter;
        currprefs.sound_filter_type = changed_prefs.sound_filter_type;
-       currprefs.sound_volume = changed_prefs.sound_volume;
+       currprefs.sound_volume_paula = changed_prefs.sound_volume_paula;
+       currprefs.sound_volume_master = changed_prefs.sound_volume_master;
+       currprefs.sound_volume_board = changed_prefs.sound_volume_board;
+       currprefs.sound_volume_cd = changed_prefs.sound_volume_cd;
        currprefs.sound_cdaudio = changed_prefs.sound_cdaudio;
        currprefs.sound_stereo_swap_paula = changed_prefs.sound_stereo_swap_paula;
        currprefs.sound_stereo_swap_ahi = changed_prefs.sound_stereo_swap_ahi;
 
+       sound_cd_volume[0] = sound_cd_volume[1] = (100 - (currprefs.sound_volume_cd < 0 ? 0 : currprefs.sound_volume_cd)) * 32768 / 100;
+       sound_paula_volume[0] = sound_paula_volume[1] = (100 - currprefs.sound_volume_paula) * 32768 / 100;
+       sndboard_ext_volume();
+
        if (ch >= 0) {
                if (currprefs.produce_sound >= 2) {
                        if (!init_audio ()) {
@@ -2304,11 +2319,11 @@ void update_cda_sound(double clk)
        cda_evt = clk * CYCLE_UNIT / 44100;
 }
 
-void audio_cda_volume(int master, int left, int right)
+void audio_cda_volume(int left, int right)
 {
        for (int j = 0; j < 2; j++) {
                cda_volume[j] = j == 0 ? left : right;
-               cda_volume[j] = (100 - master) * cda_volume[j] / 100;
+               cda_volume[j] = sound_cd_volume[j] * cda_volume[j] / 32768;
                if (cda_volume[j])
                        cda_volume[j]++;
                if (cda_volume[j] >= 32768)
index 23827c2ba66b7239019c61fac87c7d3c5c01157c..1dd87fc2015c3e9c4fdc0cef1e0741752a38615b 100644 (file)
@@ -578,7 +578,6 @@ void check_prefs_changed_cd (void)
 {
        if (!config_changed)
                return;
-       currprefs.sound_volume_cd = changed_prefs.sound_volume_cd;
 }
 
 static void check_changes (int unitnum)
index 2138a339fb332d38bbde826829a2750fd08ff608..512d9236d9615e41193c57b67c27768fb748b17b 100644 (file)
@@ -663,11 +663,11 @@ static void *cdda_play_func (void *v)
                                        cda_bufon[bufnum] = 1;
                                        next_cd_audio_buffer_callback(1 - bufnum);
                                }
-                               audio_cda_volume(currprefs.sound_volume_cd >= 0 ? currprefs.sound_volume_cd : currprefs.sound_volume, cdu->cdda_volume[0], cdu->cdda_volume[1]);
+                               audio_cda_volume(cdu->cdda_volume[0], cdu->cdda_volume[1]);
                                cda_bufon[bufnum] = 1;
                        } else {
                                cda_bufon[bufnum] = 1;
-                               cda->setvolume (currprefs.sound_volume_cd >= 0 ? currprefs.sound_volume_cd : currprefs.sound_volume, cdu->cdda_volume[0], cdu->cdda_volume[1]);
+                               cda->setvolume (cdu->cdda_volume[0], cdu->cdda_volume[1]);
                                if (!cda->play (bufnum)) {
                                        if (cdu->cdda_play > 0)
                                                setstate (cdu, AUDIO_STATUS_PLAY_ERROR);
index a648cda74954dc67edda3dfd80b8d0bf88252bdc..8a303775455f6a0b587be3e7a1a4c701e4860480 100644 (file)
@@ -396,9 +396,9 @@ static void l64111_setvolume(void)
        write_log(_T("L64111 mute %d\n"), volume ? 0 : 1);
        if (cda) {
                if (audio_mode) {
-                       audio_cda_volume(currprefs.sound_volume_cd >= 0 ? currprefs.sound_volume_cd : currprefs.sound_volume, volume, volume);
+                       audio_cda_volume(volume, volume);
                } else {
-                       cda->setvolume(currprefs.sound_volume_cd >= 0 ? currprefs.sound_volume_cd : currprefs.sound_volume, volume, volume);
+                       cda->setvolume(volume, volume);
                }
        }
 }
index 71da082fe1e745ea4309a2924bf1e58f62c52c72..86148bd076591df697f0b70ac52c5b8ae703223d 100644 (file)
@@ -1134,9 +1134,12 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
        cfgfile_write_str (f, _T("sound_interpol"), interpolmode[p->sound_interpol]);
        cfgfile_write_str (f, _T("sound_filter"), soundfiltermode1[p->sound_filter]);
        cfgfile_write_str (f, _T("sound_filter_type"), soundfiltermode2[p->sound_filter_type]);
-       cfgfile_write (f, _T("sound_volume"), _T("%d"), p->sound_volume);
+       cfgfile_write (f, _T("sound_volume"), _T("%d"), p->sound_volume_master);
+       cfgfile_write (f, _T("sound_volume_paula"), _T("%d"), p->sound_volume_paula);
        if (p->sound_volume_cd >= 0)
                cfgfile_write (f, _T("sound_volume_cd"), _T("%d"), p->sound_volume_cd);
+       if (p->sound_volume_board >= 0)
+               cfgfile_write (f, _T("sound_volume_ahi"), _T("%d"), p->sound_volume_board);
        cfgfile_write_bool (f, _T("sound_auto"), p->sound_auto);
        cfgfile_write_bool (f, _T("sound_cdaudio"), p->sound_cdaudio);
        cfgfile_write_bool (f, _T("sound_stereo_swap_paula"), p->sound_stereo_swap_paula);
@@ -1582,7 +1585,8 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type)
        else
                cfgfile_dwrite (f, _T("catweasel"), _T("%d"), p->catweasel);
        cfgfile_write_bool(f, _T("toccata"), p->sound_toccata);
-
+       if (p->sound_toccata_mixer)
+               cfgfile_write_bool(f, _T("toccata_mixer"), p->sound_toccata_mixer);
 
        cfgfile_write_str (f, _T("kbd_lang"), (p->keyboard_lang == KBD_LANG_DE ? _T("de")
                : p->keyboard_lang == KBD_LANG_DK ? _T("dk")
@@ -2112,8 +2116,10 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value)
                || cfgfile_intval (option, value, _T("state_replay_buffers"), &p->statecapturebuffersize, 1)
                || cfgfile_yesno (option, value, _T("state_replay_autoplay"), &p->inprec_autoplay)
                || cfgfile_intval (option, value, _T("sound_frequency"), &p->sound_freq, 1)
-               || cfgfile_intval (option, value, _T("sound_volume"), &p->sound_volume, 1)
+               || cfgfile_intval (option, value, _T("sound_volume"), &p->sound_volume_master, 1)
+               || cfgfile_intval (option, value, _T("sound_volume_paula"), &p->sound_volume_paula, 1)
                || cfgfile_intval (option, value, _T("sound_volume_cd"), &p->sound_volume_cd, 1)
+               || cfgfile_intval (option, value, _T("sound_volume_ahi"), &p->sound_volume_board, 1)
                || cfgfile_intval (option, value, _T("sound_stereo_separation"), &p->sound_stereo_separation, 1)
                || cfgfile_intval (option, value, _T("sound_stereo_mixing_delay"), &p->sound_mixed_stereo_delay, 1)
                || cfgfile_intval (option, value, _T("sampler_frequency"), &p->sampler_freq, 1)
@@ -3713,6 +3719,7 @@ static int cfgfile_parse_hardware (struct uae_prefs *p, const TCHAR *option, TCH
                || cfgfile_yesno (option, value, _T("floppy_write_protect"), &p->floppy_read_only)
                || cfgfile_yesno (option, value, _T("uae_hide_autoconfig"), &p->uae_hide_autoconfig)
                || cfgfile_yesno (option, value, _T("toccata"), &p->sound_toccata)
+               || cfgfile_yesno (option, value, _T("toccata_mixer"), &p->sound_toccata_mixer)
                || cfgfile_yesno (option, value, _T("uaeserial"), &p->uaeserial))
                return 1;
 
@@ -5730,7 +5737,8 @@ static void buildin_default_prefs (struct uae_prefs *p)
        p->maprom = 0;
        p->cachesize = 0;
        p->socket_emu = 0;
-       p->sound_volume = 0;
+       p->sound_volume_master = 0;
+       p->sound_volume_paula = 0;
        p->sound_volume_cd = 0;
        p->clipboard_sharing = false;
        p->ppc_mode = 0;
index 4228f74e3caa34c78ee563946a43c8aaa4fa4b3d..b3c9c50c2270cb82c78202977f51e88e3e0a4750 100644 (file)
@@ -52,7 +52,10 @@ extern void audio_state_sndboard_state(int, int, unsigned int);
 
 typedef void (*CDA_CALLBACK)(int);
 extern void audio_cda_new_buffer(uae_s16 *buffer, int length, int userdata, CDA_CALLBACK next_cd_audio_buffer_callback);
-extern void audio_cda_volume(int master, int left, int right);
+extern void audio_cda_volume(int left, int right);
+
+extern int sound_cd_volume[2];
+extern int sound_paula_volume[2];
 
 #define AUDIO_CHANNELS_PAULA 4
 #define AUDIO_CHANNELS_MAX 8
index fc9a30e0f90c93ead5f4ebfe590fdb04c7e4d7b7..d87e19fe29f9b2e515c340f7c56b68b48979de4f 100644 (file)
@@ -332,8 +332,10 @@ struct uae_prefs {
        int sound_interpol;
        int sound_filter;
        int sound_filter_type;
-       int sound_volume;
+       int sound_volume_master;
+       int sound_volume_paula;
        int sound_volume_cd;
+       int sound_volume_board;
        bool sound_stereo_swap_paula;
        bool sound_stereo_swap_ahi;
        bool sound_auto;
@@ -564,6 +566,7 @@ struct uae_prefs {
        bool uae_hide_autoconfig;
        int z3_mapping_mode;
        bool sound_toccata;
+       bool sound_toccata_mixer;
 
        int mountitems;
        struct uaedev_config_data mountconfig[MOUNT_CONFIG_SIZE];
index 29f98c55f6e0d8a0ce9cd2f4b0f7028fc911ab44..de7773d68acbcafabac66a6e192a0c2b134fa9ba 100644 (file)
@@ -6,3 +6,5 @@ void sndboard_vsync(void);
 void sndboard_rethink(void);
 void update_sndboard_sound(double);
 void sndboard_reset(void);
+void sndboard_ext_volume(void);
+
index 50e3e2d16a11290a0d897b3d81ee60f44571a170..a8d2665f75e17a98bf22e784019fd3fa352763e1 100644 (file)
@@ -664,11 +664,11 @@ static void *cdda_play (void *v)
                                        cda_bufon[bufnum] = 1;
                                        ioctl_next_cd_audio_buffer_callback(1 - bufnum);
                                }
-                               audio_cda_volume(currprefs.sound_volume_cd >= 0 ? currprefs.sound_volume_cd : currprefs.sound_volume, ciw->cdda_volume[0], ciw->cdda_volume[1]);
+                               audio_cda_volume(ciw->cdda_volume[0], ciw->cdda_volume[1]);
                                cda_bufon[bufnum] = 1;
                        } else {
                                cda_bufon[bufnum] = 1;
-                               cda->setvolume (currprefs.sound_volume_cd >= 0 ? currprefs.sound_volume_cd : currprefs.sound_volume, ciw->cdda_volume[0], ciw->cdda_volume[1]);
+                               cda->setvolume (ciw->cdda_volume[0], ciw->cdda_volume[1]);
                                if (!cda->play (bufnum)) {
                                        setstate (ciw, AUDIO_STATUS_PLAY_ERROR);
                                        goto end; // data track?
index 7ff511ba809bb3d7d8fe44f420592f60d04acc43..7291194ae832fcbd84c3256703d69b090300842c 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "options.h"
 #include "dxwrap.h"
+#include "audio.h"
 
 #include <dsound.h>
 #include <mmreg.h>
@@ -167,13 +168,14 @@ cda_audio::cda_audio(int num_sectors, int sectorsize, int samplerate)
 #endif
 }
 
-void cda_audio::setvolume(int master, int left, int right)
+void cda_audio::setvolume(int left, int right)
 {
        for (int j = 0; j < 2; j++) {
                volume[j] = j == 0 ? left : right;
-               volume[j] = (100 - master) * volume[j] / 100;
+               volume[j] = sound_cd_volume[j] * volume[j] / 32768;
                if (volume[j])
                        volume[j]++;
+               volume[j] = volume[j] * (100 - currprefs.sound_volume_master) / 100;
                if (volume[j] >= 32768)
                        volume[j] = 32768;
        }
index 384243ce1af94dfee03aebda8b0740a8a06c8e3d..fe5e948c51adc371faae03cf9e34f40de0a6e4d7 100644 (file)
@@ -26,7 +26,7 @@ public:
 
        cda_audio(int num_sectors, int sectorsize, int samplerate);
        ~cda_audio();
-       void setvolume(int master, int left, int right);
+       void setvolume(int left, int right);
        bool play(int bufnum);
        void wait(void);
        void wait(int bufnum);
index ffcb4804f2df1f57eddf5dd02868ead9cd6eff3d..fa5063371262f9b0e7c11a9aaea89cc91494debb 100644 (file)
 #define IDC_SOUNDSTYLE1                 1245
 #define IDC_SOUNDINTERPOLATION          1248
 #define IDC_INTERPOLATION0              1249
+#define IDC_SOUNDVOLUMESELECT           1249
 #define IDC_INTERPOLATION1              1250
 #define IDC_INTERPOLATION2              1251
 #define IDC_STEREOMODE                  1252
 #define IDC_SOUNDBUFFERMEM              1577
 #define IDC_HARDFLUSH                   1578
 #define IDC_SOUNDADJUSTNUM              1578
-#define IDC_SOUNDVOLUMECD               1578
+#define IDC_SOUNDVOLUMEEXT              1578
 #define IDC_CONSTJUMP                   1579
 #define IDC_SOUNDDRIVEVOLUME            1579
 #define IDC_JITFPU                      1580
 #define IDC_NOFLAGS                     1581
 #define IDC_SOUNDDRIVEVOLUME2           1581
 #define IDC_CS_CACHE_TEXT               1582
-#define IDC_SOUNDVOLUMECD2              1582
+#define IDC_SOUNDVOLUMEEXT2             1582
 #define IDC_CS_CACHE_TEXT2              1583
 #define IDC_COLLISIONS                  1584
 #define IDC_JITENABLE                   1584
 #define IDC_CS_TOCCATA                  1773
 #define IDC_DF1ENABLE                   1774
 #define IDC_FS_SELECT_DIR               1774
+#define IDC_CS_TOCCATAMIXER             1774
 #define IDC_FS_SELECT_FILE              1775
 #define IDC_FLOPPY_FFS                  1775
 #define IDC_DF2ENABLE                   1776
index af0f6671f9d49b46eb60c4d96e4cfd51e9bc249b..c3255fce592a726d5bbe0e64088acdb5d8ec858a 100644 (file)
@@ -370,13 +370,12 @@ BEGIN
     CONTROL         "Disabled, but emulated",IDC_SOUND1,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,53,107,10
     CONTROL         "Enabled",IDC_SOUND2,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,13,71,108,10
     CONTROL         "Automatic switching",IDC_SOUND_AUTO,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,13,92,108,10
-    GROUPBOX        "Master Volume",IDC_STATIC,139,19,255,69
-    RTEXT           "Paula/AHI",IDC_STATIC,152,38,51,10,SS_CENTERIMAGE
-    CONTROL         "",IDC_SOUNDVOLUME,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,207,32,105,20
-    EDITTEXT        IDC_SOUNDVOLUME2,329,35,48,12,ES_CENTER | ES_READONLY
-    RTEXT           "CD",IDC_STATIC,152,67,51,10,SS_CENTERIMAGE
-    CONTROL         "",IDC_SOUNDVOLUMECD,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,207,61,105,20
-    EDITTEXT        IDC_SOUNDVOLUMECD2,329,64,48,12,ES_CENTER | ES_READONLY
+    GROUPBOX        "Volume",IDC_STATIC,139,19,255,69
+    RTEXT           "Master",IDC_STATIC,160,38,51,10,SS_CENTERIMAGE
+    CONTROL         "",IDC_SOUNDVOLUME,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,215,32,105,20
+    EDITTEXT        IDC_SOUNDVOLUME2,337,35,48,12,ES_CENTER | ES_READONLY
+    CONTROL         "",IDC_SOUNDVOLUMEEXT,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,215,61,105,20
+    EDITTEXT        IDC_SOUNDVOLUMEEXT2,337,64,48,12,ES_CENTER | ES_READONLY
     GROUPBOX        "Sound Buffer Size",IDC_STATIC,140,90,254,42
     CONTROL         "Slider1",IDC_SOUNDBUFFERRAM,"msctls_trackbar32",TBS_AUTOTICKS | TBS_TOP | WS_TABSTOP,207,106,105,20
     EDITTEXT        IDC_SOUNDBUFFERMEM,329,109,48,12,ES_CENTER | ES_READONLY
@@ -406,6 +405,7 @@ BEGIN
     CONTROL         "OpenAL",IDC_SOUND_OPENAL,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,292,253,98,10
     CONTROL         "PortAudio",IDC_SOUND_PORTAUDIO,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,292,266,98,10
     CONTROL         "Include CD and FMV audio",IDC_SOUND_CDPAULAMIX,"Button",BS_AUTOCHECKBOX | BS_LEFT | WS_GROUP | WS_TABSTOP,13,108,108,10
+    COMBOBOX        IDC_SOUNDVOLUMESELECT,147,65,64,75,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
 END
 
 IDD_LOADSAVE DIALOGEX 0, 0, 396, 318
@@ -1134,6 +1134,8 @@ BEGIN
     COMBOBOX        IDC_NETDEVICE,202,256,178,65,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
     CONTROL         "CD32 Full Motion Video cartridge",IDC_CS_CD32FMV,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,242,151,11
     CONTROL         "Toccata Z2 sound card emulation",IDC_CS_TOCCATA,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,255,151,11
+    CONTROL         "Toccata Paula audio mix",IDC_CS_TOCCATAMIXER,
+                    "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,268,151,11
 END
 
 IDD_INPUTMAP DIALOGEX 0, 0, 421, 341
index e1c1f3da7023267be5f3927c4c1474c868f5fb94..383de45983ad37890370933fcb8b21ea96349897 100644 (file)
@@ -990,9 +990,9 @@ static LRESULT CALLBACK RPHostMsgFunction2 (UINT uMessage, WPARAM wParam, LPARAM
                }
                return 1;
        case RP_IPC_TO_GUEST_VOLUME:
-               currprefs.sound_volume = changed_prefs.sound_volume = 100 - wParam;
+               currprefs.sound_volume_master = changed_prefs.sound_volume_master = 100 - wParam;
                currprefs.sound_volume_cd = changed_prefs.sound_volume_cd = 100 - wParam;
-               set_volume (currprefs.sound_volume, 0);
+               set_volume (currprefs.sound_volume_master, 0);
                return TRUE;
        case RP_IPC_TO_GUEST_ESCAPEKEY:
                rp_rpescapekey = wParam;
@@ -1636,7 +1636,7 @@ void rp_update_volume (struct uae_prefs *p)
 {
        if (!cando ())
                return;
-       RPSendMessagex (RP_IPC_TO_HOST_VOLUME, (WPARAM)(100 - p->sound_volume), 0, NULL, 0, &guestinfo, NULL);
+       RPSendMessagex (RP_IPC_TO_HOST_VOLUME, (WPARAM)(100 - p->sound_volume_master), 0, NULL, 0, &guestinfo, NULL);
 }
 
 void rp_pause (int paused)
index 8931b6ccaa00a026fd45aff1d4f0725f5be444cd..09fd96928598f9721a57e423606709bc53f92446 100644 (file)
@@ -1567,7 +1567,7 @@ static int open_sound (void)
        if (ch != sdp->channels)
                currprefs.sound_stereo = changed_prefs.sound_stereo = get_audio_stereomode (sdp->channels);
 
-       set_volume (currprefs.sound_volume, sdp->mute);
+       set_volume (currprefs.sound_volume_master, sdp->mute);
        if (get_audio_amigachannels (currprefs.sound_stereo) == 4)
                sample_handler = sample16ss_handler;
        else
@@ -2757,25 +2757,25 @@ void sound_mute (int newmute)
                sdp->mute = sdp->mute ? 0 : 1;
        else
                sdp->mute = newmute;
-       set_volume (currprefs.sound_volume, sdp->mute);
+       set_volume (currprefs.sound_volume_master, sdp->mute);
        config_changed = 1;
 }
 
 void sound_volume (int dir)
 {
-       currprefs.sound_volume -= dir * 10;
+       currprefs.sound_volume_master -= dir * 10;
        currprefs.sound_volume_cd -= dir * 10;
-       if (currprefs.sound_volume < 0)
-               currprefs.sound_volume = 0;
-       if (currprefs.sound_volume > 100)
-               currprefs.sound_volume = 100;
-       changed_prefs.sound_volume = currprefs.sound_volume;
+       if (currprefs.sound_volume_master < 0)
+               currprefs.sound_volume_master = 0;
+       if (currprefs.sound_volume_master > 100)
+               currprefs.sound_volume_master = 100;
+       changed_prefs.sound_volume_master = currprefs.sound_volume_master;
        if (currprefs.sound_volume_cd < 0)
                currprefs.sound_volume_cd = 0;
        if (currprefs.sound_volume_cd > 100)
                currprefs.sound_volume_cd = 100;
        changed_prefs.sound_volume_cd = currprefs.sound_volume_cd;
-       set_volume (currprefs.sound_volume, sdp->mute);
+       set_volume (currprefs.sound_volume_master, sdp->mute);
        config_changed = 1;
 }
 void master_sound_volume (int dir)
index 9fefb145f6769af61ecaf1bffb6173e7b300113b..df8c200196f3f7d84a9e254f52e8809e47a838c7 100644 (file)
@@ -7963,6 +7963,7 @@ static void enable_for_expansiondlg (HWND hDlg)
        ShowWindow (GetDlgItem(hDlg, IDC_CS_SCSIMODE), SW_HIDE);
        ew(hDlg, IDC_CS_CD32FMV, en);
        ew(hDlg, IDC_CS_TOCCATA, en);
+       ew(hDlg, IDC_CS_TOCCATAMIXER, en && workprefs.sound_toccata);
        ew (hDlg, IDC_CS_SCSIMODE, FALSE);
 }
 
@@ -7977,6 +7978,7 @@ static void values_to_expansiondlg (HWND hDlg)
        CheckDlgButton (hDlg, IDC_A2065, workprefs.a2065name[0] ? 1 : 0);
        CheckDlgButton(hDlg, IDC_CS_CD32FMV, workprefs.cs_cd32fmv);
        CheckDlgButton(hDlg, IDC_CS_TOCCATA, workprefs.sound_toccata);
+       CheckDlgButton(hDlg, IDC_CS_TOCCATAMIXER, workprefs.sound_toccata_mixer);
        CheckDlgButton(hDlg, IDC_CS_SCSIMODE, workprefs.scsi == 2);
        SendDlgItemMessage (hDlg, IDC_RTG_BUFFERCNT, CB_SETCURSEL, workprefs.gfx_apmode[1].gfx_backbuffers == 0 ? 0 : workprefs.gfx_apmode[1].gfx_backbuffers - 1, 0);
        cw = catweasel_detect ();
@@ -8148,6 +8150,12 @@ static INT_PTR CALLBACK ExpansionDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LP
                                break;
                        case IDC_CS_TOCCATA:
                                workprefs.sound_toccata = ischecked(hDlg, IDC_CS_TOCCATA) ? 1 : 0;
+                               if (!workprefs.sound_toccata)
+                                       workprefs.sound_toccata_mixer = false;
+                               enable_for_expansiondlg(hDlg);
+                               break;
+                       case IDC_CS_TOCCATAMIXER:
+                               workprefs.sound_toccata_mixer = ischecked(hDlg, IDC_CS_TOCCATAMIXER) ? 1 : 0;
                                break;
                        }
                        if (HIWORD (wParam) == CBN_SELENDOK || HIWORD (wParam) == CBN_KILLFOCUS || HIWORD (wParam) == CBN_EDITCHANGE)  {
@@ -9585,8 +9593,8 @@ static void enable_for_sounddlg (HWND hDlg)
        ew (hDlg, IDC_SOUNDINTERPOLATION, workprefs.produce_sound);
        ew (hDlg, IDC_SOUNDVOLUME, workprefs.produce_sound);
        ew (hDlg, IDC_SOUNDVOLUME2, workprefs.produce_sound);
-       ew (hDlg, IDC_SOUNDVOLUMECD, workprefs.produce_sound);
-       ew (hDlg, IDC_SOUNDVOLUMECD2, workprefs.produce_sound);
+       ew (hDlg, IDC_SOUNDVOLUMEEXT, workprefs.produce_sound);
+       ew (hDlg, IDC_SOUNDVOLUMEEXT2, workprefs.produce_sound);
        ew (hDlg, IDC_SOUNDSTEREOSEP, workprefs.sound_stereo > 0 && workprefs.produce_sound);
        ew (hDlg, IDC_SOUNDSTEREOMIX, workprefs.sound_stereo > 0 && workprefs.produce_sound);
 
@@ -9663,6 +9671,7 @@ static void sound_loaddrivesamples (void)
 extern int soundpercent;
 
 static const int sndbufsizes[] = { 1024, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 32768, 65536, -1 };
+static int *volumeselection, volumeselectionindex;
 
 static int getsoundbufsizeindex (int size)
 {
@@ -9680,13 +9689,13 @@ static void update_soundgui (HWND hDlg)
        _stprintf (txt, _T("%d"), bufsize);
        SetDlgItemText (hDlg, IDC_SOUNDBUFFERMEM, txt);
 
-       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUME, TBM_SETPOS, TRUE, 100 - workprefs.sound_volume);
-       _stprintf (txt, _T("%d%%"), 100 - workprefs.sound_volume);
+       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUME, TBM_SETPOS, TRUE, 100 - workprefs.sound_volume_master);
+       _stprintf (txt, _T("%d%%"), 100 - workprefs.sound_volume_master);
        SetDlgItemText (hDlg, IDC_SOUNDVOLUME2, txt);
 
-       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMECD, TBM_SETPOS, TRUE, 100 - workprefs.sound_volume_cd);
-       _stprintf (txt, _T("%d%%"), 100 - workprefs.sound_volume_cd);
-       SetDlgItemText (hDlg, IDC_SOUNDVOLUMECD2, txt);
+       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMEEXT, TBM_SETPOS, TRUE, 100 - (*volumeselection));
+       _stprintf (txt, _T("%d%%"), 100 - (*volumeselection));
+       SetDlgItemText (hDlg, IDC_SOUNDVOLUMEEXT2, txt);
 
        SendDlgItemMessage (hDlg, IDC_SOUNDDRIVEVOLUME, TBM_SETPOS, TRUE, 100 - workprefs.dfxclickvolume);
        _stprintf (txt, _T("%d%%"), 100 - workprefs.dfxclickvolume);
@@ -9810,7 +9819,7 @@ static void values_to_sounddlg (HWND hDlg)
        SendDlgItemMessage (hDlg, IDC_SOUNDBUFFERRAM, TBM_SETPOS, TRUE, getsoundbufsizeindex (workprefs.sound_maxbsiz));
 
        SendDlgItemMessage (hDlg, IDC_SOUNDVOLUME, TBM_SETPOS, TRUE, 0);
-       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMECD, TBM_SETPOS, TRUE, 0);
+       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMEEXT, TBM_SETPOS, TRUE, 0);
        SendDlgItemMessage (hDlg, IDC_SOUNDDRIVEVOLUME, TBM_SETPOS, TRUE, 0);
 
        SendDlgItemMessage (hDlg, IDC_SOUNDCARDLIST, CB_SETCURSEL, workprefs.win32_soundcard, 0);
@@ -9938,6 +9947,20 @@ static void values_from_sounddlg (HWND hDlg)
        workprefs.sound_stereo_swap_paula = (SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_GETCURSEL, 0, 0) & 1) ? 1 : 0;
        workprefs.sound_stereo_swap_ahi = (SendDlgItemMessage (hDlg, IDC_SOUNDSWAP, CB_GETCURSEL, 0, 0) & 2) ? 1 : 0;
 
+       idx = SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_GETCURSEL, 0, 0);
+       if (idx != volumeselectionindex) {
+               volumeselectionindex = idx;
+               if (volumeselectionindex < 0 || volumeselectionindex > 2)
+                       volumeselectionindex = 0;
+               if (volumeselectionindex == 1)
+                       volumeselection = &workprefs.sound_volume_cd;
+               else if (volumeselectionindex == 2)
+                       volumeselection = &workprefs.sound_volume_board;
+               else
+                       volumeselection = &workprefs.sound_volume_paula;
+               update_soundgui (hDlg);
+       }
+
        for (i = 0; sounddrivers[i]; i++) {
                int old = sounddrivermask;
                sounddrivermask &= ~(1 << i);
@@ -9984,8 +10007,8 @@ static INT_PTR CALLBACK SoundDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
                        SendDlgItemMessage (hDlg, IDC_SOUNDVOLUME, TBM_SETRANGE, TRUE, MAKELONG (0, 100));
                        SendDlgItemMessage (hDlg, IDC_SOUNDVOLUME, TBM_SETPAGESIZE, 0, 1);
 
-                       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMECD, TBM_SETRANGE, TRUE, MAKELONG (0, 100));
-                       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMECD, TBM_SETPAGESIZE, 0, 1);
+                       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMEEXT, TBM_SETRANGE, TRUE, MAKELONG (0, 100));
+                       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMEEXT, TBM_SETPAGESIZE, 0, 1);
 
                        SendDlgItemMessage (hDlg, IDC_SOUNDDRIVEVOLUME, TBM_SETRANGE, TRUE, MAKELONG (0, 100));
                        SendDlgItemMessage (hDlg, IDC_SOUNDDRIVEVOLUME, TBM_SETPAGESIZE, 0, 1);
@@ -9997,6 +10020,16 @@ static INT_PTR CALLBACK SoundDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
                                CheckDlgButton (hDlg, sounddrivers[i], (sounddrivermask & (1 << i)) ? TRUE : FALSE);
                        }
 
+                       if (!volumeselection) {
+                               volumeselection = &workprefs.sound_volume_paula;
+                               volumeselectionindex = 0;
+                       }
+                       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_RESETCONTENT, 0, 0L);
+                       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_ADDSTRING, 0, (LPARAM)_T("Paula"));
+                       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_ADDSTRING, 0, (LPARAM)_T("CD"));
+                       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_ADDSTRING, 0, (LPARAM)_T("AHI"));
+                       SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_SETCURSEL, volumeselectionindex, 0);
+
                        SendDlgItemMessage (hDlg, IDC_SOUNDCARDLIST, CB_RESETCONTENT, 0, 0L);
                        numdevs = enumerate_sound_devices ();
                        for (card = 0; card < numdevs; card++) {
@@ -10040,8 +10073,8 @@ static INT_PTR CALLBACK SoundDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM
                        if (v >= 0)
                                workprefs.sound_maxbsiz = sndbufsizes[v];
                }
-               workprefs.sound_volume = 100 - SendMessage (GetDlgItem (hDlg, IDC_SOUNDVOLUME), TBM_GETPOS, 0, 0);
-               workprefs.sound_volume_cd = 100 - SendMessage (GetDlgItem (hDlg, IDC_SOUNDVOLUMECD), TBM_GETPOS, 0, 0);
+               workprefs.sound_volume_master = 100 - SendMessage (GetDlgItem (hDlg, IDC_SOUNDVOLUME), TBM_GETPOS, 0, 0);
+               (*volumeselection) = 100 - SendMessage (GetDlgItem (hDlg, IDC_SOUNDVOLUMEEXT), TBM_GETPOS, 0, 0);
                workprefs.dfxclickvolume = 100 - SendMessage (GetDlgItem (hDlg, IDC_SOUNDDRIVEVOLUME), TBM_GETPOS, 0, 0);
                update_soundgui (hDlg);
                break;
index 798a94597b213b23db062f1eee7bf0996f2835d9..72541fc30cf092e813b07721c292778132618496 100644 (file)
@@ -108,8 +108,8 @@ static void process_fifo(void)
                fifo_read_index = fifo_read_index % FIFO_SIZE;
        }
 
-       ch_sample[0] = ch_sample[0] * left_volume / 64;
-       ch_sample[1] = ch_sample[1] * right_volume / 64;
+       ch_sample[0] = ch_sample[0] * left_volume / 32768;
+       ch_sample[1] = ch_sample[1] * right_volume / 32768;
 
        if (data_in_fifo < FIFO_SIZE_HALF && prev_data_in_fifo >= FIFO_SIZE_HALF)
                fifo_half |= STATUS_FIFO_PLAY;
@@ -142,17 +142,42 @@ void audio_state_sndboard(int ch)
 
 static int get_volume(uae_u8 v)
 {
+       int out;
        if (v & 0x80) // Mute bit
                return 0;
-       v &= 63;
-       v = 64 - v;
-       return v;
+       out = v & 63;
+       out = 64 - out;
+       out *= 32768 / 64;
+       return out;
+}
+
+static int get_volume_in(uae_u8 v)
+{
+       int out;
+       if (v & 0x80) // Mute bit
+               return 0;
+       out = v & 31;
+       out = 32 - out;
+       out *= 32768 / 32;
+       return out;
 }
 
 static void calculate_volume(void)
 {
        left_volume = get_volume(ad1848_regs[6]);
        right_volume = get_volume(ad1848_regs[7]);
+       left_volume = (100 - currprefs.sound_volume_board) * 32768 / 100;
+       right_volume = (100 - currprefs.sound_volume_board) * 32768 / 100;
+
+       if (currprefs.sound_toccata_mixer) {
+               sound_paula_volume[0] = get_volume_in(ad1848_regs[4]);
+               sound_paula_volume[1] = get_volume_in(ad1848_regs[5]);
+       }
+}
+
+void sndboard_ext_volume(void)
+{
+       calculate_volume();
 }
 
 static const int freq_crystals[] = {
@@ -233,6 +258,8 @@ void sndboard_hsync(void)
 
 void sndboard_vsync(void)
 {
+       if (toccata_active)
+               calculate_volume();
 }
 
 static void toccata_put(uaecptr addr, uae_u8 v)
@@ -264,6 +291,12 @@ static void toccata_put(uaecptr addr, uae_u8 v)
                        else if ((old & 3) && !(v & 3))
                                codec_stop();
                        break;
+
+                       case 2:
+                       case 3:
+                       case 4:
+                       case 5:
+                       case 6:
                        case 7:
                        case 8:
                                calculate_volume();