/// <summary> /// Replaces the DurationSymbol symbolToBeReplaced (which is in this Voice's NoteObjects) /// by the all the noteObjects. Sets each of the noteObjects' Voice to this. /// </summary> public void Replace(DurationSymbol symbolToBeReplaced, List <NoteObject> noteObjects) { #region conditions M.Assert(symbolToBeReplaced != null && symbolToBeReplaced.Voice == this); #endregion conditions List <NoteObject> tempList = new List <NoteObject>(NoteObjects); this.NoteObjects.Clear(); int i = 0; while (tempList.Count > i && tempList[i] != symbolToBeReplaced) { NoteObjects.Add(tempList[i]); i++; } foreach (NoteObject noteObject in noteObjects) { noteObject.Voice = this; this.NoteObjects.Add(noteObject); } // tempList[i] is the symbolToBeReplaced i++; while (tempList.Count > i) { this.NoteObjects.Add(tempList[i]); i++; } tempList = null; }
/// <summary> /// Appends a clone of the noteObjects to this voice's NoteObjects /// (Sets each new noteObjects container to this.) /// </summary> /// <param name="noteObjects"></param> public void AppendNoteObjects(List <NoteObject> noteObjects) { foreach (NoteObject noteObject in noteObjects) { noteObject.Voice = this; NoteObjects.Add(noteObject); } }