").appendTo(labels).addClass("Label").text("release");
return {
listen : function(){
attack.listen();
decay.listen();
release.listen();
sustain.listen();
}
};
};
Interface.FilterEnvelope = function(container, node){
var element = Interface.getElement(container, "Filter");
var group = $("
").addClass("Envelope FilterEnvelope")
.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 freqGroup = $("
").appendTo(element).addClass("FreqGroup");
var minSlider = Interface.Slider(group, node, "min", 20, 20000, 2);
var maxSlider = Interface.Slider(group, node, "max", 20, 20000, 2);
return {
listen : function(){
attack.listen();
decay.listen();
release.listen();
sustain.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();
};
Interface.StepSequencer = function(container, width, height){
var element = Interface.getElement(container);
element.addClass("StepSequencer");
var matrix = nx.add("matrix", {
"parent" : element,
});
matrix.row = height;
matrix.col = width;
matrix.init();
matrix.draw();
return {
randomize : function(){
var boxes = [];
for (var i = 0; i < width; i++){
var row = [];
for (var j = 0; j < height; j++){
row.push(Math.round(Math.random()));
}
boxes.push(row);
}
// console.log(boxes);
// debugger;
matrix.matrix = boxes;
matrix.draw();
}
};
};