Esempio n. 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);
        }
Esempio n. 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());
        }
Esempio n. 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;
        }
Esempio n. 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 });
        }