public override byte[] ToBytes() { var bytes = new byte[4 + CalculatePaddedArrayLength(Value.Length)]; var valueLengthBytes = new OscInt(Value.Length).ToBytes(); Array.Copy(valueLengthBytes, 0, bytes, 0, 4); Array.Copy(Value, 0, bytes, 4, Value.Length); return(bytes); }
public static byte[] GetValue(ref byte[] bytes) { var length = OscInt.GetValue(ref bytes); var valueBytes = bytes.Take(length).ToArray(); var paddedLength = CalculatePaddedArrayLength(length, false); bytes = bytes.Skip(paddedLength).ToArray(); return(valueBytes); }
public static OscValue FromBytes(char tag, ref byte[] bytes) { switch (tag) { case 'i': return(OscInt.FromBytes(ref bytes)); case 'f': return(OscFloat.FromBytes(ref bytes)); case 's': return(OscString.FromBytes(ref bytes)); case 'b': return(OscBlob.FromBytes(ref bytes)); default: throw new OscException($"Unable to read OSC argument with tag '{tag}'."); } }