private Staff ReadTokens(Staff staff, string content) { string[] splitContent = content.Split(' '); string lastPitch = ""; for (int i = 0; i < splitContent.Length; i++) { string s = splitContent[i]; switch (s) { case "\\relative": i++; string relative = splitContent[i]; relativeOctave = 3 + relative.Count(x => x == '\'') - relative.Count(x => x == ','); staff.SetRelativeOctave(relativeOctave); lastPitch = relative[0].ToString(); break; case "\\clef": i++; staff.SetClef(splitContent[i]); break; case "\\time": i++; string time = splitContent[i]; var times = time.Split('/'); staff.SetBar((int)UInt32.Parse(times[0]), (int)UInt32.Parse(times[1])); break; case "\\tempo": i++; string tempoText = splitContent[i]; var tempo = tempoText.Split('='); staff.SetTempo((int)UInt32.Parse(tempo[1])); break; case "|": staff.AddBar(); break; default: if (s.Length != 0) { NoteRestFactory factory = NoteRestFactory.getFactory(s[0]); if (factory != null) { int length; int dots; getInfo(s, ref lastPitch, out length, out dots); staff.AddNote(factory.create(lastPitch, relativeOctave + 1, length, dots)); } } break; } } return(staff); }