Skip to content

Commit bec13a5

Browse files
authored
Initial commit
1 parent a7f86c4 commit bec13a5

File tree

4 files changed

+1443
-0
lines changed

4 files changed

+1443
-0
lines changed

MDX_Tool.lpi

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<CONFIG>
3+
<ProjectOptions>
4+
<Version Value="12"/>
5+
<PathDelim Value="\"/>
6+
<General>
7+
<Flags>
8+
<MainUnitHasCreateFormStatements Value="False"/>
9+
<MainUnitHasTitleStatement Value="False"/>
10+
<MainUnitHasScaledStatement Value="False"/>
11+
</Flags>
12+
<SessionStorage Value="InProjectDir"/>
13+
<Title Value="MDX_Tool"/>
14+
<UseAppBundle Value="False"/>
15+
<ResourceType Value="res"/>
16+
</General>
17+
<BuildModes>
18+
<Item Name="Default" Default="True"/>
19+
<Item Name="Debug">
20+
<CompilerOptions>
21+
<Version Value="11"/>
22+
<PathDelim Value="\"/>
23+
<Target>
24+
<Filename Value="MDX_Tool"/>
25+
</Target>
26+
<SearchPaths>
27+
<IncludeFiles Value="$(ProjOutDir)"/>
28+
<OtherUnitFiles Value="units"/>
29+
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
30+
</SearchPaths>
31+
<Parsing>
32+
<SyntaxOptions>
33+
<IncludeAssertionCode Value="True"/>
34+
</SyntaxOptions>
35+
</Parsing>
36+
<CodeGeneration>
37+
<Checks>
38+
<IOChecks Value="True"/>
39+
<RangeChecks Value="True"/>
40+
<OverflowChecks Value="True"/>
41+
<StackChecks Value="True"/>
42+
</Checks>
43+
<VerifyObjMethodCallValidity Value="True"/>
44+
</CodeGeneration>
45+
<Linking>
46+
<Debugging>
47+
<DebugInfoType Value="dsDwarf3"/>
48+
<UseHeaptrc Value="True"/>
49+
<TrashVariables Value="True"/>
50+
<UseExternalDbgSyms Value="True"/>
51+
</Debugging>
52+
</Linking>
53+
</CompilerOptions>
54+
</Item>
55+
<Item Name="Release Win x64">
56+
<CompilerOptions>
57+
<Version Value="11"/>
58+
<PathDelim Value="\"/>
59+
<Target>
60+
<Filename Value="bin\Win_x64\MDX_Tool.exe"/>
61+
</Target>
62+
<SearchPaths>
63+
<IncludeFiles Value="$(ProjOutDir)"/>
64+
<OtherUnitFiles Value="units"/>
65+
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
66+
</SearchPaths>
67+
<CodeGeneration>
68+
<SmartLinkUnit Value="True"/>
69+
<TargetCPU Value="x86_64"/>
70+
<TargetOS Value="win64"/>
71+
<Optimizations>
72+
<OptimizationLevel Value="3"/>
73+
</Optimizations>
74+
</CodeGeneration>
75+
<Linking>
76+
<Debugging>
77+
<GenerateDebugInfo Value="False"/>
78+
<DebugInfoType Value="dsDwarf2Set"/>
79+
</Debugging>
80+
<LinkSmart Value="True"/>
81+
</Linking>
82+
</CompilerOptions>
83+
</Item>
84+
<Item Name="Release Linux x64">
85+
<CompilerOptions>
86+
<Version Value="11"/>
87+
<PathDelim Value="\"/>
88+
<Target>
89+
<Filename Value="bin\Linux_x64\MDX_Tool"/>
90+
</Target>
91+
<SearchPaths>
92+
<IncludeFiles Value="$(ProjOutDir)"/>
93+
<OtherUnitFiles Value="units"/>
94+
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
95+
</SearchPaths>
96+
<CodeGeneration>
97+
<SmartLinkUnit Value="True"/>
98+
<TargetCPU Value="x86_64"/>
99+
<TargetOS Value="linux"/>
100+
<Optimizations>
101+
<OptimizationLevel Value="3"/>
102+
</Optimizations>
103+
</CodeGeneration>
104+
<Linking>
105+
<Debugging>
106+
<GenerateDebugInfo Value="False"/>
107+
<DebugInfoType Value="dsDwarf2Set"/>
108+
</Debugging>
109+
<LinkSmart Value="True"/>
110+
</Linking>
111+
</CompilerOptions>
112+
</Item>
113+
<Item Name="Release FreeBSD x64">
114+
<CompilerOptions>
115+
<Version Value="11"/>
116+
<PathDelim Value="\"/>
117+
<Target>
118+
<Filename Value="bin\FreeBSD_x64\MDX_Tool"/>
119+
</Target>
120+
<SearchPaths>
121+
<IncludeFiles Value="$(ProjOutDir)"/>
122+
<OtherUnitFiles Value="units"/>
123+
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
124+
</SearchPaths>
125+
<CodeGeneration>
126+
<SmartLinkUnit Value="True"/>
127+
<TargetCPU Value="x86_64"/>
128+
<TargetOS Value="freebsd"/>
129+
<Optimizations>
130+
<OptimizationLevel Value="3"/>
131+
</Optimizations>
132+
</CodeGeneration>
133+
<Linking>
134+
<Debugging>
135+
<GenerateDebugInfo Value="False"/>
136+
<DebugInfoType Value="dsDwarf2Set"/>
137+
</Debugging>
138+
<LinkSmart Value="True"/>
139+
</Linking>
140+
</CompilerOptions>
141+
</Item>
142+
</BuildModes>
143+
<PublishOptions>
144+
<Version Value="2"/>
145+
<UseFileFilters Value="True"/>
146+
</PublishOptions>
147+
<RunParams>
148+
<FormatVersion Value="2"/>
149+
</RunParams>
150+
<Units>
151+
<Unit>
152+
<Filename Value="MDX_Tool.lpr"/>
153+
<IsPartOfProject Value="True"/>
154+
</Unit>
155+
</Units>
156+
</ProjectOptions>
157+
<CompilerOptions>
158+
<Version Value="11"/>
159+
<PathDelim Value="\"/>
160+
<Target>
161+
<Filename Value="MDX_Tool"/>
162+
</Target>
163+
<SearchPaths>
164+
<IncludeFiles Value="$(ProjOutDir)"/>
165+
<OtherUnitFiles Value="units"/>
166+
<UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
167+
</SearchPaths>
168+
<Linking>
169+
<Debugging>
170+
<DebugInfoType Value="dsDwarf2Set"/>
171+
</Debugging>
172+
</Linking>
173+
</CompilerOptions>
174+
<Debugging>
175+
<Exceptions>
176+
<Item>
177+
<Name Value="EAbort"/>
178+
</Item>
179+
<Item>
180+
<Name Value="ECodetoolError"/>
181+
</Item>
182+
<Item>
183+
<Name Value="EFOpenError"/>
184+
</Item>
185+
</Exceptions>
186+
</Debugging>
187+
</CONFIG>

MDX_Tool.lpr

+175
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
program MDX_Tool;
2+
3+
{$mode objfpc}{$H+}
4+
5+
uses
6+
{$IFDEF UNIX}
7+
cthreads,
8+
{$ENDIF}
9+
Classes,
10+
SysUtils,
11+
CustApp,
12+
untDXUtils;
13+
14+
type
15+
16+
{ TMDX_Tool }
17+
18+
TMDX_Tool = class(TCustomApplication)
19+
protected
20+
procedure DoRun; override;
21+
public
22+
constructor Create(TheOwner: TComponent); override;
23+
destructor Destroy; override;
24+
procedure WriteHelp; virtual;
25+
end;
26+
27+
{ TMDX_Tool }
28+
29+
procedure TMDX_Tool.DoRun;
30+
var
31+
ErrorMsg: string;
32+
fInput: string;
33+
fOutput: string;
34+
slReport: TStringList;
35+
msInputFile: TMemoryStream;
36+
i: integer;
37+
iStartPos: integer;
38+
begin
39+
fInput := '';
40+
fOutput:= '';
41+
// quick check parameters
42+
ErrorMsg := CheckOptions('hirf:o:', 'help info repair file: output:');
43+
44+
if ErrorMsg <> '' then
45+
begin
46+
WriteHelp;
47+
ShowException(Exception.Create(ErrorMsg));
48+
Terminate;
49+
Exit;
50+
end;
51+
52+
if (ParamCount = 0) or HasOption('h', 'help') then
53+
begin
54+
WriteHelp;
55+
Terminate;
56+
Exit;
57+
end;
58+
59+
if HasOption('f', 'file') then
60+
fInput := GetOptionValue('f', 'file');
61+
if HasOption('o', 'output') then
62+
fOutput := GetOptionValue('o', 'output');
63+
64+
if HasOption('r', 'repair') then
65+
begin
66+
if not FileExists(fInput) then
67+
begin
68+
WriteLn('Parameter -f {filename} is missing or the file {file_name} could not be found');
69+
Terminate;
70+
Exit;
71+
end;
72+
73+
if fOutput <> '' then
74+
begin
75+
slReport := TStringList.Create;
76+
msInputFile := TMemoryStream.Create;
77+
msInputFile.LoadFromFile(fInput);
78+
iStartPos := 0;
79+
80+
if ContainsDX_SixOP_Data(msInputFile, iStartPos, slReport) then
81+
begin
82+
83+
end
84+
else
85+
if RepairDX7SysEx(fInput, fOutput, slReport) then
86+
begin
87+
88+
end;
89+
90+
for i := 0 to slReport.Count - 1 do
91+
WriteLn(slReport[i]);
92+
93+
msInputFile.Free;
94+
slReport.Free;
95+
end
96+
else
97+
begin
98+
WriteLn('Parameter -o {filename} is missing');
99+
Terminate;
100+
Exit;
101+
end;
102+
end;
103+
104+
if HasOption('i', 'info') then
105+
begin
106+
if not FileExists(fInput) then
107+
begin
108+
WriteLn('Parameter -f {filename} is missing or the file {file_name} could not be found');
109+
Exit;
110+
end
111+
else
112+
begin
113+
slReport := TStringList.Create;
114+
msInputFile := TMemoryStream.Create;
115+
msInputFile.LoadFromFile(fInput);
116+
iStartPos := 0;
117+
118+
if ContainsDX_SixOP_Data(msInputFile, iStartPos, slReport) then
119+
begin
120+
121+
end;
122+
123+
for i := 0 to slReport.Count - 1 do
124+
WriteLn(slReport[i]);
125+
126+
msInputFile.Free;
127+
slReport.Free;
128+
end;
129+
end;
130+
131+
Terminate;
132+
end;
133+
134+
constructor TMDX_Tool.Create(TheOwner: TComponent);
135+
begin
136+
inherited Create(TheOwner);
137+
StopOnException := True;
138+
end;
139+
140+
destructor TMDX_Tool.Destroy;
141+
begin
142+
inherited Destroy;
143+
end;
144+
145+
procedure TMDX_Tool.WriteHelp;
146+
begin
147+
writeln('');
148+
writeln('');
149+
writeln('MDX_Tool 0.9 (beta) - tool for getting info from Yamaha DX SysEx files');
150+
writeln('Author: Boban Spasic');
151+
writeln('');
152+
writeln('Usage: ', ExtractFileName(ExeName), ' -parameters');
153+
writeln(' Parameters (short and long form):');
154+
writeln(' -h --help This help message');
155+
writeln(' -i --info Information');
156+
writeln(' -r --repair Repair');
157+
// writeln(' -d --dx7 output DX7 mark I files');
158+
// writeln(' (DX7II and TX data will be removed)');
159+
writeln(' -f {filename} --file={filename} Input file');
160+
writeln(' -o {filename} --output={filename} Output file');
161+
WriteLn('');
162+
writeln(' Example usage:');
163+
writeln(' MDX_Tool -i -f my_dx_file.syx');
164+
writeln(' MDX_Tool -r -f my_dx_file.syx -o my_repaired_file.syx');
165+
writeln(' MDX_Tool --info --file=my_dx_file.syx');
166+
end;
167+
168+
var
169+
Application: TMDX_Tool;
170+
begin
171+
Application := TMDX_Tool.Create(nil);
172+
Application.Title := 'MDX_Tool';
173+
Application.Run;
174+
Application.Free;
175+
end.

0 commit comments

Comments
 (0)