public void UpdateListening() { if (Recording) { return; } var inputPorts = Ports.OfType <NidaQmxChannel>().Where(p => p.Direction == ChannelDirection.Input && p.Status == DevicePortStatus.Active); var outputPorts = Ports.OfType <NidaQmxChannel>().Where(p => p.Direction == ChannelDirection.Output && p.Status == DevicePortStatus.Active); _listeningPorts = inputPorts.Concat(outputPorts).ToList(); if (_listeningPorts.Count == 0) { return; } double maxMultiChannelRate; var result = NidaQmxHelper.DAQmxGetDevAIMaxMultiChanRate(Name, out maxMultiChannelRate); if (result < 0) { OnError?.Invoke(this, new DeviceErrorArgs(NidaQmxHelper.GetError(result))); return; } SamplerateInput = (int)(maxMultiChannelRate / inputPorts.Count()); SamplesPerChannelInput = (int)(10000.0 * Math.Floor(SamplerateInput / 20.0 / 10000.0)); foreach (var port in inputPorts) { port.Samplerate = SamplerateInput; } }