Skip to content

Commit

Permalink
Adds support for accessing a ugen's model/options via get().
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbdclark committed Feb 16, 2015
1 parent 2a4aece commit c31e7b8
Show file tree
Hide file tree
Showing 10 changed files with 1,152 additions and 407 deletions.
473 changes: 344 additions & 129 deletions dist/flocking-all.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/flocking-all.min.js

Large diffs are not rendered by default.

473 changes: 344 additions & 129 deletions dist/flocking-no-jquery.js

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions dist/flocking-no-jquery.min.js

Large diffs are not rendered by default.

42 changes: 34 additions & 8 deletions flocking/flocking-core.js
Expand Up @@ -605,8 +605,37 @@ var fluid = fluid || require("infusion"),
return specialInputs.indexOf(inputName) < 0;
};

// TODO: Replace this with a regular expression;
// this produces too much garbage!
flock.input.pathExpander = function (path) {
return path.replace(/\.(?![0-9])/g, ".inputs.");
var segs = fluid.model.parseEL(path),
separator = "inputs",
len = segs.length,
penIdx = len - 1,
togo = [],
i;

for (i = 0; i < penIdx; i++) {
var seg = segs[i];
var nextSeg = segs[i + 1];

togo.push(seg);

if (nextSeg === "model" || nextSeg === "options") {
togo = togo.concat(segs.slice(i + 1, penIdx));
break;
}

if (!isNaN(Number(nextSeg))) {
continue;
}

togo.push(separator);
}

togo.push(segs[penIdx]);

return togo.join(".");
};

flock.input.expandPaths = function (paths) {
Expand All @@ -633,7 +662,7 @@ var fluid = fluid || require("infusion"),
var input = flock.get(root, path);

// If the unit generator is a valueType ugen, return its value, otherwise return the ugen itself.
return flock.hasTag(input, "flock.ugen.valueType") ? input.model.value : input;
return flock.hasTag(input, "flock.ugen.valueType") ? input.inputs.value : input;
};

flock.input.getValuesForPathArray = function (root, paths) {
Expand Down Expand Up @@ -1252,6 +1281,8 @@ var fluid = fluid || require("infusion"),
node.gen(node.model.blockSize);
}
}

that.model.value = node.model.value;
};

/**
Expand Down Expand Up @@ -1380,13 +1411,8 @@ var fluid = fluid || require("infusion"),

flock.synth.value.finalInit = function (that) {
that.value = function () {
var nodes = that.nodes,
lastIdx = nodes.length - 1,
out = nodes[lastIdx];

that.gen(1);

return out.model.value;
return that.model.value;
};
};

Expand Down

0 comments on commit c31e7b8

Please sign in to comment.