Ejemplo n.º 1
0
        private Dictionary <Edge, Operation> GenerateLoop(string input, string output, List <Edge> edges, Dictionary <Edge, Operation> mapping)
        {
            //foreach 0 <= k1, k2, k3 < Length(s)
            //  eSet1 = GenerateStr(sigma, s[k1 : k2]);
            //  eSet2 = GenerateStr(sigma, s[k2 : k3]);
            //  eSet = Unify(eSet1, eSet2);
            //  if ([[Loop(lambda W : eSet)]]sigma = {s[k1 : k3]})
            //      W(<k1, k3>) = W'(<k1, k3>) U {Loop(lambda W : eSet)};

            int len = output.Length;

            for (int i = 0; i < len; ++i)
            {
                for (int j = i; j < len; ++j)
                {
                    for (int k = j; k < len; ++k)
                    {
                        var traceSet1 = GenerateStr(input, output.Substring(i, j - i));
                        var traceSet2 = GenerateStr(input, output.Substring(j, k - j));
                        var traceSet  = new Intersector().Unify(traceSet1, traceSet2);

                        Loop loop = new Loop(traceSet);
                        if (loop.Apply(input).Equals(output.Substring(i, k - i)))
                        {
                            Edge targetEdge = new Edge(i, k);
                            //mapping[targetEdge] = mapping[targetEdge] U loop;
                        }
                    }
                }
            }

            return(mapping);
        }
Ejemplo n.º 2
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}")
        });