Exemple #1
0
        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.");
            }
        }
Exemple #2
0
        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.");
            }
        }