public object Serdes(object existing, AssetInfo info, AssetMapping mapping, ISerializer s, IJsonUtil jsonUtil) { var oplFile = GlobalTimbreLibrary.Serdes(null, s); WoplFile wopl = new WoplFile(oplFile); return(GetRawWoplBytes(wopl)); }
static GlobalTimbreLibrary ReadOpl(string filename) { using var stream = File.OpenRead(filename); using var br = new BinaryReader(stream); return(GlobalTimbreLibrary.Serdes(null, new GenericBinaryReader(br, br.BaseStream.Length, Encoding.ASCII.GetString, Console.WriteLine))); }
public object LoadAsset(AssetKey key, string name, Func <AssetKey, object> loaderFunc) { if (key.Type != AssetType.SoundBank) { throw new InvalidOperationException($"Called SoundBankLocator with unexpected asset type {key.Type}"); } var config = (IGeneralConfig)loaderFunc(new AssetKey(AssetType.GeneralConfig)); var oplPath = Path.Combine(config.BasePath, config.ExePath, "DRIVERS", "ALBISND.OPL"); GlobalTimbreLibrary oplFile = ReadOpl(oplPath); WoplFile wopl = new WoplFile(oplFile); byte[] bankData = GetRawWoplBytes(wopl); return(bankData); }
static WoplFile OplToWopl(GlobalTimbreLibrary oplFile) { WoplFile wopl = new WoplFile { Version = 3, GlobalFlags = GlobalBankFlags.DeepTremolo | GlobalBankFlags.DeepVibrato, VolumeModel = VolumeModel.Auto }; wopl.Melodic.Add(new WoplBank { Id = 0, Name = "" }); wopl.Percussion.Add(new WoplBank { Id = 0, Name = "" }); for (int i = 0; i < oplFile.Data.Count; i++) { var timbre = oplFile.Data[i]; WoplInstrument x = i < 128 ? wopl.Melodic[0].Instruments[i] ?? new WoplInstrument() : wopl.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) { wopl.Melodic[0].Instruments[i] = x; } else { wopl.Percussion[0].Instruments[i - 128 + 35] = x; } } return(wopl); }
static void Main() { // WoplFile realWopl = ReadWopl(@"C:\Depot\bb\ualbion\albion\DRIVERS\ALBISND.wopl"); // WriteWopl(realWopl, @"C:\Depot\bb\ualbion\albion\DRIVERS\ALBISND_ROUNDTRIP.wopl"); GlobalTimbreLibrary oplFile = ReadOpl(@"C:\Depot\bb\ualbion\albion\DRIVERS\ALBISND.OPL"); WoplFile wopl = OplToWopl(oplFile); WriteWopl(wopl, newWoplPath); byte[] bankData = File.ReadAllBytes(newWoplPath); for (int i = 0; i <= 45; i++) { Console.WriteLine($"Dumping {i}"); //ExportAlbionSong(i, bankData); ExportSongEvents(i, bankData); } File.WriteAllText(@"C:\Depot\bb\ualbion\re\SongsPlayed.txt", NoteWriter.ToString()); }