Example #1
0
        private static Clip DoRatchet(Clip controlSequence, Clip targetSequence, float scaleFactor, bool scaleWithVelocity, Shape shape, RatchetMode mode)
        {
            var result      = new Clip(targetSequence.Length, targetSequence.IsLooping);
            var curvePoints = GetCurvePoints(scaleFactor, shape);

            foreach (var controlNote in controlSequence.Notes)
            {
                // treating these modes the same for now - but can optionally match pitch as well when RatchetMode.Velocity is set
//                if (mode == RatchetMode.Pitch)
//                {
                var targetNotes = targetSequence.Notes.Where(x => x.StartsInsideIntervalInclusive(controlNote.Start, controlNote.End) && x.Start != -1).ToList();
//                } else // velocity - pitch need to be taken into account as well
//                {
//                    targetNotes = targetSequence.Notes.Where(x => x.StartsInsideInterval(controlNote.Start, controlNote.End) && x.Pitch == controlNote.Pitch).ToList();
//                }
                targetNotes.ForEach(note =>
                {
                    var ratchetCount = mode == RatchetMode.Pitch ?
                                       controlNote.Pitch :
                                       controlNote.Velocity;
                    AddRatchets(result, note, ratchetCount, scaleWithVelocity, curvePoints, note.Velocity / 127m);
                });
            }

            return(result);
        }
Example #2
0
        private static Clip DoManualRatchet(IReadOnlyList <int> ratchetValues, Clip targetSequence, decimal scaleFactor, bool scaleWithVelocity, Shape shape, RatchetMode mode)
        {
            var result      = new Clip(targetSequence.Length, targetSequence.IsLooping);
            var curvePoints = GetCurvePoints((float)scaleFactor, shape);

            for (var i = 0; i < targetSequence.Notes.Count; i++)
            {
                AddRatchets(result, targetSequence.Notes[i], ratchetValues[i % ratchetValues.Count], scaleWithVelocity, curvePoints, scaleFactor);
            }
            return(result);
        }