").addClass("Envelope")
.appendTo(element);
var attack = Interface.Slider(group, node, "attack", 0.001, 2, 2);
var decay = Interface.Slider(group, node, "decay", 0.0, 2, 2);
var sustain = Interface.Slider(group, node, "sustain", 0, 1, 2);
var release = Interface.Slider(group, 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.FilterEnvelope = function(container, node){
var element = $("
").addClass("FilterEnvelope")
.appendTo(Interface.getElement(container));
var ampEnv = Interface.AmplitudeEnvelope(element, node);
// var freqGroup = $("
").appendTo(element).addClass("FreqGroup");
// var minSlider = Interface.Slider(freqGroup, node, "min", 20, 20000, 2);
// var maxSlider = Interface.Slider(freqGroup, node, "max", 20, 20000, 2);
return {
listen : function(){
ampEnv.listen();
maxSlider.listen();
minSlider.listen();
}
};
};
Interface.Filter = function(containerID, node){
var element = $("
").addClass("Filter")
.appendTo(Interface.getElement(containerID));
};
Interface.Loading = function(containerID, callback){
var element = Interface.getElement(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(Interface.getElement(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();
};