コード例 #1
0
ファイル: DataTypes.cs プロジェクト: osherbakov/MELPeModem
 public int Process(byte incomingBit)
 {
     DataArray[CurrentInIndex++] += (byte)((incomingBit == 0) ? -1 : 1); if (CurrentInIndex >= MaxBits)
     {
         CurrentInIndex = 0;
     }
     CurrentBGCounter--;
     if (CurrentBGCounter <= 0)
     {
         BitGroup bg = BGArray[CurrentBitGroupIndex++]; if (CurrentBitGroupIndex >= MaxBitGroupIndex)
         {
             CurrentBitGroupIndex = 0;
         }
         CurrentInIndex = CurrentFrame - bg.Position; if (CurrentInIndex < 0)
         {
             CurrentInIndex += MaxBits;
         }
         CurrentBGCounter = bg.Size;
     }
     CurrentInCounter++;
     if (CurrentInCounter >= NumBitsIn)
     {
         CurrentInCounter = 0;
         // Output data
         for (int i = 0; i < NumBitsOut; i++)
         {
             OutputData.Add((byte)((DataArray[CurrentFrame++] > 0) ? 1 : 0)); if (CurrentFrame >= MaxBits)
             {
                 CurrentFrame = 0;
             }
         }
         Array.Clear(DataArray, CurrentFrame, NumBitsOut);
     }
     return(this.OutputData.Count);
 }
コード例 #2
0
ファイル: DataTypes.cs プロジェクト: osherbakov/MELPeModem
        public override void Init()
        {
            Array.Clear(DataArray, 0, MaxBits);
            OutputData.Clear();
            CurrentBitGroupIndex = 0;
            CurrentInCounter     = 0;
            CurrentFrame         = 0;
            BitGroup bg = BGArray[CurrentBitGroupIndex++];

            CurrentInIndex = CurrentFrame - bg.Position; if (CurrentInIndex < 0)
            {
                CurrentInIndex += MaxBits;
            }
            CurrentBGCounter = bg.Size;
        }
コード例 #3
0
ファイル: DataTypes.cs プロジェクト: osherbakov/MELPeModem
 public void Process(CNTRL_MSG controlParam, byte incomingBit)
 {
     if (controlParam == CNTRL_MSG.DATA_IN)
     {
         DataArray[CurrentInIndex++] += (byte)((incomingBit == 0) ? -1 : 1); if (CurrentInIndex >= MaxBits)
         {
             CurrentInIndex = 0;
         }
         CurrentBGCounter--;
         if (CurrentBGCounter <= 0)
         {
             BitGroup bg = BGArray[CurrentBitGroupIndex++]; if (CurrentBitGroupIndex >= MaxBitGroupIndex)
             {
                 CurrentBitGroupIndex = 0;
             }
             CurrentInIndex = CurrentFrame - bg.Position; if (CurrentInIndex < 0)
             {
                 CurrentInIndex += MaxBits;
             }
             CurrentBGCounter = bg.Size;
         }
         CurrentInCounter++;
         if (CurrentInCounter >= NumBitsIn)
         {
             CurrentInCounter = 0;
             // Output data
             for (int i = 0; i < NumBitsOut; i++)
             {
                 DataOut.Process((byte)((DataArray[CurrentFrame++] > 0) ? 1 : 0)); if (CurrentFrame >= MaxBits)
                 {
                     CurrentFrame = 0;
                 }
             }
             Array.Clear(DataArray, CurrentFrame, NumBitsOut);
         }
     }
 }