コード例 #1
0
ファイル: SoundBankFile.cs プロジェクト: tjhorner/gtaivtools
        public void Open(Stream stream)
        {
            Stream = stream;

            BinaryReader br = new BinaryReader(stream);

            var startPosition = stream.Position;

            // Try loading as multichannel
            try
            {
                stream.Seek(startPosition, SeekOrigin.Begin);
                
                SoundBank = new SoundBankMultiChannel();
                SoundBank.Read(br);
                IsMultiChannel = true;
            }
            catch(SoundBankException)
            {
                SoundBank = null;
            }

            // Failed, so lets try mono
            if (SoundBank == null)
            {
                try
                {
                    stream.Seek(startPosition, SeekOrigin.Begin);
                    
                    SoundBank = new SoundBankMono();
                    SoundBank.Read(br);
                    IsMultiChannel = false;
                }
                catch (SoundBankException)
                {
                    SoundBank = null;
                }
            }

            if (SoundBank == null)
            {
                throw new SoundBankException("Could not load sound bank.");
            }
        }
コード例 #2
0
ファイル: SoundBankFile.cs プロジェクト: q4a/SparkIV
        public void Open(Stream stream)
        {
            Stream = stream;

            BinaryReader br = new BinaryReader(stream);

            var startPosition = stream.Position;

            // Try loading as multichannel
            try
            {
                stream.Seek(startPosition, SeekOrigin.Begin);

                SoundBank = new SoundBankMultiChannel();
                SoundBank.Read(br);
                IsMultiChannel = true;
            }
            catch (SoundBankException)
            {
                SoundBank = null;
            }

            // Failed, so lets try mono
            if (SoundBank == null)
            {
                try
                {
                    stream.Seek(startPosition, SeekOrigin.Begin);

                    SoundBank = new SoundBankMono();
                    SoundBank.Read(br);
                    IsMultiChannel = false;
                }
                catch (SoundBankException)
                {
                    SoundBank = null;
                }
            }

            if (SoundBank == null)
            {
                throw new SoundBankException("Could not load sound bank.");
            }
        }