Voice containing Ogg Vorbis data
Inheritance: IWave, DatDigger.Sound.IPlayableStream
        private void LoadVoices(BinaryReaderEx reader)
        {
            if (this.SscfHeader.NumWaves <= 0)
            {
                return;
            }

            reader.BaseStream.Position = this.SscfHeader.OffsetB;
            this.VoiceOffsets          = new List <int>(this.SscfHeader.NumWaves);
            this.Children = new List <INavigable>(this.SscfHeader.NumWaves);

            for (var i = 0; i < this.SscfHeader.NumWaves; i++)
            {
                this.VoiceOffsets.Add(reader.ReadInt32());
            }

            foreach (int offset in this.VoiceOffsets)
            {
                reader.BaseStream.Position = offset;
                WaveHeader waveHeader = ReadWaveHeader(reader);
                IWave      voice      = null;
                switch (waveHeader.Format)
                {
                case WaveCompressionFormat.PCM:
                    voice = new PcmWave()
                    {
                        Parent = this, WaveHeader = waveHeader
                    };
                    break;

                case WaveCompressionFormat.Vorbis:
                    voice = new VorbisWave()
                    {
                        Parent = this, WaveHeader = waveHeader
                    };
                    break;

                case WaveCompressionFormat.ADPCM:
                    voice = new AdpcmWave()
                    {
                        Parent = this, WaveHeader = waveHeader
                    };
                    break;

                case WaveCompressionFormat.ATRAC3:
                case WaveCompressionFormat.ATRAC3_Too:
                case WaveCompressionFormat.XMA:
                    throw new InvalidOperationException("Unsupported Wave Format: " + waveHeader.Format);

                default:
                    throw new InvalidOperationException("Unknown Wave Format: 0x" + ((int)waveHeader.Format).ToString("X"));
                }

                this.Children.Add(voice);
                voice.LoadData(reader);
            }
        }
Example #2
0
        private void LoadVoices(BinaryReaderEx reader)
        {
            if (this.SscfHeader.NumWaves <= 0)
            {
                return;
            }

            reader.BaseStream.Position = this.SscfHeader.OffsetB;
            this.VoiceOffsets = new List<int>(this.SscfHeader.NumWaves);
            this.Children = new List<INavigable>(this.SscfHeader.NumWaves);

            for (var i = 0; i < this.SscfHeader.NumWaves; i++)
            {
                this.VoiceOffsets.Add(reader.ReadInt32());
            }

            foreach (int offset in this.VoiceOffsets)
            {
                reader.BaseStream.Position = offset;
                WaveHeader waveHeader = ReadWaveHeader(reader);
                IWave voice = null;
                switch (waveHeader.Format)
                {
                    case WaveCompressionFormat.PCM:
                        voice = new PcmWave() { Parent = this, WaveHeader = waveHeader };
                        break;
                    case WaveCompressionFormat.Vorbis:
                        voice = new VorbisWave() { Parent = this, WaveHeader = waveHeader };
                        break;
                    case WaveCompressionFormat.ADPCM:
                        voice = new AdpcmWave() { Parent = this, WaveHeader = waveHeader };
                        break;
                    case WaveCompressionFormat.ATRAC3:
                    case WaveCompressionFormat.ATRAC3_Too:
                    case WaveCompressionFormat.XMA:
                        throw new InvalidOperationException("Unsupported Wave Format: " + waveHeader.Format);
                    default:
                        throw new InvalidOperationException("Unknown Wave Format: 0x" + ((int)waveHeader.Format).ToString("X"));
                }

                this.Children.Add(voice);
                voice.LoadData(reader);
            }
        }