Inheritance: IVorbisStreamStatus
Beispiel #1
0
        internal static VorbisMode Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            var mode = new VorbisMode(vorbis);
            mode.BlockFlag = packet.ReadBit();
            mode.WindowType = (int)packet.ReadBits(16);
            mode.TransformType = (int)packet.ReadBits(16);
            var mapping = (int)packet.ReadBits(8);

            if (mode.WindowType != 0 || mode.TransformType != 0 || mapping >= vorbis.Maps.Length) throw new InvalidDataException();

            mode.Mapping = vorbis.Maps[mapping];
            mode.BlockSize = mode.BlockFlag ? vorbis.Block1Size : vorbis.Block0Size;

            // now pre-calc the window(s)...
            if (mode.BlockFlag)
            {
                // long block
                mode._windows = new float[4][];
                mode._windows[0] = new float[vorbis.Block1Size];
                mode._windows[1] = new float[vorbis.Block1Size];
                mode._windows[2] = new float[vorbis.Block1Size];
                mode._windows[3] = new float[vorbis.Block1Size];
            }
            else
            {
                // short block
                mode._windows = new float[1][];
                mode._windows[0] = new float[vorbis.Block0Size];
            }
            mode.CalcWindows();

            return mode;
        }
        internal static VorbisCodebook Create(VorbisStreamDecoder vorbis, DataPacket packet, int number)
        {
            var tmp = new VorbisCodebook(number);

            tmp.Init(packet);
            return(tmp);
        }
Beispiel #3
0
 internal static VorbisMode Init(VorbisStreamDecoder vorbis, DataPacket packet)
 {
   VorbisMode vorbisMode = new VorbisMode(vorbis);
   vorbisMode.BlockFlag = packet.ReadBit();
   vorbisMode.WindowType = (int) packet.ReadBits(16);
   vorbisMode.TransformType = (int) packet.ReadBits(16);
   int index = (int) packet.ReadBits(8);
   if (vorbisMode.WindowType != 0 || vorbisMode.TransformType != 0 || index >= vorbis.Maps.Length)
     throw new InvalidDataException();
   vorbisMode.Mapping = vorbis.Maps[index];
   vorbisMode.BlockSize = vorbisMode.BlockFlag ? vorbis.Block1Size : vorbis.Block0Size;
   if (vorbisMode.BlockFlag)
   {
     vorbisMode._windows = new float[4][];
     vorbisMode._windows[0] = new float[vorbis.Block1Size];
     vorbisMode._windows[1] = new float[vorbis.Block1Size];
     vorbisMode._windows[2] = new float[vorbis.Block1Size];
     vorbisMode._windows[3] = new float[vorbis.Block1Size];
   }
   else
   {
     vorbisMode._windows = new float[1][];
     vorbisMode._windows[0] = new float[vorbis.Block0Size];
   }
   vorbisMode.CalcWindows();
   return vorbisMode;
 }
Beispiel #4
0
        internal static VorbisMode Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            VorbisMode vorbisMode = new VorbisMode(vorbis);

            vorbisMode.BlockFlag     = packet.ReadBit();
            vorbisMode.WindowType    = (int)packet.ReadBits(16);
            vorbisMode.TransformType = (int)packet.ReadBits(16);
            int num = (int)packet.ReadBits(8);

            if (vorbisMode.WindowType != 0 || vorbisMode.TransformType != 0 || num >= vorbis.Maps.Length)
            {
                throw new InvalidDataException();
            }
            vorbisMode.Mapping   = vorbis.Maps[num];
            vorbisMode.BlockSize = (vorbisMode.BlockFlag ? vorbis.Block1Size : vorbis.Block0Size);
            if (vorbisMode.BlockFlag)
            {
                vorbisMode._windows    = new float[4][];
                vorbisMode._windows[0] = new float[vorbis.Block1Size];
                vorbisMode._windows[1] = new float[vorbis.Block1Size];
                vorbisMode._windows[2] = new float[vorbis.Block1Size];
                vorbisMode._windows[3] = new float[vorbis.Block1Size];
            }
            else
            {
                vorbisMode._windows    = new float[1][];
                vorbisMode._windows[0] = new float[vorbis.Block0Size];
            }
            vorbisMode.CalcWindows();
            return(vorbisMode);
        }
Beispiel #5
0
 internal static VorbisCodebook Init(VorbisStreamDecoder vorbis, DataPacket packet, int number)
 {
   VorbisCodebook vorbisCodebook = new VorbisCodebook();
   vorbisCodebook.BookNum = number;
   vorbisCodebook.Init(packet);
   return vorbisCodebook;
 }
Beispiel #6
0
        public bool SwitchStreams(int index)
        {
            if (index < 0 || index >= StreamCount)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            if (_decoders == null)
            {
                throw new ObjectDisposedException("VorbisReader");
            }
            if (_streamIdx == index)
            {
                return(false);
            }
            VorbisStreamDecoder vorbisStreamDecoder = _decoders[_streamIdx];

            _streamIdx = index;
            VorbisStreamDecoder vorbisStreamDecoder2 = _decoders[_streamIdx];

            if (vorbisStreamDecoder._channels == vorbisStreamDecoder2._channels)
            {
                return(vorbisStreamDecoder._sampleRate != vorbisStreamDecoder2._sampleRate);
            }
            return(true);
        }
Beispiel #7
0
 internal static VorbisCodebook Init(VorbisStreamDecoder vorbis, DataPacket packet, int number)
 {
     var temp = new VorbisCodebook();
     temp.BookNum = number;
     temp.Init(packet);
     return temp;
 }
        internal static VorbisResidue Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            int           num           = (int)packet.ReadBits(16);
            VorbisResidue vorbisResidue = null;

            switch (num)
            {
            case 0:
                vorbisResidue = new Residue0(vorbis);
                break;

            case 1:
                vorbisResidue = new Residue1(vorbis);
                break;

            case 2:
                vorbisResidue = new Residue2(vorbis);
                break;
            }
            if (vorbisResidue == null)
            {
                throw new InvalidDataException();
            }
            vorbisResidue.Init(packet);
            return(vorbisResidue);
        }
Beispiel #9
0
        internal static VorbisCodebook Init(VorbisStreamDecoder vorbis, DataPacket packet, int number)
        {
            var temp = new VorbisCodebook();

            temp.BookNum = number;
            temp.Init(packet);
            return(temp);
        }
Beispiel #10
0
        internal static VorbisCodebook Init(VorbisStreamDecoder vorbis, DataPacket packet, int number)
        {
            VorbisCodebook vorbisCodebook = new VorbisCodebook();

            vorbisCodebook.BookNum = number;
            vorbisCodebook.Init(packet);
            return(vorbisCodebook);
        }
Beispiel #11
0
 public VorbisResidue(VorbisStreamDecoder vorbis)
 {
     _vorbis  = vorbis;
     _residue = new float[_vorbis._channels][];
     for (int i = 0; i < _vorbis._channels; i++)
     {
         _residue[i] = new float[_vorbis.Block1Size];
     }
 }
Beispiel #12
0
        protected VorbisResidue(VorbisStreamDecoder vorbis)
        {
            _vorbis = vorbis;

            _residue = new float[_vorbis._channels][];
            for (int i = 0; i < _vorbis._channels; i++)
            {
                _residue[i] = new float[_vorbis.Block1Size];
            }
        }
Beispiel #13
0
 internal static VorbisTime Init(VorbisStreamDecoder vorbis, DataPacket packet)
 {
   int num = (int) packet.ReadBits(16);
   VorbisTime vorbisTime = (VorbisTime) null;
   if (num == 0)
     vorbisTime = (VorbisTime) new VorbisTime.Time0(vorbis);
   if (vorbisTime == null)
     throw new InvalidDataException();
   vorbisTime.Init(packet);
   return vorbisTime;
 }
Beispiel #14
0
 internal static VorbisMapping Init(VorbisStreamDecoder vorbis, DataPacket packet)
 {
   int num = (int) packet.ReadBits(16);
   VorbisMapping vorbisMapping = (VorbisMapping) null;
   if (num == 0)
     vorbisMapping = (VorbisMapping) new VorbisMapping.Mapping0(vorbis);
   if (vorbisMapping == null)
     throw new InvalidDataException();
   vorbisMapping.Init(packet);
   return vorbisMapping;
 }
Beispiel #15
0
        internal static VorbisTime Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            var type = (int)packet.ReadBits(16);

            VorbisTime time = null;
            switch (type)
            {
                case 0: time = new Time0(vorbis); break;
            }
            if (time == null) throw new InvalidDataException();

            time.Init(packet);
            return time;
        }
Beispiel #16
0
        internal static VorbisMapping Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            var type = (int)packet.ReadBits(16);

            VorbisMapping mapping = null;
            switch (type)
            {
                case 0: mapping = new Mapping0(vorbis); break;
            }
            if (mapping == null) throw new Exception();

            mapping.Init(packet);
            return mapping;
        }
Beispiel #17
0
        public void NewStream(object sender, NewStreamEventArgs ea)
        {
            IPacketProvider     packetProvider      = ea.PacketProvider;
            VorbisStreamDecoder vorbisStreamDecoder = new VorbisStreamDecoder(packetProvider);

            if (vorbisStreamDecoder.TryInit())
            {
                _decoders.Add(vorbisStreamDecoder);
                _serials.Add(packetProvider.StreamSerial);
            }
            else
            {
                ea.IgnoreStream = true;
            }
        }
Beispiel #18
0
        internal static VorbisFloor Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            var type = (int)packet.ReadBits(16);

            VorbisFloor floor = null;
            switch (type)
            {
                case 0: floor = new Floor0(vorbis); break;
                case 1: floor = new Floor1(vorbis); break;
            }
            if (floor == null) throw new InvalidDataException();

            floor.Init(packet);
            return floor;
        }
        /// <summary>
        /// Reads decoded samples from the current logical stream
        /// </summary>
        /// <param name="buffer">The buffer to write the samples to.</param>
        /// <returns>The number of samples written</returns>
        public int ReadSamples(Span <float> buffer)
        {
            int samples = ActiveDecoder.ReadSamples(buffer);

            if (ClipSamples)
            {
                VorbisStreamDecoder decoder = _decoders[StreamIndex];
                for (int i = 0; i < samples; i++)
                {
                    buffer[i] = Utils.ClipValue(buffer[i], ref decoder._clipped);
                }
            }

            return(samples);
        }
Beispiel #20
0
        internal static VorbisTime Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            int        num        = (int)packet.ReadBits(16);
            VorbisTime vorbisTime = (VorbisTime)null;

            if (num == 0)
            {
                vorbisTime = (VorbisTime) new VorbisTime.Time0(vorbis);
            }
            if (vorbisTime == null)
            {
                throw new InvalidDataException();
            }
            vorbisTime.Init(packet);
            return(vorbisTime);
        }
Beispiel #21
0
        internal static VorbisResidue Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            var type = (int)packet.ReadBits(16);

            VorbisResidue residue = null;
            switch (type)
            {
                case 0: residue = new Residue0(vorbis); break;
                case 1: residue = new Residue1(vorbis); break;
                case 2: residue = new Residue2(vorbis); break;
            }
            if (residue == null) throw new InvalidDataException();

            residue.Init(packet);
            return residue;
        }
Beispiel #22
0
        internal static VorbisMapping Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            int           num           = (int)packet.ReadBits(16);
            VorbisMapping vorbisMapping = null;

            if (num == 0)
            {
                vorbisMapping = new Mapping0(vorbis);
            }
            if (vorbisMapping == null)
            {
                throw new InvalidDataException();
            }
            vorbisMapping.Init(packet);
            return(vorbisMapping);
        }
Beispiel #23
0
        void NewStream(object sender, NewStreamEventArgs ea)
        {
            var packetProvider = ea.PacketProvider;
            var decoder        = new VorbisStreamDecoder(packetProvider);

            if (decoder.TryInit())
            {
                _decoders.Add(decoder);
                _serials.Add(packetProvider.StreamSerial);
            }
            else
            {
                // This is almost certainly not a Vorbis stream
                ea.IgnoreStream = true;
            }
        }
Beispiel #24
0
        private void NewStream(int streamSerial)
        {
            DataPacket nextPacket = this._packetProvider.GetNextPacket(streamSerial);

            if ((int)nextPacket.PeekByte() != (int)VorbisStreamDecoder.InitialPacketMarker)
            {
                return;
            }
            VorbisStreamDecoder vorbisStreamDecoder = new VorbisStreamDecoder((Func <DataPacket>)(() =>
            {
                IPacketProvider local_0 = this._packetProvider;
                if (local_0 != null)
                {
                    return(local_0.GetNextPacket(streamSerial));
                }
                else
                {
                    return((DataPacket)null);
                }
            }), (Func <int>)(() =>
            {
                IPacketProvider local_0 = this._packetProvider;
                if (local_0 != null)
                {
                    return(local_0.GetTotalPageCount(streamSerial));
                }
                else
                {
                    return(0);
                }
            }));

            try
            {
                if (!vorbisStreamDecoder.TryInit(nextPacket))
                {
                    return;
                }
                this._decoders.Add(vorbisStreamDecoder);
                this._serials.Add(streamSerial);
            }
            catch (InvalidDataException ex)
            {
            }
        }
Beispiel #25
0
        internal static VorbisTime Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            var type = (int)packet.ReadBits(16);

            VorbisTime time = null;

            switch (type)
            {
            case 0: time = new Time0(vorbis); break;
            }
            if (time == null)
            {
                throw new InvalidDataException();
            }

            time.Init(packet);
            return(time);
        }
        void NewStream(object sender, NewStreamEventArgs ea)
        {
            var packetProvider = ea.PacketProvider;
            var decoder        = new VorbisStreamDecoder(packetProvider);

            if (decoder.TryInit())
            {
                _decoders.Add(decoder);
                _serials.Add(packetProvider.StreamSerial);
            }
            else
            {
                // NB: This could be an Ogg Skeleton stream...  We should check that, just in case
                // NB: This could be a RTP stream...  We should check that, just in case

                ea.IgnoreStream = true;
            }
        }
Beispiel #27
0
 internal static VorbisFloor Init(VorbisStreamDecoder vorbis, DataPacket packet)
 {
   int num = (int) packet.ReadBits(16);
   VorbisFloor vorbisFloor = (VorbisFloor) null;
   switch (num)
   {
     case 0:
       vorbisFloor = (VorbisFloor) new VorbisFloor.Floor0(vorbis);
       break;
     case 1:
       vorbisFloor = (VorbisFloor) new VorbisFloor.Floor1(vorbis);
       break;
   }
   if (vorbisFloor == null)
     throw new InvalidDataException();
   vorbisFloor.Init(packet);
   return vorbisFloor;
 }
Beispiel #28
0
        internal static VorbisMapping Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            var type = (int)packet.ReadBits(16);

            VorbisMapping mapping = null;

            switch (type)
            {
            case 0: mapping = new Mapping0(vorbis); break;
            }
            if (mapping == null)
            {
                throw new InvalidDataException();
            }

            mapping.Init(packet);
            return(mapping);
        }
Beispiel #29
0
        internal static VorbisFloor Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            var type = (int)packet.ReadBits(16);

            VorbisFloor floor = null;

            switch (type)
            {
            case 0: floor = new Floor0(vorbis); break;

            case 1: floor = new Floor1(vorbis); break;
            }
            if (floor == null)
            {
                throw new InvalidDataException();
            }

            floor.Init(packet);
            return(floor);
        }
Beispiel #30
0
 internal static VorbisResidue Init(VorbisStreamDecoder vorbis, DataPacket packet)
 {
   int num = (int) packet.ReadBits(16);
   VorbisResidue vorbisResidue = (VorbisResidue) null;
   switch (num)
   {
     case 0:
       vorbisResidue = (VorbisResidue) new VorbisResidue.Residue0(vorbis);
       break;
     case 1:
       vorbisResidue = (VorbisResidue) new VorbisResidue.Residue1(vorbis);
       break;
     case 2:
       vorbisResidue = (VorbisResidue) new VorbisResidue.Residue2(vorbis);
       break;
   }
   if (vorbisResidue == null)
     throw new InvalidDataException();
   vorbisResidue.Init(packet);
   return vorbisResidue;
 }
Beispiel #31
0
        internal static VorbisFloor Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            int         num         = (int)packet.ReadBits(16);
            VorbisFloor vorbisFloor = (VorbisFloor)null;

            switch (num)
            {
            case 0:
                vorbisFloor = (VorbisFloor) new VorbisFloor.Floor0(vorbis);
                break;

            case 1:
                vorbisFloor = (VorbisFloor) new VorbisFloor.Floor1(vorbis);
                break;
            }
            if (vorbisFloor == null)
            {
                throw new InvalidDataException();
            }
            vorbisFloor.Init(packet);
            return(vorbisFloor);
        }
Beispiel #32
0
        internal static VorbisResidue Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            var type = (int)packet.ReadBits(16);

            VorbisResidue residue = null;

            switch (type)
            {
            case 0: residue = new Residue0(vorbis); break;

            case 1: residue = new Residue1(vorbis); break;

            case 2: residue = new Residue2(vorbis); break;
            }
            if (residue == null)
            {
                throw new InvalidDataException();
            }

            residue.Init(packet);
            return(residue);
        }
Beispiel #33
0
        internal static VorbisMode Init(VorbisStreamDecoder vorbis, DataPacket packet)
        {
            var mode = new VorbisMode(vorbis);

            mode.BlockFlag     = packet.ReadBit();
            mode.WindowType    = (int)packet.ReadBits(16);
            mode.TransformType = (int)packet.ReadBits(16);
            var mapping = (int)packet.ReadBits(8);

            if (mode.WindowType != 0 || mode.TransformType != 0 || mapping >= vorbis.Maps.Length)
            {
                throw new Exception();
            }

            mode.Mapping   = vorbis.Maps[mapping];
            mode.BlockSize = mode.BlockFlag ? vorbis.Block1Size : vorbis.Block0Size;

            // now pre-calc the window(s)...
            if (mode.BlockFlag)
            {
                // long block
                mode._windows    = new float[4][];
                mode._windows[0] = new float[vorbis.Block1Size];
                mode._windows[1] = new float[vorbis.Block1Size];
                mode._windows[2] = new float[vorbis.Block1Size];
                mode._windows[3] = new float[vorbis.Block1Size];
            }
            else
            {
                // short block
                mode._windows    = new float[1][];
                mode._windows[0] = new float[vorbis.Block0Size];
            }
            mode.CalcWindows();

            return(mode);
        }
Beispiel #34
0
 public int ReadSamples(float[] buffer, int offset, int count)
 {
     if (offset < 0)
     {
         throw new ArgumentOutOfRangeException("offset");
     }
     if (count < 0 || offset + count > buffer.Length)
     {
         throw new ArgumentOutOfRangeException("count");
     }
     count = ActiveDecoder.ReadSamples(buffer, offset, count);
     if (ClipSamples)
     {
         VorbisStreamDecoder vorbisStreamDecoder = _decoders[_streamIdx];
         int num = 0;
         while (num < count)
         {
             buffer[offset] = Utils.ClipValue(buffer[offset], ref vorbisStreamDecoder._clipped);
             num++;
             offset++;
         }
     }
     return(count);
 }
Beispiel #35
0
        public bool SwitchStreams(int index)
        {
            if (index < 0 || index >= this.StreamCount)
            {
                throw new ArgumentOutOfRangeException("index");
            }
            if (this._streamIdx == index)
            {
                return(false);
            }
            VorbisStreamDecoder vorbisStreamDecoder1 = this._decoders[this._streamIdx];

            this._streamIdx = index;
            VorbisStreamDecoder vorbisStreamDecoder2 = this._decoders[this._streamIdx];

            if (vorbisStreamDecoder1._channels == vorbisStreamDecoder2._channels)
            {
                return(vorbisStreamDecoder1._sampleRate != vorbisStreamDecoder2._sampleRate);
            }
            else
            {
                return(true);
            }
        }
Beispiel #36
0
 internal Time0(VorbisStreamDecoder vorbis)
     : base(vorbis)
 {
 }
Beispiel #37
0
 protected VorbisTime(VorbisStreamDecoder vorbis)
 {
     _vorbis = vorbis;
 }
Beispiel #38
0
 internal Residue2(VorbisStreamDecoder vorbis) : base(vorbis)
 {
 }
Beispiel #39
0
 private int WindowSamples(VorbisStreamDecoder.PacketDecodeInfo pdi)
 {
   float[] window = pdi.Mode.GetWindow(pdi.PrevFlag, pdi.NextFlag);
   int num1 = pdi.Mode.BlockSize;
   int end = num1;
   int switchPoint = end >> 1;
   int start = 0;
   int num2 = -switchPoint;
   int num3 = switchPoint;
   if (pdi.Mode.BlockFlag)
   {
     if (!pdi.PrevFlag)
     {
       start = this.Block1Size / 4 - this.Block0Size / 4;
       switchPoint = start + this.Block0Size / 2;
       num2 = this.Block0Size / -2 - start;
     }
     if (!pdi.NextFlag)
     {
       end -= num1 / 4 - this.Block0Size / 4;
       num3 = num1 / 4 + this.Block0Size / 4;
     }
   }
   int index = this._outputBuffer.Length / this._channels + num2;
   for (int channel = 0; channel < this._channels; ++channel)
     this._outputBuffer.Write(channel, index, start, switchPoint, end, pdi.Residue[channel], window);
   int num4 = this._outputBuffer.Length / this._channels - num3;
   int num5 = num4 - this._preparedLength;
   this._preparedLength = num4;
   return num5;
 }
Beispiel #40
0
 protected VorbisResidue(VorbisStreamDecoder vorbis)
 {
   this._vorbis = vorbis;
 }
Beispiel #41
0
 protected VorbisFloor(VorbisStreamDecoder vorbis)
 {
     _vorbis = vorbis;
 }
Beispiel #42
0
 internal Residue0(VorbisStreamDecoder vorbis)
   : base(vorbis)
 {
 }
Beispiel #43
0
 internal Mapping0(VorbisStreamDecoder vorbis) : base(vorbis)
 {
 }
Beispiel #44
0
 protected VorbisMapping(VorbisStreamDecoder vorbis)
 {
     _vorbis = vorbis;
 }
Beispiel #45
0
 private VorbisMode(VorbisStreamDecoder vorbis)
 {
     _vorbis = vorbis;
 }
Beispiel #46
0
 public VorbisMapping(VorbisStreamDecoder vorbis)
 {
     _vorbis = vorbis;
 }
Beispiel #47
0
        void NewStream(int streamSerial)
        {
            var initialPacket = _packetProvider.GetNextPacket(streamSerial);
            var checkByte = (byte)initialPacket.PeekByte();

            // TODO: determine what type of stream this is, load the correct decoder (or ignore
            //       it), then keep going.  If it's a skeleton stream, try to load it.  Only
            //       allow one instance.  Then force another page to be read.

            // for now, we only support the Vorbis decoder; Skeleton will happen later
            if (checkByte == VorbisStreamDecoder.InitialPacketMarker)
            {
                var decoder = new VorbisStreamDecoder(
                    () => {
                        var provider = _packetProvider;
                        if (provider != null)
                        {
                            return provider.GetNextPacket(streamSerial);
                        }
                        return null;
                    },
                    () =>
                    {
                        var provider = _packetProvider;
                        if (provider != null)
                        {
                            return provider.GetTotalPageCount(streamSerial);
                        }
                        return 0;
                    }
                );
                try
                {
                    if (decoder.TryInit(initialPacket))
                    {
                        // the init worked, so we have a valid stream...

                        _decoders.Add(decoder);
                        _serials.Add(streamSerial);
                    }
                    // else: the initial packet wasn't for Vorbis...
                }
                catch (InvalidDataException)
                {
                    // there was an error loading the headers... problem is, we're past the first packet, so we can't go back and try again...
                    // TODO: log the error
                }
            }
            // we're not supporting Skeleton yet...
            //else if (checkByte == Ogg.SkeletonDecoder.InitialPacketMarker)
            //{
            //    // load it
            //    if (_skeleton != null) throw new InvalidDataException("Second skeleton stream found!");
            //    _skeleton = new Ogg.SkeletonDecoder(() => _packetProvider.GetNextPacket(streamSerial));

            //    if (_skeleton.Init(initialPacket))
            //    {
            //        // force the next stream to load
            //        _packetProvider.FindNextStream(streamSerial);
            //    }
            //    else
            //    {
            //        _skeleton = null;
            //    }
            //}
        }
Beispiel #48
0
        void NewStream(object sender, NewStreamEventArgs ea)
        {
            var packetProvider = ea.PacketProvider;
            var decoder = new VorbisStreamDecoder(packetProvider);
            if (decoder.TryInit())
            {
                _decoders.Add(decoder);
                _serials.Add(packetProvider.StreamSerial);
            }
            else
            {
                // NB: This could be an Ogg Skeleton stream...  We should check that, just in case
                // NB: This could be a RTP stream...  We should check that, just in case

                ea.IgnoreStream = true;
            }
        }
Beispiel #49
0
 private void NewStream(int streamSerial)
 {
   DataPacket nextPacket = this._packetProvider.GetNextPacket(streamSerial);
   if ((int) nextPacket.PeekByte() != (int) VorbisStreamDecoder.InitialPacketMarker)
     return;
   VorbisStreamDecoder vorbisStreamDecoder = new VorbisStreamDecoder((Func<DataPacket>) (() =>
   {
     IPacketProvider local_0 = this._packetProvider;
     if (local_0 != null)
       return local_0.GetNextPacket(streamSerial);
     else
       return (DataPacket) null;
   }), (Func<int>) (() =>
   {
     IPacketProvider local_0 = this._packetProvider;
     if (local_0 != null)
       return local_0.GetTotalPageCount(streamSerial);
     else
       return 0;
   }));
   try
   {
     if (!vorbisStreamDecoder.TryInit(nextPacket))
       return;
     this._decoders.Add(vorbisStreamDecoder);
     this._serials.Add(streamSerial);
   }
   catch (InvalidDataException ex)
   {
   }
 }
Beispiel #50
0
 void NewStream(object sender, NewStreamEventArgs ea)
 {
     var packetProvider = ea.PacketProvider;
     var decoder = new VorbisStreamDecoder(packetProvider);
     if (decoder.TryInit())
     {
         _decoders.Add(decoder);
         _serials.Add(packetProvider.StreamSerial);
     }
     else
     {
         // This is almost certainly not a Vorbis stream
         ea.IgnoreStream = true;
     }
 }
Beispiel #51
0
 internal Floor0(VorbisStreamDecoder vorbis) : base(vorbis)
 {
 }
Beispiel #52
0
 internal Time0(VorbisStreamDecoder vorbis) : base(vorbis)
 {
 }
Beispiel #53
0
 protected VorbisFloor(VorbisStreamDecoder vorbis)
 {
     _vorbis = vorbis;
 }
Beispiel #54
0
 private int DecodePacket(VorbisStreamDecoder.PacketDecodeInfo pdi)
 {
   VorbisMapping.CouplingStep[] couplingStepArray = pdi.Mode.Mapping.CouplingSteps;
   int num1 = pdi.Mode.BlockSize / 2;
   for (int index1 = couplingStepArray.Length - 1; index1 >= 0; --index1)
   {
     float[] numArray1 = pdi.Residue[couplingStepArray[index1].Magnitude];
     float[] numArray2 = pdi.Residue[couplingStepArray[index1].Angle];
     for (int index2 = 0; index2 < num1; ++index2)
     {
       float num2;
       float num3;
       if ((double) numArray1[index2] > 0.0)
       {
         if ((double) numArray2[index2] > 0.0)
         {
           num2 = numArray1[index2];
           num3 = numArray1[index2] - numArray2[index2];
         }
         else
         {
           num3 = numArray1[index2];
           num2 = numArray1[index2] + numArray2[index2];
         }
       }
       else if ((double) numArray2[index2] > 0.0)
       {
         num2 = numArray1[index2];
         num3 = numArray1[index2] + numArray2[index2];
       }
       else
       {
         num3 = numArray1[index2];
         num2 = numArray1[index2] - numArray2[index2];
       }
       numArray1[index2] = num2;
       numArray2[index2] = num3;
     }
   }
   for (int index = 0; index < this._channels; ++index)
   {
     VorbisFloor.PacketData packetData = pdi.FloorData[index];
     float[] numArray = pdi.Residue[index];
     if (packetData.ExecuteChannel)
     {
       pdi.Mode.Mapping.ChannelSubmap[index].Floor.Apply(packetData, numArray);
       Mdct.Reverse(numArray);
     }
   }
   return this.WindowSamples(pdi);
 }
Beispiel #55
0
 protected VorbisMapping(VorbisStreamDecoder vorbis)
 {
   this._vorbis = vorbis;
 }
Beispiel #56
0
 internal Floor1(VorbisStreamDecoder vorbis)
     : base(vorbis)
 {
 }
Beispiel #57
0
 internal Mapping0(VorbisStreamDecoder vorbis)
   : base(vorbis)
 {
 }
Beispiel #58
0
 protected VorbisTime(VorbisStreamDecoder vorbis)
 {
     _vorbis = vorbis;
     vorbis  = _vorbis;
 }