-
Notifications
You must be signed in to change notification settings - Fork 12
/
5F_MIB2_Dataset_0x003900.BIN.bt
284 lines (244 loc) · 7.95 KB
/
5F_MIB2_Dataset_0x003900.BIN.bt
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
//------------------------------------------------
//--- 010 Editor v13.0 Binary Template
//
// File: 0x003900.BIN
// Authors: Alex Strelets
// Version: 0.1
// Purpose: Parse the contents of the MIB2 Sound Channels and Effects.
// Category:
// File Mask:
// ID Bytes:
// History: 0.1 - Initial version
//------------------------------------------------
BigEndian();
string getSignalflow(int type) {
switch (type) {
case 0x10: return "2ch (4.0)";
case 0x20: return "4ch (8.0)";
case 0x21: return "4ch / 2ch compatible (8.0 / 4.0)";
case 0x25: return "5ch center (9.0)";
case 0x30: return "6ch center sub (9.1)";
case 0x31: return "6ch center sub / 2/4ch compatible (9.1 / 8.0 / 4.0)";
case 0x32: return "6ch doublesub (8.2)";
case 0x33: return "6ch doublesub / 2/4ch compatible (8.2 / 8.0 / 4.0)";
case 0x34: return "6ch frontwoofer (9.1)";
case 0x35: return "6ch frontwoofer / 2/4ch compatible (9.1 / 8.0 / 4.0)";
default: return "Unknown";
}
}
string getFilterType(int type) {
switch (type) {
case 0x00: return "Bypass";
case 0x01: return "Shelf 1 High";
case 0x02: return "Shelf 2 High";
case 0x03: return "Shelf 1 Low";
case 0x04: return "Shelf 2 Low";
case 0x05: return "Peak 1";
case 0x06: return "Peak 2";
case 0x07: return "Highpass 1";
case 0x08: return "Highpass 2";
case 0x09: return "Lowpass 1";
case 0x0A: return "Lowpass 2";
case 0x10: return "Coefficients";
default: return "Unknown";
}
}
typedef struct {
ubyte type <bgcolor=cAqua, read=getFilterType>;
ubyte quality <bgcolor=cLtGreen>; // [0.2 .. 5]
ushort frequency <bgcolor=cGreen>; // [20 .. 20000]
ubyte gainOffset <bgcolor=cDkAqua>; // [-6 .. +6]
ubyte maxGain <bgcolor=cDkAqua>; // [0 .. 15]
} EQ;
typedef struct {
ubyte type <bgcolor=cAqua, read=getFilterType>;
ubyte quality <bgcolor=cLtGreen>;
ushort frequency <bgcolor=cGreen>;
ubyte gain[19] <bgcolor=cDkAqua>;
} EQ2;
typedef struct {
ubyte type <bgcolor=cAqua, read=getFilterType>;
ubyte quality <bgcolor=cLtGreen>;
ushort frequency <bgcolor=cGreen>;
byte gain <bgcolor=cDkAqua>; // [-12.5 .. 12.5]
} EQ3;
typedef struct {
EQ3 Filter1;
EQ3 Filter2;
EQ3 Filter3;
EQ3 Filter4;
EQ3 Filter5;
EQ3 Filter6;
EQ3 Filter7;
byte Gain <bgcolor=cLtYellow>;
ubyte Delay <bgcolor=cYellow>;
ubyte Phase <bgcolor=cDkYellow>;
} CarEQ;
float calcQuality (ubyte value) {
return (float) value / 10;
}
float calcGain (byte value) {
return (float) value / 12.5;
}
float calcAbsGain (ubyte value) {
return (float) value / 12.5;
}
float calcMaxGain (ubyte value) {
return (float) value / 15;
}
void printEQ2(EQ2 &s, string name, int unknownFlag) {
Printf("\n%s", name);
Printf("\nType \tQ Factor\tFrequency\n");
Printf("==================================\n");
Printf("%-13s%7.1f\t %6gHz\n",
getFilterType(s.type),
calcQuality(s.quality),
s.frequency);
Printf("==================================\n");
if (!unknownFlag) {
Printf("Volume: \t");
for (i = 0; i < 19; i++) {
Printf("%5g ", 18 - i);
}
Printf("\n");
}
Printf("Gain: \t");
for (i = 0; i < 19; i++) {
Printf("%5.2f ", calcAbsGain(s.gain[i]));
}
Printf("\n");
}
local string spacer = "\t\t\t";
void printEQFilter(EQ3 &filter, int index) {
local string str = (index > 1 ? "\n" : spacer);
Printf("%-13s %5.1f\t %6gHz\t %5.2f %s",
getFilterType(filter.type),
calcQuality(filter.quality),
filter.frequency,
calcGain(filter.gain),
str);
}
void printProfileName (int index) {
Printf("[ CarEQ SoundProfile #%i ] %s", index, index > 1 ? "\n\n": spacer);
}
string getChannelName(int index) {
switch (index) {
case 0: return "REAR_R_CH "; break;
case 1: return "FRONT_R_CH"; break;
case 2: return "FRONT_L_CH"; break;
case 3: return "REAR_L_CH "; break;
case 4: return "SUBWOOFER "; break;
case 5: return "CENTER_CH "; break;
}
return Str("CHANNEL_%i ", index+1);
}
string getEQBand(int index) {
switch (index) {
case 0: return "Bass"; break;
case 1: return "MidBass "; break;
case 2: return "Middle"; break;
case 3: return "MidTreble"; break;
case 4: return "Treble"; break;
}
return Str("Band_%i ", index+1);
}
void printChannelHeader(CarEQ eq[], int index, int profileIndex) {
local string str = (profileIndex > 1 ? "\n" : spacer);
Printf("%s [ Gain: %-6.2f Delay: %-2gms Phase: %s ]%s",
getChannelName(index),
calcGain(eq[index].Gain),
(float) eq[index].Delay,
(char) eq[index].Phase > 0 ? 'R' : '0',
str);
}
void printLines() {
local string str = "------------------------------------------------%s";
Printf(str, spacer);
Printf(str, "\n");
}
void printDoubleLines() {
local string str = "================================================%s";
Printf(str, spacer);
Printf(str, "\n");
}
void printFiltersHeader() {
local string str = "Type \tQ Factor\t Frequency\t Gain %s";
Printf(str, spacer);
Printf(str, "\n");
}
byte Signalflow <bgcolor=cDkGreen, read=getSignalflow>;
CarEQ Profile_1[6] <optimize=true>;
CarEQ Profile_2[6] <optimize=true>;
FSeek(FileSize() - 4 - 0x1e - 6);
// one of those bytes could be "Limiter THDmax" [0 .. 30]
struct {
byte unknown[5] <bgcolor=cPurple>;
byte THDmax <bgcolor=cBlue>;
} Limiters; // Warmth ??? potentially
struct {
ubyte attackTime <bgcolor=cDkGreen>;
ushort releaseTime <bgcolor=cGreen>;
ubyte threshold <bgcolor=cLtGreen>;
ubyte holdTime <bgcolor=cAqua>;
} DRC[6];
struct {
char major <bgcolor=cDkBlue>;
char minor <bgcolor=cDkBlue>;
} DatasetVersion;
ushort checksum <bgcolor=cDkRed>;
////////////////////////
/// PARSING FINISHED ///
////////////////////////
Printf("\nSIGNAL FLOW: %s\n", getSignalflow(Signalflow));
Printf("\n\n");
local int i = 0;
local int j = 0;
local int k = 0;
printProfileName(1);
printProfileName(2);
for (i = 0; i < 6; i++) {
printChannelHeader(Profile_1, i, 1);
printChannelHeader(Profile_2, i, 2);
printLines();
printFiltersHeader();
printDoubleLines();
printEQFilter(Profile_1[i].Filter1, 1);
printEQFilter(Profile_2[i].Filter1, 2);
printEQFilter(Profile_1[i].Filter2, 1);
printEQFilter(Profile_2[i].Filter2, 2);
printEQFilter(Profile_1[i].Filter3, 1);
printEQFilter(Profile_2[i].Filter3, 2);
printEQFilter(Profile_1[i].Filter4, 1);
printEQFilter(Profile_2[i].Filter4, 2);
printEQFilter(Profile_1[i].Filter5, 1);
printEQFilter(Profile_2[i].Filter5, 2);
printEQFilter(Profile_1[i].Filter6, 1);
printEQFilter(Profile_2[i].Filter6, 2);
printEQFilter(Profile_1[i].Filter7, 1);
printEQFilter(Profile_2[i].Filter7, 2);
printDoubleLines();
Printf("\n");
}
Printf("LIMITERS\n");
Printf("\t\t THD\n");
Printf("---------------------------------------\n");
for (i = 0; i < 5; i++) {
Printf("%3i ", Limiters.unknown[i]);
}
Printf("%3i", Limiters.THDmax);
Printf("\n\n");
Printf("DYNAMIC RANGE COMPRESSION\n");
Printf("Channel Threshold Attack Hold Release\n");
Printf("================================================\n");
for (i = 0; i < 6; i++) {
Printf("%s %5.1fdB %6.1f %6.1f %4gms\n",
getChannelName(i),
DRC[i].threshold / -20, // [-20 .. 0 ]
(float) DRC[i].attackTime / 20, // [0.5 .. 20]
(float) DRC[i].holdTime / 20, // [0.5 .. 20]
DRC[i].releaseTime // [5 .. 2000]
);
}
Printf("================================================");
local ushort file_checksum = Checksum(CHECKSUM_CRCCCITT, 0, FileSize() - 2, -1, -1); // algo, size, length, poly, init
Printf("\n\nFILE CHECKSUM: %.04X", file_checksum);