public Form1() { InitializeComponent(); System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; System.Threading.Thread.CurrentThread.CurrentCulture = customCulture; CultureInfo.DefaultThreadCurrentCulture = customCulture; CultureInfo.DefaultThreadCurrentUICulture = customCulture; TOMLPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\FlexASIO.toml"; flexGUIConfig = new FlexGUIConfig(); if (File.Exists(TOMLPath)) { flexGUIConfig = Toml.ReadFile <FlexGUIConfig>(TOMLPath); } numericBufferSize.Maximum = 8192; numericBufferSize.Value = 256; numericBufferSize.Increment = 16; numericLatencyInput.Increment = 0.1m; numericLatencyOutput.Increment = 0.1m; PortAudioInterop.Pa_Initialize(); for (var i = 0; i < Configuration.HostApiCount; i++) { comboBackend.Items.Add(Configuration.GetHostApiInfo(i).name); } if (comboBackend.Items.Contains(flexGUIConfig.backend)) { comboBackend.SelectedIndex = comboBackend.Items.IndexOf(flexGUIConfig.backend); } else { comboBackend.SelectedIndex = 0; } numericBufferSize.Value = (Int64)flexGUIConfig.bufferSizeSamples; treeDevicesInput.SelectedNode = treeDevicesInput.Nodes.Cast <TreeNode>().FirstOrDefault(x => x.Text == (flexGUIConfig.input.device == "" ? "(None)" : flexGUIConfig.input.device)); treeDevicesOutput.SelectedNode = treeDevicesOutput.Nodes.Cast <TreeNode>().FirstOrDefault(x => x.Text == (flexGUIConfig.output.device == "" ? "(None)" : flexGUIConfig.output.device)); numericLatencyInput.Value = (decimal)(double)flexGUIConfig.input.suggestedLatencySeconds; numericLatencyOutput.Value = (decimal)(double)flexGUIConfig.output.suggestedLatencySeconds; numericChannelsInput.Value = (decimal)(flexGUIConfig.input.channels ?? 0); numericChannelsOutput.Value = (decimal)(flexGUIConfig.output.channels ?? 0); wasapiExclusiveInput.Checked = flexGUIConfig.input.wasapiExclusiveMode; wasapiExclusiveOutput.Checked = flexGUIConfig.output.wasapiExclusiveMode; wasapiAutoConvertInput.Checked = flexGUIConfig.input.wasapiAutoConvert; wasapiAutoConvertOutput.Checked = flexGUIConfig.output.wasapiAutoConvert; InitDone = true; SetStatusMessage($"FlexASIO GUI for FlexASIO 0.15 started ({Configuration.VersionString})"); GenerateOutput(); }
public Form1() { InitializeComponent(); this.Text = $"FlexASIO GUI v{flexasioGuiVersion}"; System.Globalization.CultureInfo customCulture = (System.Globalization.CultureInfo)System.Threading.Thread.CurrentThread.CurrentCulture.Clone(); customCulture.NumberFormat.NumberDecimalSeparator = "."; Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); enc1252 = Encoding.GetEncoding(1252); System.Threading.Thread.CurrentThread.CurrentCulture = customCulture; CultureInfo.DefaultThreadCurrentCulture = customCulture; CultureInfo.DefaultThreadCurrentUICulture = customCulture; TOMLPath = $"{Environment.GetFolderPath(Environment.SpecialFolder.UserProfile)}\\{tomlName}"; flexGUIConfig = new FlexGUIConfig(); if (File.Exists(TOMLPath)) { flexGUIConfig = Toml.ReadFile <FlexGUIConfig>(TOMLPath); } numericBufferSize.Maximum = 8192; numericBufferSize.Increment = 16; numericLatencyInput.Increment = 0.1m; numericLatencyOutput.Increment = 0.1m; for (var i = 0; i < Configuration.HostApiCount; i++) { comboBackend.Items.Add(Configuration.GetHostApiInfo(i).name); } if (comboBackend.Items.Contains(flexGUIConfig.backend)) { comboBackend.SelectedIndex = comboBackend.Items.IndexOf(flexGUIConfig.backend); } else { comboBackend.SelectedIndex = 0; } checkBoxSetBufferSize.Checked = numericBufferSize.Enabled = flexGUIConfig.bufferSizeSamples != null; if (flexGUIConfig.bufferSizeSamples != null) { numericBufferSize.Value = (Int64)flexGUIConfig.bufferSizeSamples; } treeDevicesInput.SelectedNode = treeDevicesInput.Nodes.Cast <TreeNode>().FirstOrDefault(x => x.Text == (flexGUIConfig.input.device == "" ? "(None)" : flexGUIConfig.input.device)); treeDevicesOutput.SelectedNode = treeDevicesOutput.Nodes.Cast <TreeNode>().FirstOrDefault(x => x.Text == (flexGUIConfig.output.device == "" ? "(None)" : flexGUIConfig.output.device)); checkBoxSetInputLatency.Checked = numericLatencyInput.Enabled = flexGUIConfig.input.suggestedLatencySeconds != null; checkBoxSetOutputLatency.Checked = numericLatencyOutput.Enabled = flexGUIConfig.output.suggestedLatencySeconds != null; if (flexGUIConfig.input.suggestedLatencySeconds != null) { numericLatencyInput.Value = (decimal)(double)flexGUIConfig.input.suggestedLatencySeconds; } if (flexGUIConfig.output.suggestedLatencySeconds != null) { numericLatencyOutput.Value = (decimal)(double)flexGUIConfig.output.suggestedLatencySeconds; } numericChannelsInput.Value = (decimal)(flexGUIConfig.input.channels ?? 0); numericChannelsOutput.Value = (decimal)(flexGUIConfig.output.channels ?? 0); checkBoxWasapiInputSet.Checked = flexGUIConfig.input.wasapiExclusiveMode != null || flexGUIConfig.input.wasapiAutoConvert != null; checkBoxWasapiOutputSet.Checked = flexGUIConfig.output.wasapiExclusiveMode != null || flexGUIConfig.output.wasapiAutoConvert != null; wasapiExclusiveInput.Enabled = flexGUIConfig.input.wasapiExclusiveMode != null; wasapiExclusiveInput.Checked = flexGUIConfig.input.wasapiExclusiveMode ?? false; wasapiExclusiveOutput.Enabled = flexGUIConfig.output.wasapiExclusiveMode != null; wasapiExclusiveOutput.Checked = flexGUIConfig.output.wasapiExclusiveMode ?? false; wasapiAutoConvertInput.Enabled = flexGUIConfig.input.wasapiAutoConvert != null; wasapiAutoConvertInput.Checked = flexGUIConfig.input.wasapiAutoConvert ?? false; wasapiAutoConvertOutput.Enabled = flexGUIConfig.output.wasapiAutoConvert != null; wasapiAutoConvertOutput.Checked = flexGUIConfig.output.wasapiAutoConvert ?? false; InitDone = true; SetStatusMessage($"FlexASIO GUI for FlexASIO {flexasioVersion} started ({Configuration.VersionString})"); GenerateOutput(); }