Exemplo n.º 1
0
 public AudioDevice(string name, string host, int idx, AudioDeviceDirection direction, bool isDefault)
 {
     this.Name      = name;
     this.Host      = host;
     this.Index     = idx;
     this.Direction = direction;
     this.IsDefault = isDefault;
 }
Exemplo n.º 2
0
        public static List <AudioDevice> GetDevices(AudioDeviceDirection direction)
        {
            List <AudioDevice> audioDevices = new List <AudioDevice>();
            int count      = Pa_GetDeviceCount();
            int defaultIn  = Pa_GetDefaultInputDevice();
            int defaultOut = Pa_GetDefaultOutputDevice();

            for (int i = 0; i < count; i++)
            {
                PaDeviceInfo         deviceInfo      = Pa_GetDeviceInfo(i);
                AudioDeviceDirection deviceDirection = deviceInfo.maxInputChannels > 0 ? (deviceInfo.maxOutputChannels > 0 ? AudioDeviceDirection.InputOutput : AudioDeviceDirection.Input) : AudioDeviceDirection.Output;
                if (deviceDirection == direction || deviceDirection == AudioDeviceDirection.InputOutput)
                {
                    PaHostApiInfo hostInfo = Pa_GetHostApiInfo(deviceInfo.hostApi);
                    audioDevices.Add(new AudioDevice(deviceInfo.name, hostInfo.name, i, deviceDirection, i == defaultIn || i == defaultOut));
                }
            }

            return(audioDevices);
        }