Exemplo n.º 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);
        }
Exemplo n.º 2
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);
 }