public WaveStream[] Read() { SectionHeader sectionHeader = _input.ReadContent <SectionHeader>(); SscfHeader sscfHeader = _input.ReadContent <SscfHeader>(); BinaryReader br = new BinaryReader(_input); _input.SetPosition(sscfHeader.WavesOffset); int[] offsets = new int[sscfHeader.NumWaves]; for (int i = 0; i < offsets.Length; i++) { offsets[i] = br.ReadInt32(); } WaveStream[] result = new WaveStream[sscfHeader.NumWaves]; for (int i = 0; i < offsets.Length; i++) { _input.SetPosition(offsets[i]); SscfWaveHeader waveHeader = _input.ReadContent <SscfWaveHeader>(); if (waveHeader.Format == SscfWaveFormat.Vorbis) { _input.SetPosition(waveHeader.DataOffset); byte[] vorbisData = _input.EnsureRead(waveHeader.DataLength); MemoryStream vorbisMs = new MemoryStream(vorbisData, 0, vorbisData.Length, false); result[i] = new VorbisWaveReader(vorbisMs); continue; } WaveFormat format = ReadWaveFormat(waveHeader); if (format == null) { continue; } _input.SetPosition(waveHeader.DataOffset); byte[] data = _input.EnsureRead(waveHeader.DataLength); MemoryStream ms = new MemoryStream(data, 0, data.Length, false); result[i] = new RawSourceWaveStream(ms, format); } return(result); }
public virtual void ReadFromStream(Stream stream) { SectionHeader = stream.ReadContent<SectionHeader>(); }
public virtual void ReadFromStream(Stream stream) { SectionHeader = stream.ReadContent <SectionHeader>(); }