public Osufile(Stream stream) { var ms = new MemoryStream(); stream.CopyTo(ms); string[] osuString = Encoding.UTF8.GetString(ms.ToArray()).Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); ParseMode mode = ParseMode.None; foreach (var line in osuString) { if (mode != ParseMode.None) { switch (mode) { case ParseMode.General: ParseGeneral(line); break; case ParseMode.Metadata: ParseMetadata(line); break; case ParseMode.Difficulty: ParseDifficulty(line); break; case ParseMode.TimingPoints: ParseTimingPoint(line); break; case ParseMode.HitObjects: ParseHitObject(line); break; default: break; } } if (line.Contains("[General]")) { mode = ParseMode.General; } else if (line.Contains("[Metadata]")) { mode = ParseMode.Metadata; } else if (line.Contains("[Difficulty]")) { mode = ParseMode.Difficulty; } else if (line.Contains("[TimingPoints]")) { mode = ParseMode.TimingPoints; } else if (line.Contains("[HitObjects]")) { mode = ParseMode.HitObjects; } else if (line.Contains("[Colours]")) { mode = ParseMode.None; } else if (line.Contains("[Events]")) { mode = ParseMode.None; } else if (line.Contains("[Editor]")) { mode = ParseMode.None; } else if (line.Length < 0) { mode = ParseMode.None; } } TimingPoint initialTimingPoint = new TimingPoint(0f, timingPoints[0].beatTime, timingPoints[0].vol, false, false); initialTimingPoint.meter = timingPoints[0].meter; timingPoints.Insert(0, initialTimingPoint); FixFirstTimingPoint(timingPoints); MergeTimingPoints(); CalculateSliderEndTimes(); CalculateAudicaTicks(); DetectStreams(); }