comparison nodescore.js @ 58:474c1ad1e811

big fix to seq logic and control css
author tzara <rc-web@kiben.net>
date Sun, 31 Mar 2013 01:46:39 +0000
parents 66bf613fb818
children 5ba250832739
comparison
equal deleted inserted replaced
57:a47aa7866ed8 58:474c1ad1e811
34 clientFiles.serve(request, response); 34 clientFiles.serve(request, response);
35 process.setMaxListeners(0); 35 process.setMaxListeners(0);
36 }); 36 });
37 }); 37 });
38 38
39 httpServer.listen(8889); 39 httpServer.listen(8890);
40 40
41 var pinging=0 41 var pinging=0
42 console.log("ping set to 0") 42 console.log("ping set to 0")
43 43
44 //requirejs(['socketsstuff'],function(socketsstuff) {}); 44 //requirejs(['socketsstuff'],function(socketsstuff) {});
45
46
47 //////////////////////////////////////////// 45 ////////////////////////////////////////////
48 // connect to websockets 46 // connect to websockets
49 //////////////////////////////////////////// 47 ////////////////////////////////////////////
50 48
51 io = sio.listen(httpServer) 49 io = sio.listen(httpServer)
203 var time = ((seq.durations[seq.counter]+1) *timemultiplier) + 30000 + (outcount*tempoms); 201 var time = ((seq.durations[seq.counter]+1) *timemultiplier) + 30000 + (outcount*tempoms);
204 var time = Math.floor(time) 202 var time = Math.floor(time)
205 var ztime = time; 203 var ztime = time;
206 var totaltime = Math.floor(time/tempoms) 204 var totaltime = Math.floor(time/tempoms)
207 var unit = seq.units[seq.counter]; 205 var unit = seq.units[seq.counter];
206 var unitlast = seq.units[seq.counter-1];
207
208 var voice = seq.voice; 208 var voice = seq.voice;
209 console.log(time) 209 console.log(unit,unitlast)
210 // initiate first page here 210 // initiate first page here
211 socket.broadcast.emit("pageFlipfromserver", voice, unit, time, seq.mm,seq.counter); 211 socket.broadcast.emit("pageFlipfromserver", voice, unit, time, seq.mm,seq.counter,unitlast);
212 socket.emit("pageFlipfromserver", voice, unit, time, seq.mm,seq.counter); 212 socket.emit("pageFlipfromserver", voice, unit, time, seq.mm,seq.counter,unitlast);
213 console.log("pageFlipfromserver", voice, unit, time, seq.mm,seq.counter, seq.durations[seq.counter])
214
213 215
214 function sequenCer() { 216 function sequenCer() {
215 // console.log(ztime) 217 // console.log(ztime)
216 if (ztime >= 0 ){ 218 if (ztime >= 0 ){
217 219
220 //////////////////////////////////////////// 222 ////////////////////////////////////////////
221 223
222 var counter = Math.floor(ztime/tempoms) 224 var counter = Math.floor(ztime/tempoms)
223 //console.log(counter) 225 //console.log(counter)
224 if (counter >= 0 ){ 226 if (counter >= 0 ){
225 socket.broadcast.emit('counterText', voice, seq.counter, counter); 227 socket.broadcast.emit('counterText', voice, unit, counter,seq.counter,unitlast);
226 socket.emit('counterText', voice, seq.counter, counter); 228 socket.emit('counterText', voice, unit, counter,seq.counter,unitlast);
227 229
228 if (counter <= outcount ) { 230 if (counter <= outcount ) {
229 socket.broadcast.emit('countinFromServer', voice, counter, "","stop in: ", "red", "transparent"); 231 socket.broadcast.emit('countinFromServer', voice, counter, "","stop in: ", "red", "transparent",unit);
230 } 232 }
231 233
232 if (counter > (totaltime)-incount && counter <= totaltime ) { 234 if (counter > (totaltime)-incount && counter <= totaltime ) {
233 socket.broadcast.emit('countinFromServer', voice, counter-(totaltime-incount), "","play in: ", "green","transparent"); 235 socket.broadcast.emit('countinFromServer', voice, counter-(totaltime-incount), "","play in: ", "green","transparent",unit);
234 socket.emit('countinFromServer', voice, counter-(totaltime-incount), "","play in: ", "green","transparent"); 236 socket.emit('countinFromServer', voice, counter-(totaltime-incount), "","play in: ", "green","transparent",unit);
235 } 237 }
236 238
237 if (counter == (totaltime)-incount ) { 239 if (counter == (totaltime)-incount ) {
238 socket.broadcast.emit('countinFromServer', voice, "+", "","playing.. ", "green","transparent"); 240 socket.broadcast.emit('countinFromServer', voice, "+", "","playing.. ", "green","transparent",unit);
239 socket.emit('countinFromServer', voice, "+", "","playing.. ", "green","transparent"); 241 socket.emit('countinFromServer', voice, "+", "","playing.. ", "green","transparent",unit);
240 } 242 }
241 243
242 // remove displayed number with " " at end of both countin/out 244 // remove displayed number with " " at end of both countin/out
243 245
244 if (counter == 0 ) { 246 if (counter == 0 ) {
245 socket.broadcast.emit('countinFromServer', voice, "", "","", "green","transparent"); 247 socket.broadcast.emit('countinFromServer', voice, "", "","", "green","transparent",unit);
246 socket.broadcast.emit('counterText', voice, seq.counter, ""); 248 socket.broadcast.emit('counterText', voice, seq.counter, "", unit);
247 socket.emit('counterText', voice, seq.counter, ""); 249 socket.emit('counterText', voice, seq.counter, "",unit);
248 } 250 }
249 } 251 }
250 252
251 // on each beat do: 253 // on each beat do:
252 254
259 261
260 // flip the page 262 // flip the page
261 if (counter == 0){ 263 if (counter == 0){
262 seq.counter = (seq.counter + 1) % seq.durations.length 264 seq.counter = (seq.counter + 1) % seq.durations.length
263 socket.broadcast.emit("pageFlipfromserver", voice, unit, time, seq.mm,seq.counter); 265 socket.broadcast.emit("pageFlipfromserver", voice, unit, time, seq.mm,seq.counter);
266 console.log("pageFlipfromserver", voice, unit, time, seq.mm,seq.counter, seq.durations[seq.counter])
264 //delete tockTock; 267 //delete tockTock;
265 step(seq); 268 step(seq);
266 } 269 }
267 270
268 // decrement the time 271 // decrement the time