Example #1
0
 public AudioService()
 {
     api     = PortAudioHostApi.SupportedHostApis.First();
     Devices = api.Devices.Where(x => x.MaxOutputChannels > 0).ToArray();
     if (Devices.Length == 0)
     {
         throw new InvalidOperationException("PC has no sound output device");
     }
     OutputDevice = api.DefaultOutputDevice;
 }
        public PortAudioOutputController(PortAudioHostApi api)
        {
            _api    = api;
            ApiName = $"{Regex.Replace(api.Name, "^Windows ", "")} (PortAudio)";

            var devList = new List <PortAudioDevice>();

            foreach (var device in api.Devices)
            {
                if (device.MaxOutputChannels <= 0)
                {
                    device.Dispose();
                    continue;
                }

                devList.Add(device);
            }

            _outputDevices = devList;
        }