From: Toni Wilen Date: Sun, 4 Dec 2016 11:47:21 +0000 (+0200) Subject: MIDI and Genlock video volume control. X-Git-Tag: 3400~15 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=0fee68968e9baeb292294d87fb6947e6331f0bb9;p=francis%2Fwinuae.git MIDI and Genlock video volume control. --- diff --git a/arcadia.cpp b/arcadia.cpp index 76703538..8e5baa91 100644 --- a/arcadia.cpp +++ b/arcadia.cpp @@ -753,12 +753,12 @@ void alg_serial_read(uae_u16 w) case 0x46: // CH-1 ON 'F' ack(); ld_audio |= 1; - setvolumevideograb(32768); + setvolumevideograb(100 - currprefs.sound_volume_genlock); break; case 0x48: // CH-2 ON 'H' ack(); ld_audio |= 2; - setvolumevideograb(32768); + setvolumevideograb(100 - currprefs.sound_volume_genlock); break; case 0x47: // CH-1 OFF 'G' ack(); @@ -838,9 +838,6 @@ static void alg_vsync(void) alg_nvram_write(); } } - if (isvideograb()) { - isvideograb_status(); - } } int alg_serial_write(void) diff --git a/cfgfile.cpp b/cfgfile.cpp index fa1d534a..56e2286c 100644 --- a/cfgfile.cpp +++ b/cfgfile.cpp @@ -1592,6 +1592,10 @@ void cfgfile_save_options (struct zfile *f, struct uae_prefs *p, int type) 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); + if (p->sound_volume_midi >= 0) + cfgfile_write (f, _T("sound_volume_midi"), _T("%d"), p->sound_volume_midi); + if (p->sound_volume_genlock >= 0) + cfgfile_write (f, _T("sound_volume_genlock"), _T("%d"), p->sound_volume_genlock); 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); @@ -2819,6 +2823,8 @@ static int cfgfile_parse_host (struct uae_prefs *p, TCHAR *option, TCHAR *value) || 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_volume_midi"), &p->sound_volume_midi, 1) + || cfgfile_intval (option, value, _T("sound_volume_genlock"), &p->sound_volume_genlock, 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) diff --git a/include/options.h b/include/options.h index b52b74f2..33ab811b 100644 --- a/include/options.h +++ b/include/options.h @@ -448,6 +448,8 @@ struct uae_prefs { int sound_volume_paula; int sound_volume_cd; int sound_volume_board; + int sound_volume_midi; + int sound_volume_genlock; bool sound_stereo_swap_paula; bool sound_stereo_swap_ahi; bool sound_auto; diff --git a/od-win32/midi.cpp b/od-win32/midi.cpp index 52a8d424..103b354c 100644 --- a/od-win32/midi.cpp +++ b/od-win32/midi.cpp @@ -76,6 +76,7 @@ static int outbufferselect = 0; static int out_allocated = 0; static volatile int exitin = 0; static CRITICAL_SECTION cs_proc; + /* * FUNCTION: getmidiouterr * @@ -99,6 +100,21 @@ static TCHAR *getmidiouterr(TCHAR *txt, int err) return txt; } +static void MidiSetVolume(HMIDIOUT oh) +{ + TCHAR err[MAX_DPATH]; + MMRESULT verr; + DWORD vol = 0xffffffff; + if (currprefs.sound_volume_midi > 0) { + uae_u16 v = (uae_u16)(65535.0 - (65535.0 * currprefs.sound_volume_midi / 100.0)); + vol = (v << 16) | v; + } + verr = midiOutSetVolume (oh, vol); + if (verr) { + write_log(_T("MIDI OUT: midiOutSetVolume error %s / %d\n"), getmidiouterr(err, verr), verr); + } +} + /* * FUNCTION: MidiOut_Alloc * @@ -638,6 +654,7 @@ int Midi_Open(void) result = 0; } else { InitializeCriticalSection(&cs_proc); + MidiSetVolume(outHandle); // We don't need input for output... if((currprefs.win32_midiindev >= 0) && (result = midiInOpen(&inHandle, currprefs.win32_midiindev, (DWORD_PTR)MidiInProc, 0, CALLBACK_FUNCTION|MIDI_IO_STATUS))) { diff --git a/od-win32/win32_videograb.cpp b/od-win32/win32_videograb.cpp index ff7e425e..6aa7fe55 100644 --- a/od-win32/win32_videograb.cpp +++ b/od-win32/win32_videograb.cpp @@ -310,7 +310,7 @@ bool initvideograb(const TCHAR *filename) hr = filterGraph->QueryInterface(IID_IMediaEvent, (void**)&mediaEvent); hr = filterGraph->QueryInterface(IID_IBasicAudio, (void**)&audio); - setvolumevideograb(0); + setvolumevideograb(100 - currprefs.sound_volume_genlock); hr = filterGraph->QueryInterface(IID_IMediaControl, (void**)&mediaControl); if (FAILED(hr)) { @@ -360,7 +360,7 @@ void setvolumevideograb(int volume) { if (!audio) return; - long vol = log10((float)volume / 32768.0) * 4000.0; + long vol = log10((float)volume / 100.0) * 4000.0; audio->put_Volume(vol); } @@ -428,6 +428,10 @@ void isvideograb_status(void) { if (!videoInitialized) return; + if (currprefs.sound_volume_genlock != changed_prefs.sound_volume_genlock) { + currprefs.sound_volume_genlock = changed_prefs.sound_volume_genlock; + setvolumevideograb(100 - currprefs.sound_volume_genlock); + } if (mediaEvent == NULL) return; long EventCode; diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index 9baff6ee..d16feba3 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -2385,10 +2385,12 @@ int check_prefs_changed_gfx (void) } if (currprefs.win32_midiindev != changed_prefs.win32_midiindev || currprefs.win32_midioutdev != changed_prefs.win32_midioutdev || + currprefs.sound_volume_midi != changed_prefs.sound_volume_midi || currprefs.win32_midirouter != changed_prefs.win32_midirouter) { currprefs.win32_midiindev = changed_prefs.win32_midiindev; currprefs.win32_midioutdev = changed_prefs.win32_midioutdev; + currprefs.sound_volume_midi = changed_prefs.sound_volume_midi; currprefs.win32_midirouter = changed_prefs.win32_midirouter; #ifdef SERIAL_PORT if (midi_ready) { diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index 54e36191..5c33d00b 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -12018,12 +12018,16 @@ static void values_from_sounddlg (HWND hDlg) idx = SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_GETCURSEL, 0, 0); if (idx != volumeselectionindex) { volumeselectionindex = idx; - if (volumeselectionindex < 0 || volumeselectionindex > 2) + if (volumeselectionindex < 0 || volumeselectionindex > 4) volumeselectionindex = 0; if (volumeselectionindex == 1) volumeselection = &workprefs.sound_volume_cd; else if (volumeselectionindex == 2) volumeselection = &workprefs.sound_volume_board; + else if (volumeselectionindex == 3) + volumeselection = &workprefs.sound_volume_midi; + else if (volumeselectionindex == 4) + volumeselection = &workprefs.sound_volume_genlock; else volumeselection = &workprefs.sound_volume_paula; update_soundgui (hDlg); @@ -12098,6 +12102,8 @@ static INT_PTR CALLBACK SoundDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM 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_ADDSTRING, 0, (LPARAM)_T("MIDI")); + SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_ADDSTRING, 0, (LPARAM)_T("Genlock")); SendDlgItemMessage (hDlg, IDC_SOUNDVOLUMESELECT, CB_SETCURSEL, volumeselectionindex, 0); SendDlgItemMessage (hDlg, IDC_SOUNDCARDLIST, CB_RESETCONTENT, 0, 0L); diff --git a/specialmonitors.cpp b/specialmonitors.cpp index f75b3946..cea37649 100755 --- a/specialmonitors.cpp +++ b/specialmonitors.cpp @@ -2431,6 +2431,7 @@ skip: uninitvideograb(); genlock_video = false; } + isvideograb_status(); #endif if (currprefs.genlock_image != 4 && currprefs.genlock_image != 5 && currprefs.genlock_image != 6) { genlock_video_file[0] = 0;