private void FormatOrDeviceChanged() { if (sample.SelectedItem != null) { var attrs = XtAudio.GetSampleAttributes((XtSample)sample.SelectedItem); attributes.Text = XtPrint.AttributesToString(attrs); } XtFormat inputFormat = GetFormat(false); XtDevice inputDevice = this.inputDevice.SelectedItem == null ? null : ((DeviceView)(this.inputDevice.SelectedItem)).device; bool inputSupported = inputDevice == null ? false : inputDevice.SupportsFormat(inputFormat); inputFormatSupported.Text = inputSupported.ToString(); XtBuffer inputBuffer = !inputSupported ? null : inputDevice.GetBuffer(inputFormat); inputBufferSizes.Text = !inputSupported ? "N/A" : string.Format("{0} / {1} / {2}", inputBuffer.min.ToString("N1"), inputBuffer.current.ToString("N1"), inputBuffer.max.ToString("N1")); inputMix.Text = inputDevice == null || inputDevice.GetMix() == null ? "N/A" : inputDevice.GetMix().ToString(); inputInterleaved.Text = inputDevice == null ? "N/A" : inputDevice.SupportsAccess(true) && inputDevice.SupportsAccess(false) ? "Both" : inputDevice.SupportsAccess(false) ? "False" : "True"; List <ChannelView> inputViews = new List <ChannelView>(); if (inputDevice != null) { inputViews = (from i in Enumerable.Range(0, inputDevice.GetChannelCount(false)) select new ChannelView { index = i, name = (1 + i) + ": " + inputDevice.GetChannelName(false, i) }) .ToList(); } inputChannels.DataSource = null; inputChannels.DataSource = inputViews; inputChannels.SelectedItems.Clear(); XtFormat outputFormat = GetFormat(true); XtDevice outputDevice = this.outputDevice.SelectedItem == null ? null : ((DeviceView)(this.outputDevice.SelectedItem)).device; bool outputSupported = outputDevice == null ? false : outputDevice.SupportsFormat(outputFormat); outputFormatSupported.Text = outputSupported.ToString(); XtBuffer outputBuffer = !outputSupported ? null : outputDevice.GetBuffer(outputFormat); outputBufferSizes.Text = !outputSupported ? "N/A" : string.Format("{0} / {1} / {2}", outputBuffer.min.ToString("N1"), outputBuffer.current.ToString("N1"), outputBuffer.max.ToString("N1")); outputMix.Text = outputDevice == null || outputDevice.GetMix() == null ? "N/A" : outputDevice.GetMix().ToString(); outputInterleaved.Text = outputDevice == null ? "N/A" : outputDevice.SupportsAccess(true) && outputDevice.SupportsAccess(false) ? "Both" : outputDevice.SupportsAccess(false) ? "False" : "True"; List <ChannelView> outputViews = new List <ChannelView>(); if (outputDevice != null) { outputViews = (from i in Enumerable.Range(0, outputDevice.GetChannelCount(true)) select new ChannelView { index = i, name = (1 + i) + ": " + outputDevice.GetChannelName(true, i) }) .ToList(); } outputChannels.DataSource = null; outputChannels.DataSource = outputViews; outputChannels.SelectedItems.Clear(); bufferSize.Minimum = 1; bufferSize.Maximum = 5000; bufferSize.Value = 1000; if (outputBuffer != null) { bufferSize.Minimum = (int)Math.Floor(outputBuffer.min); bufferSize.Maximum = (int)Math.Ceiling(outputBuffer.max); bufferSize.Value = (int)Math.Ceiling(outputBuffer.current); bufferSize.TickFrequency = (bufferSize.Maximum - bufferSize.Minimum) / 10; } }