Esempio n. 1
0
        /// <summary>
        /// Returns a list having the position and duration of the originalRest.
        /// The iLmdds have been put in(side) the original rest, either at the beginning, middle, or end.
        /// </summary>
        private List <IUniqueDef> GetReplacementList(IUniqueDef originalRest, VoiceDef iVoiceDef)
        {
            Debug.Assert(originalRest is RestDef);
            Debug.Assert(iVoiceDef[0] is MidiChordDef || iVoiceDef[0] is InputChordDef);
            Debug.Assert(iVoiceDef[iVoiceDef.Count - 1] is MidiChordDef || iVoiceDef[iVoiceDef.Count - 1] is InputChordDef);

            List <IUniqueDef> rList = new List <IUniqueDef>();

            if (iVoiceDef[0].MsPosition > originalRest.MsPosition)
            {
                RestDef rest1 = new RestDef(originalRest.MsPosition, iVoiceDef[0].MsPosition - originalRest.MsPosition);
                rList.Add(rest1);
            }
            rList.AddRange(iVoiceDef.UniqueDefs);
            int iLmddsEndMsPos       = iVoiceDef[iVoiceDef.Count - 1].MsPosition + iVoiceDef[iVoiceDef.Count - 1].MsDuration;
            int originalRestEndMsPos = originalRest.MsPosition + originalRest.MsDuration;

            if (originalRestEndMsPos > iLmddsEndMsPos)
            {
                RestDef rest2 = new RestDef(iLmddsEndMsPos, originalRestEndMsPos - iLmddsEndMsPos);
                rList.Add(rest2);
            }

            return(rList);
        }
Esempio n. 2
0
        protected void _InsertRange(int index, VoiceDef voiceDef)
        {
            M.Assert(!(Container is Bar), "Cannot Insert range of IUniqueDefs inside a Bar.");

            _uniqueDefs.InsertRange(index, voiceDef.UniqueDefs);
            SetMsPositionsReFirstUD();

            AssertConsistency();
        }
Esempio n. 3
0
        /// <summary>
        /// This function __moves__ the voiceDef's UniqueDefs to the end of this voiceDef's UniqueDefs _without_cloning_them_ (c.f. Trk.ConcatCloneAt(...) ).
        /// Rests are automatically agglommerated.
        /// </summary>
        protected void _AddRange(VoiceDef voiceDef)
        {
            M.Assert(!(Container is Bar), "Cannot AddRange of VoiceDefs inside a Bar.");

            _uniqueDefs.AddRange(voiceDef.UniqueDefs);

            AgglomerateRests();

            SetMsPositionsReFirstUD();

            AssertConsistency();
        }
Esempio n. 4
0
        private void InsertVoiceDefInRest(int restIndex, VoiceDef iVoiceDef)
        {
            List <IUniqueDef> lmdds       = _uniqueDefs;
            IUniqueDef        rest        = lmdds[restIndex];
            List <IUniqueDef> replacement = GetReplacementList(rest, iVoiceDef);
            int replacementStart          = replacement[0].MsPosition;
            int replacementEnd            = replacement[replacement.Count - 1].MsPosition + replacement[replacement.Count - 1].MsDuration;
            int restStart = rest.MsPosition;
            int restEnd   = rest.MsPosition + rest.MsDuration;

            Debug.Assert(restStart == replacementStart && restEnd == replacementEnd);
            lmdds.RemoveAt(restIndex);
            lmdds.InsertRange(restIndex, replacement);
        }
Esempio n. 5
0
        protected void _InsertInRest(VoiceDef iVoiceDef)
        {
            int iLmddsStartMsPos = iVoiceDef[0].MsPosition;
            int iLmddsEndMsPos   = iVoiceDef[iVoiceDef.Count - 1].MsPosition + iVoiceDef[iVoiceDef.Count - 1].MsDuration;

            int restIndex = FindIndexOfSpanningRest(iLmddsStartMsPos, iLmddsEndMsPos);

            // if index >= 0, it is the index of a rest into which the chord will fit.
            if (restIndex >= 0)
            {
                InsertVoiceDefInRest(restIndex, iVoiceDef);
                SetMsPositions(); // just to be sure!
            }
            else
            {
                Debug.Assert(false, "Can't find a rest spanning the chord!");
            }
        }
Esempio n. 6
0
 internal void SetToRange(VoiceDef argVoiceDef, int startMsPosReSeq, int endMsPosReSeq)
 {
     _uniqueDefs.Clear();
     foreach (IUniqueDef iud in argVoiceDef)
     {
         int msPos = iud.MsPositionReFirstUD;
         if (msPos < startMsPosReSeq)
         {
             continue;
         }
         if (msPos >= endMsPosReSeq)
         {
             break;
         }
         _uniqueDefs.Add(iud);
     }
     //SetMsPositionsReFirstUD();
 }
Esempio n. 7
0
        public void Concat(Bar bar2)
        {
            M.Assert(_voiceDefs.Count == bar2._voiceDefs.Count);

            for (int i = 0; i < _voiceDefs.Count; ++i)
            {
                VoiceDef vd1 = _voiceDefs[i];
                VoiceDef vd2 = bar2._voiceDefs[i];

                vd1.Container = null;
                vd2.Container = null;
                vd1.AddRange(vd2);
                vd1.RemoveDuplicateClefDefs();
                vd1.AgglomerateRests();
                vd1.Container = this;
            }

            AssertConsistency();
        }
Esempio n. 8
0
 protected void _InsertRange(int index, VoiceDef voiceDef)
 {
     _uniqueDefs.InsertRange(index, voiceDef.UniqueDefs);
     SetMsPositions();
 }
Esempio n. 9
0
 protected void _AddRange(VoiceDef voiceDef)
 {
     _uniqueDefs.AddRange(voiceDef.UniqueDefs);
     SetMsPositions();
 }
Esempio n. 10
0
 public abstract void AddRange(VoiceDef voiceDef);