コード例 #1
0
ファイル: BBPRecord.cs プロジェクト: adibsurani/Degausser
        // From a file
        public BBPRecord(string path)
        {
            FullPath = path;
            if (Path.GetExtension(path).ToLower() == ".bin")
            {
                BIN2BBP.Convert(path, out mgrItem, out bbp, out vocaloid);
            }
            else if (Path.GetExtension(path).ToLower() == ".bdx")
            {
                var bytes = File.ReadAllBytes(path);
                if (bytes.Length != 32768)
                {
                    throw new InvalidDataException($"{path} has an incorrect filesize!");
                }
                var bdx = bytes.ToStruct<BDXFormat>();
                bbp = BDX2BBP.Convert(bdx, out mgrItem);
                //mgrItem = new JbMgrFormat.JbMgrItem() { Author = bdx.contributor.ToString() };
            }
            else
            {
                var buffer = File.ReadAllBytes(path);
                mgrItem = buffer.Take(312).ToArray().ToStruct<JbMgrFormat.JbMgrItem>();
                var bytes = buffer.Skip(312).ToArray();
                var nums = Enumerable.Range(0, 17).Select(i => BitConverter.ToInt32(bytes, i * 4)).ToList();

                var unc1 = Decompress(bytes, nums[3], nums[4]);
                bbp = unc1.ToStruct<BBPFormat>();
                if (nums[5] == 1) vocaloid = Decompress(bytes, nums[7], nums[8]);
            }
        }
コード例 #2
0
ファイル: BDX2BBP.cs プロジェクト: adibsurani/Degausser
        BDX2BBP(BDXFormat bdx)
        {
            this.bdx = bdx;
            bbp = new byte[Marshal.SizeOf<BBPFormat>()].ToStruct<BBPFormat>();
            DoCommonStuff();
            DoChannelStuff();
            var instrTypes = bbp.channelInfo.Select(c => c.playType);
            var hasPiano = instrTypes.Contains(PlayType.Piano);
            var hasGuitar = instrTypes.Contains(PlayType.Guitar);
            var hasDrum = instrTypes.Contains(PlayType.Drum);

            if (hasPiano && hasGuitar) throw new Exception("Not expecting both to exist!!!");

            if (hasPiano)
            {
                DoPianoStuff();
            }
            else if (hasGuitar)
            {
                DoGuitarStuff();
            }
            DoKaraokeStuff();
            // DoMetadataStuff() // mainly Author

            // metadata stuff temporarily here
            mgr = JbMgrFormat.JbMgrItem.Empty;
            //mgr.Author = bdx.contributor.ToString();
            mgr.Author = "Degausser2.2a";
            mgr.Title = bbp.title.ArrayToString();
            mgr.TitleSimple = mgr.Title;
            //mgr.Flags
            mgr.ID = 0x80000001;
            mgr.Flags = new JbMgrFormat.JbMgrItem.JbFlags
            {
                HasDrum = hasDrum,
                HasGuitar = hasGuitar,
                HasPiano = hasPiano,
                HasLyrics = bdx.hasKaraoke != 0,
                HasMelody = bdx.mainInstrument != 0xFF, // not sure about this
                IsValid = true,
                OnSD = true,
                Parts = bdx.channelInfo.Count(c => c.instrument != 0)
            };
        }
コード例 #3
0
ファイル: BBPRecord.cs プロジェクト: adibsurani/Degausser
        public byte[] vocaloid; // uncompressed

        // From known item and packpath
        public BBPRecord(JbMgrFormat.JbMgrItem item, string path, int slot)
        {
            Slot = slot;
            FullPath = path;
            mgrItem = item;
            if (item.Flags.OnSD)
            {
                var buffer = File.ReadAllBytes(path);
                var bytes = buffer;
                var nums = Enumerable.Range(0, 17).Select(i => BitConverter.ToInt32(bytes, i * 4)).ToList();

                var unc1 = Decompress(bytes, nums[3], nums[4]);
                bbp = unc1.ToStruct<BBPFormat>();
                if (nums[5] == 1) vocaloid = Decompress(bytes, nums[7], nums[8]);
            }
            else
            {
                bbp = new BBPFormat
                {
                    title = item.Title.StringToArray(250),
                    channelInfo = new BBPFormat.ChannelInfo[0]
                };
            }
        }