Пример #1
0
 internal override VorbisFloor.PacketData UnpackPacket(DataPacket packet, int blockSize)
 {
     VorbisFloor.Floor0.PacketData0 packetData0_1 = new VorbisFloor.Floor0.PacketData0();
     packetData0_1.BlockSize = blockSize;
     VorbisFloor.Floor0.PacketData0 packetData0_2 = packetData0_1;
     packetData0_2.Amp = (float)packet.ReadBits(this._ampBits);
     if ((double)packetData0_2.Amp > 0.0)
     {
         try
         {
             List <float> list = new List <float>();
             uint         num  = (uint)packet.ReadBits(this._bookBits);
             if ((long)num >= (long)this._books.Length)
             {
                 throw new InvalidDataException();
             }
             VorbisCodebook vorbisCodebook = this._books[(IntPtr)num];
             for (int index1 = 0; index1 < this._order; ++index1)
             {
                 int index2 = vorbisCodebook.DecodeScalar(packet);
                 for (int index3 = 0; index3 < vorbisCodebook.Dimensions; ++index3)
                 {
                     list.Add(vorbisCodebook[index2, index3]);
                 }
             }
             packetData0_2.Coeff = list.ToArray();
         }
         catch (EndOfStreamException ex)
         {
             packetData0_2.Amp = 0.0f;
         }
     }
     return((VorbisFloor.PacketData)packetData0_2);
 }
Пример #2
0
            internal override void Apply(VorbisFloor.PacketData packetData, float[] residue)
            {
                VorbisFloor.Floor0.PacketData0 packetData0 = packetData as VorbisFloor.Floor0.PacketData0;
                if (packetData0 == null)
                {
                    throw new ArgumentException("Incorrect packet data!");
                }
                if ((double)packetData0.Amp <= 0.0)
                {
                    return;
                }
                float[] numArray = this._barkMaps[packetData0.BlockSize];
                int     index    = 0;

label_9:
                if (index >= packetData0.BlockSize)
                {
                    return;
                }
                double d = Math.PI * (double)numArray[index] / (double)this._bark_map_size;
                float  num1;
                int    num2;
                float  num3;
                int    num4;

                if (this._order % 2 == 1)
                {
                    num1 = (float)(1.0 - Math.Pow(Math.Cos(d), 2.0));
                    num2 = 3;
                    num3 = 0.25f;
                    num4 = 1;
                }
                else
                {
                    num1 = (float)(1.0 - Math.Cos(d));
                    num2 = 2;
                    num3 = (float)(1.0 + Math.Cos(d));
                    num4 = 2;
                }
                double num5 = (double)num1 * (double)(this._order - num2) / (4.0 * Math.Pow(Math.Cos((double)packetData0.Coeff[1]) - Math.Cos(d), 2.0) * (4.0 * Math.Pow(Math.Cos((double)packetData0.Coeff[3]) - Math.Cos(d), 2.0)) * (4.0 * Math.Pow(Math.Cos((double)packetData0.Coeff[5]) - Math.Cos(d), 2.0)));
                double num6 = (double)num3 * (double)(this._order - num4) / (4.0 * Math.Pow(Math.Cos((double)packetData0.Coeff[0]) - Math.Cos(d), 2.0) * (4.0 * Math.Pow(Math.Cos((double)packetData0.Coeff[2]) - Math.Cos(d), 2.0)) * (4.0 * Math.Pow(Math.Cos((double)packetData0.Coeff[4]) - Math.Cos(d), 2.0)));
                float  num7 = (float)Math.Exp(0.11512925 * ((double)packetData0.Amp * (double)this._ampOfs / ((double)((1 << this._ampBits) - 1) * Math.Sqrt(num5 + num6)) - (double)this._ampOfs));
                float  num8;

                do
                {
                    num8            = numArray[index];
                    residue[index] *= num7;
                    ++index;
                }while ((double)numArray[index] == (double)num8);
                goto label_9;
            }
Пример #3
0
 internal override VorbisFloor.PacketData UnpackPacket(DataPacket packet, int blockSize)
 {
   VorbisFloor.Floor0.PacketData0 packetData0_1 = new VorbisFloor.Floor0.PacketData0();
   packetData0_1.BlockSize = blockSize;
   VorbisFloor.Floor0.PacketData0 packetData0_2 = packetData0_1;
   packetData0_2.Amp = (float) packet.ReadBits(this._ampBits);
   if ((double) packetData0_2.Amp > 0.0)
   {
     try
     {
       List<float> list = new List<float>();
       uint num = (uint) packet.ReadBits(this._bookBits);
       if ((long) num >= (long) this._books.Length)
         throw new InvalidDataException();
       VorbisCodebook vorbisCodebook = this._books[(IntPtr) num];
       for (int index1 = 0; index1 < this._order; ++index1)
       {
         int index2 = vorbisCodebook.DecodeScalar(packet);
         for (int index3 = 0; index3 < vorbisCodebook.Dimensions; ++index3)
           list.Add(vorbisCodebook[index2, index3]);
       }
       packetData0_2.Coeff = list.ToArray();
     }
     catch (EndOfStreamException ex)
     {
       packetData0_2.Amp = 0.0f;
     }
   }
   return (VorbisFloor.PacketData) packetData0_2;
 }