diff -r 9d968fbcaa2a -r 0d7dac03c1a0 client/annotviz/app/js/main.js --- a/client/annotviz/app/js/main.js Tue Jan 20 12:00:40 2015 +0100 +++ b/client/annotviz/app/js/main.js Tue Jan 20 18:37:51 2015 +0100 @@ -7,304 +7,20 @@ 'use strict'; - -var PIXI = require('pixi'); -var rgb2hex = require('./utils'); - -// Config vars -var horizontalView = false; -var logger = false; -var sceneWidth = 1920; -var sceneHeight = 1080; -var prSize1 = 435; -var prSize2 = 435; -var prSize3 = 300; -var sceneBgColor = 0xFFFFFF; -var lineColor = 0x444444; -if (horizontalView){ - var pixelsPerSecond1 = Math.floor(sceneWidth / 10); // nb of pixels per second -} else{ - var pixelsPerSecond1 = Math.floor(sceneHeight / 10); // nb of pixels per second -} -var manualFramerate = pixelsPerSecond1 / 4; -if (horizontalView){ - var pixelsPerSecond2 = Math.floor(sceneWidth / 60); // nb of pixels per second -} else { - var pixelsPerSecond2 = Math.floor(sceneHeight / 60); // nb of pixels per second -} -var pixelsPerSecond3 = Math.floor(sceneHeight / 60); // nb of pixels per second -var lineInterval = 5000; // means line every 5 seconds -var nbLines = -1; -var noteHeight = 110; -var noteColors = [0xB90000, 0x4BDD71, 0xAF931E, 0x1C28BA, 0x536991]; -var colorsReg = {}; -// Vars -var noteDict = []; -// Timecode method -var timePageLoaded = Date.now(); -var offsetMusic = false; -var categoriesColor = { - "ntm" : rgb2hex(205,200,63), - "iam" : rgb2hex(205,200,63), - "hip" : rgb2hex(205,200,63), - "hop" : rgb2hex(205,200,63), - "rock" : rgb2hex(222,139,83), - "rap" : rgb2hex(222,139,83), - "classic" : rgb2hex(222,139,83), - "drums" : rgb2hex(197,163,202), - "guitar" : rgb2hex(197,163,202), - "bass" : rgb2hex(121,187,146), - "default": rgb2hex(128,128,128) -}; - -//create an new instance of a pixi stage -var stage = new PIXI.Stage(sceneBgColor); - -//create a renderer instance. -var renderer = PIXI.autoDetectRenderer(sceneWidth, sceneHeight); - -//add the renderer view element to the DOM -document.getElementById('canvasContainer').appendChild(renderer.view); - -var uberContainer = new PIXI.DisplayObjectContainer(); -if (horizontalView){ - uberContainer.position.x = Math.floor(sceneWidth*9/10); - uberContainer.position.y = 0; -} else { - uberContainer.position.x = 0; - uberContainer.position.y = Math.floor(sceneHeight*9/10); -} -stage.addChild(uberContainer); - -/* ---------------------------------------------------------------- */ -/* ------------------- Init Pianoroll containers ------------------ */ -/* ---------------------------------------------------------------- */ - -var PianoRoll = require('./pianoroll.js') +var doubleroll = require('./doubleroll'); +var annotsroll = require('./annotsroll'); +var annotstimeline = require('./annotstimeline'); +var stageview = require('./stageview'); +var wswrapper = require('./wswrapper'); +var logger = require('./logger'); -var containerList = []; - -if (horizontalView){ - containerList.push(new PianoRoll(uberContainer, 0, 0, prSize1, true, pixelsPerSecond1, sceneWidth, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize1 / 128, horizontalView)); - containerList.push(new PianoRoll(uberContainer, 0, prSize1, prSize2, false, pixelsPerSecond2, sceneWidth, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize2 / 128, horizontalView)); -} else { -// containerList.push(new PianoRoll(uberContainer, sceneWidth - prSize1, 0, sceneHeight, true, pixelsPerSecond1, prSize1, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize1 / 128, horizontalView)); -// containerList.push(new PianoRoll(uberContainer, sceneWidth - (prSize1 + prSize2), 0, sceneHeight, false, pixelsPerSecond2, prSize2, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize2 / 128, horizontalView)); - containerList.push(new PianoRoll(uberContainer, sceneWidth - prSize1, 0, sceneHeight, false, pixelsPerSecond2, prSize2, noteColors, colorsReg, lineColor, lineInterval, offsetMusic, prSize2 / 128, horizontalView)); -} - -// Line between two containers -var graphics = new PIXI.Graphics(); -graphics.beginFill(0xFFFF00); -graphics.lineStyle(1, lineColor); -if (horizontalView){ - graphics.moveTo(0, prSize1); - graphics.lineTo(sceneWidth, prSize1); -} else { - graphics.moveTo(sceneWidth - prSize1, 0); - graphics.lineTo(sceneWidth - prSize1, sceneHeight); - graphics.moveTo(sceneWidth - (prSize1 + prSize3), 0); - graphics.lineTo(sceneWidth - (prSize1 + prSize3), sceneHeight); -} -graphics.endFill(); -stage.addChild(graphics); - -function addNotes(data){ - if(!offsetMusic){ - // get difference between the current note timecode and my zero to set the difference between the canvas's zero and the music's zero - // in order to place in real time - var now = Date.now(); - var timeBetweenNowAndStart = now - timePageLoaded; - offsetMusic = timeBetweenNowAndStart - data.content[1]; - } - var note = data.content[3]; - var velocity = data.content[4]; - if(velocity===0){ - if(typeof noteDict[data.content[2]][note]!=='undefined'){ - // We close the note in container one - var duration = data.content[1] - noteDict[data.content[2]][note].ts; - for(var i=0;i