Exemple #1
0
        void ValidateOverlap(UProject project, UNote note)
        {
            if (Error)
            {
                return;
            }
            float consonantStretch = (float)Math.Pow(2f, 1.0f - GetExpression(project, "vel").Item1 / 100f);

            overlap    = (float)oto.Overlap * consonantStretch * (overlapScale ?? 1);
            preutter   = (float)oto.Preutter * consonantStretch * (preutterScale ?? 1);
            overlapped = false;

            if (Prev == null)
            {
                return;
            }
            int   gapTick     = Parent.position + position - (Prev.Parent.position + Prev.End);
            float gapMs       = (float)project.TickToMillisecond(gapTick);
            float maxPreutter = preutter;

            if (gapMs <= 0)
            {
                // Keep at least half of last phoneme, or 10% if preutterScale is set.
                overlapped  = true;
                maxPreutter = (float)project.TickToMillisecond(Prev.Duration) * (preutterScale == null ? 0.5f : 0.9f);
            }
            else if (gapMs < preutter)
            {
                maxPreutter = gapMs;
            }
            if (preutter > maxPreutter)
            {
                float ratio = maxPreutter / preutter;
                preutter = maxPreutter;
                overlap *= ratio;
            }
            preutter         = Math.Max(0, preutter);
            overlap          = Math.Min(overlap, preutter);
            Prev.tailIntrude = overlapped ? preutter : 0;
            Prev.tailOverlap = overlapped ? overlap : 0;
            Prev.ValidateEnvelope(project, Prev.Parent);
            if (Next == null)
            {
                tailIntrude = 0;
                tailOverlap = 0;
            }
        }