/// <summary> /// Serializes the Header to the specified buffer. /// </summary> /// <param name="buf">The buffer to write the serialized header to.</param> public void Serialize(ByteBuffer buf) { buf.PutInt(NumChans); buf.PutInt(NumSamples); buf.PutInt(NumEvents); buf.PutFloat(FSample); buf.PutInt(DataType); if (ChannelNameSize <= NumChans) { // channel names are all empty or array length does not match buf.PutInt(0); } else { buf.PutInt(8 + ChannelNameSize); // 8 bytes for chunk def buf.PutInt(CHUNK_CHANNEL_NAMES); buf.PutInt(ChannelNameSize); for (int i = 0; i < NumChans; i++) { if (Labels[i] != null) buf.PutString(Labels[i]); buf.PutByte((byte)0); } } }