@@ -21,13 +21,18 @@ public partial class Form1 : Form
2121 private bool InitDone = false ;
2222 private string TOMLPath ;
2323 private FlexGUIConfig flexGUIConfig ;
24+ private System . Text . Encoding enc1252 ;
2425
2526 public Form1 ( )
2627 {
2728 InitializeComponent ( ) ;
2829
30+ this . Text = "FlexASIO GUI v0.2" ;
31+
2932 System . Globalization . CultureInfo customCulture = ( System . Globalization . CultureInfo ) System . Threading . Thread . CurrentThread . CurrentCulture . Clone ( ) ;
3033 customCulture . NumberFormat . NumberDecimalSeparator = "." ;
34+ Encoding . RegisterProvider ( CodePagesEncodingProvider . Instance ) ;
35+ enc1252 = Encoding . GetEncoding ( 1252 ) ;
3136
3237 System . Threading . Thread . CurrentThread . CurrentCulture = customCulture ;
3338 CultureInfo . DefaultThreadCurrentCulture = customCulture ;
@@ -48,8 +53,6 @@ public Form1()
4853 numericLatencyInput . Increment = 0.1m ;
4954 numericLatencyOutput . Increment = 0.1m ;
5055
51- PortAudioInterop . Pa_Initialize ( ) ;
52-
5356 for ( var i = 0 ; i < Configuration . HostApiCount ; i ++ )
5457 {
5558 comboBackend . Items . Add ( Configuration . GetHostApiInfo ( i ) . name ) ;
@@ -87,13 +90,21 @@ public Form1()
8790 GenerateOutput ( ) ;
8891 }
8992
93+ private string W1252fromUTF ( string s )
94+ {
95+ byte [ ] bytes = Encoding . Default . GetBytes ( s ) ;
96+ byte [ ] output = Encoding . Convert ( Encoding . UTF8 , enc1252 , bytes ) ;
97+ return Encoding . UTF8 . GetString ( output ) ;
98+ }
99+
90100 private TreeNode [ ] GetDevicesForBackend ( string Backend , bool Input )
91101 {
92102 List < TreeNode > treeNodes = new List < TreeNode > ( ) ;
93103 treeNodes . Add ( new TreeNode ( "(None)" ) ) ;
94104 for ( var i = 0 ; i < Configuration . DeviceCount ; i ++ )
95105 {
96106 var deviceInfo = Configuration . GetDeviceInfo ( i ) ;
107+
97108 var apiInfo = Configuration . GetHostApiInfo ( deviceInfo . hostApi ) ;
98109
99110 if ( apiInfo . name != Backend )
@@ -103,14 +114,14 @@ private TreeNode[] GetDevicesForBackend(string Backend, bool Input)
103114 {
104115 if ( deviceInfo . maxInputChannels > 0 )
105116 {
106- treeNodes . Add ( new TreeNode ( deviceInfo . name ) ) ;
117+ treeNodes . Add ( new TreeNode ( W1252fromUTF ( deviceInfo . name ) ) ) ;
107118 }
108119 }
109120 else
110121 {
111122 if ( deviceInfo . maxOutputChannels > 0 )
112123 {
113- treeNodes . Add ( new TreeNode ( deviceInfo . name ) ) ;
124+ treeNodes . Add ( new TreeNode ( W1252fromUTF ( deviceInfo . name ) ) ) ;
114125 }
115126 }
116127 }
@@ -145,46 +156,6 @@ private void GenerateOutput()
145156 {
146157 if ( ! InitDone ) return ;
147158
148- // Old manual way of writing the config file...
149-
150- //StringBuilder config = new StringBuilder();
151- //var backend = comboBackend.SelectedItem.ToString();
152- //var input = treeDevicesInput?.SelectedNode?.Text;
153- //var output = treeDevicesOutput?.SelectedNode?.Text;
154- //var inputLatency = numericLatencyInput.Value.ToString();
155- //var outputLatency = numericLatencyOutput.Value.ToString();
156-
157- //config.AppendLine($"# Host API backend");
158- //config.AppendLine($"backend = \"{comboBackend.SelectedItem?.ToString()}\"");
159- //config.AppendLine($"bufferSizeSamples = {numericBufferSize?.Value.ToString()}");
160- //config.AppendLine("");
161- //config.AppendLine($"[input]");
162- //if (input == "(None)")
163- // config.AppendLine($"device = \"\"");
164- //else
165- // config.AppendLine($"device = \"{treeDevicesInput?.SelectedNode?.Text}\"");
166- //if (numericChannelsInput.Value > 0)
167- //{
168- // config.AppendLine($"channels = {numericChannelsInput?.Value.ToString()}");
169- //}
170- //config.AppendLine($"suggestedLatencySeconds = {numericLatencyInput?.Value.ToString("0.0", new CultureInfo("en-US"))}");
171- //config.AppendLine($"wasapiExclusiveMode = {wasapiExclusiveInput?.Checked.ToString().ToLower()}");
172- //config.AppendLine($"wasapiAutoConvert = {wasapiAutoConvertInput?.Checked.ToString().ToLower()}");
173- //config.AppendLine("");
174- //config.AppendLine($"[output]");
175- //if (output == "(None)")
176- // config.AppendLine($"device = \"\"");
177- //else
178- // config.AppendLine($"device = \"{treeDevicesOutput?.SelectedNode?.Text}\"");
179- //if (numericChannelsOutput.Value > 0)
180- //{
181- // config.AppendLine($"channels = {numericChannelsOutput?.Value.ToString()}");
182- //}
183- //config.AppendLine($"suggestedLatencySeconds = {numericLatencyOutput?.Value.ToString("0.0", new CultureInfo("en-US"))}");
184- //config.AppendLine($"wasapiExclusiveMode = {wasapiExclusiveOutput?.Checked.ToString().ToLower()}");
185- //config.AppendLine($"wasapiAutoConvert = {wasapiAutoConvertOutput?.Checked.ToString().ToLower()}");
186- //configOutput.Text = config.ToString();
187-
188159 configOutput . Clear ( ) ;
189160 configOutput . Text = Toml . WriteString ( flexGUIConfig ) ;
190161 }
0 commit comments