Skip to content

Commit

Permalink
SysEx extraction from w2b
Browse files Browse the repository at this point in the history
  • Loading branch information
BobanSpasic committed Nov 23, 2023
1 parent 6befc8a commit 7b47d30
Show file tree
Hide file tree
Showing 9 changed files with 249 additions and 114 deletions.
226 changes: 116 additions & 110 deletions MDX_PerfConv.lps

Large diffs are not rendered by default.

Binary file modified MDX_PerfConv.res
Binary file not shown.
Binary file added Test_files/PLG150-DX/NOSEBLEE.W2B
Binary file not shown.
Binary file added Test_files/TX802_Collections/fmori/perf_1-64.syx
Binary file not shown.
Binary file added Test_files/TX802_Collections/fmori/voice_1-32.syx
Binary file not shown.
Binary file not shown.
19 changes: 17 additions & 2 deletions units/untDXUtils.pas
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ TDXSysExUniversalDump = record
end;

type
MEMS6 = (VMEM, AMEM, PMEM, LMPMEM, PMEM802);
// D=double, T=triple, Q=quadruple
MEMS6 = (VMEM, AMEM, PMEM, LMPMEM, PMEM802, D_VMEM, D_AMEM, T_VMEM, T_AMEM, Q_VMEM, Q_AMEM);
CEDS6 = (VCED, ACED, PCED);

type
Expand Down Expand Up @@ -326,9 +327,19 @@ function ContainsDX_SixOP_MemSet(dmp: TMemoryStream): MemSet;
if rHeader.f = $02 then
Result := Result + [PMEM];
if rHeader.f = $06 then
begin
if T_AMEM in Result then Result := Result + [Q_AMEM];
if D_AMEM in Result then Result := Result + [T_AMEM];
if AMEM in Result then Result := Result + [D_AMEM];
Result := Result + [AMEM];
end;
if rHeader.f = $09 then
begin
if T_VMEM in Result then Result := Result + [Q_VMEM];
if D_VMEM in Result then Result := Result + [T_VMEM];
if VMEM in Result then Result := Result + [D_VMEM];
Result := Result + [VMEM];
end;
if rHeader.f = $7E then
begin
if (dmp.Position + 10) <= dmp.Size then
Expand All @@ -349,11 +360,15 @@ function ContainsDX_SixOP_MemSet(dmp: TMemoryStream): MemSet;
if iDumpEnd = -1 then iDumpEnd := dmp.Size;
iRep := iDumpEnd + 1;
end
else
if iDumpStart > -1 then iRep := iDumpStart + 1
else
Inc(iRep);
//exit;
end;
end;
end
else
Inc(iRep);
end;
end;

Expand Down
107 changes: 106 additions & 1 deletion untConverter.pas
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ interface
untMDXSupplement, untDX7IIPerformance, untDX7IIPerformanceBank,
untDXUtils, untParConst, Math, untUtils, untTX802Performance, untTX802PerformanceBank, IniFiles;

procedure ConvertTX7toMDX(var ms: TMemoryStream; APath: string; ANumber: integer; AVerbose: boolean); // VMEM + PMEM 1-32
procedure ConvertTX7toMDX(var ms: TMemoryStream; APath: string; ANumber: integer; AVerbose: boolean); // VMEM + PMEM 1-32
procedure ConvertDX7IItoMDX(var ms: TMemoryStream; APath: string; ANumber: integer; AVerbose: boolean; ASettings: string); // VMEM + AMEM 1-32
procedure ConvertMultiDX7IItoMDX(var ms: TMemoryStream; APath: string; ANumber: integer; AVerbose: boolean; ASettings: string); // multiple VMEM + AMEM 1-32
procedure ConvertDX5toMDX(var ms: TMemoryStream; APath: string; ANumber: integer; AVerbose: boolean); // 4xVMEM, PMEM
procedure ConvertTX802ToMDX(var ms: TMemoryStream; APath: string; ANumber: integer; AVerbose: boolean; ASettings: string); // 4xVMEM, 4xAMEM, 2xPMEM
procedure ConvertBigDX7IItoMDX(var ms: TMemoryStream; APath: string; ANumber: integer; AVerbose: boolean; ASettings: string); // 2xVMEM, 2xAMEM, 1xPMEM
Expand Down Expand Up @@ -599,6 +600,110 @@ procedure ConvertDX7IItoMDX(var ms: TMemoryStream; APath: string; ANumber: integ
MDX.Free;
end;

procedure ConvertMultiDX7IItoMDX(var ms: TMemoryStream; APath: string; ANumber: integer; AVerbose: boolean; ASettings: string);
var
DX7: TDX7BankContainer;
DX7II: TDX7IISupplBankContainer;
MDX: TMDXPerformanceContainer;

DX7_VCED: TDX7VoiceContainer;
DX7II_ACED: TDX7IISupplementContainer;
MDX_TG: TMDXSupplementContainer;

msSearchPositionV: integer;
msFoundPositionV: integer;
msSearchPositionA: integer;
msFoundPositionA: integer;

i, j: integer;
sName: string;
bank_counter: integer;

perg, ams1, ams2, ams3, ams4, ams5, ams6: byte;
AMS_table: TAMS;
PEGR_table: TPEGR;
begin
msSearchPositionV := 0;
msFoundPositionV := 0;
msSearchPositionA := 0;
msFoundPositionA := 0;
bank_counter := 0;

while FindDX_SixOP_MEM(VMEM, ms, msSearchPositionV, msFoundPositionV) do
begin

DX7 := TDX7BankContainer.Create;
DX7II := TDX7IISupplBankContainer.Create;
MDX := TMDXPerformanceContainer.Create;
if FindDX_SixOP_MEM(VMEM, ms, msSearchPositionV, msFoundPositionV) then
begin
DX7.LoadBankFromStream(ms, msFoundPositionV);
WriteLn('VMEM loaded from ' + IntToStr(msFoundPositionV));
if AVerbose then
for i := 1 to 32 do
WriteLn(DX7.GetVoiceName(i));
end;
msSearchPositionV := msFoundPositionV;

if FindDX_SixOP_MEM(AMEM, ms, msSearchPositionA, msFoundPositionA) then
begin
DX7II.LoadSupplBankFromStream(ms, msFoundPositionA);
WriteLn('AMEM loaded from ' + IntToStr(msFoundPositionA));
end;
msSearchPositionA := msFoundPositionA;

for i := 0 to 3 do
begin
MDX.InitPerformance;
MDX.AllMIDIChToZero;
MDX.FMDX_Params.General.Name :=
'Voices ' + IntToStr(i * 8) + ' to ' + IntToStr((i + 1) * 8 - 1);
MDX.FMDX_Params.General.Category := 'Converted';
MDX.FMDX_Params.General.Origin := 'Conversion from DX7II Voices';

sName := Format('%.6d', [i + ANumber + bank_counter + 1]) + '_' +
Trim(ExtractFileNameWithoutExt(ExtractFileName(APath)));
sName := copy(sName, 1, 19) + '_' + IntToStr(i + bank_counter);

for j := 1 to 8 do
begin
DX7_VCED := TDX7VoiceContainer.Create;
DX7II_ACED := TDX7IISupplementContainer.Create;
MDX_TG := TMDXSupplementContainer.Create;

DX7.GetVoice(i * 8 + j, DX7_VCED);
DX7II.GetSupplement(i * 8 + j, DX7II_ACED);
perg := DX7II_ACED.Get_ACED_Params.Pitch_EG_Range;
ams1 := DX7II_ACED.Get_ACED_Params.OP1_AM_Sensitivity;
ams2 := DX7II_ACED.Get_ACED_Params.OP2_AM_Sensitivity;
ams3 := DX7II_ACED.Get_ACED_Params.OP3_AM_Sensitivity;
ams4 := DX7II_ACED.Get_ACED_Params.OP4_AM_Sensitivity;
ams5 := DX7II_ACED.Get_ACED_Params.OP5_AM_Sensitivity;
ams6 := DX7II_ACED.Get_ACED_Params.OP6_AM_Sensitivity;
if GetSettingsFromFile(ASettings, AMS_table, PEGR_table) = True then
DX7_VCED.Mk2ToMk1(perg, ams1, ams2, ams3, ams4, ams5, ams6, AMS_table, PEGR_table)
else
DX7_VCED.Mk2ToMk1(perg, ams1, ams2, ams3, ams4, ams5, ams6);
MDX.LoadVoiceToTG(j, DX7_VCED.Get_VCED_Params);
MDX_TG.Set_PCEDx_Params(LoadDX7IIACEDtoPCEDx(DX7II_ACED));
MDX.LoadPCEDxToTG(j, MDX_TG.Get_PCEDx_Params);
MDX.FMDX_Params.TG[j].MIDIChannel := j;
MDX.SavePerformanceToFile(IncludeTrailingPathDelimiter(APath) +
sName + '.ini', False);

DX7_VCED.Free;
DX7II_ACED.Free;
MDX_TG.Free;
end;
end;
inc(bank_counter, 4);

DX7.Free;
DX7II.Free;
MDX.Free;
end;
end;

procedure ConvertDX5toMDX(var ms: TMemoryStream; APath: string; ANumber: integer; AVerbose: boolean);
var
DXA1: TDX7BankContainer;
Expand Down
11 changes: 10 additions & 1 deletion untDispatcher.pas
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ procedure DispatchCheck(ABank: string; ANumber: integer; AVerbose: boolean; AOut
msBank.LoadFromFile(ABank);
ms := ContainsDX_SixOP_MemSet(msBank);

if (VMEM in ms) and (AMEM in ms) and not ((PMEM in ms) or (LMPMEM in ms)) then
if (VMEM in ms) and (AMEM in ms) and not ((PMEM in ms) or (LMPMEM in ms) or (D_VMEM in ms) or (D_AMEM in ms)) then
begin
if msBank.Size >= 5232 then
begin
Expand All @@ -44,6 +44,15 @@ procedure DispatchCheck(ABank: string; ANumber: integer; AVerbose: boolean; AOut
ConvertDX7IItoMDX(msBank, AOutput, ANumber, AVerbose, ASettings);
end;
end;
if (VMEM in ms) and (AMEM in ms) and (D_VMEM in ms) and (D_AMEM in ms) and not ((PMEM in ms) or (LMPMEM in ms)) then
begin
if msBank.Size >= 5232 then
begin
WriteLn('It is a multiple DX7II bank with supplement');
if AVerbose then WriteLn('Using ConvertMultiDX7IItoMDX with one stream');
ConvertMultiDX7IItoMDX(msBank, AOutput, ANumber, AVerbose, ASettings);
end;
end;
if (VMEM in ms) and (PMEM in ms) and not ((AMEM in ms) or (LMPMEM in ms)) then
begin
if msBank.Size >= 8192 then
Expand Down

0 comments on commit 7b47d30

Please sign in to comment.