Mercurial > hg > nodescore
changeset 70:753414e075a0
danger stash pop
author | tzara <rc-web@kiben.net> |
---|---|
date | Sat, 26 Oct 2013 13:43:08 +0000 |
parents | 333afcfd3f3a |
children | a1eacfae4fcf |
files | nodescore nodescore.js www/emma/index.html www/emma/js/controlseq.js www/emma/js/nodescore-slides.js |
diffstat | 5 files changed, 90 insertions(+), 155 deletions(-) [+] |
line wrap: on
line diff
--- a/nodescore Sat Oct 26 14:12:50 2013 +0100 +++ b/nodescore Sat Oct 26 13:43:08 2013 +0000 @@ -10,7 +10,7 @@ # nodescore@kiben.net # nodescore.kiben.net -export NODE_PATH=${NODE_PATH}:/home/root/node_modules/:/home/rob/node_modules/:/usr/share/nodescore/ +export NODE_PATH=${NODE_PATH}:/home/root/node_modules/:/home/rob/node_modules/:/home/pi/node_modules/:/usr/share/nodescore/ if [ "$1" = "home" ] then
--- a/nodescore.js Sat Oct 26 14:12:50 2013 +0100 +++ b/nodescore.js Sat Oct 26 13:43:08 2013 +0000 @@ -22,7 +22,6 @@ //are loaded relative to the top-level JS file. nodeRequire: require, findNestedDependencies: true - }); // run webserver serving static html @@ -71,35 +70,30 @@ io.sockets.emit('nicknames', nicknames); } }); - + /// chat user messages to screens and to log file // date format for filename - var da = new Date(); var dtstring = da.getFullYear()+ '-' + da.getMonth()+ '-' + da.getDate(); - //////////////////////// /// log messages to file socket.on('user message', function (msg) { fs.open('logs/chatlog-'+dtstring+'.txt', 'a', 666, function( e, id ) { //time format for message stamp var dt = new Date();var timestring = dt.getHours() + ':' + dt.getMinutes() + ':' + dt.getSeconds(); - - socket.broadcast.emit('user message', socket.nickname, msg); - + socket.broadcast.emit('user message', socket.nickname, msg); var fs = require('fs'), str = msg; fs.write( id, timestring+" " + socket.nickname + ": "+ msg+"\n", null, 'utf8', function(){}); }); }); - -// /* + //////////////////////////////////////////// // chronometer + sequencer controls (all this should be modularised) //////////////////////////////////////////// socket.on('stopWatch', function (state) { stopWatch(state);}); - socket.on('stopChr', function () { stopChr();}); + socket.on('stopChr', function () { stopChr(); }); socket.on('resetChr', function () { resetChr();}); - socket.on('startSeq', function () { startChr();}); + socket.on('startSeq', function () { startChr(); }); var chronstate=0; // send the date/time every second @@ -109,84 +103,45 @@ socket.broadcast.emit('dateTime', d) socket.emit('dateTime', d) }, 1000) + + ////////////////////////////// + // /* this should be moved to its own file chronometer.js + function chronCtrl (state,interval){ + if (state==1){ console.log("chronControl....onestate") + var date = new Date(); var starttime = new Date().getTime() / 1000; + xstopwatch = setInterval(function () { + var nowtime = new Date().getTime() / 1000; + now = nowtime-starttime + hours = parseInt( now / 3600 ) % 24; + minutes = parseInt( now / 60 ) % 60; + seconds = parseInt(now % 60); + milliseconds = Math.floor((now-seconds)*10)%60; + time = + (hours < 10 ? "0" + hours : hours) + ":" + + (minutes < 10 ? "0" + minutes : minutes) + ":" + + (seconds < 10 ? "0" + seconds : seconds) + "."+ + milliseconds; + socket.broadcast.emit('chronFromServer', time) + socket.emit('chronFromServer', time) + }, 100) + } + + if (state==0) { console.log("chronControl....zerostate") ; clearInterval(xstopwatch); } + + } + + + // if not already started start the chronometer and sequencer + function startChr(socket) { chronCtrl(1,100); step(seqA);step(seqB); step(seqC); step(seqD); } + // stop the chronometer + function stopChr() { console.log("stop chron"); chronCtrl(0); } - // if not already started start the chronometer and sequencer - function startChr(socket) { if (chronstate !== 1) { - chronstate = 1; - chronCtrl(1,100); - step(seqA);step(seqB); step(seqC); step(seqD); - } - } - - // if not already started start the chronometer - function stopWatch(state) { if (chronstate !== 1) { - if (state==1){ - chronstate = 1; - chronCtrl(1,100);} - } - - // if get 0 then stop the chron - if (state==0){ - chronstate = 0; - clearInterval(xstopwatch); - } - // if get 2 then reset the chron - if (state==2){ - chronstate = 0; - c=ch.zeroChron() - socket.broadcast.emit('chronFromServer', c) - socket.emit('chronFromServer', c) - } - } - - -////////////////////////////// -// /* this should be moved to its own file chronometer.js - - function chronCtrl (state,interval){ - console.log("=========================== chronstate=" + chronstate) - if (state==1){ - var date = new Date() - var starttime = new Date().getTime() / 1000; - //var interval = 1020 - date.getMilliseconds(); - xstopwatch = setInterval(function () { - var nowtime = new Date().getTime() / 1000; - now = nowtime-starttime - hours = parseInt( now / 3600 ) % 24; - minutes = parseInt( now / 60 ) % 60; - seconds = parseInt(now % 60); - milliseconds = Math.floor((now-seconds)*10)%60; - time = - (hours < 10 ? "0" + hours : hours) + ":" + - (minutes < 10 ? "0" + minutes : minutes) + ":" + - (seconds < 10 ? "0" + seconds : seconds) + "."+ - milliseconds; - socket.broadcast.emit('chronFromServer', time) - socket.emit('chronFromServer', time) - }, 100) - } - if (state==0) { - clearInterval(xstopwatch); - } - } -//*/ - - // stop the chronometer - - function stopChr() {console.log("stop chron................................................") - chronCtrl(0) - chronstate=0 - } - function pad(number) { return (number < 10 ? '0' : '') + number } function resetChr() {//clearInterval(); - chronstate = 0; - zecsec = 0; seconds = 0; - mins = 0; hours = 0; - chronstate = 0; + zecsec = 0; seconds = 0; mins = 0; hours = 0; var chron = pad(hours) +":"+pad(mins)+ ':'+ pad(seconds)+ ":"+ zecsec - // send 0.0.0 values to display + // send 0.00.00 values to display socket.broadcast.emit('chronFromServer', chron) socket.emit('chronFromServer', chron) } @@ -196,7 +151,7 @@ //////////////////////////////////////////// // all the variables this sequencer needs are in scoreB.js requirejs(['scoreB'],function(scoreB) {}); - + var sequencerState=0; var numberoftransects=3 var order=8 @@ -211,36 +166,26 @@ var time = dur; var ztime=time; var totaltime=time + initPage=function(seq){ + // initiate first page here + socket.emit("pageIni", voice, unit, time, seq.mm,seq.counter,seq.nextunit ); + socket.emit("pageFlipfromserver", voice, unit, time, seq.mm,seq.counter,seq.nextunit ); + } - if (seq.counter == 7){ seq.nexttransect=seq.transect+1 ; - seq.nextunit=seq.units[seq.nexttransect%numberoftransects][seq.counter]; - } - else - seq.nextunit=seq.units[seq.transect%numberoftransects][seq.counter+1]; - - // initiate first page here - socket.broadcast.emit("pageFlipfromserver", - voice, unit, time, - seq.mm,seq.counter,seq.nextunit ); - socket.emit("pageFlipfromserver", - voice, unit, time, - seq.mm,seq.counter,seq.nextunit ); - function sequenCer() { - if (ztime >= 0 ){ + if (ztime >= 0 ){ var counter = ztime - // flip the page - if (counter == 0){ - //increment the row position - seq.counter = (seq.counter + 1) % (order) - //increment the transect - if ( seq.counter==0 ){ seq.transect += 1 } - socket.broadcast.emit("pageFlipfromserver", voice, unit, time, seq.mm,seq.counter,seq.nextunit); - - clearInterval(pulse) - step(seq); - } - + // flip the page + if (counter == 0){ + //increment the row position + seq.counter = (seq.counter + 1) % (order) + //increment the transect + if ( seq.counter==0 ){ seq.transect += 1 } + socket.broadcast.emit("pageFlipfromserver", voice, unit, time, seq.mm,seq.counter,seq.nextunit); + clearInterval(pulse) + step(seq); + } + if (counter >= 0 ){ socket.broadcast.emit('counterText', voice, unit, counter,seq.counter,unitlast,seq.transect%numberoftransects); @@ -282,8 +227,6 @@ socket.emit('metroPulse', tempoms, voice, seq.metrobeat); } - - // decrement the time ztime -= 1 @@ -294,21 +237,21 @@ var pulse = setInterval(sequenCer, tempoms); socket.on('stopSeq', function () { - //donaldduck = mickeymouse + 7 sequenCer.clearInterval console.log("sequencer stopping...") // grrr why wont this clearInterval work sequencerState = 0 clearInterval(pulse) - stopChr(); + sequenCer.clearInterval(pulse) + stopChr(); }); }; step = function (seq) { - clearInterval(countdowntick); countdowntick(seq) sequencerState=1; + initPage(seq) }; socket.on('resetSeq', function () { resetChr(); }); @@ -356,14 +299,7 @@ socket.emit("latencyFromServer", latency); }); - // this is the trigger from the control client to start the process - // maybe remove this and have latency connections constantly running - - /* - socket.on("getLatencies", function(x){ - serverTime(x); - }); - */ + serverTime(1000); @@ -378,10 +314,7 @@ socket.broadcast.emit('nicknames', nicknames); }); +}); -}); -//}); -//exports.io = io; -//exports.sio = sio; exports.socket= io.sockets; exports.httpServer = httpServer;
--- a/www/emma/index.html Sat Oct 26 14:12:50 2013 +0100 +++ b/www/emma/index.html Sat Oct 26 13:43:08 2013 +0000 @@ -2,7 +2,7 @@ <html> <head> <meta charset="UTF-8"> - <title>controls@nodescore</title> + <title>controlx@nodescore</title> <script src="/socket.io/socket.io.js"></script> <link rel="shortcut icon" href="/kiben_favicon.ico" type="image/x-icon" /> <link href="css/nodescore.css" rel="stylesheet"> @@ -15,7 +15,7 @@ <script src="js/nodescore-slides.js"></script> </head> -<body> +<body onload="initPage()"> <input type="hidden" id="group" value='1'/>
--- a/www/emma/js/controlseq.js Sat Oct 26 14:12:50 2013 +0100 +++ b/www/emma/js/controlseq.js Sat Oct 26 13:43:08 2013 +0000 @@ -1,10 +1,13 @@ ////////////////////////////////////////////// var socket = io.connect(); ////////////////////////////////////////////// + + // Sequencer Controls function startSeq() { socket.emit("startSeq") } function stopSeq() { socket.emit("stopSeq") } function resetSeq() { socket.emit("resetSeq") } + ////////////////////////////////////////////// // Chron Controls function stopWatch(value) { socket.emit("stopWatch", value) } @@ -101,11 +104,11 @@ */ -function pad2(number) { return (number < 10 ? '0' : '') + number } -socket.on("pageFlipfromserver", pageTurn); -function pageTurn (group,unit,time,mm) { - var g= pad2(group); - var groupPage=document.getElementById('group').value; - $("#previewbox-"+group).html("<img src='svg/"+(unit) + ".svg" + "' width='515'>") - } +//function pad2(number) { return (number < 10 ? '0' : '') + number } +//socket.on("pageFlipfromserver", pageTurn); +//function pageTurn (group,unit,time,mm) { +// var g= pad2(group); +// var groupPage=document.getElementById('group').value; + // $("#previewbox-"+group).html("<img src='svg/"+(unit) + ".svg" + "' width='515'>") +// }
--- a/www/emma/js/nodescore-slides.js Sat Oct 26 14:12:50 2013 +0100 +++ b/www/emma/js/nodescore-slides.js Sat Oct 26 13:43:08 2013 +0000 @@ -3,27 +3,26 @@ var socket = io.connect(); +function initPage() { socket.emit("initPage"); + console.log("init.client.log") + } + //socket.on("metroPulse", metronomeTick); ///////////////////////////////////////////////// socket.on("metroPulse", pulseInClient); function pulseInClient(pulse,groupID,metrobeat){ - var groupPage=document.getElementById('group').value if (groupID == groupPage) { metronomeTick(1000, groupID, metrobeat); } } + ///////////////////////////////////////////////// function metroCss(beat, beatcolor,text){ var color = beatcolor; $(".metrocase > div").each(function(){$(this).stop()}); $(".metrocase > div").each(function(){$(this).css('background-color', beatcolor)}); $(".metrocase > div").each(function(){$(this).text(" ")}); - // $(".metrocase > div").each(function(){$(this).animate({color: blue}, -// 50, -// function() { $(this).animate({color:red}); } -// ); -// }) } function metronomeTick(pulse, voice,metrobeat) { @@ -37,8 +36,6 @@ socket.on("chronFromServer", function(chron) { $("div#client_chronometer").text(chron); }); // server time -//var groupPage=document.getElementById('group').value -//if (groupID == groupPage) { socket.on("dateTime", function(datetime) { $("div#datetime").text("" +datetime); }); @@ -81,21 +78,23 @@ var groupPage=document.getElementById('group').value; if (group == groupPage) { console.log(unit + " ---> " + nextunit) - var g= pad2(group); - var p= pad2(unit); - var units=8; - var next=(((unit+1)%units)+units)%units - //$("#live").load("music.html #"+unit +" *"); $("#live").load("music.html #"+unit); - - //$("#live").html("<img src='thumbs/"+ (unit) + ".png" + "' width='715'>") $("#preview").html("<h3 style='background:transparent; position: relative; font-size:1.5em;top:14px; left:10px;';> n e x t : </h3><img src='thumbs/"+ (nextunit) + ".png" + "' width='305'>") + //$("#previewbox-"+group).html("<img src='svg/"+(unit) + ".svg" + "' width='515'>") } else { - //console.log("not for this group... ignoring... for group:" + group ); + console.log("not for this group... ignoring... for group:" + group ); } } +socket.on("pageIni", pageIni); +function pageIni (group,unit,time,mm,seqcounter,nextunit) { + console.log(unit + " ---> " + nextunit) + //$("#live").load("music.html #"+unit); + //$("#preview").html("<h3 style='background:transparent; position: relative; font-size:1.5em;top:14px; left:10px;';> n e x t : </h3><img src='thumbs/"+ (nextunit) + ".png" + "' width='305'>") + $("#previewbox-"+group).html("<img src='svg/"+(unit) + ".svg" + "' width='515'>") +} + //////////////////////////////////////////////// /* commented out for now as interferes with chat