Пример #1
0
 public bool SetupTxAndRxDeviceIndicies(ref bool SetupMaySelectDevices, ref uint RxInDevice, ref uint TxOutDevice, DigiRiteLogger.ForceLeftRight flr)
 {   // the RxInDevice and TxOutDevice are relevant only in this process. This call cannot be forwarded out of process.
     return(false);
 }
Пример #2
0
        public bool SetupTxAndRxDeviceIndicies(ref bool SetupMaySelectDevices, ref uint RxInDevice, ref uint TxOutDevice,
                                               DigiRiteLogger.ForceLeftRight flr)
        {
            var lr = iWlEntry.GetLeftRight();

            if ((lr != 0) && (lr != 1))
            {
                // instance #1 is allowed to select neither L nor R
                if ((instanceNumber == 1) && (lr == (short)-1))
                {
                    lr = 0; // put on left
                }
                else if (lr > 1)
                {                  // Radio #3 or #4
                    return(false); // use setup form
                }
                else
                {
                    MessageBox.Show("DigiRite requires the Entry Window to be set to either L or R");
                    return(false);
                }
            }
            SetupMaySelectDevices = false;
            var RxInDevices  = XD.WaveDeviceEnumerator.waveInDevices();
            var TxOutDevices = XD.WaveDeviceEnumerator.waveOutDevices();

            Microsoft.Win32.RegistryKey rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(
                "Software\\W5XD\\writelog.ini\\OneDevicePerRadio");
            if ((rk != null) && (rk.ValueCount > 1))
            {
                // WL Sound Mixer is set up one-device-per-radio
                object v = null;
                RxInDevice  = UInt32.MaxValue;
                TxOutDevice = UInt32.MaxValue;
                if (rk != null)
                {
                    // RX side
                    v = rk.GetValue(lr == 0 ? "LeftReceiverAudioDeviceId" : "RightReceiverAudioDeviceId");
                    if (v != null)
                    {
                        string id = v.ToString().ToUpper();
                        for (int i = 0; i < RxInDevices.Count; i++)
                        {
                            if (String.Equals(XD.WaveDeviceEnumerator.waveInInstanceId(i).ToUpper(), id))
                            {
#if DEBUG
                                // have a look at the user-friendly name of the device
                                var waveIns = XD.WaveDeviceEnumerator.waveInDevices();
                                if (i < waveIns.Count)
                                {
                                    string name = waveIns[i];
                                }
#endif
                                RxInDevice = (uint)i;
                                break;
                            }
                        }
                        if (RxInDevice < 0)
                        {
                            MessageBox.Show("Use WriteLog Sound Mixer to set the " + (lr == 0 ? "Left" : "Right") + " Rx audio in");
                        }
                    }
                    else
                    {
                        MessageBox.Show("WriteLog Sound Mixer control is not set up for " + (lr == 0 ? "Left" : "Right") + " RX audio in");
                    }
                    // TX side
                    v = rk.GetValue(lr == 0 ? "LeftTransmitterAudioDeviceId" : "RightTransmitterAudioDeviceId");
                    if (v != null)
                    {
                        string id = v.ToString().ToUpper();
                        for (int i = TxOutDevices.Count - 1; i >= 0; i -= 1)
                        {
                            if (XD.WaveDeviceEnumerator.waveOutInstanceId(i).ToUpper() == id)
                            {
#if DEBUG
                                // have a look at the user-friendly name of the device
                                var waveOuts = XD.WaveDeviceEnumerator.waveOutDevices();
                                if (i < waveOuts.Count)
                                {
                                    string name = waveOuts[i];
                                }
#endif
                                TxOutDevice = (uint)i;
                                break;
                            }
                        }
                        if (TxOutDevice < 0)
                        {
                            MessageBox.Show("Use WriteLog Sound Mixer to set the " + (lr == 0 ? "Left" : "Right") + " TX audio out");
                        }
                    }
                    else
                    {
                        MessageBox.Show("WriteLog Sound Mixer control is not set up for " + (lr == 0 ? "Left" : "Right") + " RX audio in");
                    }
                }
            }
            else
            {
                // WL Sound Mixer is set up for separate device per radio
                object v = null;
                rk = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\\W5XD\\writelog.ini\\WlSound");
                if (rk != null)
                {
                    v = rk.GetValue("RxInDevice");
                }
                if (v != null)
                {
                    string RxInDeviceName = v.ToString().ToUpper();
                    for (int i = RxInDevices.Count - 1; i >= 0; i -= 1)
                    {
                        if (RxInDevices[i].ToUpper().Contains(RxInDeviceName))
                        {
                            RxInDevice = (uint)i;
                            break;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("WriteLog Sound Mixer control is not set up for RX audio in");
                }
                v = rk.GetValue("TxOutDevice");
                if (v != null)
                {
                    string TxOutDeviceName = v.ToString().ToUpper();
                    for (int i = 0; i < TxOutDevices.Count; i++)
                    {
                        if (TxOutDevices[i].ToUpper().Contains(TxOutDeviceName))
                        {
                            TxOutDevice = (uint)i;
                            break;
                        }
                    }
                }
                else
                {
                    MessageBox.Show("WriteLog Sound Mixer control is not set up for TX audio out");
                }
                flr(lr);
            }
            return(true);
        }