コード例 #1
0
        private static Tuple <int, int> GetSelectedDevices(string apiName, int inDeviceId, int outDeviceId, string inputDeviceName, string outputDeviceName)
        {
            var devices = Enumerable.Range(0, PortAudio.Pa_GetDeviceCount())
                          .ToDictionary(x => x, x => PortAudio.Pa_GetDeviceInfo(x))
                          .Where(x => PortAudio.Pa_GetHostApiInfo(x.Value.hostApi).name == apiName)
                          .ToDictionary(x => x.Key, x => x.Value);

            int realInputDeviceId;
            int realOutputDeviceId;

            var matchedInputArr = devices.Where(x => x.Key == inDeviceId && x.Value.name == inputDeviceName).ToArray();

            if (matchedInputArr.Length == 1)
            {
                realInputDeviceId = matchedInputArr[0].Key;
            }
            else
            {
                realInputDeviceId = devices.Where(x => x.Value.name == inputDeviceName).First().Key;
            }

            var matchedOutputArr = devices.Where(x => x.Key == outDeviceId && x.Value.name == outputDeviceName).ToArray();

            if (matchedOutputArr.Length == 1)
            {
                realOutputDeviceId = matchedOutputArr[0].Key;
            }
            else
            {
                realOutputDeviceId = devices.Where(x => x.Value.name == outputDeviceName).First().Key;
            }

            return(Tuple.Create(realInputDeviceId, realOutputDeviceId));
        }
コード例 #2
0
        public void populateHostAPIs()
        {
            int hostCount = PortAudio.Pa_GetHostApiCount();

            for (int i = 0; i < hostCount; i++)
            {
                hostInfos.Add(PortAudio.Pa_GetHostApiInfo(i));
            }

            int deviceCount = PortAudio.Pa_GetDeviceCount();

            for (int i = 0; i < deviceCount; i++)
            {
                deviceInfos.Add(PortAudio.Pa_GetDeviceInfo(i));
            }

            foreach (var info in hostInfos)
            {
                comboBoxHost.Items.Add(info.name);
            }
        }