コード例 #1
0
        public static ProcessResultArray <Clip> ProcessCommand(Command command, Clip[] incomingClips, ClipMetaData targetMetadata)
        {
            var clips = new Clip[incomingClips.Length];

            for (var i = 0; i < incomingClips.Length; i++)
            {
                clips[i] = new Clip(incomingClips[i]);
            }

            return(command.Id switch
            {
                TokenType.Arpeggiate => Arpeggiate.Apply(command, clips),
                TokenType.Concat => Concat.Apply(clips),
                TokenType.Crop => Crop.Apply(command, clips),
                TokenType.Filter => Filter.Apply(command, clips),
                TokenType.Interleave => Interleave.Apply(command, targetMetadata, clips),
                TokenType.Legato => Legato.Apply(clips),
                TokenType.Mask => Mask.Apply(command, clips),
                TokenType.Monophonize => Monophonize.Apply(clips),
                TokenType.Padding => Padding.Apply(command, clips),
                TokenType.Quantize => Quantize.Apply(command, clips),
                TokenType.Ratchet => Ratchet.Apply(command, clips),
                TokenType.Relength => Relength.Apply(command, clips),
                TokenType.Remap => Remap.Apply(command, clips),
                TokenType.Resize => Resize.Apply(command, clips),
                TokenType.Scale => Scale.Apply(command, clips),
                TokenType.Scan => Scan.Apply(command, clips),
                TokenType.SetLength => SetLength.Apply(command, clips),
                TokenType.SetPitch => SetPitch.Apply(command, clips),
                TokenType.SetRhythm => SetRhythm.Apply(command, clips),
                TokenType.Shuffle => Shuffle.Apply(command, clips),
                TokenType.Skip => Skip.Apply(command, clips),
                TokenType.Slice => Slice.Apply(command, clips),
                TokenType.Take => Take.Apply(command, clips),
                TokenType.Transpose => Transpose.Apply(command, clips),
                TokenType.VelocityScale => VelocityScale.Apply(command, clips),
                TokenType.InterleaveEvent => ((Func <ProcessResultArray <Clip> >)(() =>
                {
                    var(success, msg) = OptionParser.TryParseOptions(command, out InterleaveOptions options);
                    if (!success)
                    {
                        return new ProcessResultArray <Clip>(msg);
                    }

                    options.Mode = InterleaveMode.Event;
                    return Interleave.Apply(options, targetMetadata, clips);
                }))(),
                _ => new ProcessResultArray <Clip>($"Unsupported command {command.Id}")
            });
コード例 #2
0
 //[Test]
 public void TestShuffleComplex()
 {
     var clip   = IOUtilities.StringToClip("8 True 36 0.00000 0.25000 100 39 0.00000 0.25000 100 42 0.25000 0.25000 100 41 0.50000 0.25000 100 36 0.75000 0.25000 100 39 0.75000 0.25000 100 38 1.00000 0.25000 100 39 1.25000 0.25000 100 42 1.50000 0.25000 100 38 1.75000 0.25000 100 42 2.00000 0.25000 100 38 2.50000 0.25000 100 50 2.50000 0.75000 100 42 3.00000 0.25000 100 38 3.25000 0.25000 100 50 3.25000 0.50000 100 36 4.00000 0.25000 100 39 4.00000 0.25000 100 42 4.25000 0.25000 100 41 4.50000 0.25000 100 36 4.75000 0.25000 100 39 4.75000 0.25000 100 38 5.00000 0.25000 100 42 5.25000 0.25000 100 39 5.50000 0.25000 100 38 5.75000 0.25000 100 42 6.00000 0.25000 100 48 6.25000 0.25000 100 38 6.50000 0.25000 100 37 6.75000 0.25000 100 42 7.00000 0.25000 100 48 7.25000 0.25000 100 44 7.50000 0.25000 100 38 7.75000 0.25000 100");
     var byClip = new Clip(4, true)
     {
         Notes = new SortedList <NoteEvent>()
         {
             new NoteEvent(40, 0, .5m, 100),
             new NoteEvent(49, 1, .5m, 100),
             new NoteEvent(50, 2, .5m, 100)
         }
     };
     var resultObj = Shuffle.Apply(new ShuffleOptions()
     {
         By = byClip
     }, clip);
 }
コード例 #3
0
    public static ProcessResult <Clip[]> ProcessCommand(Command command, Clip[] incomingClips, ClipMetaData targetMetadata)
    {
        var clips = new Clip[incomingClips.Length];

        for (var i = 0; i < incomingClips.Length; i++)
        {
            clips[i] = new Clip(incomingClips[i]);
        }

        return(command.Id switch
        {
            TokenType.Arpeggiate => Arpeggiate.Apply(command, clips),
            TokenType.Concat => Concat.Apply(clips),
            TokenType.Crop => Crop.Apply(command, clips),
            TokenType.Echo => Echo.Apply(command, clips),
            TokenType.Extract => Take.Apply(command, clips, true),
            TokenType.Filter => Filter.Apply(command, clips),
            TokenType.Invert => Invert.Apply(command, clips),
            TokenType.Interleave => Interleave.Apply(command, targetMetadata, clips, InterleaveMode.NotSpecified),
            TokenType.InterleaveEvent => Interleave.Apply(command, targetMetadata, clips, InterleaveMode.Event),
            TokenType.Legato => Legato.Apply(clips),
            TokenType.Loop => Loop.Apply(command, clips),
            TokenType.Mask => Mask.Apply(command, clips),
            TokenType.Monophonize => Monophonize.Apply(clips),
            TokenType.Padding => Padding.Apply(command, clips),
            TokenType.Quantize => Quantize.Apply(command, clips),
            TokenType.Ratchet => Ratchet.Apply(command, clips),
            TokenType.Relength => Relength.Apply(command, clips),
            TokenType.Remap => Remap.Apply(command, clips),
            TokenType.Resize => Resize.Apply(command, clips),
            TokenType.Scale => Scale.Apply(command, clips),
            TokenType.Scan => Scan.Apply(command, clips),
            TokenType.SetLength => SetLength.Apply(command, clips),
            TokenType.SetPitch => SetPitch.Apply(command, clips),
            TokenType.SetRhythm => SetRhythm.Apply(command, clips),
            TokenType.Shuffle => Shuffle.Apply(command, clips),
            TokenType.Skip => Skip.Apply(command, clips),
            TokenType.Slice => Slice.Apply(command, clips),
            TokenType.Take => Take.Apply(command, clips),
            TokenType.Transpose => Transpose.Apply(command, clips),
            TokenType.VelocityScale => VelocityScale.Apply(command, clips),
            _ => new ProcessResult <Clip[]>($"Unsupported command {command.Id}")
        });
コード例 #4
0
    public void TestShuffleGrouped()
    {
        var clip = new Clip(4, true)
        {
            Notes = new SortedList <NoteEvent>()
            {
                new NoteEvent(60, 0, .5m, 100),
                new NoteEvent(61, .5m, .5m, 100),
                new NoteEvent(62, 1, .5m, 100),
                new NoteEvent(63, 1.5m, .5m, 100),
                new NoteEvent(64, 2, .5m, 100),
                new NoteEvent(65, 2.5m, 1.5m, 100),
                new NoteEvent(70, 2.5m, .5m, 100),
                new NoteEvent(66, 3m, .5m, 100)
            }
        };
        var byClip = new Clip(4, true)
        {
            Notes = new SortedList <NoteEvent>()
            {
                new NoteEvent(40, 0, .5m, 100),
                new NoteEvent(44, 1, .5m, 100),
                new NoteEvent(40, 2, .5m, 100)
            }
        };
        var resultObj = Shuffle.Apply(new ShuffleOptions()
        {
            By = byClip
        }, clip);

        Assert.IsTrue(resultObj.Success);
        var result = resultObj.Result[0];

        Assert.AreEqual(60, result.Notes[0].Pitch);
        Assert.AreEqual(65, result.Notes[1].Pitch);
        Assert.AreEqual(70, result.Notes[2].Pitch);
        Assert.AreEqual(61, result.Notes[3].Pitch);
        Assert.AreEqual(62, result.Notes[4].Pitch);
    }
コード例 #5
0
ファイル: ClipProcessor.cs プロジェクト: rinckd/mutateful
        public static ProcessResultArray <Clip> ProcessCommand(Command command, Clip[] incomingClips, ClipMetaData targetMetadata)
        {
            var clips = new Clip[incomingClips.Length];

            for (var i = 0; i < incomingClips.Length; i++)
            {
                clips[i] = new Clip(incomingClips[i]);
            }

            ProcessResultArray <Clip> resultContainer;

            switch (command.Id)
            {
            case TokenType.Arpeggiate:
                resultContainer = Arpeggiate.Apply(command, clips);
                break;

            case TokenType.Concat:
                resultContainer = Concat.Apply(clips);
                break;

            case TokenType.Crop:
                resultContainer = Crop.Apply(command, clips);
                break;

            case TokenType.Filter:
                resultContainer = Filter.Apply(command, clips);
                break;

            case TokenType.Interleave:
                resultContainer = Interleave.Apply(command, targetMetadata, clips);
                break;

            case TokenType.InterleaveEvent:
                var(success, msg) = OptionParser.TryParseOptions(command, out InterleaveOptions options);
                if (!success)
                {
                    return(new ProcessResultArray <Clip>(msg));
                }
                options.Mode    = InterleaveMode.Event;
                resultContainer = Interleave.Apply(options, targetMetadata, clips);
                break;

            case TokenType.Legato:
                resultContainer = Legato.Apply(clips);
                break;

            case TokenType.Mask:
                resultContainer = Mask.Apply(command, clips);
                break;

            case TokenType.Monophonize:
                resultContainer = Monophonize.Apply(clips);
                break;

            case TokenType.Quantize:
                resultContainer = Quantize.Apply(command, clips);
                break;

            case TokenType.Ratchet:
                resultContainer = Ratchet.Apply(command, clips);
                break;

            case TokenType.Relength:
                resultContainer = Relength.Apply(command, clips);
                break;

            case TokenType.Resize:
                resultContainer = Resize.Apply(command, clips);
                break;

            case TokenType.Scale:
                resultContainer = Scale.Apply(command, clips);
                break;

            case TokenType.Scan:
                resultContainer = Scan.Apply(command, clips);
                break;

            case TokenType.SetLength:
                resultContainer = SetLength.Apply(command, clips);
                break;

            case TokenType.SetRhythm:
                resultContainer = SetRhythm.Apply(command, clips);
                break;

            case TokenType.Shuffle:
                resultContainer = Shuffle.Apply(command, clips);
                break;

            case TokenType.Skip:
                resultContainer = Skip.Apply(command, clips);
                break;

            case TokenType.Slice:
                resultContainer = Slice.Apply(command, clips);
                break;

            case TokenType.Take:
                resultContainer = Take.Apply(command, clips);
                break;

            case TokenType.Transpose:
                resultContainer = Transpose.Apply(command, clips);
                break;

            default:
                return(new ProcessResultArray <Clip>($"Unsupported command {command.Id}"));
            }
            return(resultContainer);
        }