Ejemplo n.º 1
0
 public static BPMS Parse (string raw) {
     BPMS result = new BPMS();
     MatchCollection matches = BPMSRegex.Matches(raw);
     foreach (Match m in matches) {
         result.data.Add(new Data(
             float.Parse(m.Groups[1].Value),
             float.Parse(m.Groups[2].Value)
         ));
         if (result.data.Count == 1) {
             if (result.data[0].beat != 0.0f) {
                 throw new FormatException("First BPM must be at beat zero");
             }
         }
     }
     return result;
 }
Ejemplo n.º 2
0
 public static Chart Parse (IEnumerator etor, BPMS default_bpms) {
     Chart result = new Chart();
     while (etor.MoveNext()) {
         Match m = (Match)etor.Current;
         string key = m.Groups[1].Value;
         string val = m.Groups[2].Value;
         if (key == KEY_NOTES) {
             result.measures = Measure.ParseMeasures(val);
             break;
         }
         if (key == KEY_BPMS) {
             result.bpms = BPMS.Parse(val);
         }
         if (key == KEY_DELAYS) {
             result.delays = DELAYS.Parse(val);
         }
         if (key == KEY_STOPS && val != string.Empty) {
             throw new NotImplementedException();
         }
         if (key == KEY_WARPS && val != string.Empty) {
             result.warps = WARPS.Parse(val);
         }
         if (key == KEY_OFFSET) {
             result.offset = float.Parse(val);
         }
         result.raw_data.Add(key, val);
     }
     if (result.bpms.data.Count == 0) {
         result.bpms = default_bpms;
     }
     result.calculateHoldBodies();
     result.total_second = CalculateTimes(
         result.offset,
         result.measures,
         new List<BPMS.Data>(result.bpms.data),
         new List<DELAYS.Data>(result.delays.data),
         new List<WARPS.Data>(result.warps.data)
     );
     return result;
 }