public Note(NoteName name) { Note note = new Notes()[name]; _name = note.Name; _alias = note.Alias; _hertz = note.Hertz; _positions = note.Positions; }
/// <summary> /// Reads a sequence from a *.vgts file. /// </summary> /// <param name="fileName">The file's name (no extension).</param> /// <returns>Returns the sequence of that file.</returns> protected Sequence SequenceReader(string fileName) { //string songsFolderPath = _activity.Resources.GetString(Resource.String.SongsFolderPath); string[] sequenceLines = GetFileLinesFromAssets(fileName + SONG_FILE_EXTENSION, _activity.Assets); DiscardCommentsAndEmptyLines(ref sequenceLines); Sequence sequence = new Sequence(sequenceLines.Length); string[] lineSegments; Notes notesReference = new Notes(); for (int i = 0; i < sequenceLines.Length; i++) { string line = sequenceLines[i]; lineSegments = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); NoteName noteName; double delay, duration; bool isNoteName = NoteName.TryParse(lineSegments[0], out noteName); bool isDouble1 = double.TryParse(lineSegments[1], out delay); bool isDouble2 = double.TryParse(lineSegments[2], out duration); if (!(isNoteName && isDouble1 && isDouble2)) throw new Exception("Parsing segments of song file failed. " + "Only the following format is allowed: string double double. " + "And make sure the string name is spelled correctly."); Note note = notesReference[noteName]; if (i == 0) note = new Note(noteName, note.Positions[0], delay, duration); else note = new Note(noteName, CalculateClosestPositionFromPreviousNote(sequence[i - 1], note), delay, duration); sequence[i] = note; } return sequence; }