Skip to content

Commit e6b505c

Browse files
committed
More parameter inspection for -i parameter
1 parent 0f9511b commit e6b505c

7 files changed

+497
-125
lines changed

MDX_Tool.lpi

+6-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<Version Value="11"/>
2222
<PathDelim Value="\"/>
2323
<Target>
24-
<Filename Value="MDX_Tool"/>
24+
<Filename Value="bin\debug\MDX_Tool"/>
2525
</Target>
2626
<SearchPaths>
2727
<IncludeFiles Value="$(ProjOutDir)"/>
@@ -148,6 +148,11 @@
148148
<RunParams>
149149
<FormatVersion Value="2"/>
150150
</RunParams>
151+
<RequiredPackages>
152+
<Item>
153+
<PackageName Value="HashLib4PascalPackage"/>
154+
</Item>
155+
</RequiredPackages>
151156
<Units>
152157
<Unit>
153158
<Filename Value="MDX_Tool.lpr"/>

MDX_Tool.lpr

+61-18
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
Third aspect (not yet implemented) will be the conversion from VMEM to VCED and vice-versa.
1313
1414
ToDo:
15-
- get voice list
1615
- conversion VMEM <> VCED
1716
- duplicate finder along a collection of files
1817
}
@@ -24,11 +23,12 @@
2423
uses
2524
{$IFDEF UNIX}
2625
cthreads,
27-
{$ENDIF}
26+
{$ENDIF}
2827
Classes,
2928
SysUtils,
3029
CustApp,
31-
untUtils, untDXUtils,
30+
untUtils,
31+
untDXUtils,
3232
untDXObjInterface;
3333

3434
type
@@ -55,10 +55,12 @@ TMDX_Tool = class(TCustomApplication)
5555
msInputFile: TMemoryStream;
5656
i: integer;
5757
iStartPos: integer;
58+
iDmpPos: integer;
5859
begin
5960
fInput := '';
6061
// quick check parameters
61-
ErrorMsg := CheckOptions('hirvcsxjf:d:', 'help info repair voices crop split xsplit join file: dir:');
62+
ErrorMsg := CheckOptions('himnrvcsxjf:d:',
63+
'help info hname vname repair voices crop split xsplit join file: dir:');
6264

6365
if ErrorMsg <> '' then
6466
begin
@@ -117,20 +119,56 @@ TMDX_Tool = class(TCustomApplication)
117119
msInputFile := TMemoryStream.Create;
118120
msInputFile.LoadFromFile(fInput);
119121
iStartPos := 0;
122+
iDmpPos := 0;
120123

121124
if ContainsDX_SixOP_Data_New(msInputFile, iStartPos, slReport) then
122125
begin
123-
126+
for i := 0 to slReport.Count - 1 do
127+
WriteLn(slReport[i]);
128+
iStartPos := 0;
129+
if ContainsDX7BankDump(msInputFile, iStartPos, iDmpPos) then
130+
if CheckIntegrity(msInputFile, iDmpPos) then
131+
WriteLn('VMEM data integrity is OK');
132+
end
133+
else
134+
begin
135+
for i := 0 to slReport.Count - 1 do
136+
WriteLn(slReport[i]);
124137
end;
125138

126-
for i := 0 to slReport.Count - 1 do
127-
WriteLn(slReport[i]);
128-
129139
msInputFile.Free;
130140
slReport.Free;
131141
end;
132142
end;
133143

144+
if HasOption('m', 'hname') then
145+
begin
146+
if not FileExists(fInput) then
147+
begin
148+
WriteLn('Parameter -f {filename} is missing or the file {filename} could not be found');
149+
Terminate;
150+
Exit;
151+
end
152+
else
153+
begin
154+
Hash2Name(fInput);
155+
end;
156+
end;
157+
158+
if HasOption('n', 'vname') then
159+
begin
160+
if not FileExists(fInput) then
161+
begin
162+
WriteLn('Parameter -f {filename} is missing or the file {filename} could not be found');
163+
Terminate;
164+
Exit;
165+
end
166+
else
167+
begin
168+
Voice2Name(fInput);
169+
end;
170+
end;
171+
134172
if HasOption('v', 'voices') then
135173
begin
136174
if not FileExists(fInput) then
@@ -192,10 +230,11 @@ TMDX_Tool = class(TCustomApplication)
192230
end
193231
else
194232
begin
195-
fOutputDir :=IncludeTrailingPathDelimiter(GetOptionValue('d', 'outdir'));
196-
if pos(':\', fOutputDir) = 0 then fOutputDir := IncludeTrailingPathDelimiter(GetCurrentDir) + fOutputDir;
233+
fOutputDir := IncludeTrailingPathDelimiter(GetOptionValue('d', 'outdir'));
234+
if pos(':\', fOutputDir) = 0 then
235+
fOutputDir := IncludeTrailingPathDelimiter(GetCurrentDir) + fOutputDir;
197236
if not DirectoryExists(fOutputDir) then
198-
ForceDirectories(fOutputDir);
237+
ForceDirectories(fOutputDir);
199238
msInputFile := TMemoryStream.Create;
200239
msInputFile.LoadFromFile(fInput);
201240

@@ -225,10 +264,11 @@ TMDX_Tool = class(TCustomApplication)
225264
end
226265
else
227266
begin
228-
fOutputDir :=IncludeTrailingPathDelimiter(GetOptionValue('d', 'outdir'));
229-
if pos(':\', fOutputDir) = 0 then fOutputDir := IncludeTrailingPathDelimiter(GetCurrentDir) + fOutputDir;
267+
fOutputDir := IncludeTrailingPathDelimiter(GetOptionValue('d', 'outdir'));
268+
if pos(':\', fOutputDir) = 0 then
269+
fOutputDir := IncludeTrailingPathDelimiter(GetCurrentDir) + fOutputDir;
230270
if not DirectoryExists(fOutputDir) then
231-
ForceDirectories(fOutputDir);
271+
ForceDirectories(fOutputDir);
232272
msInputFile := TMemoryStream.Create;
233273
msInputFile.LoadFromFile(fInput);
234274

@@ -240,10 +280,11 @@ TMDX_Tool = class(TCustomApplication)
240280
end;
241281
end;
242282

243-
if HasOption('j', 'join') then
283+
if HasOption('j', 'join') then
244284
begin
245-
fOutputDir :=IncludeTrailingPathDelimiter(GetOptionValue('d', 'dir'));
246-
if pos(':\', fOutputDir) = 0 then fOutputDir := IncludeTrailingPathDelimiter(GetCurrentDir) + fOutputDir;
285+
fOutputDir := IncludeTrailingPathDelimiter(GetOptionValue('d', 'dir'));
286+
if pos(':\', fOutputDir) = 0 then
287+
fOutputDir := IncludeTrailingPathDelimiter(GetCurrentDir) + fOutputDir;
247288
if not DirectoryExists(fOutputDir) then
248289
begin
249290
WriteLn('Parameter -d {directory} is missing or the directory could not be found');
@@ -284,14 +325,16 @@ TMDX_Tool = class(TCustomApplication)
284325
begin
285326
writeln('');
286327
writeln('');
287-
writeln('MDX_Tool 1.2 - tool for various manipulation of DX7 VMEM and VCED SysEx files');
328+
writeln('MDX_Tool 1.4 - tool for various manipulation of DX7 VMEM and VCED SysEx files');
288329
writeln('Author: Boban Spasic');
289330
writeln('https://github.com/BobanSpasic/MDX_Tool');
290331
writeln('');
291332
writeln('Usage: ', ExtractFileName(ExeName), ' -parameters');
292333
writeln(' Parameters (short and long form):');
293334
writeln(' -h --help This help message');
294335
writeln(' -i --info Information');
336+
writeln(' -n --vname Rename file to the name of the contained voice');
337+
writeln(' -m --hname Rename file to the SHA2-256 hash of the file');
295338
writeln(' -r --repair Repair/extract DX7 VMEM data from files');
296339
writeln(' -c --crop Crop headers from the VMEM/VCED files');
297340
writeln(' -s --split Split bank (VMEM) into single voices (VCED)');

0 commit comments

Comments
 (0)