Пример #1
0
 static byte[] GetRawWoplBytes(WoplFile wopl)
 {
     using var ms = new MemoryStream();
     using var bw = new BinaryWriter(ms);
     WoplFile.Serdes(wopl, new GenericBinaryWriter(bw, Encoding.ASCII.GetBytes, ApiUtil.Assert));
     return(ms.ToArray());
 }
Пример #2
0
    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));
    }
Пример #3
0
 static void WriteWopl(WoplFile wopl, string filename)
 {
     using var ms = new MemoryStream();
     using var bw = new BinaryWriter(ms);
     WoplFile.Serdes(wopl, new GenericBinaryWriter(bw, Encoding.ASCII.GetBytes, Console.WriteLine));
     byte[] bytes = ms.ToArray();
     File.WriteAllBytes(filename, bytes);
 }
Пример #4
0
        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);
        }
Пример #5
0
        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);
        }
Пример #6
0
        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());
        }
Пример #7
0
 static WoplFile ReadWopl(string filename)
 {
     using var stream2 = File.OpenRead(filename);
     using var br      = new BinaryReader(stream2);
     return(WoplFile.Serdes(null, new GenericBinaryReader(br, br.BaseStream.Length, Encoding.ASCII.GetString, Console.WriteLine)));
 }