Пример #1
0
        /// <summary>
        /// Returns a deep clone of this TrkDef.
        /// </summary>
        public TrkDef DeepClone()
        {
            List <IUniqueDef> clonedLmdds = new List <IUniqueDef>();

            foreach (IUniqueDef iu in this._uniqueDefs)
            {
                IUniqueDef clone = iu.DeepClone();
                clonedLmdds.Add(clone);
            }

            // Clefchange symbols must point at the following object in their own VoiceDef
            for (int i = 0; i < clonedLmdds.Count; ++i)
            {
                ClefChangeDef clone = clonedLmdds[i] as ClefChangeDef;
                if (clone != null)
                {
                    Debug.Assert(i < (clonedLmdds.Count - 1));
                    ClefChangeDef replacement = new ClefChangeDef(clone.ClefType, clonedLmdds[i + 1]);
                    clonedLmdds.RemoveAt(i);
                    clonedLmdds.Insert(i, replacement);
                }
            }

            return(new TrkDef(this.MidiChannel, clonedLmdds));
        }
Пример #2
0
        /// <summary>
        /// For an example of using this function, see SongSixAlgorithm.cs
        /// Note that clef changes must be inserted backwards per voiceDef, so that IUniqueDef indices are correct.
        /// Inserting a clef change changes the subsequent indices.
        /// Note also that if a ClefChange is defined here on a UniqueMidiRestDef which has no MidiChordDef
        /// to its right on the staff, the resulting ClefSymbol will be placed immediately before the final barline
        /// on the staff.
        /// ClefChanges which would happen at the beginning of a staff are moved to the end of the equivalent staff
        /// in the previous system.
        /// A ClefChange defined here on a MidiChordDef or UniqueMidiRestDef which is eventually preceded
        /// by a barline, are placed to the left of the barline.
        /// The clefType must be one of the following strings "t", "t1", "t2", "t3", "b", "b1", "b2", "b3"
        /// </summary>
        public void InsertClefChange(int index, string clefType)
        {
            #region check args
            Debug.Assert(index < _uniqueDefs.Count);
            if (String.Equals(clefType, "t") == false &&
                String.Equals(clefType, "t1") == false &&
                String.Equals(clefType, "t2") == false &&
                String.Equals(clefType, "t3") == false &&
                String.Equals(clefType, "b") == false &&
                String.Equals(clefType, "b1") == false &&
                String.Equals(clefType, "b2") == false &&
                String.Equals(clefType, "b3") == false)
            {
                Debug.Assert(false, "Unknown clef type.");
            }
            #endregion

            ClefChangeDef clefChangeDef = new ClefChangeDef(clefType, _uniqueDefs[index]);
            _uniqueDefs.Insert(index, clefChangeDef);
        }
Пример #3
0
        /// <summary>
        /// ACHTUNG: The clone points at the same _followingChordOrRestDef as the original.
        /// This is not usually what is wanted. After cloning a VoiceDef, the cloned
        /// ClefChangeDefs should be replaced. See VoiceDef.Clone().
        /// </summary>
        /// <returns></returns>
        public IUniqueDef DeepClone()
        {
            ClefChangeDef deepClone = new ClefChangeDef(this._clefType, this._followingChordOrRestDef);

            return(deepClone);
        }
Пример #4
0
 public object Clone()
 {
     ClefChangeDef deepClone = new ClefChangeDef(_clefType, MsPositionReFirstUD);
     return deepClone;
 }
Пример #5
0
 /// <summary>
 /// ACHTUNG: The clone points at the same _followingChordOrRestDef as the original.
 /// This is not usually what is wanted. After cloning a VoiceDef, the cloned
 /// ClefChangeDefs should be replaced. See VoiceDef.Clone().
 /// </summary>
 /// <returns></returns>
 public IUniqueDef DeepClone()
 {
     ClefChangeDef deepClone = new ClefChangeDef(this._clefType, this._followingChordOrRestDef);
     return deepClone;
 }
Пример #6
0
        /// <summary>
        /// Returns a deep clone of this InputVoiceDef.
        /// </summary>
        public InputVoiceDef DeepClone()
        {
            List<IUniqueDef> clonedLmdds = new List<IUniqueDef>();
            foreach(IUniqueDef iu in this._uniqueDefs)
            {
                IUniqueDef clone = iu.DeepClone();
                clonedLmdds.Add(clone);
            }

            // Clefchange symbols must point at the following object in their own VoiceDef
            for(int i = 0; i < clonedLmdds.Count; ++i)
            {
                ClefChangeDef clone = clonedLmdds[i] as ClefChangeDef;
                if(clone != null)
                {
                    Debug.Assert(i < (clonedLmdds.Count - 1));
                    ClefChangeDef replacement = new ClefChangeDef(clone.ClefType, clonedLmdds[i + 1]);
                    clonedLmdds.RemoveAt(i);
                    clonedLmdds.Insert(i, replacement);
                }
            }

            return new InputVoiceDef(clonedLmdds);
        }