private static Recording ParseRecordLine(string line) { var parts = line.Split('\t'); var srate = int.Parse(parts[1]); var begin = RecordSetUtils.ParseTimeStamp(parts[2]); var end = RecordSetUtils.ParseTimeStamp(parts[3]); var rec = new Recording(parts[0], srate, begin, end); return(rec); }
public static Recording[] ReadRecords(string file) { if (!RecordSetUtils.IsValidRecordSet(file)) { throw new FormatException("Invalid file format for set"); } return(System.IO.File.ReadAllLines(file) .Skip(1) .Select(line => ParseRecordLine(line)) .ToArray()); }
public RecordSetWriter(string file) { if (!System.IO.File.Exists(file)) { RecordSetUtils.CreateNewFile(file); } else { if (!RecordSetUtils.IsValidRecordSet(file)) { throw new FormatException("Invalid file format for set"); } } File = file; }
public void AddRecord(Recording record) { var line = $"{record.Filename}\t{record.Samplerate}\t{RecordSetUtils.CreateTimeStamp(record.Begin)}\t{RecordSetUtils.CreateTimeStamp(record.End)}"; System.IO.File.AppendAllLines(File, new string[] { line }); }