Beispiel #1
0
        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);
        }
Beispiel #2
0
        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());
        }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        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 });
        }