Skip to content

Commit

Permalink
Add OPL to WOPL conversion code to WoplFile
Browse files Browse the repository at this point in the history
  • Loading branch information
csinkers committed Apr 12, 2020
1 parent 586d920 commit 3223432
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/WoplFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,40 @@ public static WoplFile Serdes(WoplFile w, ISerializer s)
public ushort Version { get; set; } = 3;
public GlobalBankFlags GlobalFlags { get; set; }
public VolumeModel VolumeModel { get; set; }

public WoplFile() { }
public WoplFile(GlobalTimbreLibrary timbreLibrary)
{
Version = 3;
GlobalFlags = GlobalBankFlags.DeepTremolo | GlobalBankFlags.DeepVibrato;
VolumeModel = VolumeModel.Auto;

Melodic.Add(new WoplBank { Id = 0, Name = "" });
Percussion.Add(new WoplBank { Id = 0, Name = "" });

for(int i = 0; i < timbreLibrary.Data.Count; i++)
{
var timbre = timbreLibrary.Data[i];
WoplInstrument x =
i < 128
? Melodic[0].Instruments[i] ?? new WoplInstrument()
: Percussion[0].Instruments[i - 128 + 35] ?? new WoplInstrument();

x.Name = "";
x.NoteOffset1 = timbre.MidiPatchNumber;
x.NoteOffset2 = timbre.MidiBankNumber;
x.InstrumentMode = InstrumentMode.TwoOperator;
x.FbConn1C0 = timbre.FeedbackConnection;
x.Operator0 = timbre.Carrier;
x.Operator1 = timbre.Modulation;
x.Operator2 = Operator.Blank;
x.Operator3 = Operator.Blank;

if (i < 128)
Melodic[0].Instruments[i] = x;
else
Percussion[0].Instruments[i - 128 + 35] = x;
}
}
}
}

0 comments on commit 3223432

Please sign in to comment.