From 0cf128d6edf5f456b3bad85d9b12c238b75d56d0 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Fri, 23 Jan 2015 19:29:06 +0200 Subject: [PATCH] Audio master/subvolume update. Toccata Paula mixing. --- audio.cpp | 79 ++++++++++++++++++++------------- blkdev.cpp | 1 - blkdev_cdimage.cpp | 4 +- cd32_fmv.cpp | 4 +- cfgfile.cpp | 16 +++++-- include/audio.h | 5 ++- include/options.h | 5 ++- include/sndboard.h | 2 + od-win32/blkdev_win32_ioctl.cpp | 4 +- od-win32/cda_play.cpp | 6 ++- od-win32/cda_play.h | 2 +- od-win32/resources/resource.h | 6 ++- od-win32/resources/winuae.rc | 16 ++++--- od-win32/rp.cpp | 6 +-- od-win32/sounddep/sound.cpp | 18 ++++---- od-win32/win32gui.cpp | 57 +++++++++++++++++++----- sndboard.cpp | 43 +++++++++++++++--- 17 files changed, 188 insertions(+), 86 deletions(-) diff --git a/audio.cpp b/audio.cpp index a825ce0c..562a6226 100644 --- 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) diff --git a/blkdev.cpp b/blkdev.cpp index 23827c2b..1dd87fc2 100644 --- a/blkdev.cpp +++ b/blkdev.cpp @@ -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) diff --git a/blkdev_cdimage.cpp b/blkdev_cdimage.cpp index 2138a339..512d9236 100644 --- a/blkdev_cdimage.cpp +++ b/blkdev_cdimage.cpp @@ -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); diff --git a/cd32_fmv.cpp b/cd32_fmv.cpp index a648cda7..8a303775 100644 --- a/cd32_fmv.cpp +++ b/cd32_fmv.cpp @@ -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); } } } diff --git a/cfgfile.cpp b/cfgfile.cpp index 71da082f..86148bd0 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -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; diff --git a/include/audio.h b/include/audio.h index 4228f74e..b3c9c50c 100644 --- a/include/audio.h +++ b/include/audio.h @@ -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 diff --git a/include/options.h b/include/options.h index fc9a30e0..d87e19fe 100644 --- a/include/options.h +++ b/include/options.h @@ -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]; diff --git a/include/sndboard.h b/include/sndboard.h index 29f98c55..de7773d6 100644 --- a/include/sndboard.h +++ b/include/sndboard.h @@ -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); + diff --git a/od-win32/blkdev_win32_ioctl.cpp b/od-win32/blkdev_win32_ioctl.cpp index 50e3e2d1..a8d2665f 100644 --- a/od-win32/blkdev_win32_ioctl.cpp +++ b/od-win32/blkdev_win32_ioctl.cpp @@ -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? diff --git a/od-win32/cda_play.cpp b/od-win32/cda_play.cpp index 7ff511ba..7291194a 100644 --- a/od-win32/cda_play.cpp +++ b/od-win32/cda_play.cpp @@ -15,6 +15,7 @@ #include "options.h" #include "dxwrap.h" +#include "audio.h" #include #include @@ -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; } diff --git a/od-win32/cda_play.h b/od-win32/cda_play.h index 384243ce..fe5e948c 100644 --- a/od-win32/cda_play.h +++ b/od-win32/cda_play.h @@ -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); diff --git a/od-win32/resources/resource.h b/od-win32/resources/resource.h index ffcb4804..fa506337 100644 --- a/od-win32/resources/resource.h +++ b/od-win32/resources/resource.h @@ -553,6 +553,7 @@ #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 @@ -774,7 +775,7 @@ #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 @@ -782,7 +783,7 @@ #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 @@ -1106,6 +1107,7 @@ #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 diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index af0f6671..c3255fce 100644 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -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 diff --git a/od-win32/rp.cpp b/od-win32/rp.cpp index e1c1f3da..383de459 100644 --- a/od-win32/rp.cpp +++ b/od-win32/rp.cpp @@ -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) diff --git a/od-win32/sounddep/sound.cpp b/od-win32/sounddep/sound.cpp index 8931b6cc..09fd9692 100644 --- a/od-win32/sounddep/sound.cpp +++ b/od-win32/sounddep/sound.cpp @@ -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) diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 9fefb145..df8c2001 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -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; diff --git a/sndboard.cpp b/sndboard.cpp index 798a9459..72541fc3 100644 --- a/sndboard.cpp +++ b/sndboard.cpp @@ -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(); -- 2.47.3