sdr 0.7

net.cscott.sdr.calls.transform
Class RemoveIn

java.lang.Object
  extended by net.cscott.sdr.calls.transform.TransformVisitor<Fraction>
      extended by net.cscott.sdr.calls.transform.RemoveIn

public class RemoveIn
extends TransformVisitor<Fraction>

Push Ins down a call tree and adjust Prim timing where possible. Only push the In down one level, so we don't end up doing more work than we need to on the untaken side of an Opt. If we end up at a Seq of Prims, use the "inherent" times given by a BeatCounter to proportionally allocate the available beats from the top down.

Tests:
Eliminate In from 1/2 DOSADO:
js> importPackage(net.cscott.sdr.calls)
js> importPackage(net.cscott.sdr.calls.ast)
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined;
js> a = new Apply(new Expr("_fractional", Expr.literal("1/2"), Expr.literal("dosado")))
(Apply (Expr _fractional '1/2 'dosado))
js> def = a.evaluator(ds).simpleExpansion()
(In (Expr _multiply num '1/2 '6) (Opt (From 'ANY (Seq (Part 'INDIVISIBLE '1 (Seq (Apply '_mixed touch))) (Part 'DIVISIBLE '3 (In (Expr _multiply num '1/3 '6) (Opt (From 'RH MINIWAVE (Seq (Prim 1, 1, none, 1, SASHAY_FINISH))))))))))
js> def = RemoveIn.removeIn(ds, def)
(Opt (From 'ANY (In '3 (Seq (Part 'INDIVISIBLE '1 (Seq (Apply '_mixed touch))) (Part 'DIVISIBLE '3 (In (Expr _multiply num '1/3 '6) (Opt (From 'RH MINIWAVE (Seq (Prim 1, 1, none, 1, SASHAY_FINISH))))))))))
js> def = RemoveIn.removeIn(ds, def.children.get(0).child)
(Seq (Part 'INDIVISIBLE '1 (Seq (Apply (Expr _in '3/4 '_mixed touch)))) (Part 'DIVISIBLE '3 (Opt (From 'RH MINIWAVE (In '2 1/4 (Seq (Prim 1, 1, none, 1, SASHAY_FINISH)))))))
Proper handling of Part:
js> importPackage(net.cscott.sdr.calls)
js> importPackage(net.cscott.sdr.calls.ast)
js> ds = new DanceState(new DanceProgram(Program.C4), Formation.SQUARED_SET); undefined;
js> a = AstNode.valueOf('(In \'1 (Seq (Part \'INDIVISIBLE \'1 (Seq (Prim 0, 1, none, 1) (Prim 0, 1, in 1/4, 1)))))')
(In '1 (Seq (Part 'INDIVISIBLE '1 (Seq (Prim 0, 1, none, 1) (Prim 0, 1, in 1/4, 1)))))
js> RemoveIn.removeIn(ds, a)
(Seq (Part 'INDIVISIBLE '1 (Seq (Prim 0, 1, none, 1/2) (Prim 0, 1, in 1/4, 1/2))))

Method Summary
static Comp removeIn(DanceState ds, In in)
          Main method: pass in a Comp, and get out a Comp without In nodes.
 Apply visit(Apply a, Fraction f)
           
 Comp visit(In in, Fraction f)
           
 Opt visit(Opt o, Fraction f)
           
 Par visit(Par p, Fraction f)
           
 Prim visit(Prim p, Fraction f)
           
 Seq visit(Seq s, Fraction f)
           
 
Methods inherited from class net.cscott.sdr.calls.transform.TransformVisitor
visit, visit, visit, visit, visit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

removeIn

public static Comp removeIn(DanceState ds,
                            In in)
Main method: pass in a Comp, and get out a Comp without In nodes.


visit

public Seq visit(Seq s,
                 Fraction f)
Overrides:
visit in class TransformVisitor<Fraction>

visit

public Prim visit(Prim p,
                  Fraction f)
Overrides:
visit in class TransformVisitor<Fraction>

visit

public Apply visit(Apply a,
                   Fraction f)
Overrides:
visit in class TransformVisitor<Fraction>

visit

public Par visit(Par p,
                 Fraction f)
Overrides:
visit in class TransformVisitor<Fraction>

visit

public Opt visit(Opt o,
                 Fraction f)
Overrides:
visit in class TransformVisitor<Fraction>

visit

public Comp visit(In in,
                  Fraction f)
Overrides:
visit in class TransformVisitor<Fraction>

sdr 0.7

Copyright © 2006-2009 C. Scott Ananian