Exemplo n.º 1
0
 //[TestMethod]
 public void MyTestMethod()
 {
     for (var i = 10; i < 36; i += 5)
     {
         Console.WriteLine($"pitch {i} nearest: {ClipUtilities.FindNearestNotePitchInSet(i, new int[] { 0,12,24,32 })}");
     }
 }
Exemplo n.º 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 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));
        }
Exemplo n.º 3
0
    public static ProcessResult <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 ProcessResult <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.StartsInsideIntervalInclusive(note.Start, note.End) || x.CoversInterval(note.Start, note.End)).ToSortedList();
                }
                if (masterNotes.Count == 0)
                {
                    masterNotes = masterClip.Notes;
                }

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