").addClass("Envelope")
.appendTo(element);
var attack = Interface.Knob(group[0], node, "attack", 0.001, 2, 2);
var decay = Interface.Knob(group[0], node, "decay", 0.0, 2, 2);
var sustain = Interface.Knob(group[0], node, "sustain", 0, 1, 2);
var release = Interface.Knob(group[0], node, "release", 0.001, 4, 2);
var labels = $("
").attr("id", "Labels")
.appendTo(group);
$("
").appendTo(labels).addClass("Label").text("attack");
$("
").appendTo(labels).addClass("Label").text("decay");
$("
").appendTo(labels).addClass("Label").text("sustain");
$("
").appendTo(labels).addClass("Label").text("release");
return {
listen : function(){
attack.listen();
decay.listen();
release.listen();
sustain.listen();
}
};
};
Interface.Loading = function(containerID, callback){
var element = $("#"+containerID);
element.addClass("LoadingBar");
var loader = $("
").appendTo(element)
.attr("id", "Loader");
Tone.Buffer.onprogress = function(percent){
loader.width((percent * 100) + "%");
};
Tone.Buffer.onload = function(){
element.css({
height: 0,
opacity : 0,
margin: 0
});
setTimeout(function(){
element.remove();
}, 500);
if (callback){
callback();
}
};
};
Interface.Range = function(containerID, callback){
var range = nx.add("range", {
"parent" : containerID
});
range.label = "";
range.on("*", callback);
return range;
};
Interface.Meter = function(container, node, label, units){
var meter = new Tone.Meter();
node.connect(meter);
var element = $("
").appendTo("#"+container)
.addClass("Meter");
label = label || "";
units = units || "";
$("
").appendTo(element)
.text(label)
.attr("id", "Label");
var value = $("
").appendTo(element)
.attr("id", "Value");
$("
").appendTo(element)
.text(units)
.attr("id", "Units");
function update(){
requestAnimationFrame(update);
value.text(meter.getValue().toFixed(3));
}
update();
};