Ejemplo n.º 1
0
        public DeviceCaptureChannel(JSONClass json)
        {
            channelName            = json[nameof(channelName)];
            outputFormat           = (OutputFormat)json[nameof(outputFormat)].AsInt;
            cacheLength            = json[nameof(cacheLength)].AsInt;
            storeInMemoryUntilSave = json[nameof(storeInMemoryUntilSave)].AsBool;

            var id = json[nameof(channelDevice.DeviceID)];

            using (var enumerator = new MMDeviceEnumerator()) {
                deviceList = new List <MMDevice>(enumerator.EnumAudioEndpoints(DataFlow.All, DeviceState.Active));
                foreach (var device in deviceList)
                {
                    if (device.DeviceID == id)
                    {
                        channelDevice = device;
                        break;
                    }
                }

                if (channelDevice == null)
                {
                    channelDevice = enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);
                }
            }

            cacheLength = 60;             // default cache length, for now

            Debug.WriteLine("Populating properties window");
            propertiesWindow = new DeviceCaptureProperties {
                Visible = false
            };
            propertiesWindow.Populate(this);
        }
Ejemplo n.º 2
0
        public DeviceCaptureChannel(string name, OutputFormat fmt = OutputFormat.WAV)
        {
            channelName  = name;
            outputFormat = fmt;
            cacheLength  = 60;            // default cache length, for now
            using (MMDeviceEnumerator enumerator = new MMDeviceEnumerator()) {
                channelDevice = (MMDevice)enumerator.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia);

                deviceList = new List <MMDevice>(enumerator.EnumAudioEndpoints(DataFlow.All, DeviceState.Active));
            }

            Debug.WriteLine("Populating properties window");
            propertiesWindow = new DeviceCaptureProperties {
                Visible = false
            };
            propertiesWindow.Populate(this);
        }