private int WriteAnnotation(TAL annotations) { #if TRACE_BYTES Console.WriteLine("Write position before annotation: " + this.BaseStream.Position); #endif var bytesToWrite = TALExtensions.GetBytes(annotations); #if TRACE_BYTES Console.WriteLine("Bytes to write: " + bytesToWrite.Length); #endif this.Write(bytesToWrite); #if TRACE_BYTES Console.WriteLine("Write position after annotation: " + this.BaseStream.Position); #endif return(bytesToWrite.Length); }
/// <summary> /// Returns a byte array witch represent a TAL format according to /// https://www.edfplus.info/specs/edfplus.html#annotationssignal section 2.2.2. /// </summary> /// <param name="tal"></param> /// <returns></returns> public static byte[] GetBytes(this TAL tal) { List <byte> result = new List <byte>(); result.AddRange(Encoding.ASCII.GetBytes(tal.StartSecondsString)); if (tal.DurationSecondsString != null) { result.Add(TAL.byte_21); //15 in HEX result.AddRange(Encoding.ASCII.GetBytes(tal.DurationSecondsString)); } result.Add(TAL.byte_20); result.AddRange(Encoding.ASCII.GetBytes(tal.AnnotationDescription)); result.Add(TAL.byte_20); result.Add(TAL.byte_0); return(result.ToArray()); }