author | rougeronj |
Thu, 16 Apr 2015 12:15:33 +0200 | |
changeset 153 | 60bd2b36b9dc |
parent 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, |
153
60bd2b36b9dc
put showTime as an option and add it to static pianoroll template on server
rougeronj
parents:
152
diff
changeset
|
20 |
showTimer: false, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
21 |
pianorolls : [ |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
{ |
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
|
23 |
height: 384, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
24 |
timeWidth: 10, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
25 |
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
|
26 |
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
|
27 |
range: { |
147
4902992b2783
add scene width options to the scene and options for the 2 pianorolls
rougeronj
parents:
146
diff
changeset
|
28 |
bottom: 40, |
146 | 29 |
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
|
30 |
}, |
146 | 31 |
dynamicRange: true, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
}, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
{ |
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
|
34 |
height: 384, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
35 |
timeWidth: 60, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
36 |
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
|
37 |
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
|
38 |
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
|
39 |
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
|
40 |
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
|
41 |
}, |
146 | 42 |
dynamicRange: false, |
94
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 |
], |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
framerate: 25, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
offsetMusic: false, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
47 |
sceneBgColor: 0xFFFFFF, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
48 |
lineColor: 0x444444, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
49 |
lineFillColor: 0xFFFF00, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
noteColors: [0xB90000, 0x4BDD71, 0xAF931E, 0x1C28BA, 0x536991], |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
51 |
noteHeight: undefined, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
zeroShift: 0.9, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
timeWidth: 60, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
lineInterval: 5000, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
55 |
// wsUri: undefined, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
56 |
// eventCode: undefined |
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 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
60 |
function DoubleRoll(options) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
61 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
62 |
var _this = this; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
63 |
var opts = _(options).defaults(defaultConfig).value(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
64 |
|
95 | 65 |
var orientation = opts.orientation; |
66 |
var isHorizontal = (orientation !== 'vertical'); |
|
67 |
||
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
68 |
this.logger = opts.logger; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
69 |
this.lineColor = opts.lineColor; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
70 |
this.lineFillColor = opts.lineFillColor; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
71 |
this.framerate = opts.framerate; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
72 |
this.offsetMusic = opts.offsetMusic; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
73 |
this.noteColors = opts.noteColors; |
153
60bd2b36b9dc
put showTime as an option and add it to static pianoroll template on server
rougeronj
parents:
152
diff
changeset
|
74 |
this.showTimer = opts.showTimer; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
75 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
76 |
var noteHeight = opts.noteHeight; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
77 |
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
|
78 |
var timeWidth = opts.timeWidth; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
79 |
var lineInterval = opts.lineInterval; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
80 |
var offsetMusic = opts.offsetMusic; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
81 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
82 |
var sceneWidth = opts.sceneWidth; |
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
83 |
var stageView = opts.stageView; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
84 |
|
153
60bd2b36b9dc
put showTime as an option and add it to static pianoroll template on server
rougeronj
parents:
152
diff
changeset
|
85 |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
86 |
var zeroShift = opts.zeroShift; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
87 |
|
98 | 88 |
var ws = opts.ws; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
89 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
90 |
var colorsReg = {}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
91 |
|
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
92 |
this.container = new PIXI.DisplayObjectContainer(); |
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
93 |
this.container.x = Math.floor(sceneWidth*zeroShift); |
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
94 |
this.container.y = 0; |
131 | 95 |
|
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
96 |
stageView.registerComponent(this); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
97 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
98 |
var pianorollList = []; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
99 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
100 |
var pianorollOptions = { |
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
101 |
parentContainer: this.container, |
95 | 102 |
orientation: orientation, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
103 |
xInit: 0, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
104 |
width: sceneWidth, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
105 |
noteColors: this.noteColors, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
106 |
colorsReg: colorsReg, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
107 |
lineColor: this.lineColor, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
108 |
lineInterval: lineInterval, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
109 |
offsetMusic: offsetMusic, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
110 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
111 |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
112 |
var yInit = opts.yInit || 0; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
113 |
var linesDown = true; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
114 |
_(opts.pianorolls).forEach(function(prDef, i) { |
146 | 115 |
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
|
116 |
var prTimeWidth = prDef.timeWidth || timeWidth; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
117 |
pianorollList.push(new PianoRoll(_({ |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
118 |
yInit: yInit, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
119 |
height: prDef.height, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
120 |
linesDown: linesDown, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
121 |
pixelsPerSecond: Math.floor(sceneWidth / prTimeWidth), |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
122 |
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
|
123 |
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
|
124 |
range: prDef.range, |
146 | 125 |
dynamicRange: prDef.dynamicRange, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
}).defaults(pianorollOptions).value())); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
127 |
yInit += prDef.height; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
128 |
linesDown = !linesDown; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
129 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
130 |
if(i<(opts.pianorolls.length-1)) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
131 |
var lineGraphics = new PIXI.Graphics() |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
132 |
.beginFill(_this.lineFillColor) |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
133 |
.lineStyle(1, _this.lineColor) |
95 | 134 |
.moveTo(Math.floor(sceneWidth*zeroShift), yInit) |
135 |
.lineTo(-sceneWidth - Math.floor(sceneWidth*zeroShift), yInit) |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
136 |
.endFill(); |
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
137 |
_this.container.addChild(lineGraphics); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
138 |
} |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
139 |
}); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
140 |
|
153
60bd2b36b9dc
put showTime as an option and add it to static pianoroll template on server
rougeronj
parents:
152
diff
changeset
|
141 |
if (this.showTimer){ |
60bd2b36b9dc
put showTime as an option and add it to static pianoroll template on server
rougeronj
parents:
152
diff
changeset
|
142 |
var currentTimeText = new PIXI.Text('-- : -- : --', { font: '40pt Arial', fill: '#646464' }); |
60bd2b36b9dc
put showTime as an option and add it to static pianoroll template on server
rougeronj
parents:
152
diff
changeset
|
143 |
currentTimeText.x = -currentTimeText.width - 60; |
60bd2b36b9dc
put showTime as an option and add it to static pianoroll template on server
rougeronj
parents:
152
diff
changeset
|
144 |
currentTimeText.y = sceneHeight - currentTimeText.height - 30; |
60bd2b36b9dc
put showTime as an option and add it to static pianoroll template on server
rougeronj
parents:
152
diff
changeset
|
145 |
this.container.addChild(currentTimeText); |
60bd2b36b9dc
put showTime as an option and add it to static pianoroll template on server
rougeronj
parents:
152
diff
changeset
|
146 |
} |
150
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
147 |
|
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
148 |
|
95 | 149 |
if(!isHorizontal) { |
150
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
150 |
this.container.rotation = Math.PI/2; |
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
151 |
this.container.y = sceneHeight; |
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
152 |
this.container.x = sceneWidth; |
95 | 153 |
} |
154 |
||
155 |
||
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
156 |
this.init = function() { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
157 |
|
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
158 |
ws.message(function(data) { |
98 | 159 |
_this.addNotes(data); |
160 |
}); |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
161 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
162 |
}; |
150
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
163 |
|
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
164 |
this.updateTime = function(){ |
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
165 |
currentTimeText.setText(Utils.formatTime(Date.now())); |
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
166 |
}; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
167 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
168 |
this.addNotes = function(data) { |
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 |
pianorollList.forEach(function(c) { |
98 | 171 |
c.addNoteRaw(data); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
172 |
}); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
173 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
174 |
|
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
175 |
this.refresh = function() { |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
176 |
pianorollList.forEach(function(c) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
177 |
c.move(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
178 |
}); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
179 |
}; |
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 |
// Init page and intervals |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
182 |
var startTs; |
150
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
183 |
var refreshTimeInterval; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
184 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
185 |
this.start = function() { |
153
60bd2b36b9dc
put showTime as an option and add it to static pianoroll template on server
rougeronj
parents:
152
diff
changeset
|
186 |
if (this.showTimer){ |
60bd2b36b9dc
put showTime as an option and add it to static pianoroll template on server
rougeronj
parents:
152
diff
changeset
|
187 |
refreshTimeInterval = setInterval(function() {_this.updateTime();}, 1000); |
60bd2b36b9dc
put showTime as an option and add it to static pianoroll template on server
rougeronj
parents:
152
diff
changeset
|
188 |
} |
150
c8fe9606d967
add temporary timeCode on doubleroll and copy change to server
rougeronj
parents:
149
diff
changeset
|
189 |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
190 |
startTs = Date.now(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
191 |
pianorollList.forEach(function(c) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
192 |
c.start(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
193 |
}); |
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 |
this.stop = function() { |
131 | 197 |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
198 |
pianorollList.forEach(function(c) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
199 |
c.stop(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
200 |
}); |
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 |
this.log = function(m) { |
98 | 205 |
if(this.logger) { |
206 |
this.logger.log(m); |
|
94
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 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
210 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
211 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
212 |
return this; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
213 |
} |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
214 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
215 |
module.exports = { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
216 |
DoubleRoll: DoubleRoll |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
217 |
}; |