public Tuning(Instrument instrument, XmlNode tuningNode) { if (null == instrument) { throw new ArgumentNullException("instrument"); } if (null == tuningNode) { throw new ArgumentNullException("tuningNode"); } this.Instrument = instrument; this.Name = tuningNode.Attributes["name"].Value; string notes = tuningNode.Attributes["notes"].Value; string[] s = notes.Split(';'); Note[] rootNotes = new Note[s.Length]; if (rootNotes.Length != instrument.NumStrings) { throw new ArgumentOutOfRangeException(); } for (int i = 0; i < rootNotes.Length; i++) { rootNotes[i] = NoteUtils.ParseNote(s[i]); } this.RootNotes = rootNotes; }
public static FullNote Parse(string s) { if (StringUtils.IsNullOrWhiteSpace(s)) { throw new ArgumentNullException(nameof(s)); } s = s.Trim(); int splitIndex = s.IndexOfAny(digits); if (splitIndex <= 0) { throw new ArgumentException(Strings.InvalidNoteArgumentExceptionMessage); } string notePortion = s.Substring(0, splitIndex); string octavePortion = s.Substring(splitIndex); Note note = NoteUtils.ParseNote(notePortion); int octave = int.Parse(octavePortion); return(new FullNote(note, octave)); }