示例#1
0
        public static ArrayList GetPAInputDevices(int hostIndex)
        {
            var a = new ArrayList();

            if (hostIndex >= PA19.PA_GetHostApiCount())
            {
                a.Add(new PADeviceInfo("HPSDR (PCM A/D)", 0));
                return(a);
            }

            PA19.PaHostApiInfo hostInfo = PA19.PA_GetHostApiInfo(hostIndex);
            for (int i = 0; i < hostInfo.deviceCount; i++)
            {
                int devIndex = PA19.PA_HostApiDeviceIndexToDeviceIndex(hostIndex, i);
                PA19.PaDeviceInfo devInfo = PA19.PA_GetDeviceInfo(devIndex);
                if (devInfo.maxInputChannels > 0)
                {
                    string name  = devInfo.name;
                    int    index = name.IndexOf("- ");
                    if (index > 0)
                    {
                        char c = name[index - 1]; // make sure this is what we're looking for
                        if (c >= '0' && c <= '9') // it is... remove index
                        {
                            int x = name.IndexOf("(");
                            name  = devInfo.name.Substring(0, x + 1);                                   // grab first part of string including "("
                            name += devInfo.name.Substring(index + 2, devInfo.name.Length - index - 2); // add end of string;
                        }
                    }
                    a.Add(new PADeviceInfo(name, i) /* + " - " + devIndex*/);
                }
            }
            return(a);
        }
示例#2
0
        public static ArrayList GetPAHosts() // returns a text list of driver types
        {
            var a = new ArrayList();

            for (int i = 0; i < PA19.PA_GetHostApiCount(); i++)
            {
                PA19.PaHostApiInfo info = PA19.PA_GetHostApiInfo(i);
                a.Add(info.name);
            }
            a.Add("HPSDR (USB/UDP)");
            return(a);
        }
示例#3
0
 public static bool CheckPAOutputDevices(int hostIndex, string name)
 {
     PA19.PaHostApiInfo hostInfo = PA19.PA_GetHostApiInfo(hostIndex);
     for (int i = 0; i < hostInfo.deviceCount; i++)
     {
         int devIndex = PA19.PA_HostApiDeviceIndexToDeviceIndex(hostIndex, i);
         PA19.PaDeviceInfo devInfo = PA19.PA_GetDeviceInfo(devIndex);
         if (devInfo.maxOutputChannels > 0 && devInfo.name.Contains(name))
         {
             return(true);
         }
     }
     return(false);
 }
示例#4
0
        public static void EnableVAC2(bool enable)
        {
            bool retval = false;

            if (enable)
            {
                unsafe
                {
                    int num_chan    = 1;
                    int sample_rate = sample_rate3;
                    int block_size  = block_size_vac2;

                    double in_latency     = vac2_latency_manual ? latency3 / 1000.0 : PA19.PA_GetDeviceInfo(input_dev3).defaultLowInputLatency;
                    double out_latency    = vac2_latency_out_manual ? vac2_latency_out / 1000.0 : PA19.PA_GetDeviceInfo(output_dev3).defaultLowOutputLatency;
                    double pa_in_latency  = vac2_latency_pa_in_manual ? vac2_latency_pa_in / 1000.0 : PA19.PA_GetDeviceInfo(input_dev3).defaultLowInputLatency;
                    double pa_out_latency = vac2_latency_pa_out_manual ? vac2_latency_pa_out / 1000.0 : PA19.PA_GetDeviceInfo(output_dev3).defaultLowOutputLatency;

                    if (vac2_output_iq)
                    {
                        num_chan    = 2;
                        sample_rate = sample_rate_rx2;
                        block_size  = block_size_rx2;
                    }
                    else if (vac2_stereo)
                    {
                        num_chan = 2;
                    }

                    VAC2RBReset = true;

                    ivac.SetIVAChostAPIindex(1, host3);
                    ivac.SetIVACinputDEVindex(1, input_dev3);
                    ivac.SetIVACoutputDEVindex(1, output_dev3);
                    ivac.SetIVACnumChannels(1, num_chan);
                    ivac.SetIVACInLatency(1, in_latency, 0);
                    ivac.SetIVACOutLatency(1, out_latency, 0);
                    ivac.SetIVACPAInLatency(1, pa_in_latency, 0);
                    ivac.SetIVACPAOutLatency(1, pa_out_latency, 1);

                    try
                    {
                        retval = ivac.StartAudioIVAC(1) == 1;
                        if (retval && console.PowerOn)
                        {
                            ivac.SetIVACrun(1, 1);
                        }
                    }
                    catch (Exception)
                    {
                        MessageBox.Show("The program is having trouble starting the VAC audio streams.\n" +
                                        "Please examine the VAC related settings on the Setup Form -> Audio Tab and try again.",
                                        "VAC2 Audio Stream Startup Error",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                ivac.SetIVACrun(1, 0);
                ivac.StopAudioIVAC(1);
            }
        }