--- a/annot-server/static/js/pianoroll.js Tue Oct 28 09:47:11 2014 +0100
+++ b/annot-server/static/js/pianoroll.js Tue Oct 28 15:31:55 2014 +0100
@@ -110,13 +110,18 @@
}
i++;
}
+ //console.log("before : ", nbChilds, ", after : ", _this.container.children.length);
};
-
+
+ // remove notes each scene width
+ var removeInterval = window.setInterval(this.removePassedObjets, 1000 * sceneWidth / this.pixelsPerSecond );
+
}
// Init containers
-var container1 = new PianoRoll(uberContainer, 0, 0, prHeight1, true, pixelsPerSecond1, sceneWidth);
-var container2 = new PianoRoll(uberContainer, 0, prHeight1, prHeight2, false, pixelsPerSecond2, sceneWidth);
+var containerList = [];
+containerList.push(new PianoRoll(uberContainer, 0, 0, prHeight1, true, pixelsPerSecond1, sceneWidth));
+containerList.push(new PianoRoll(uberContainer, 0, prHeight1, prHeight2, false, pixelsPerSecond2, sceneWidth));
// Line between two containers
var graphics = new PIXI.Graphics();
@@ -131,8 +136,10 @@
function replaceContainers(){
var diff = (Date.now() - timePageLoaded)/1000;// nb of seconds since page loaded
//console.log("replace ! diff1 = ", container1.x - Math.floor(-diff*pixelsPerSecond1), ", diff 2 = ", container2.x - Math.floor(-diff*pixelsPerSecond2));
- container1.moveTo(-diff);
- container2.moveTo(-diff);
+ var nb = containerList.length;
+ for(var i=0;i<nb;i++){
+ containerList[i].moveTo(-diff);
+ }
renderer.render(stage);
}
@@ -152,11 +159,11 @@
// We close the note in container one
//console.log("coucou 2", data);
var duration = data.content[1] - noteDict[data.content[2]][note].ts;
- //addNoteInContainer(note, noteDict[data.content[2]][note].ts, duration, noteDict[data.content[2]][note].velocity, pixelsPerSecond1, container1, prHeight1, data.content[2]);
- // addNote(note, startTime, duration, velocity, canal)
- container1.addNote(note, noteDict[data.content[2]][note].ts, duration, noteDict[data.content[2]][note].velocity, data.content[2]);
- //addNoteInContainer(note, noteDict[data.content[2]][note].ts, duration, noteDict[data.content[2]][note].velocity, pixelsPerSecond2, container2, prHeight2, data.content[2]);
- container2.addNote(note, noteDict[data.content[2]][note].ts, duration, noteDict[data.content[2]][note].velocity, data.content[2]);
+ var nb = containerList.length;
+ for(var i=0;i<nb;i++){
+ // addNote(note, startTime, duration, velocity, canal)
+ containerList[i].addNote(note, noteDict[data.content[2]][note].ts, duration, noteDict[data.content[2]][note].velocity, data.content[2]);
+ }
// delete entry
delete noteDict[data.content[2]][note];
}
@@ -171,8 +178,10 @@
function addLine(){
nbLines++;
- container1.addLine(nbLines);
- container2.addLine(nbLines);
+ var nb = containerList.length;
+ for(var i=0;i<nb;i++){
+ containerList[i].addLine(nbLines);
+ }
}
@@ -213,25 +222,25 @@
}
if (sock) {
- sock.onopen = function(){
- if(logger){
- log("Connected to " + wsuri);
- }
- }
+ sock.onopen = function(){
+ if(logger){
+ log("Connected to " + wsuri);
+ }
+ }
- sock.onclose = function(e) {
- if(logger){
- log("Connection closed (wasClean = " + e.wasClean + ", code = " + e.code + ", reason = '" + e.reason + "')");
- }
- sock = null;
- }
+ sock.onclose = function(e) {
+ if(logger){
+ log("Connection closed (wasClean = " + e.wasClean + ", code = " + e.code + ", reason = '" + e.reason + "')");
+ }
+ sock = null;
+ }
- sock.onmessage = function(e) {
- if(logger){
- log("Got message: " + e.data);
- }
- addNotes(JSON.parse(e.data));
- }
+ sock.onmessage = function(e) {
+ if(logger){
+ log("Got message: " + e.data);
+ }
+ addNotes(JSON.parse(e.data));
+ }
}
};
@@ -240,8 +249,6 @@
addLine();
var moveInterval = window.setInterval(replaceContainers, 1000/manualFramerate);
var verticalLinesInterval = window.setInterval(addLine, lineInterval);
-var removeInterval1 = window.setInterval(container1.removePassedObjets, 1000 * sceneWidth / pixelsPerSecond1 );
-var removeInterval2 = window.setInterval(container2.removePassedObjets, 1000 * sceneWidth / pixelsPerSecond2 );
// Little inteval to show time
var nbSec = 0;