diff -r 9611905b58fe -r 79ae42ad97d4 client/annotviz/app/js/main.js --- a/client/annotviz/app/js/main.js Tue Jan 13 15:27:20 2015 +0100 +++ b/client/annotviz/app/js/main.js Fri Jan 16 03:16:19 2015 +0100 @@ -5,11 +5,20 @@ * Take a look at http://browserify.org/ for more info */ + /* global window: false */ + /* global document: false */ + /* global WebSocket: false */ + /* global MozWebSocket: false */ + + /* global eventCode: false */ 'use strict'; var PIXI = require('pixi'); +var _ = require('lodash'); + +var NTP_EPOCH_DELTA = 2208988800; //c.f. RFC 868 // Config vars var logger = false; var sceneWidth = 1920; @@ -22,14 +31,10 @@ var manualFramerate = pixelsPerSecond1 / 4; var pixelsPerSecond2 = Math.floor(sceneWidth / 60); // nb of pixels per second var lineInterval = 5000; // means line every 5 seconds -var nbLines = -1; -var noteHeight = 110; +//var noteHeight = 110; var noteColors = [0xB90000, 0x4BDD71, 0xAF931E, 0x1C28BA, 0x536991]; var colorsReg = {}; -// Vars -var noteDict = []; // Timecode method -var timePageLoaded = Date.now(); var offsetMusic = false; @@ -47,12 +52,38 @@ uberContainer.position.y = 0; stage.addChild(uberContainer); -var PianoRoll = require('./pianoroll.js') +var PianoRoll = require('./pianoroll.js'); // Init containers var containerList = []; -containerList.push(new PianoRoll(uberContainer, 0, 0, prHeight1, true, pixelsPerSecond1, sceneWidth, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prHeight1 / 128)); -containerList.push(new PianoRoll(uberContainer, 0, prHeight1, prHeight2, false, pixelsPerSecond2, sceneWidth, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prHeight2 / 128)); + +var pianorollOptions = { + parentContainer: uberContainer, + xInit: 0, + width: sceneWidth, + noteColors: noteColors, + colorsReg: colorsReg, + lineColor: lineColor, + lineInterval: lineInterval, + offsetMusic: offsetMusic +}; + + +containerList.push(new PianoRoll(_.extend(_.clone(pianorollOptions), { + yInit: 0, + height: prHeight1, + linesDown: true, + pixelsPerSecond: pixelsPerSecond1, + noteHeight: prHeight1 / 128 +}))); +containerList.push(new PianoRoll(_.extend(_.clone(pianorollOptions), { + yInit: prHeight1, + height: prHeight2, + linesDown: false, + pixelsPerSecond: pixelsPerSecond2, + noteHeight: prHeight2 / 128 +}))); + // Line between two containers var graphics = new PIXI.Graphics(); @@ -64,52 +95,16 @@ stage.addChild(graphics); -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)); - for(var i=0;i