Ejemplo n.º 1
0
        public SvagContainer Read(Stream stream)
        {
            var reader = new BinaryReader(stream);

            if (reader.ReadInt32() != 0x67617653)
            {
                throw new RhythmCodexException("Svag header ID is not valid.");
            }
            reader.ReadInt32(); // data length
            var freq       = reader.ReadInt32();
            var channels   = reader.ReadInt32();
            var interleave = reader.ReadInt32();

            reader.ReadInt32();             // reserved 0
            reader.ReadInt32();             // reserved 1
            reader.ReadBytes(0x800 - 0x1C); // discard the rest of the header

            var chunk = _vagStreamReader.Read(stream, channels, interleave);

            return(new SvagContainer
            {
                VagChunk = chunk,
                SampleRate = freq
            });
        }
Ejemplo n.º 2
0
        public BeatmaniaPs2Bgm Read(Stream stream)
        {
            var reader = new BinaryReader(stream);
            var length = reader.ReadInt32S();

            reader.ReadByte();
            var volume   = reader.ReadByte();
            var rate     = reader.ReadUInt16S();
            var channels = reader.ReadByte();

            // skip the rest of the header
            reader.ReadBytes(0x800 - 9);

            var source = reader.ReadBytes(length);

            using (var mem = new MemoryStream(source))
            {
                var data = _vagStreamReader.Read(mem, channels, 0x800);
                return(new BeatmaniaPs2Bgm
                {
                    Data = data,
                    Volume = volume,
                    Rate = rate,
                });
            }
        }
        public BeatmaniaPs2Bgm Read(Stream stream)
        {
            var reader = new BinaryReader(stream);
            var header = Enumerable.Range(0, 12).Select(i => reader.ReadInt32()).ToArray();

            var headerLength = header[2];
            var dataLength   = header[3];
            var loopStart    = header[4];
            var loopEnd      = header[5];
            var rate         = header[6];
            var channels     = header[7];
            var interleave   = header[9];
            var volume       = header[10];

            reader.ReadBytes(headerLength - 0x30);

            var data = reader.ReadBytes(dataLength);

            using (var mem = new MemoryStream(data))
            {
                return(new BeatmaniaPs2Bgm
                {
                    Channels = channels,
                    Rate = rate,
                    Volume = volume,
                    Data = _vagStreamReader.Read(mem, channels, interleave)
                });
            }
        }
Ejemplo n.º 4
0
        public Xa2Container Read(Stream stream)
        {
            var reader     = new BinaryReader(stream);
            var channels   = reader.ReadInt32();
            var interleave = reader.ReadInt32();

            reader.ReadBytes(0x800 - 0x008); // discard the rest of the header

            var chunk = _vagStreamReader.Read(stream, channels, interleave);

            return(new Xa2Container
            {
                VagChunk = chunk
            });
        }
        public IList <BeatmaniaPsxKeysound> Read(Stream stream)
        {
            var reader = new BinaryReader(stream);

            reader.ReadInt32S(); // directory offset
            var directoryLength = reader.ReadInt32S();

            reader.ReadInt32S();
            reader.ReadInt32S();

            var keysounds = Enumerable
                            .Range(0, directoryLength / 0x10)
                            .Select(i => new BeatmaniaPsxKeysound
            {
                DirectoryEntry = new BeatmaniaPsxKeysoundDirectoryEntry
                {
                    Offset   = reader.ReadInt32(),
                    Unknown0 = reader.ReadInt32(),
                    Unknown1 = reader.ReadInt32(),
                    Unknown2 = reader.ReadInt32()
                }
            })
                            .ToList();

            var dataOffset = reader.ReadInt32S();
            var dataLength = reader.ReadInt32S();

            reader.ReadInt32S();
            reader.ReadInt32S();

            var data = reader.ReadBytes(dataLength);

            using (var dataStream = new ReadOnlyMemoryStream(data))
            {
                foreach (var keysound in keysounds)
                {
                    dataStream.Position = keysound.DirectoryEntry.Offset - dataOffset;
                    keysound.Data       = _vagStreamReader.Read(dataStream, 1, 16);
                }
            }

            return(keysounds);
        }
Ejemplo n.º 6
0
        public SvagContainer Read(HeuristicResult result, Stream stream)
        {
            if (!(result is VagHeuristicResult info))
            {
                return(null);
            }

            if (info.Start != null)
            {
                stream.TryRead(0, (int)info.Start);
            }

            var output = _vagStreamReader.Read(stream, info.Channels ?? 1, info.Interleave ?? 0);

            output.Volume     = info.Volume;
            output.SampleRate = info.SampleRate;
            output.Length     = info.Length;

            return(new SvagContainer
            {
                SampleRate = info.SampleRate,
                VagChunk = output
            });
        }
        public VagChunk Read(HeuristicResult result, Stream stream)
        {
            if (!(result is VagHeuristicResult info))
            {
                return(null);
            }

            var decryptStream = info.Key != null
                ? new BeatmaniaPs2NewAudioDecryptStream(stream, info.Key)
                : stream;

            if (info.Start != null)
            {
                stream.TryRead(0, (int)info.Start);
            }

            var output = _vagStreamReader.Read(decryptStream, info.Channels ?? 1, info.Interleave ?? 0);

            output.Volume     = info.Volume;
            output.SampleRate = info.SampleRate;
            output.Length     = info.Length;

            return(output);
        }
        public VagChunk Read(HeuristicResult result, Stream stream)
        {
            var info = result as VagHeuristicResult;

            return(_vagStreamReader.Read(stream, info?.Channels ?? 1, info?.Interleave ?? 0));
        }
Ejemplo n.º 9
0
        public BeatmaniaPs2KeysoundSet Read(Stream stream)
        {
            var reader = new BinaryReader(stream);
            var header = Enumerable.Range(0, 8).Select(i => reader.ReadInt32()).ToArray();
            var length = header[0];
            var hunk   = reader.ReadBytes(length - 0x20);

            using (var hunkMem = new MemoryStream(hunk))
            {
                var hunkReader = new BinaryReader(hunkMem);
                var entries    = Enumerable.Range(0, 511).Select(i =>
                {
                    hunkMem.Position = i * 0x20;

                    var result = new BeatmaniaPs2Keysound
                    {
                        SampleNumber   = hunkReader.ReadInt16(),
                        Reserved0      = hunkReader.ReadInt16(),
                        Channel        = hunkReader.ReadByte(),
                        Volume         = hunkReader.ReadByte(),
                        Panning        = hunkReader.ReadByte(),
                        SampleType     = hunkReader.ReadByte(),
                        FrequencyLeft  = hunkReader.ReadInt32(),
                        FrequencyRight = hunkReader.ReadInt32(),
                        OffsetLeft     = hunkReader.ReadInt32(),
                        OffsetRight    = hunkReader.ReadInt32(),
                        PseudoLeft     = hunkReader.ReadInt32(),
                        PseudoRight    = hunkReader.ReadInt32()
                    };

                    switch (result.SampleType)
                    {
                    case 2:
                        {
                            hunkMem.Position = result.OffsetLeft - 61488;
                            result.Data      = new List <VagChunk> {
                                _vagStreamReader.Read(hunkMem, 1, 0)
                            };
                            break;
                        }

                    case 3:
                        {
                            hunkMem.Position = header[1] + result.OffsetLeft + 16368;
                            result.Data      = new List <VagChunk> {
                                _vagStreamReader.Read(hunkMem, 1, 0)
                            };
                            break;
                        }

                    case 4:
                        {
                            hunkMem.Position = result.OffsetLeft - 61488;
                            var dataLeft     = _vagStreamReader.Read(hunkMem, 1, 0);
                            hunkMem.Position = result.OffsetRight - 61488;
                            var dataRight    = _vagStreamReader.Read(hunkMem, 1, 0);
                            result.Data      = new List <VagChunk> {
                                dataLeft, dataRight
                            };
                            break;
                        }

                    default:
                        {
                            return(null);
                        }
                    }

                    return(result);
                }).Where(entry => entry != null).ToList();

                return(new BeatmaniaPs2KeysoundSet
                {
                    Keysounds = entries
                });
            }
        }