Example #1
0
        public bool Equals(OscTimeTag value)
        {
            if ((object)value == null)
            {
                return(false);
            }

            return(timeStamp.Equals(value.timeStamp));
        }
Example #2
0
        public override bool Equals(object value)
        {
            if (value == null)
            {
                return(false);
            }

            OscTimeTag rhs = value as OscTimeTag;

            if (rhs == null)
            {
                return(false);
            }

            return(timeStamp.Equals(rhs.timeStamp));
        }
Example #3
0
        public static new OscBundle FromByteArray(byte[] data, ref int start, int end)
        {
            string address = ValueFromByteArray <string>(data, ref start);

            if (address != BUNDLE_PREFIX)
            {
                throw new ArgumentException();
            }

            OscTimeTag timeStamp = ValueFromByteArray <OscTimeTag>(data, ref start);
            OscBundle  bundle    = new OscBundle(timeStamp);

            while (start < end)
            {
                int length    = ValueFromByteArray <int>(data, ref start);
                int packetEnd = start + length;
                bundle.Append(OscPacket.FromByteArray(data, ref start, packetEnd));
            }

            return(bundle);
        }
Example #4
0
 public OscBundle(OscTimeTag timeStamp) : base(BUNDLE_PREFIX)
 {
     this.timeStamp = timeStamp;
 }
Example #5
0
 public static bool Equals(OscTimeTag lhs, OscTimeTag rhs)
 {
     return(lhs.Equals(rhs));
 }
Example #6
0
 public OscBundle(OscTimeTag timeStamp)
     : base(BUNDLE_PREFIX)
 {
     this.timeStamp = timeStamp;
 }
Example #7
0
        public static T ValueFromByteArray <T>(byte[] data, ref int start)
        {
            Type   type = typeof(T);
            object value;

            switch (type.Name)
            {
            case "String":
            {
                int count = 0;
                for (int index = start; index < data.Length && data[index] != 0; index++)
                {
                    count++;
                }

                value  = Encoding.ASCII.GetString(data, start, count);
                start += count + 1;
                start  = ((start + 3) / 4) * 4;
                break;
            }

            case "Byte[]":
            {
                int    length = ValueFromByteArray <int>(data, ref start);
                byte[] buffer = data.CopySubArray(start, length);

                value  = buffer;
                start += buffer.Length + 1;
                start  = ((start + 3) / 4) * 4;
                break;
            }

            case "OscTimeTag":
            {
                byte[] buffer = data.CopySubArray(start, 8);
                value  = new OscTimeTag(buffer);
                start += buffer.Length;
                break;
            }

            case "Char":
            {
                value = Convert.ToChar(ValueFromByteArray <int>(data, ref start));
                break;
            }

            default:
            {
                int bufferLength;
                switch (type.Name)
                {
                case "Int32":
                case "Single":
                    bufferLength = 4;
                    break;

                case "Int64":
                case "Double":
                    bufferLength = 8;
                    break;

                default:
                    throw new Exception("Unsupported data type.");
                }

                byte[] buffer = data.CopySubArray(start, bufferLength);
                start += buffer.Length;

                if (BitConverter.IsLittleEndian != littleEndianByteOrder)
                {
                    buffer = Utility.SwapEndian(buffer);
                }

                switch (type.Name)
                {
                case "Int32":
                    value = BitConverter.ToInt32(buffer, 0);
                    break;

                case "Int64":
                    value = BitConverter.ToInt64(buffer, 0);
                    break;

                case "Single":
                    value = BitConverter.ToSingle(buffer, 0);
                    break;

                case "Double":
                    value = BitConverter.ToDouble(buffer, 0);
                    break;

                default:
                    throw new Exception("Unsupported data type.");
                }
                break;
            }
            }

            return((T)value);
        }
Example #8
0
        public bool Equals(OscTimeTag value)
        {
            if ((object) value == null) {
                return false;
            }

            return timeStamp.Equals(value.timeStamp);
        }
Example #9
0
 public static bool Equals(OscTimeTag lhs, OscTimeTag rhs)
 {
     return lhs.Equals(rhs);
 }