forked from EmK530/ConMIDI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConMIDI.c
163 lines (162 loc) · 4.46 KB
/
ConMIDI.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
#include <stdio.h>
#include <windows.h>
#include <unistd.h>
#include "Essentials.h"
#include "Sound\Sound.h"
#include "MIDI\LoadMIDI.h"
#include "Playback\MIDIClock.h"
#include "Playback\MainPlayer.h"
FILE *file_ptr;
char version[] = "v2.0.9";
char *title;
int main(int argc, char *argv[])
{
if (argc > 1)
{
int mode = 0;
for (int i = 1; i < argc; i++)
{
switch (mode)
{
case 0:
{
char *read = argv[i];
if (strcmp(read, "-cp") == 0)
{
mode = 1;
}
else if (strcmp(read, "-hm") == 0 || strcmp(read, "-hidemeta") == 0)
{
for (int a = 0; a < 10; a++)
{
metaAllow[a] = FALSE;
}
}
else if (strcmp(read, "-sm") == 0 || strcmp(read, "-showmeta") == 0)
{
for (int a = 0; a < 10; a++)
{
metaAllow[a] = TRUE;
}
}
else if (strcmp(read, "-em") == 0)
{
mode = 2;
}
else if (strcmp(read, "-dm") == 0)
{
mode = 3;
}
else if (strcmp(read, "-fps") == 0)
{
showFpsOutsideLag = TRUE;
}
break;
}
case 1:
{
unsigned int b;
sscanf(argv[i], "%u", &b);
SetConsoleOutputCP(b);
mode = 0;
break;
}
case 2:
{
unsigned int b;
sscanf(argv[i], "%u", &b);
if (b > 9)
{
printf("\nCommand line error, -em parameter above 9 (set to %u)", b);
exit(0);
}
metaAllow[b] = TRUE;
mode = 0;
break;
}
case 3:
{
unsigned int b;
sscanf(argv[i], "%u", &b);
if (b > 9)
{
printf("\nCommand line error, -dm parameter above 9 (set to %u)", b);
exit(0);
}
metaAllow[b] = FALSE;
mode = 0;
break;
}
}
}
}
printf("ConMIDI %s\n\n", version);
setupntdll();
title = concat("ConMIDI ", version);
prgTitle = title;
SetConsoleTitle(prgTitle);
// Check for sound engines
Sound_Setup();
// Start sound selection if more than one sound engine is available otherwise auto load only available engine
if (usables > 1)
{
while (TRUE)
{
int id = intInput("\nPick sound device ID: ");
int test = Sound_Init(id);
if (test == 1)
{
break;
}
}
}
else
{
int i;
for (i = 0; i < 2; i++)
{
if (usable[i])
{
Sound_Init(i + 1);
break;
}
}
}
// File path input
char path[260];
char fixedPath[260];
while (TRUE)
{
printf("\nSelect a MIDI\n");
OPENFILENAME ofn;
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFilter = "MIDI Files\0*.mid\0";
ofn.lpstrFile = path;
ofn.nMaxFile = sizeof(path);
ofn.lpstrTitle = "Select a MIDI file";
ofn.Flags = OFN_DONTADDTORECENT | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
if (!GetOpenFileName(&ofn))
{
printf("No file selected.");
memset(path, 0, sizeof(path));
printf("\nEnter file path: ");
scanf("%260[^\n]", path);
fflush(stdin);
}
removeSymbol(path, '\"', fixedPath);
if (access(fixedPath, F_OK) != -1)
{
break;
}
else
{
printf("Invalid path");
memset(path, 0, sizeof(path));
}
}
unsigned int bufSize = 64;
printf("\nLoading MIDI...");
LoadMIDI(fixedPath, bufSize);
return 0;
}