diff -r 7e3156578f28 -r 31cea001a298 annot-server/static/js/pianoroll.js --- a/annot-server/static/js/pianoroll.js Wed Oct 22 09:18:15 2014 +0200 +++ b/annot-server/static/js/pianoroll.js Thu Oct 23 09:16:16 2014 +0200 @@ -14,10 +14,31 @@ var lineInterval = 5000; // means line every 5 seconds var nbLines = -1; var noteHeight = 110; -var noteColor = 0xB74141; +var noteColor = [0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141, + 0x2222FF, 0xB74141]; //var speed = 1; // container -x position at each frame. Speed = 1 ~ 100px for 2 seconds //var zeroTime = new Date("2014-10-06T12:16:43.000000Z").getTime(); -var noteDict = {}; +var noteDict = [{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{},{}]; var pianoNotes = [1,0,1,0,1,1,0,1,0,1,0,1];//Do, Do#, Ré, Ré#, Mi, Fa, Fa#, Sol, Sol#, La, La#, Si // Visual config var drawPianoNotes = false; @@ -121,13 +142,13 @@ renderer.render(stage); } -function addNoteInContainer(note, startTime, duration, velocity, pixelsPerSecond, container, prHeight){ +function addNoteInContainer(note, startTime, duration, velocity, pixelsPerSecond, container, prHeight, canal){ //console.log("coucou 1", note, timeFromZero, ts, velocity, pixelsPerSecond, container, prHeight); var beginX = (offsetMusic + startTime) * pixelsPerSecond / 1000; var width = duration * pixelsPerSecond / 1000; // We draw the rectangle var graphics = new PIXI.Graphics(); - graphics.beginFill(noteColor, (velocity / 128)); + graphics.beginFill(noteColor[canal], (velocity / 128)); var y = (128-note) * prHeight / 128; // (128-note) because y = 0 is for note = 128 and y = 128 for note = 0 graphics.drawRect(beginX, Math.floor(y - (noteHeight/2) + ((prHeight / 128)/2)), width, noteHeight); graphics.endFill(); @@ -146,18 +167,21 @@ var note = data.content[3]; var velocity = data.content[4]; if(velocity===0){ - if(note in noteDict){ + if(typeof noteDict[data.content[2]][note]!=='undefined'){ // We close the note in container one //console.log("coucou 2", data); - var duration = data.content[1] - noteDict[note].ts; - addNoteInContainer(note, noteDict[note].ts, duration, noteDict[note].velocity, pixelsPerSecond1, container1, prHeight1); - addNoteInContainer(note, noteDict[note].ts, duration, noteDict[note].velocity, pixelsPerSecond2, container2, prHeight2); + 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]); + addNoteInContainer(note, noteDict[data.content[2]][note].ts, duration, noteDict[data.content[2]][note].velocity, pixelsPerSecond2, container2, prHeight2, data.content[2]); // delete entry - delete noteDict[note]; + delete noteDict[data.content[2]][note]; } } else{ - noteDict[note] = {ts: data.content[1], velocity:velocity}; + if(typeof noteDict[data.content[2]]==='undefined'){ + noteDict[data.content[2]] = {}; + } + noteDict[data.content[2]][note] = {ts: data.content[1], velocity:velocity}; } }