pianoroll/app.js
changeset 16 3343e89b04a1
parent 15 f1ae020c2872
child 17 4dd9a96a6d3b
equal deleted inserted replaced
15:f1ae020c2872 16:3343e89b04a1
    91             var graphics = new PIXI.Graphics();
    91             var graphics = new PIXI.Graphics();
    92             graphics.beginFill(0x0000AA, (noteDict[note].velocity / 128));
    92             graphics.beginFill(0x0000AA, (noteDict[note].velocity / 128));
    93             var y = (128-note) * sceneHeight / 128; // (128-note) because y = 0 is for note = 128 and y = 128 for note = 0
    93             var y = (128-note) * sceneHeight / 128; // (128-note) because y = 0 is for note = 128 and y = 128 for note = 0
    94             graphics.drawRect(beginX, y, width, sceneHeight / 128);
    94             graphics.drawRect(beginX, y, width, sceneHeight / 128);
    95             graphics.endFill();
    95             graphics.endFill();
    96             //console.log("diff temporelle = ", x);
       
    97             container.addChild(graphics);
    96             container.addChild(graphics);
    98             delete noteDict[note];
    97             delete noteDict[note];
    99         }
    98         }
   100     }
    99     }
   101     else{
   100     else{
   142 
   141 
   143 function addLine(){
   142 function addLine(){
   144     nbLines++;
   143     nbLines++;
   145     var graphics = new PIXI.Graphics();
   144     var graphics = new PIXI.Graphics();
   146     var x = nbLines * (lineInterval/1000) * pixelsPerSecond;
   145     var x = nbLines * (lineInterval/1000) * pixelsPerSecond;
   147     console.log("nbLines = ",nbLines, "x = ", x);
   146     //console.log("nbLines = ",nbLines, "x = ", x);
   148     graphics.beginFill(0xFFFF00);
   147     graphics.beginFill(0xFFFF00);
   149     graphics.lineStyle(1, 0x444444);
   148     graphics.lineStyle(1, 0x444444);
   150     graphics.moveTo(x, 0);
   149     graphics.moveTo(x, 0);
   151     graphics.lineTo(x, sceneHeight);
   150     graphics.lineTo(x, sceneHeight);
   152     graphics.endFill();
   151     graphics.endFill();
   153 
       
   154     container.addChild(graphics);
   152     container.addChild(graphics);
       
   153     // Add text
       
   154     var totalSec = nbLines * lineInterval / 1000;
       
   155     var hours = parseInt( totalSec / 3600 ) % 24;
       
   156     var minutes = parseInt( totalSec / 60 ) % 60;
       
   157     var seconds = totalSec % 60;
       
   158     var timeStr = (hours < 10 ? "0" + hours : hours) + ":" + (minutes < 10 ? "0" + minutes : minutes) + ":" + (seconds  < 10 ? "0" + seconds : seconds);
       
   159     var t = new PIXI.Text(timeStr, { font: "10pt Arial", fill: "#444444" });
       
   160     t.x = x + 2;
       
   161     t.y = sceneHeight - 20;
       
   162     container.addChild(t);
   155 }
   163 }
   156 var moveInterval = window.setInterval(moveContainer, 1000/manualFramerate);
   164 var moveInterval = window.setInterval(moveContainer, 1000/manualFramerate);
   157 var linesInterval = window.setInterval(addLine, lineInterval);
   165 var linesInterval = window.setInterval(addLine, lineInterval);