示例#1
0
        public static ProcessResultArray <Clip> Apply(ScaleOptions options, params Clip[] clips)
        {
            if (options.By != null)
            {
                clips = clips.Prepend(options.By).ToArray();
            }
            ClipUtilities.NormalizeClipLengths(clips);
            if (clips.Length < 2)
            {
                return(new ProcessResultArray <Clip>(clips));
            }
            var masterClip     = clips[0];
            var slaveClips     = clips.Skip(1).ToArray();
            var processedClips = slaveClips.Select(c => new Clip(c.Length, c.IsLooping)).ToArray();

            for (var i = 0; i < slaveClips.Length; i++)
            {
                var slaveClip = slaveClips[i];
                foreach (var note in slaveClip.Notes)
                {
                    var constrainedNote = new NoteEvent(note);
                    constrainedNote.Pitch = options.Strict ?
                                            ClipUtilities.FindNearestNotePitchInSet(note, masterClip.Notes) :
                                            ClipUtilities.FindNearestNotePitchInSetMusical(note, masterClip.Notes);
                    processedClips[i].Notes.Add(constrainedNote);
                }
            }
            return(new ProcessResultArray <Clip>(processedClips));
        }
示例#2
0
        public static ProcessResultArray <Clip> Apply(ScaleOptions options, params Clip[] clips)
        {
            if (options.By != null)
            {
                clips = clips.Prepend(options.By).ToArray();
            }
            ClipUtilities.NormalizeClipLengths(clips);
            if (clips.Length < 2)
            {
                return(new ProcessResultArray <Clip>(clips));
            }
            var masterClip     = clips[0];
            var slaveClips     = clips.Skip(1).ToArray();
            var processedClips = slaveClips.Select(c => new Clip(c.Length, c.IsLooping)).ToArray();

            for (var i = 0; i < slaveClips.Length; i++)
            {
                var slaveClip = slaveClips[i];
                foreach (var note in slaveClip.Notes)
                {
                    var masterNotes = SortedList <NoteEvent> .Empty;
                    if (options.PositionAware)
                    {
                        masterNotes = masterClip.Notes.Where(x => x.InsideIntervalInclusive(note.Start, note.End)).ToSortedList();
                    }
                    if (masterNotes.Count == 0)
                    {
                        masterNotes = masterClip.Notes;
                    }

                    var constrainedNote = new NoteEvent(note);
                    constrainedNote.Pitch = options.Strict ?
                                            ClipUtilities.FindNearestNotePitchInSet(note, masterNotes) :
                                            ClipUtilities.FindNearestNotePitchInSetMusical(note, masterNotes);
                    processedClips[i].Notes.Add(constrainedNote);
                }
            }
            return(new ProcessResultArray <Clip>(processedClips));
        }