]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
MIDI and Genlock video volume control.
authorToni Wilen <twilen@winuae.net>
Sun, 4 Dec 2016 11:47:21 +0000 (13:47 +0200)
committerToni Wilen <twilen@winuae.net>
Sun, 4 Dec 2016 11:47:21 +0000 (13:47 +0200)
arcadia.cpp
cfgfile.cpp
include/options.h
od-win32/midi.cpp
od-win32/win32_videograb.cpp
od-win32/win32gfx.cpp
od-win32/win32gui.cpp
specialmonitors.cpp

index 76703538b1aa0d7ca823ce698b0de226c990d318..8e5baa9157e9914de2655ef8da28c0a9fb2bac1f 100644 (file)
@@ -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)
index fa1d534a59a8178a4fde83a1e01f372e873a99f7..56e2286c5b3af690ecf851799845261a65eb9ba0 100644 (file)
@@ -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)
index b52b74f2c237cac1327bf4e419809a498a0af571..33ab811bab71049b239d2519e9c845bafd8e3791 100644 (file)
@@ -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;
index 52a8d424378c8d95db6700a1ca747be91bef4df5..103b354ced854d6d9f4119aed77783cb5eeb88e8 100644 (file)
@@ -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))) {
index ff7e425e8f42f8d727ac8377d7d47486a0f61f8e..6aa7fe553e1dca747d05a8ae1a1ad8d93ffb2b2b 100644 (file)
@@ -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;
index 9baff6ee0f8b7cc8720426ad87aea5603e623718..d16feba3b1f5103a067933b27a32d5239bcb0e46 100644 (file)
@@ -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) {
index 54e36191fa8980e9dc16048decd8042559b26026..5c33d00b5ba906fb4554509829c913f64129a275 100644 (file)
@@ -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);
index f75b39469a119fe1f076a98b2e34af470b37cbde..cea37649ece7bf776540146c65f850e3efa58396 100755 (executable)
@@ -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;