-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
X32CopyFX.c
642 lines (640 loc) · 26.3 KB
/
X32CopyFX.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
/*
* X32CopyFX.c
*
* Created on: Nov 6, 2016
* Author: Patrick-Gilles Maillot
*
* X32CopyFX will copy one fx to another, or one side of a selected FX to its other side
* The utility is aimed at EQ (TEQ or GEQ), with a few options included
*
* log history:
* ver 1.00: initial release
* ver 1.10: added reset capability
* ver 1.20: added reset From->To, with real default values respective of each effects
* ver 1.30: users can overwrite standards default with their own default parameter sets (-f option)
* ver 1.31: source code cosmetic changes, additional comments
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
//
#include <winsock2.h> // Windows functions for std GUI & sockets
#include <mmsystem.h> // Multimedia functions (such as MIDI) for Windows
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
//
#define MAXFXNUM 8 // X32 supports up to 8 effects
#define BSIZE 512 // UDP buffers max length values
#define BSIZEm1 BSIZE - 1 // max buffer fgets() length values
//
// Effect ref names
char* FXref[] = {
"HALL",
"AMBI",
"RPLT",
"ROOM",
"CHAM",
"PLAT",
"VREV",
"VRM",
"GATE",
"RVRS",
"DLY",
"3TAP",
"4TAP",
"CRS",
"FLNG",
"PHAS",
"DIMC",
"FILT",
"ROTA",
"PAN",
"SUB",
"D/RV",
"CR/R",
"FL/R",
"D/CR",
"D/FL",
"MODD",
"GEQ2",
"GEQ",
"TEQ2",
"TEQ",
"DES2",
"DES",
"P1A",
"P1A2",
"PQ5",
"PQ5S",
"WAVD",
"LIM",
"CMB",
"CMB2",
"FAC",
"FAC1M",
"FAC2",
"LEC",
"LEC2",
"ULC",
"ULC2",
"ENH2",
"ENH",
"EXC2",
"EXC",
"IMG",
"EDI",
"SON",
"AMP2",
"AMP",
"DRV2",
"DRV",
"PIT2",
"PIT"
};
int FXrefMAX = sizeof(FXref) / sizeof(char*);
//
// Effects defaults. The trailing zeroes are not necessary - No big deal but todo: remove them!
char* FXdef[] = {
"20 1.57 60 5k74 25 0.0 83 7k2 0.95 25 50 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0",
"4 0.84 60 5k06 30 0.0 71 7k9 20 50 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0",
"10 1.70 27 4k47 100 0.0 89 5k0 0.81 18 26 50 90 80 34 -28 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0",
"6 0.43 18 3k94 68 1.5 83 5k0 1.00 18 40 25 10 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0",
"14 1.70 56 4k47 100 0.0 60 5k0 1.00 33 70 50 115 135 54 66 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0",
"32 2.11 60 6k50 30 0.0 60 7k2 1.09 211.44 20 20 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0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0 0 0 0 0 0 0 0 0",
"0 -10 5.0 100 -50 100 0 10 6.9 100 50 15k8 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0",
"0 0 5.0 52 15k8 100 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
};
//
int keep_on = 1; // 1 as long as program runs
int Xconnected; // whether X32 is connected or not
//
char r_buf[BSIZE], s_buf[BSIZE]; // X32 receive and send buffers
int r_len, s_len; // associated data lengths
int p_status; // "polling" status
//
WSADATA wsa; // Windows Sockets
int Xfd; // X32 socket
struct sockaddr_in Xip; // IP structure
struct sockaddr *Xip_addr = (struct sockaddr*) &Xip;
struct timeval timeout; // timeout for non blocking udp comm
fd_set ufds; // file descriptor
int Xip_len = sizeof(Xip); // length of addresses
char xremote[12] = "/xremote"; // automatic trailing zeroes
char Xip_str[32]; // X32 IP address as a string
time_t before, now; // timers for /xremote
char str1[64];
//
int FXnum; // current selected FX number
char* FXNames[MAXFXNUM] = {0, 0, 0, 0, 0, 0, 0, 0}; // array of pointers to FX name strings
time_t FXcpy = 0; // fx time stamp indicator
char* FXcpOptions[] = {"Reset FROM:", "Reset FROM -> TO", "Copy FROM: A->B",
"Copy FROM: B->A", "Copy FROM -> TO"};
int FXcpOptMAX = sizeof(FXcpOptions) / sizeof(char*);
int FXcpmstr = 0; // copy master flag
//
char* *FXref_ram; // array of FX names
char* *FXdef_ram; // array of FX parameter data strings
//
// Windows Declarations
WINBASEAPI HWND WINAPI GetConsoleWindow(VOID);
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//
HINSTANCE hInstance = 0;
HWND hwndipaddr, hwndlistFXfrom, hwndlistFXto, hwndFXcpy, hwndconx, hwndcpmstr, hwndcpdir;
HFONT hfont, htmp;
HDC hdc;
PAINTSTRUCT ps;
MSG wMsg;
//
//
// Macros:
//
#define RPOLL \
do { \
FD_ZERO (&ufds); \
FD_SET (Xfd, &ufds); \
p_status = select(Xfd+1, &ufds, NULL, NULL, &timeout); \
} while (0);
//
#define RECV \
do { \
r_len = recvfrom(Xfd, r_buf, BSIZE, 0, 0, 0); \
} while (0);
//
#define SEND \
do { \
if (sendto (Xfd, s_buf, s_len, 0, Xip_addr, Xip_len) < 0) { \
perror ("Error while sending data"); \
exit (EXIT_FAILURE); \
} \
} while(0);
//
#define SENDR \
do { \
if (sendto (Xfd, r_buf, r_len, 0, Xip_addr, Xip_len) < 0) { \
perror ("Error while sending data"); \
exit (EXIT_FAILURE); \
} \
} while(0);
//
// External calls used
extern int Xsprint(char *buffer, int index, char format, void *data);
extern int Xfprint(char *buffer, int index, char *header, char format, void *data);
extern int X32Connect(int Xconnected, char* Xip_str, int btime);
extern int validateIP4Dotted(const char *s);
//
// Private functions
void XlistFX(int fill);
void XcopyFX();
void XReset(int j);
//
// Windows main function and main loop
//
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR lpCmdLine, int nCmdFile) {
//
WNDCLASSW wc = {0};
wc.lpszClassName = L"X32CopyFX";
wc.hInstance = hInstance;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc;
wc.hCursor = LoadCursor(0, IDC_ARROW);
//
RegisterClassW(&wc);
CreateWindowW(wc.lpszClassName, L"X32CopyFX",
WS_OVERLAPPEDWINDOW | WS_VISIBLE, 50, 50, 300, 230, 0, 0, hInstance, 0);
//
Xconnected = 0;
// Main loop
while (keep_on) {
if (PeekMessage(&wMsg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&wMsg);
DispatchMessage(&wMsg);
}
if (Xconnected) {
// check if copy time stamp expired
now = time(NULL);
if (FXcpy) {
if (now > FXcpy + 1) {
SetWindowText(hwndFXcpy, "APPLY");
FXcpy = 0;
}
}
}
Sleep(5); // avoid high CPU by waiting 5ms
}
return (int) wMsg.wParam;
}
//
//
// Windows Callbacks
//
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
int i;
//
switch (msg) {
case WM_CREATE:
//
hwndipaddr = CreateWindow("Edit", NULL,
WS_CHILD | WS_VISIBLE | WS_BORDER, 5, 40, 120, 20, hwnd,
(HMENU )0, NULL, NULL);
hwndconx = CreateWindow("button", "Connect", WS_VISIBLE | WS_CHILD,
130, 40, 145, 20, hwnd, (HMENU )1, NULL, NULL);
// Propose FX list as combo box. The list will be populated when connecting to X32
// set height so there's enough room for 8 lines (170 ... > 8*20)
hwndlistFXfrom = CreateWindowW(L"COMBOBOX", NULL, CBS_DROPDOWN | WS_CHILD | WS_VISIBLE,
5, 80, 180, 170, hwnd, (HMENU)0, NULL, NULL);
hwndlistFXto = CreateWindowW(L"COMBOBOX", NULL, CBS_DROPDOWN | WS_CHILD | WS_VISIBLE,
5, 120, 180, 170, hwnd, (HMENU)0, NULL, NULL);
hwndcpdir = CreateWindowW(L"COMBOBOX", NULL, CBS_DROPDOWN | WS_CHILD | WS_VISIBLE,
5, 160, 150, 170, hwnd, (HMENU)0, NULL, NULL);
hwndcpmstr = CreateWindow("BUTTON", "Copy Master",
WS_VISIBLE | WS_CHILD | BS_CHECKBOX,
170, 163, 120, 20, hwnd, (HMENU)2, NULL, NULL);
hwndFXcpy = CreateWindow("button", "APPLY", WS_VISIBLE | WS_CHILD | BS_MULTILINE,
195, 80, 80, 63, hwnd, (HMENU )3, NULL, NULL);
break;
//
case WM_PAINT:
//
hdc = BeginPaint(hwnd, &ps);
SetBkMode(hdc, TRANSPARENT);
// update user information
SetWindowText(hwndipaddr, (LPSTR) Xip_str);
//
hfont = CreateFont(16, 0, 0, 0, FW_REGULAR, 0, 0, 0,
DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY, VARIABLE_PITCH, TEXT("Arial"));
htmp = (HFONT) SelectObject(hdc, hfont);
TextOut(hdc, 5, 0, str1, wsprintf(str1, "X32CopyFX - ©2016 - Patrick-Gilles Maillot"));
DeleteObject(htmp);
DeleteObject(hfont);
//
// update diverse texts
hfont = CreateFont(14, 0, 0, 0, FW_LIGHT, 0, 0, 0,
DEFAULT_CHARSET, OUT_OUTLINE_PRECIS, CLIP_DEFAULT_PRECIS,
ANTIALIASED_QUALITY, FIXED_PITCH, NULL);//TEXT("Arial"));
htmp = (HFONT) SelectObject(hdc, hfont);
TextOut(hdc, 235, 15, str1, wsprintf(str1, "v 1.31"));
TextOut(hdc, 5, 25, str1, wsprintf(str1, "Set X32 IP below:"));
TextOut(hdc, 5, 65, str1, wsprintf(str1, "Select FX FROM:"));
TextOut(hdc, 5, 105, str1, wsprintf(str1, "Select FX TO:"));
TextOut(hdc, 5, 145, str1, wsprintf(str1, "Action selection:"));
DeleteObject(htmp);
DeleteObject(hfont);
EndPaint(hwnd, &ps);
break;
//
case WM_COMMAND:
if (HIWORD(wParam) == BN_CLICKED) { // user action
switch (LOWORD(wParam)) {
case 1: // connect X32
GetWindowText(hwndipaddr, Xip_str, GetWindowTextLength(hwndipaddr) + 1);
if (validateIP4Dotted(Xip_str)) {
Xconnected = X32Connect(Xconnected, Xip_str, 5000);
if (Xconnected) {
SetWindowText(hwndconx, "Connected");
// Load dropdown item list
XlistFX(1);
sprintf(s_buf, "X32CopyFX: Please note the program does not\ncheck for the result of the copy, nor does it\ncheck if the operation is a valid one or not.\n\nX32CopyFX will just apply the selected operations\nto the up to 64 parameters of the selected effect(s).\n");
MessageBox(NULL, s_buf, "Note", MB_OK);
} else {
SetWindowText(hwndconx, "Connect");
// free allocated name spaces
XlistFX(0);
}
} else {
MessageBox(NULL, "Incorrect IP string form", NULL, MB_OK);
}
break;
case 2:
// Copy FX "from" to "to", according to options/settings
FXcpmstr ^= 1;
SendMessage(hwndcpmstr, BM_SETCHECK, FXcpmstr, 0);
break;
case 3:
// Copy FX "from" to "to", according to options/settings
XcopyFX();
SetWindowText(hwndFXcpy, "DONE");
FXcpy = time(NULL);
break;
}
}
break;
//
case WM_DESTROY:
if (Xconnected) close(Xfd);
Xconnected = 0;
// Free allocated name spaces
for (i = 0; i <MAXFXNUM; i++) {
if (FXNames[i]) free(FXNames[i]);
FXNames[i] = 0;
}
// Stop mainloop
keep_on = 0;
PostQuitMessage(0);
break;
}
return DefWindowProcW(hwnd, msg, wParam, lParam);
}
//
// XlistFX(fill):
// fill - 1: run through all 8 FX from X32, get their names and fill combo box list with
// names in the form "n: fxname".
// name fields are dynamically allocated.
// fill = 0: free name space memory if needed
// reset combo box names
void XlistFX(int fill) {
int i, j;
if (fill) {
// there's something to display; fetch it from the console
for (i = 0; i < MAXFXNUM; i++) {
sprintf(r_buf, "fx/%d", i+1);
s_len = Xfprint (s_buf, 0, "/node", 's', r_buf);
SEND;
RECV;
FXNames[i] = 0;
j = 0;
while (j < r_len && r_buf[j] != ' ') j += 1;
if ((FXNames[i] = malloc(sizeof(char) * r_len - j + 4)) != NULL) {
FXNames[i][0] = i + 1 + (int)'0';
FXNames[i][1] = ':';
FXNames[i][2] = ' ';
FXNames[i][3] = 0;
strcat(FXNames[i], r_buf + j + 1);
FXNames[i][strlen(FXNames[i]) - 1] = 0;
}
SendMessage(hwndlistFXfrom, CB_ADDSTRING, (WPARAM)0, (LPARAM)FXNames[i]);
SendMessage(hwndlistFXto, CB_ADDSTRING, (WPARAM)0, (LPARAM)FXNames[i]);
}
// set list of possible operations
for (i = 0; i < FXcpOptMAX; i++) {
SendMessage(hwndcpdir, CB_ADDSTRING, (WPARAM)0, (LPARAM)FXcpOptions[i]);
}
// display initial item 0 in the selection field
SendMessage(hwndlistFXfrom, CB_SETCURSEL, (WPARAM)FXnum, (LPARAM)0);
SendMessage(hwndlistFXto, CB_SETCURSEL, (WPARAM)FXnum, (LPARAM)0);
SendMessage(hwndcpdir, CB_SETCURSEL, (WPARAM)FXnum, (LPARAM)0);
} else {
// not connected - remove effects and operations
for (i = 0; i <MAXFXNUM; i++) {
if (FXNames[i]) free(FXNames[i]);
FXNames[i] = 0;
SendMessage(hwndlistFXfrom, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
SendMessage(hwndlistFXto, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
}
for (i = 0; i < FXcpOptMAX; i++) {
SendMessage(hwndcpdir, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0);
}
}
}
//
//
// XReset: reset the effect at index J [1-8] with its default values.
// values are retrieved from the default table in FXdef_ram
void XReset(int j) {
int i;
//
for (i = 0; i < FXrefMAX; i++ ) {
// below, the "+ 3" is to point to the effect name, avoiding the "1: " before the name
if (strcmp(FXref_ram[i], FXNames[j - 1] + 3) == 0) {
// found: send default values
memcpy(s_buf, "/\0\0\0,s\0\0fx/1/par \0", 17);
strcpy(s_buf + 17, FXdef_ram[i]); // s_buf almost ready
s_len = strlen(FXdef_ram[i]) + 17; // length
s_buf[s_len++] = 0; // 0 ending
while(s_len & 3) s_buf[s_len++] = 0; // set length to multiple of 4
s_buf[11] = j + '0'; // set FX slot number [1..8]
SEND
RECV
return;
}
}
return;
}
//
// XcopyFX() Manage the actual copy of FX data, after getting source, destination
// and options
void XcopyFX() {
int i;
int FXfrom, FXto, FXdir, FXmstr;
// get source FX number; X32 FX numbers start at 1
FXfrom = 1 + SendMessage(hwndlistFXfrom, CB_GETCURSEL,(WPARAM) 0, (LPARAM) 0);
// get destination FX number
FXto = 1 + SendMessage(hwndlistFXto, CB_GETCURSEL,(WPARAM) 0, (LPARAM) 0);
// get operation & Copy Master values
FXdir = SendMessage(hwndcpdir, CB_GETCURSEL,(WPARAM) 0, (LPARAM) 0);
FXmstr = SendMessage(hwndcpmstr, BM_GETCHECK,(WPARAM) 0, (LPARAM) 0);
//
switch (FXdir) {
case 0: // Reset From:
// search effect name within list of FXnames
XReset(FXfrom);
break;
case 1: // Reset From: to To:
for (i = FXfrom; i < FXto + 1; i++) XReset(i);
break;
case 2: // copy From: A->B
for (i = 1; i < 32; i++) { // par source = [01..31]
sprintf(r_buf, "/fx/%d/par/%02d", FXfrom, i);
s_len = Xsprint (s_buf, 0, 's', r_buf);
SEND
RECV
sprintf(r_buf+10, "%02d", i+32);
SENDR // SENDR sends to X32 using read buffer
}
if (FXmstr) {
sprintf(r_buf, "/fx/%d/par/32", FXfrom);
s_len = Xsprint (s_buf, 0, 's', r_buf);
SEND
RECV
r_buf[10] = '6';
r_buf[11] = '4';
SENDR // SENDR sends to X32 using read buffer
}
break;
case 3: // copy From: B->A
for (i = 33; i < 64; i++) { // par source = [33..63]
sprintf(r_buf, "/fx/%d/par/%02d", FXfrom, i);
s_len = Xsprint (s_buf, 0, 's', r_buf);
SEND
RECV
sprintf(r_buf+10, "%02d", i-32);
SENDR // SENDR sends to X32 using read buffer
}
if (FXmstr) {
sprintf(r_buf, "/fx/%d/par/64", FXfrom);
s_len = Xsprint (s_buf, 0, 's', r_buf);
SEND
RECV
r_buf[10] = '3';
r_buf[11] = '2';
SENDR // SENDR sends to X32 using read buffer
}
break;
case 4: // copy From to To
for (i = 1; i < 32; i++) { // par = [01..31] and [33..63]
sprintf(r_buf, "/fx/%d/par/%02d", FXfrom, i);
s_len = Xsprint (s_buf, 0, 's', r_buf);
SEND
RECV
r_buf[4] = (char)FXto + '0';
SENDR;
sprintf(r_buf, "/fx/%d/par/%02d", FXfrom, i + 32);
s_len = Xsprint (s_buf, 0, 's', r_buf);
SEND
RECV
r_buf[4] = (char)FXto + '0';
SENDR;
}
if (FXmstr) {
sprintf(r_buf, "/fx/%d/par/32", FXfrom);
s_len = Xsprint (s_buf, 0, 's', r_buf);
SEND
RECV
r_buf[4] = (char)FXto + '0';
SENDR;
sprintf(r_buf, "/fx/%d/par/64", FXfrom);
s_len = Xsprint (s_buf, 0, 's', r_buf);
SEND
RECV
r_buf[4] = (char)FXto + '0';
SENDR;
}
break;
default:
break;
}
}
//
//
// Main program
int main(int argc, char **argv) {
HINSTANCE hPrevInstance = 0;
PWSTR pCmdLine = 0;
int nCmdFile = 0;
int filein, i;
FILE *UserFXfile;
char input_ch;
filein = 0;
while ((input_ch = getopt(argc, argv, "f:h")) != (char)0xff) {
switch (input_ch) {
case 'f':
filein = 1;
sscanf(optarg, "%s", r_buf);
break;
case 'h':
default:
printf("Usage:\n");
printf("./X32CopyFx [-f <file>]\n");
printf("\tWhere if -f is set and <file> is provided, file is in the form of pair of lines:\n");
printf("\t\tFX name\n");
printf("\t\tparameter data string associated to FX name\n");
sleep(30);
return(0);
break;
}
}
// copy default FX tables parameter data
FXref_ram = malloc(FXrefMAX * sizeof(char*));
FXdef_ram = malloc(FXrefMAX * sizeof(char*));
for (i = 0; i < FXrefMAX; i++) {
FXref_ram[i] = FXref[i]; // copy pointers only
FXdef_ram[i] = FXdef[i]; // copy pointers only
}
// if filein is set, open user description and update default table values
// accordingly
if (filein) {
if ((UserFXfile = fopen(r_buf, "r")) != NULL) {
// valid (?) file from the user - read and set buffers in place
while (fgets(r_buf, BSIZEm1, UserFXfile) > 0) {
// the first line of a pair is the FX name; search for it in our list
for (i = 0; i < FXrefMAX; i++) {
r_len = sizeof(FXref[i]); // avoids comiler warning
if (strncmp(FXref[i], r_buf, r_len) == 0) {
// found
// the next line of a pair is the FX default parameters data string
if (fgets(r_buf, BSIZEm1, UserFXfile) > 0) {
// free a potentially already replaced set
if (FXdef_ram[i] != FXdef[i]) free(FXdef_ram[i]);
// allocate a new buffer for user default parameters set
FXdef_ram[i] = malloc(sizeof(r_buf));
strcpy(FXdef_ram[i], r_buf); // save user default parameters set
break;
}
}
}
}
}
}
// done
// hide command window
ShowWindow(GetConsoleWindow(), SW_HIDE); // Hide console window
// start man window and loop
wWinMain(hInstance, hPrevInstance, pCmdLine, nCmdFile);
//
// free memory allocated to save user parameter default sets
for (i = 0; i < FXrefMAX; i++) {
if (FXdef_ram[i] != FXdef[i]) free(FXdef_ram[i]);
}
free(FXref_ram);
free(FXdef_ram);
return(0);
}