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