author | rougeronj |
Thu, 16 Apr 2015 11:08:05 +0200 | |
changeset 150 | c8fe9606d967 |
parent 149 | 3a74c554c9b9 |
child 152 | f0e12afcfba1 |
permissions | -rw-r--r-- |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
1 |
/** |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
2 |
* scripts/doubleroll.js |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
3 |
* |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
4 |
* This is the starting point for your application. |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
5 |
* Take a look at http://browserify.org/ for more info |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
6 |
*/ |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
7 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
8 |
'use strict'; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
9 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
10 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
11 |
var PIXI = require('pixi'); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
12 |
var _ = require('lodash'); |
131 | 13 |
var PianoRoll = require('./pianoroll'); |
150
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
14 |
var Utils = require('./utils.js'); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
16 |
var defaultConfig = { |
95 | 17 |
orientation: 'horizontal', |
98 | 18 |
logger: undefined, |
104 | 19 |
sceneWidth: 1024, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
pianorolls : [ |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
{ |
145
a8052f8ab19c
add range options to scale the scene depending on this range. Add rescale function to rescale the scene when a note is out of this range
rougeronj
parents:
131
diff
changeset
|
22 |
height: 384, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
timeWidth: 10, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
lineInterval: 5000, |
145
a8052f8ab19c
add range options to scale the scene depending on this range. Add rescale function to rescale the scene when a note is out of this range
rougeronj
parents:
131
diff
changeset
|
25 |
noteHeight: undefined, |
a8052f8ab19c
add range options to scale the scene depending on this range. Add rescale function to rescale the scene when a note is out of this range
rougeronj
parents:
131
diff
changeset
|
26 |
range: { |
147
4902992b2783
add scene width options to the scene and options for the 2 pianorolls
rougeronj
parents:
146
diff
changeset
|
27 |
bottom: 40, |
146 | 28 |
top: 90, |
145
a8052f8ab19c
add range options to scale the scene depending on this range. Add rescale function to rescale the scene when a note is out of this range
rougeronj
parents:
131
diff
changeset
|
29 |
}, |
146 | 30 |
dynamicRange: true, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
31 |
}, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
{ |
145
a8052f8ab19c
add range options to scale the scene depending on this range. Add rescale function to rescale the scene when a note is out of this range
rougeronj
parents:
131
diff
changeset
|
33 |
height: 384, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
34 |
timeWidth: 60, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
lineInterval: 5000, |
145
a8052f8ab19c
add range options to scale the scene depending on this range. Add rescale function to rescale the scene when a note is out of this range
rougeronj
parents:
131
diff
changeset
|
36 |
noteHeight: undefined, |
a8052f8ab19c
add range options to scale the scene depending on this range. Add rescale function to rescale the scene when a note is out of this range
rougeronj
parents:
131
diff
changeset
|
37 |
range:{ |
a8052f8ab19c
add range options to scale the scene depending on this range. Add rescale function to rescale the scene when a note is out of this range
rougeronj
parents:
131
diff
changeset
|
38 |
bottom: 0, |
a8052f8ab19c
add range options to scale the scene depending on this range. Add rescale function to rescale the scene when a note is out of this range
rougeronj
parents:
131
diff
changeset
|
39 |
top: 128, |
a8052f8ab19c
add range options to scale the scene depending on this range. Add rescale function to rescale the scene when a note is out of this range
rougeronj
parents:
131
diff
changeset
|
40 |
}, |
146 | 41 |
dynamicRange: false, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
42 |
}, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
43 |
], |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
44 |
framerate: 25, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
offsetMusic: false, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
sceneBgColor: 0xFFFFFF, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
47 |
lineColor: 0x444444, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
48 |
lineFillColor: 0xFFFF00, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
49 |
noteColors: [0xB90000, 0x4BDD71, 0xAF931E, 0x1C28BA, 0x536991], |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
noteHeight: undefined, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
51 |
zeroShift: 0.9, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
timeWidth: 60, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
lineInterval: 5000, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
// wsUri: undefined, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
55 |
// eventCode: undefined |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
56 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
57 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
58 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
59 |
function DoubleRoll(options) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
60 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
61 |
var _this = this; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
62 |
var opts = _(options).defaults(defaultConfig).value(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
63 |
|
95 | 64 |
var orientation = opts.orientation; |
65 |
var isHorizontal = (orientation !== 'vertical'); |
|
66 |
||
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
67 |
this.logger = opts.logger; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
68 |
this.lineColor = opts.lineColor; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
69 |
this.lineFillColor = opts.lineFillColor; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
70 |
this.framerate = opts.framerate; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
71 |
this.offsetMusic = opts.offsetMusic; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
72 |
this.noteColors = opts.noteColors; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
73 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
74 |
var noteHeight = opts.noteHeight; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
75 |
var sceneHeight = opts.sceneHeight || _(opts.pianorolls).reduce(function(s,p) { return s + p.height; }, 0); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
76 |
var timeWidth = opts.timeWidth; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
77 |
var lineInterval = opts.lineInterval; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
78 |
var offsetMusic = opts.offsetMusic; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
79 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
80 |
var sceneWidth = opts.sceneWidth; |
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
81 |
var stageView = opts.stageView; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
82 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
83 |
var zeroShift = opts.zeroShift; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
84 |
|
98 | 85 |
var ws = opts.ws; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
86 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
87 |
var colorsReg = {}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
88 |
|
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
89 |
this.container = new PIXI.DisplayObjectContainer(); |
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
90 |
this.container.x = Math.floor(sceneWidth*zeroShift); |
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
91 |
this.container.y = 0; |
131 | 92 |
|
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
93 |
stageView.registerComponent(this); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
94 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
95 |
var pianorollList = []; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
96 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
97 |
var pianorollOptions = { |
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
98 |
parentContainer: this.container, |
95 | 99 |
orientation: orientation, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
100 |
xInit: 0, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
101 |
width: sceneWidth, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
102 |
noteColors: this.noteColors, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
103 |
colorsReg: colorsReg, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
104 |
lineColor: this.lineColor, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
105 |
lineInterval: lineInterval, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
106 |
offsetMusic: offsetMusic, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
107 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
108 |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
109 |
var yInit = opts.yInit || 0; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
110 |
var linesDown = true; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
111 |
_(opts.pianorolls).forEach(function(prDef, i) { |
146 | 112 |
var prNoteHeight = noteHeight || prDef.noteHeight || prDef.height / (prDef.range.top - prDef.range.bottom + 1); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
113 |
var prTimeWidth = prDef.timeWidth || timeWidth; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
114 |
pianorollList.push(new PianoRoll(_({ |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
115 |
yInit: yInit, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
116 |
height: prDef.height, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
117 |
linesDown: linesDown, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
118 |
pixelsPerSecond: Math.floor(sceneWidth / prTimeWidth), |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
119 |
noteHeight: prNoteHeight, |
145
a8052f8ab19c
add range options to scale the scene depending on this range. Add rescale function to rescale the scene when a note is out of this range
rougeronj
parents:
131
diff
changeset
|
120 |
lineInterval: prDef.lineInterval, |
a8052f8ab19c
add range options to scale the scene depending on this range. Add rescale function to rescale the scene when a note is out of this range
rougeronj
parents:
131
diff
changeset
|
121 |
range: prDef.range, |
146 | 122 |
dynamicRange: prDef.dynamicRange, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
}).defaults(pianorollOptions).value())); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
yInit += prDef.height; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
125 |
linesDown = !linesDown; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
127 |
if(i<(opts.pianorolls.length-1)) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
128 |
var lineGraphics = new PIXI.Graphics() |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
129 |
.beginFill(_this.lineFillColor) |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
.lineStyle(1, _this.lineColor) |
95 | 131 |
.moveTo(Math.floor(sceneWidth*zeroShift), yInit) |
132 |
.lineTo(-sceneWidth - Math.floor(sceneWidth*zeroShift), yInit) |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
133 |
.endFill(); |
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
134 |
_this.container.addChild(lineGraphics); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
135 |
} |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
136 |
}); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
137 |
|
150
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
138 |
var currentTimeText = new PIXI.Text('-- : -- : --', { font: '40pt Arial', fill: '#646464' }); |
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
139 |
console.log(currentTimeText); |
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
140 |
currentTimeText.x = -currentTimeText.width - 60; |
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
141 |
currentTimeText.y = sceneHeight - currentTimeText.height - 30; |
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
142 |
this.container.addChild(currentTimeText); |
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
143 |
|
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
144 |
|
95 | 145 |
if(!isHorizontal) { |
150
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
146 |
this.container.rotation = Math.PI/2; |
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
147 |
this.container.y = sceneHeight; |
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
148 |
this.container.x = sceneWidth; |
95 | 149 |
} |
150 |
||
151 |
||
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
152 |
this.init = function() { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
153 |
|
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
154 |
ws.message(function(data) { |
98 | 155 |
_this.addNotes(data); |
156 |
}); |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
157 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
158 |
}; |
150
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
159 |
|
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
160 |
this.updateTime = function(){ |
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
161 |
currentTimeText.setText(Utils.formatTime(Date.now())); |
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
162 |
}; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
163 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
164 |
this.addNotes = function(data) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
165 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
166 |
pianorollList.forEach(function(c) { |
98 | 167 |
c.addNoteRaw(data); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
168 |
}); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
169 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
170 |
|
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
171 |
this.refresh = function() { |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
172 |
pianorollList.forEach(function(c) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
173 |
c.move(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
174 |
}); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
175 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
176 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
177 |
// Init page and intervals |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
178 |
var startTs; |
150
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
179 |
var refreshTimeInterval; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
180 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
181 |
this.start = function() { |
150
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
182 |
refreshTimeInterval = setInterval(function() {_this.updateTime();}, 1000); |
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
183 |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
184 |
startTs = Date.now(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
185 |
pianorollList.forEach(function(c) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
186 |
c.start(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
187 |
}); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
188 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
189 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
190 |
this.stop = function() { |
131 | 191 |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
192 |
pianorollList.forEach(function(c) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
193 |
c.stop(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
194 |
}); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
195 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
196 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
197 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
198 |
this.log = function(m) { |
98 | 199 |
if(this.logger) { |
200 |
this.logger.log(m); |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
201 |
} |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
202 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
203 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
204 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
205 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
206 |
return this; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
207 |
} |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
208 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
209 |
module.exports = { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
210 |
DoubleRoll: DoubleRoll |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
211 |
}; |