/// <summary> /// Initializes a new instance of the OscReader class based on the supplied stream. /// </summary> /// <param name="stream">a stream</param> /// <param name="mode">the format of the packets in the stream</param> public OscReader(Stream stream, OscPacketFormat mode) { this.BaseStream = stream; Format = mode; switch (Format) { case OscPacketFormat.Binary: binaryReader = new BinaryReader(this.BaseStream); break; case OscPacketFormat.Slip: binaryReader = new BinaryReader(this.BaseStream); slipReader = new Slip.SlipPacketReader(1024 * 8); slipByteCache = new byte[1024]; slipByteIndex = 0; slipByteCount = 0; break; case OscPacketFormat.String: stringReader = new StreamReader(this.BaseStream); break; default: throw new Exception($@"Invalid OSC stream format ""{Format}""."); } }
/// <summary> /// Initializes a new instance of the OscReader class based on the supplied stream. /// </summary> /// <param name="stream">a stream</param> /// <param name="mode">the format of the packets in the stream</param> public OscReader(Stream stream, OscPacketFormat mode) { m_Stream = stream; m_Format = mode; if (m_Format == OscPacketFormat.Binary) { m_BinaryReader = new BinaryReader(m_Stream); } else { m_StringReader = new StreamReader(m_Stream); } }
/// <summary> /// Initializes a new instance of the OscWriter class based on the supplied stream. /// </summary> /// <param name="stream">a stream</param> /// <param name="format">packet format</param> public OscWriter(Stream stream, OscPacketFormat format) { m_Stream = stream; m_Format = format; if (m_Format == OscPacketFormat.Binary) { m_BinaryWriter = new BinaryWriter(m_Stream); } else { m_StringWriter = new StreamWriter(m_Stream); } }
/// <summary> /// Initializes a new instance of the OscWriter class based on the supplied stream. /// </summary> /// <param name="stream">a stream</param> /// <param name="format">packet format</param> public OscWriter(Stream stream, OscPacketFormat format) { this.BaseStream = stream; this.Format = format; if (this.Format != OscPacketFormat.String) { binaryWriter = new BinaryWriter(this.BaseStream); } else { stringWriter = new StreamWriter(this.BaseStream); } }
public OscFileWriter(string filePath, FileMode fileMode, OscPacketFormat format) { file = new FileStream(filePath, fileMode, FileAccess.Write); writer = new OscWriter(file, format); }
public OscFileReader(string filePath, OscPacketFormat format) { file = new FileStream(filePath, FileMode.Open, FileAccess.Read); reader = new OscReader(file, format); }