author | rougeronj |
Fri, 10 Apr 2015 16:45:34 +0200 | |
changeset 145 | a8052f8ab19c |
parent 131 | 0bb70072a56f |
child 146 | 192d7d7f7bb4 |
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'); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
14 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
15 |
var defaultConfig = { |
95 | 16 |
orientation: 'horizontal', |
98 | 17 |
logger: undefined, |
104 | 18 |
sceneWidth: 1024, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
19 |
pianorolls : [ |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
20 |
{ |
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
|
21 |
height: 384, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
22 |
timeWidth: 10, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
23 |
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
|
24 |
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
|
25 |
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
|
26 |
bottom: 60, |
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 |
top: 70, |
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
|
28 |
}, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
29 |
}, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
30 |
{ |
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
|
31 |
height: 384, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
32 |
timeWidth: 60, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
33 |
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
|
34 |
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
|
35 |
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
|
36 |
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
|
37 |
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
|
38 |
}, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
39 |
}, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
40 |
], |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
41 |
framerate: 25, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
42 |
offsetMusic: false, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
43 |
sceneBgColor: 0xFFFFFF, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
44 |
lineColor: 0x444444, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
45 |
lineFillColor: 0xFFFF00, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
46 |
noteColors: [0xB90000, 0x4BDD71, 0xAF931E, 0x1C28BA, 0x536991], |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
47 |
noteHeight: undefined, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
48 |
zeroShift: 0.9, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
49 |
timeWidth: 60, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
50 |
lineInterval: 5000, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
51 |
// wsUri: undefined, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
52 |
// eventCode: undefined |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
53 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
54 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
55 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
56 |
function DoubleRoll(options) { |
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 |
var _this = this; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
59 |
var opts = _(options).defaults(defaultConfig).value(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
60 |
|
95 | 61 |
var orientation = opts.orientation; |
62 |
var isHorizontal = (orientation !== 'vertical'); |
|
63 |
||
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
64 |
this.logger = opts.logger; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
65 |
this.lineColor = opts.lineColor; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
66 |
this.lineFillColor = opts.lineFillColor; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
67 |
this.framerate = opts.framerate; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
68 |
this.offsetMusic = opts.offsetMusic; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
69 |
this.noteColors = opts.noteColors; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
70 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
71 |
var noteHeight = opts.noteHeight; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
72 |
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
|
73 |
var timeWidth = opts.timeWidth; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
74 |
var lineInterval = opts.lineInterval; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
75 |
var offsetMusic = opts.offsetMusic; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
76 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
77 |
var sceneWidth = opts.sceneWidth; |
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
78 |
var stageView = opts.stageView; |
94
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 zeroShift = opts.zeroShift; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
81 |
|
98 | 82 |
var ws = opts.ws; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
83 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
84 |
var colorsReg = {}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
85 |
|
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
86 |
this.container = new PIXI.DisplayObjectContainer(); |
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
87 |
this.container.x = Math.floor(sceneWidth*zeroShift); |
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
88 |
this.container.y = 0; |
131 | 89 |
|
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
90 |
stageView.registerComponent(this); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
91 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
92 |
var pianorollList = []; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
93 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
94 |
var pianorollOptions = { |
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
95 |
parentContainer: this.container, |
95 | 96 |
orientation: orientation, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
97 |
xInit: 0, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
98 |
width: sceneWidth, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
99 |
noteColors: this.noteColors, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
100 |
colorsReg: colorsReg, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
101 |
lineColor: this.lineColor, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
102 |
lineInterval: lineInterval, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
103 |
offsetMusic: offsetMusic, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
104 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
105 |
|
105
25ac8802c189
Improve interface + Add horizontal pianoroll to annotsvizview
rougeronj
parents:
104
diff
changeset
|
106 |
var yInit = opts.yInit || 0; |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
107 |
var linesDown = true; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
108 |
_(opts.pianorolls).forEach(function(prDef, i) { |
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
|
109 |
var prNoteHeight = noteHeight || prDef.noteHeight || prDef.height / (prDef.top - prDef.bottom); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
110 |
var prTimeWidth = prDef.timeWidth || timeWidth; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
111 |
pianorollList.push(new PianoRoll(_({ |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
112 |
yInit: yInit, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
113 |
height: prDef.height, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
114 |
linesDown: linesDown, |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
115 |
pixelsPerSecond: Math.floor(sceneWidth / prTimeWidth), |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
116 |
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
|
117 |
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
|
118 |
range: prDef.range, |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
119 |
}).defaults(pianorollOptions).value())); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
120 |
yInit += prDef.height; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
121 |
linesDown = !linesDown; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
122 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
123 |
if(i<(opts.pianorolls.length-1)) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
124 |
var lineGraphics = new PIXI.Graphics() |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
125 |
.beginFill(_this.lineFillColor) |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
126 |
.lineStyle(1, _this.lineColor) |
95 | 127 |
.moveTo(Math.floor(sceneWidth*zeroShift), yInit) |
128 |
.lineTo(-sceneWidth - Math.floor(sceneWidth*zeroShift), yInit) |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
129 |
.endFill(); |
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
130 |
_this.container.addChild(lineGraphics); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
131 |
} |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
132 |
}); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
133 |
|
95 | 134 |
if(!isHorizontal) { |
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
135 |
this.container.rotation = Math.PI/2; |
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
136 |
this.container.y = sceneHeight; |
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
137 |
this.container.x = sceneWidth; |
95 | 138 |
} |
139 |
||
140 |
||
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
141 |
this.init = function() { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
142 |
|
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
143 |
ws.message(function(data) { |
98 | 144 |
_this.addNotes(data); |
145 |
}); |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
146 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
147 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
148 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
149 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
150 |
this.addNotes = function(data) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
151 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
152 |
pianorollList.forEach(function(c) { |
98 | 153 |
c.addNoteRaw(data); |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
154 |
}); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
155 |
}; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
156 |
|
100
0d7dac03c1a0
Merge with 72d767c5142df7fc6387215096321295fbaaa73d
rougeronj
parents:
98
diff
changeset
|
157 |
this.refresh = function() { |
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
158 |
pianorollList.forEach(function(c) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
159 |
c.move(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
160 |
}); |
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 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
163 |
// Init page and intervals |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
164 |
var startTs; |
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 |
this.start = function() { |
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 |
startTs = Date.now(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
169 |
pianorollList.forEach(function(c) { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
170 |
c.start(); |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
171 |
}); |
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 |
this.stop = function() { |
131 | 175 |
|
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.stop(); |
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 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
182 |
this.log = function(m) { |
98 | 183 |
if(this.logger) { |
184 |
this.logger.log(m); |
|
94
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
185 |
} |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
186 |
}; |
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 |
return this; |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
191 |
} |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
192 |
|
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
193 |
module.exports = { |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
194 |
DoubleRoll: DoubleRoll |
e0e514c5470f
create doubleroll component and modularize app
ymh <ymh.work@gmail.com>
parents:
diff
changeset
|
195 |
}; |