-
Notifications
You must be signed in to change notification settings - Fork 1
/
SoundOfSails-LangeNacht
1 lines (1 loc) · 118 KB
/
SoundOfSails-LangeNacht
1
[{"id":"b33df394.0d87b8","type":"http in","z":"26e4310.b9db45","name":"","url":"/image","method":"get","swaggerDoc":"","x":174.0992431640625,"y":2410.940399169922,"wires":[["27275584.d246ea"]]},{"id":"989b86fa.c93bb8","type":"function","z":"26e4310.b9db45","name":"Set Content-Type header","func":"msg.headers = {\n \"Content-Type\":\"image/jpeg\"\n};\nreturn msg;","outputs":1,"noerr":0,"x":784.5992431640625,"y":2475.690399169922,"wires":[["6369f768.101ff"]]},{"id":"27275584.d246ea","type":"switch","z":"26e4310.b9db45","name":"file specified","property":"payload.file","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","outputs":2,"x":364.0992431640625,"y":2410.440399169922,"wires":[["23094f2b.5d156"],["bc8699ac.b29228"]]},{"id":"23094f2b.5d156","type":"function","z":"26e4310.b9db45","name":"not found","func":"msg.payload = \"404 not found\"\nreturn msg;","outputs":1,"noerr":0,"x":585.0992431640625,"y":2404.440399169922,"wires":[["6369f768.101ff"]]},{"id":"bc8699ac.b29228","type":"function","z":"26e4310.b9db45","name":"file name","func":"msg.filename = msg.payload.file;\nreturn msg;","outputs":1,"noerr":0,"x":442.5992431640625,"y":2475.690399169922,"wires":[["3589fbb.8629984"]]},{"id":"fdaff844.2bc488","type":"http in","z":"26e4310.b9db45","name":"","url":"/sos","method":"get","swaggerDoc":"","x":118.5714111328125,"y":112.85713958740234,"wires":[["9069e3bb.e70ae"]]},{"id":"6369f768.101ff","type":"http response","z":"26e4310.b9db45","name":"","x":1000.5992546081543,"y":2404.190400123596,"wires":[]},{"id":"86dd0531.8f6eb","type":"http response","z":"26e4310.b9db45","name":"","x":897.1429443359375,"y":112.85712432861328,"wires":[]},{"id":"70759966.5d37","type":"template","z":"26e4310.b9db45","name":"Overview Page","field":"payload","fieldType":"msg","format":"html","syntax":"mustache","template":"<html>\n\t<head>\n\t\t<title>Sound of Sails</title>\n\t\t<meta name=\"description\" content=\"Die Altonaer Schiffsgemäldesammlung vertont von IBM Watson Visual Recognition\">\n\n\t\t<style>\n\t\t\tbody {background: #000;text-align:center;}\n\t\t\t.image {\n\t\t\t width: 30%;margin-left:1%;margin-top: 1%;\n\t\t\t \n\t\t\t}\n\t\t\t\n\t\t\t.header {\n\t\t\t width: 100%;margin-bottom: 1%;\n\t\t\t}\n\t\t\t\n\t\t\t.footer {\n\t\t\t width: 100%;margin-bottom: 1%;\n\t\t\t}\n\t\t\t\n\t\t</style>\n\t</head>\n\t<body>\n <p><a href=\"http://{{ip}}/Credits\"><img class=\"header\" alt=\"\" src=\"http://{{ip}}/image?file=/Website/banner.png\"></a></p>\n\t\t\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82520ab637.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82520ab637.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825218aee2.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825218aee2.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825220573b.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825220573b.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82522669eb.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82522669eb.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252278997.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252278997.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82522ec2c3.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82522ec2c3.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825235bab2.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825235bab2.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82523d5894.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82523d5894.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252453730.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252453730.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82524c393b.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82524c393b.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82525410b5.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82525410b5.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825259ffb7.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825259ffb7.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825261ed43.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825261ed43.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825268b3b7.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825268b3b7.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82527054a4.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82527054a4.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82527a2f5e.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82527a2f5e.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82527be687.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82527be687.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82528358b7.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82528358b7.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82528a331f.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82528a331f.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252915847.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252915847.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252999eba.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252999eba.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252a36cc8.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252a36cc8.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252aaa1bb.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252aaa1bb.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252abb541.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252abb541.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252ac8bf3.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252ac8bf3.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252b4ac96.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252b4ac96.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252be0cfc.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252be0cfc.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252c4f6a4.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252c4f6a4.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252cb0859.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252cb0859.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252d291da.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252d291da.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252d9e4fc.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252d9e4fc.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252db1a07.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252db1a07.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252e2606a.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252e2606a.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252e975c0.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252e975c0.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252f0506a.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252f0506a.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252f6322b.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252f6322b.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252fc4e14.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252fc4e14.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82530263d0.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82530263d0.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82530b5005.jpg\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82530b5005.jpg\"></a>\n\t\n\t <p><a href=\"http://{{ip}}/Credits\"><img class=\"footer\" alt=\"\" src=\"http://{{ip}}/image?file=/Website/credits.png\"></a></p>\n\n\t</body>{{path}}class=\"image\" \n</html>{{path}}class=\"image\" \nclass=\"image\" ","x":675.6429443359375,"y":129.10712432861328,"wires":[["86dd0531.8f6eb"]]},{"id":"91d1d481.343b88","type":"http response","z":"26e4310.b9db45","name":"","x":1568.071346282959,"y":373.85711002349854,"wires":[]},{"id":"c2347085.fa849","type":"http in","z":"26e4310.b9db45","name":"","url":"/show","method":"get","swaggerDoc":"","x":116.5714111328125,"y":274.8571472167969,"wires":[["cc65d6c3.b0fbd8","bc5a537d.60ee1"]]},{"id":"cc65d6c3.b0fbd8","type":"function","z":"26e4310.b9db45","name":"file name","func":"msg.filename = msg.payload.file;\n\nmsg.payload = {\n \"image\" : msg.payload.file\n \n}\nreturn msg;","outputs":1,"noerr":0,"x":256.5714111328125,"y":274.8571472167969,"wires":[["46a943ed.9cbaf4","83672ff.73209d"]]},{"id":"ae6b294e.7ae748","type":"comment","z":"26e4310.b9db45","name":"Overview Page","info":"","x":138.5714111328125,"y":72.85713958740234,"wires":[]},{"id":"5fe1af0f.1af51","type":"comment","z":"26e4310.b9db45","name":"Detail Page (single image)","info":"","x":166.5714111328125,"y":234.85714721679688,"wires":[]},{"id":"87930341.162078","type":"comment","z":"26e4310.b9db45","name":"Serve images from /home/pi/sound_of_sails/","info":"","x":274.0992431640625,"y":2371.690399169922,"wires":[]},{"id":"9069e3bb.e70ae","type":"function","z":"26e4310.b9db45","name":"IP oder Domain und Audio Pfad","func":"msg.ip = \"sound-of-sails.mybluemix.net\"; //your ip here\nmsg.path = \"Schiffsportraits\"\nreturn msg;","outputs":1,"noerr":0,"x":374.6429443359375,"y":114.10712432861328,"wires":[["70759966.5d37"]]},{"id":"46a943ed.9cbaf4","type":"function","z":"26e4310.b9db45","name":"Hier IP eintragen","func":"msg.ip = \"sound-of-sails.mybluemix.net\"; //your ip here\nreturn msg;","outputs":1,"noerr":0,"x":426.5714111328125,"y":274.8571472167969,"wires":[["543b7aab.b8fd24"]]},{"id":"78798be9.33bc54","type":"comment","z":"26e4310.b9db45","name":"Image Analysis","info":"See corresponding Lab instructions in the link below :\n\n[Watson Visual Recognition](https://github.com/watson-developer-cloud/node-red-labs/tree/master/basic_examples/visual_recognition_v3)\n","x":624.488109588623,"y":482.44052362442017,"wires":[]},{"id":"b4e4a041.b56b","type":"function","z":"26e4310.b9db45","name":"set Classifier","func":"// initialise the counter to 0 if it doesn't exist already\nvar count = context.get('count')||0;\ncount += 1;\ncount %= 40;\n// store the value back\ncontext.set('count',count);\n// make it part of the outgoing msg object\nmsg.count = count;\n\n//msg.filename=\"Ship (\" + (count) + \").jpg\";\nmsg.params={};\nmsg.params[\"owners\"]=\"me\";\nmsg.params[\"classifier_ids\"]=[\"sun_409678915\",\"threemast_372982515\",\"storm_1384366973\"];\nreturn msg;","outputs":1,"noerr":0,"x":503.23810958862305,"y":550.1905236244202,"wires":[["825bef90.8b36a"]]},{"id":"ff94d306.bf4d3","type":"visual-recognition-v3","z":"26e4310.b9db45","name":"","apikey":"","image-feature":"classifyImage","lang":"en","x":629.238109588623,"y":589.1905236244202,"wires":[["f57e0abe.4a29d"]]},{"id":"fa7dc402.78684","type":"comment","z":"26e4310.b9db45","name":"Play Audio on SOS Webpage","info":"","x":1344.9525871276855,"y":515.0476098060608,"wires":[]},{"id":"3589fbb.8629984","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"","name":"","x":590.222282409668,"y":2474.8332176208496,"wires":[["989b86fa.c93bb8"]]},{"id":"274deffb.60ed1","type":"play audio","z":"26e4310.b9db45","name":"","x":1399.2025871276855,"y":850.8334069252014,"wires":[]},{"id":"83672ff.73209d","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"","name":"","x":423.16669845581055,"y":513.583315372467,"wires":[["b4e4a041.b56b"]]},{"id":"aa8c8ff8.8ea63","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"","name":"","x":1288.9882316589355,"y":809.1905846595764,"wires":[["274deffb.60ed1"]]},{"id":"6a0fbec7.b2c638","type":"comment","z":"26e4310.b9db45","name":"Play Audio in Node RED","info":"https://www.html5rocks.com/en/tutorials/webaudio/intro/","x":1340.2738761901855,"y":765.9762291908264,"wires":[]},{"id":"9da61a1c.244cb","type":"template","z":"26e4310.b9db45","name":"","field":"payload","fieldType":"msg","format":"html","syntax":"mustache","template":"<html>\n\n<script>\n\nconsole.log(\"starting audio script!\");\n\n// Websocket\nvar connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n\n// When the connection is open, send some data to the server\nconnection.onopen = function () {\n connection.send('Ready'); // Send the message 'Ping' to the server\n};\n\n// Log errors\nconnection.onerror = function (error) {\n console.log('WebSocket Error ' + error);\n connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n};\n\n// Log messages from the server\nconnection.onmessage = function (e) {\n console.log('Server: ' + e.data);\n};\n\n// BufferloaderClass\nfunction BufferLoader(context, urlList, callback) {\n this.context = context;\n this.urlList = urlList;\n this.onload = callback;\n this.bufferList = new Array();\n this.loadCount = 0;\n}\n\nBufferLoader.prototype.loadBuffer = function(url, index) {\n // Load buffer asynchronously\n var request = new XMLHttpRequest();\n request.open(\"GET\", url, true);\n request.responseType = \"arraybuffer\";\n\n var loader = this;\n\n request.onload = function() {\n // Asynchronously decode the audio file data in request.response\n loader.context.decodeAudioData(\n request.response,\n function(buffer) {\n if (!buffer) {\n alert('error decoding file data: ' + url);\n return;\n }\n loader.bufferList[index] = buffer;\n if (++loader.loadCount == loader.urlList.length)\n loader.onload(loader.bufferList);\n },\n function(error) {\n console.error('decodeAudioData error', error);\n }\n );\n }\n\n request.onerror = function() {\n alert('BufferLoader: XHR error');\n }\n\n request.send();\n}\n\nBufferLoader.prototype.load = function() {\n for (var i = 0; i < this.urlList.length; ++i)\n this.loadBuffer(this.urlList[i], i);\n}\n\n// !BufferloaderClass\n\n// AudioPlayback\n//window.onload = init;\nvar context;\nvar bufferLoader;\nvar gainNode;\n\n// Log messages from the server\nconnection.onmessage = function (e) {\n console.log('Server: ' + e.data);\n \n//};\n//function init() {\n \n console.log(\"calling init!\");\n \n // Fix up prefixing\n window.AudioContext = window.AudioContext || window.webkitAudioContext;\n context = new AudioContext();\n \n console.log(\"loading buffer!\");\n bufferLoader = new BufferLoader(\n context,\n [\n 'http://{{ip}}/sound?file=' + e.data // Audio/joy.wav\n// 'http://{{ip}}/sound?file=/Audio/fear.wav',\n ],\n finishedLoading\n );\n\n bufferLoader.load();\n}\n\nfunction finishedLoading(bufferList) {\n \n console.log(\"done loading, creating audio source!\");\n // Create two sources and play them both together.\n var source1 = context.createBufferSource();\n //var source2 = context.createBufferSource();\n source1.buffer = bufferList[0];\n //source2.buffer = bufferList[1];\n\n console.log(\"creating gain node!\");\n // Create a gain node.\n gainNode = context.createGain();\n // Connect the source to the gain node.\n source1.connect(gainNode);\n //source2.connect(gainNode);\n // Connect the gain node to the destination.\n gainNode.connect(context.destination);\n \n console.log(\"setting gain to 1!\");\n gainNode.gain.value = 1;\n\n console.log(\"starting audio playback!\");\n source1.start(0);\n //source2.start(0);\n \n window.setInterval(stopCallback, 3000);\n}\n\nfunction stopCallback() {\n console.log(\"setting gain to 0!\");\n gainNode.gain.value = 0;\n }\n</script>\n</html>\n","x":590.8728637695312,"y":2861.388885498047,"wires":[["fc254151.98a23"]]},{"id":"3f5fa804.8003c8","type":"function","z":"26e4310.b9db45","name":"Hier IP eintragen","func":"msg.ip = \"sound-of-sails.mybluemix.net\"; //your ip here\nreturn msg;","outputs":1,"noerr":0,"x":398.0950241088867,"y":2860.952419281006,"wires":[["9da61a1c.244cb"]]},{"id":"864aa3f0.20ebd","type":"http in","z":"26e4310.b9db45","name":"","url":"/test","method":"get","swaggerDoc":"","x":164.76165771484375,"y":2861.904754638672,"wires":[["3f5fa804.8003c8"]]},{"id":"fc254151.98a23","type":"http response","z":"26e4310.b9db45","name":"","x":754.999755859375,"y":2859.285858154297,"wires":[]},{"id":"567aecd1.ecddd4","type":"http in","z":"26e4310.b9db45","name":"","url":"/sound","method":"get","swaggerDoc":"","x":173.8527946472168,"y":2586.2121438980103,"wires":[["935566ed.1971d"]]},{"id":"2e8840e7.9d3708","type":"function","z":"26e4310.b9db45","name":"Set Content-Type header","func":"msg.headers = {\n \"Content-Type\":\"audio/wav\"\n};\nreturn msg;","outputs":1,"noerr":0,"x":786.4955101013184,"y":2651.9263772964478,"wires":[["f3fd1c23.03a628"]]},{"id":"935566ed.1971d","type":"switch","z":"26e4310.b9db45","name":"file specified","property":"payload.file","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","outputs":2,"x":365.99551010131836,"y":2586.6763772964478,"wires":[["1804f89d.7cf8b7"],["3b6daf11.21e438"]]},{"id":"1804f89d.7cf8b7","type":"function","z":"26e4310.b9db45","name":"not found","func":"msg.payload = \"404 not found\"\nreturn msg;","outputs":1,"noerr":0,"x":586.9955101013184,"y":2580.6763772964478,"wires":[["f3fd1c23.03a628"]]},{"id":"3b6daf11.21e438","type":"function","z":"26e4310.b9db45","name":"file name","func":"msg.filename = msg.payload.file;\nreturn msg;","outputs":1,"noerr":0,"x":444.49551010131836,"y":2651.9263772964478,"wires":[["4f3554e8.ddeda4"]]},{"id":"f3fd1c23.03a628","type":"http response","z":"26e4310.b9db45","name":"","x":1002.4955215454102,"y":2580.426378250122,"wires":[]},{"id":"4f3554e8.ddeda4","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"","name":"","x":592.1185493469238,"y":2651.0691957473755,"wires":[["2e8840e7.9d3708"]]},{"id":"7d5ee8a2.8eaa","type":"comment","z":"26e4310.b9db45","name":"Serve images from /home/pi/sound_of_sails/","info":"","x":272.42432403564453,"y":2546.2120838165283,"wires":[]},{"id":"ca96b092.e75d08","type":"template","z":"26e4310.b9db45","name":"","field":"payload","fieldType":"msg","format":"html","syntax":"mustache","template":"<html>\n\n<script>\n\nconsole.log(\"starting audio script!\");\n\nfunction BufferLoader(context, urlList, callback) {\n this.context = context;\n this.urlList = urlList;\n this.onload = callback;\n this.bufferList = new Array();\n this.loadCount = 0;\n}\n\nBufferLoader.prototype.loadBuffer = function(url, index) {\n // Load buffer asynchronously\n var request = new XMLHttpRequest();\n request.open(\"GET\", url, true);\n request.responseType = \"arraybuffer\";\n\n var loader = this;\n\n request.onload = function() {\n // Asynchronously decode the audio file data in request.response\n loader.context.decodeAudioData(\n request.response,\n function(buffer) {\n if (!buffer) {\n alert('error decoding file data: ' + url);\n return;\n }\n loader.bufferList[index] = buffer;\n if (++loader.loadCount == loader.urlList.length)\n loader.onload(loader.bufferList);\n },\n function(error) {\n console.error('decodeAudioData error', error);\n }\n );\n }\n\n request.onerror = function() {\n alert('BufferLoader: XHR error');\n }\n\n request.send();\n}\n\nBufferLoader.prototype.load = function() {\n for (var i = 0; i < this.urlList.length; ++i)\n this.loadBuffer(this.urlList[i], i);\n}\n\nwindow.onload = init;\nvar context;\nvar bufferLoader;\nvar gainNode;\n\nfunction init() {\n \n console.log(\"calling init!\");\n \n // Fix up prefixing\n window.AudioContext = window.AudioContext || window.webkitAudioContext;\n context = new AudioContext();\n \n console.log(\"loading buffer!\");\n bufferLoader = new BufferLoader(\n context,\n [\n 'http://{{ip}}/sound?file=/Audio/joy.wav'\n// 'http://{{ip}}/sound?file=/Audio/fear.wav',\n ],\n finishedLoading\n );\n\n bufferLoader.load();\n}\n\nfunction finishedLoading(bufferList) {\n \n console.log(\"done loading, creating audio source!\");\n // Create two sources and play them both together.\n var source1 = context.createBufferSource();\n //var source2 = context.createBufferSource();\n source1.buffer = bufferList[0];\n //source2.buffer = bufferList[1];\n\n console.log(\"creating gain node!\");\n // Create a gain node.\n gainNode = context.createGain();\n // Connect the source to the gain node.\n source1.connect(gainNode);\n //source2.connect(gainNode);\n // Connect the gain node to the destination.\n gainNode.connect(context.destination);\n \n console.log(\"setting gain to 1!\");\n gainNode.gain.value = 1;\n\n console.log(\"starting audio playback!\");\n source1.start(0);\n //source2.start(0);\n \n window.setInterval(stopCallback, 3000);\n}\n\nfunction stopCallback() {\n console.log(\"setting gain to 0!\");\n gainNode.gain.value = 0;\n }\n</script>\n</html>\n","x":589.29638671875,"y":2928.0370178222656,"wires":[[]]},{"id":"9e4c458b.44579","type":"websocket out","z":"26e4310.b9db45","name":"","server":"b76a1ee4.f1e918","client":"","x":1285.5060539245605,"y":559.4821801185608,"wires":[]},{"id":"4355b6ae.3605e","type":"template","z":"26e4310.b9db45","name":"Image Detail Page","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n\t<head>\n\t\t<title>Sound of Sails</title>\n\t\t<style>\n\t\t\tbody {margin:0;background: #000;text-align:center;}\n\t\t\timg {height: 80%;margin-top:5%;}\n\t\t</style>\n\t</head>\n\t\t<a href=\"http://{{ip}}/sos\"><img alt=\"\" src=\"http://{{ip}}/image?file={{payload.image}}\"></a>\n\t</body>\n</html>","x":1125.4583129882812,"y":150.62502479553223,"wires":[[]]},{"id":"58403a6c.f81dd4","type":"websocket out","z":"26e4310.b9db45","name":"","server":"b76a1ee4.f1e918","client":"","x":1371.3395500183105,"y":703.4822106361389,"wires":[]},{"id":"b5e2e404.c129b8","type":"inject","z":"26e4310.b9db45","name":"","topic":"","payload":"mute","payloadType":"str","repeat":"","crontab":"","once":false,"x":1278.2284660339355,"y":665.1119713783264,"wires":[["58403a6c.f81dd4"]]},{"id":"d342554c.90eb98","type":"comment","z":"26e4310.b9db45","name":"Mute Audio","info":"","x":1297.0895500183105,"y":622.2321801185608,"wires":[]},{"id":"f57e0abe.4a29d","type":"function","z":"26e4310.b9db45","name":"Result Parser","func":"var newMsg = {payload:\"\"}\nnewMsg.threemast = new Object;\nnewMsg.sun = new Object;\nnewMsg.storm = new Object;\nnewMsg.sun.score = 0;\nnewMsg.storm.score = 0;\nnewMsg.threemast.score = 0;\n\nif(msg.result.images !== null)\n{\n //msg.params[\"classifier_ids\"]=[\"sun_409678915\",\"threemast_372982515\",\"storm_1384366973\"];\n\n if(msg.result.images[0].classifiers !== null)\n {\n var classifiers = msg.result.images[0].classifiers;\n for(var classifier of classifiers) \n {\n if(String(classifier.classifier_id).includes(\"threemast_372982515\"))\n { \n var classes = classifier.classes;\n var middle = 0;\n \n for(var classs of classes) \n {\n middle += classs.score;\n \n }\n middle/= 2;\n newMsg.threemast.score = middle;\n newMsg.threemast.name = classifier.classifier_id;\n } \n else if(String(classifier.classifier_id).includes(\"sun_409678915\"))\n { \n var classes = classifier.classes;\n var middle = 0;\n \n for(var classs of classes) \n {\n middle += classs.score;\n \n }\n middle/= 2;\n \n newMsg.sun.score = middle;\n newMsg.sun.name = classifier.classifier_id;\n } \n else if(String(classifier.classifier_id).includes(\"storm_1384366973\"))\n { \n var classes = classifier.classes;\n var middle = 0;\n \n for(var classs of classes) \n {\n middle += classs.score;\n \n }\n middle/= 2;\n \n newMsg.storm.score = middle;\n newMsg.storm.name = classifier.classifier_id;\n \n\n } \n }\n return newMsg;\n }\n else {\n msg.payload = 0 + \",\";\n return msg;\n }\n}\nelse {\n var newMsg = { payload: \"no image or result\" };\n return msg;\n}\n","outputs":1,"noerr":0,"x":770.708568572998,"y":549.1249718666077,"wires":[["c936390a.f1a61","d30e600.488f32"]]},{"id":"20afe682.e6616a","type":"comment","z":"26e4310.b9db45","name":"Classifier Mapping Magic","info":"","x":950.458324432373,"y":699.791567325592,"wires":[]},{"id":"ababf3d7.2492e8","type":"comment","z":"26e4310.b9db45","name":"Sun classifier","info":"build new Specific Classifier to be used.","x":1712.857177734375,"y":147.14285278320312,"wires":[]},{"id":"5a615c57.87784c","type":"visual-recognition-util-v3","z":"26e4310.b9db45","name":"create a classifier","apikey":"","image-feature":"createClassifier","x":2178.2857666015625,"y":317.14288330078125,"wires":[["5f8a84b2.225064"]]},{"id":"ba685cf5.98f0b","type":"inject","z":"26e4310.b9db45","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":1725.857177734375,"y":186.14285278320312,"wires":[["a0a9b401.dc9ca8"]]},{"id":"aa7fb5e1.9d09c8","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"Classifier/sun/sun1_positive.zip","name":"","x":1817.357177734375,"y":235.14285278320312,"wires":[["bc3c3fb6.f442c"]]},{"id":"57cbe528.9b963c","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"Classifier/sun/negative.zip","name":"","x":1808.7857666015625,"y":323.14287757873535,"wires":[["3a4ec80d.681e7"]]},{"id":"bc3c3fb6.f442c","type":"change","z":"26e4310.b9db45","name":"set positives","rules":[{"t":"set","p":"params.sun1_positive_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2064.4285583496094,"y":220.85714149475098,"wires":[["c0058c06.de0f48"]]},{"id":"3a4ec80d.681e7","type":"change","z":"26e4310.b9db45","name":"set negatives","rules":[{"t":"set","p":"params.negative_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1985.7857666015625,"y":325.14287757873535,"wires":[["5a615c57.87784c"]]},{"id":"a0a9b401.dc9ca8","type":"function","z":"26e4310.b9db45","name":"set name","func":"msg.params={'name':'sun'};\nreturn msg;","outputs":1,"noerr":0,"x":1869.857177734375,"y":186.14285278320312,"wires":[["aa7fb5e1.9d09c8"]]},{"id":"5f8a84b2.225064","type":"debug","z":"26e4310.b9db45","name":"","active":true,"console":"false","complete":"result","x":2430.5714721679688,"y":316.9999942779541,"wires":[]},{"id":"c0058c06.de0f48","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"Classifier/sun/sun2_positive.zip","name":"","x":1816.4286193847656,"y":262.1785831451416,"wires":[["85934d2.4b1913"]]},{"id":"85934d2.4b1913","type":"change","z":"26e4310.b9db45","name":"set positives","rules":[{"t":"set","p":"params.sun2_positive_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2063.5,"y":247.89287185668945,"wires":[["4593acad.98cdf4"]]},{"id":"4593acad.98cdf4","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"Classifier/sun/sun3_positive.zip","name":"","x":1816.4286193847656,"y":285.0357303619385,"wires":[["6307101d.5d0ee8"]]},{"id":"6307101d.5d0ee8","type":"change","z":"26e4310.b9db45","name":"set positives","rules":[{"t":"set","p":"params.sun3_positive_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2063.5,"y":270.7500190734863,"wires":[["57cbe528.9b963c"]]},{"id":"d35b3bf9.eb4fb8","type":"comment","z":"26e4310.b9db45","name":"TRAINING of the image classifiers","info":"build new Specific Classifier to be used.","x":1782.857177734375,"y":78.5714340209961,"wires":[]},{"id":"cbe6a2b9.9cbd4","type":"visual-recognition-util-v3","z":"26e4310.b9db45","name":"retrieve classifiers list","apikey":"","image-feature":"retrieveClassifiersList","x":2168.5716552734375,"y":927.1428165435791,"wires":[["f2408d69.f95bb8"]]},{"id":"a8299797.605dd","type":"inject","z":"26e4310.b9db45","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":1730.5716552734375,"y":925.142822265625,"wires":[["cbe6a2b9.9cbd4"]]},{"id":"3ce1f775.9d5ec8","type":"comment","z":"26e4310.b9db45","name":"Storm classifier","info":"build new Specific Classifier to be used.","x":1721.4284973144531,"y":412.857177734375,"wires":[]},{"id":"c25f080.71c66f8","type":"visual-recognition-util-v3","z":"26e4310.b9db45","name":"create a classifier","apikey":"","image-feature":"createClassifier","x":2176.8570861816406,"y":582.8572082519531,"wires":[["a3c714f.c573d68"]]},{"id":"114451cc.506cbe","type":"inject","z":"26e4310.b9db45","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":1724.4284973144531,"y":451.857177734375,"wires":[["25be74dc.42662c"]]},{"id":"c4f95c42.fee86","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"Classifier/storm/storm1_positive.zip","name":"","x":1835.9284973144531,"y":500.857177734375,"wires":[["6fc53960.7e5aa8"]]},{"id":"d4c5ba3d.b0a898","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"Classifier/storm/negative.zip","name":"","x":1807.3570861816406,"y":588.8572025299072,"wires":[["c1b1ef4a.33d848"]]},{"id":"6fc53960.7e5aa8","type":"change","z":"26e4310.b9db45","name":"set positives","rules":[{"t":"set","p":"params.storm1_positive_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2062.9998779296875,"y":486.57146644592285,"wires":[["742d01e5.56aa9"]]},{"id":"c1b1ef4a.33d848","type":"change","z":"26e4310.b9db45","name":"set negatives","rules":[{"t":"set","p":"params.negative_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1984.3570861816406,"y":590.8572025299072,"wires":[["c25f080.71c66f8"]]},{"id":"25be74dc.42662c","type":"function","z":"26e4310.b9db45","name":"set name","func":"msg.params={'name':'storm'};\nreturn msg;","outputs":1,"noerr":0,"x":1868.4284973144531,"y":451.857177734375,"wires":[["c4f95c42.fee86"]]},{"id":"a3c714f.c573d68","type":"debug","z":"26e4310.b9db45","name":"","active":true,"console":"false","complete":"result","x":2429.142791748047,"y":582.714319229126,"wires":[]},{"id":"742d01e5.56aa9","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"Classifier/storm/storm2_positive.zip","name":"","x":1834.9999389648438,"y":527.8929080963135,"wires":[["e4a22b34.f090d"]]},{"id":"e4a22b34.f090d","type":"change","z":"26e4310.b9db45","name":"set positives","rules":[{"t":"set","p":"params.storm2_positive_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2062.071319580078,"y":513.6071968078613,"wires":[["c35d0ed9.a9b988"]]},{"id":"c35d0ed9.a9b988","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"Classifier/storm/storm3_positive.zip","name":"","x":1834.9999389648438,"y":550.7500553131104,"wires":[["44d2c5e8.ea9f7c"]]},{"id":"44d2c5e8.ea9f7c","type":"change","z":"26e4310.b9db45","name":"set positives","rules":[{"t":"set","p":"params.storm3_positive_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2062.071319580078,"y":536.4643440246582,"wires":[["d4c5ba3d.b0a898"]]},{"id":"b36ac474.8e6598","type":"comment","z":"26e4310.b9db45","name":"Threemast classifier","info":"build new Specific Classifier to be used.","x":1727.142822265625,"y":662.857177734375,"wires":[]},{"id":"787b10a4.c6f228","type":"visual-recognition-util-v3","z":"26e4310.b9db45","name":"create a classifier","apikey":"","image-feature":"createClassifier","x":2172.5714111328125,"y":832.8572082519531,"wires":[["f2408d69.f95bb8"]]},{"id":"84584e1f.6baa","type":"inject","z":"26e4310.b9db45","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":1720.142822265625,"y":701.857177734375,"wires":[["f8f36f90.078e3"]]},{"id":"9f875626.507718","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"Classifier/threemast/threemast1_positive.zip","name":"","x":1851.642822265625,"y":750.857177734375,"wires":[["9aaa2f26.0beb"]]},{"id":"ca3ca1a0.ed857","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"Classifier/threemast/negative.zip","name":"","x":1823.0714111328125,"y":838.8572025299072,"wires":[["e3910a4e.e43ab"]]},{"id":"9aaa2f26.0beb","type":"change","z":"26e4310.b9db45","name":"set positives","rules":[{"t":"set","p":"params.threemast1_positive_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2058.7142028808594,"y":736.5714664459229,"wires":[["216ce223.00c666"]]},{"id":"e3910a4e.e43ab","type":"change","z":"26e4310.b9db45","name":"set negatives","rules":[{"t":"set","p":"params.negative_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1980.0714111328125,"y":840.8572025299072,"wires":[["787b10a4.c6f228"]]},{"id":"f8f36f90.078e3","type":"function","z":"26e4310.b9db45","name":"set name","func":"msg.params={'name':'threemast'};\nreturn msg;","outputs":1,"noerr":0,"x":1864.142822265625,"y":701.857177734375,"wires":[["9f875626.507718"]]},{"id":"f2408d69.f95bb8","type":"debug","z":"26e4310.b9db45","name":"","active":true,"console":"false","complete":"result","x":2424.8571166992188,"y":832.714319229126,"wires":[]},{"id":"216ce223.00c666","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"Classifier/threemast/threemast2_positive.zip","name":"","x":1850.7142639160156,"y":777.8929080963135,"wires":[["e7c58459.d58058"]]},{"id":"e7c58459.d58058","type":"change","z":"26e4310.b9db45","name":"set positives","rules":[{"t":"set","p":"params.threemast2_positive_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2057.78564453125,"y":763.6071968078613,"wires":[["92e790c2.ab2068"]]},{"id":"92e790c2.ab2068","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"Classifier/threemast/threemast3_positive.zip","name":"","x":1850.7142639160156,"y":800.7500553131104,"wires":[["5b1e482f.fc53f8"]]},{"id":"5b1e482f.fc53f8","type":"change","z":"26e4310.b9db45","name":"set positives","rules":[{"t":"set","p":"params.threemast3_positive_examples","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":2057.78564453125,"y":786.4643440246582,"wires":[["ca3ca1a0.ed857"]]},{"id":"c936390a.f1a61","type":"function","z":"26e4310.b9db45","name":"Mapping","func":"var newMsg = {payload:0}\n//newMsg.threemast = new Object;\nvar threemast=0.00;\nvar sun=0.00;\nvar storm=0.00;\n\nif(msg.threemast !== null)\n{\n threemast = msg.threemast.score * 0.85;\n}\nif(msg.sun !== null)\n{\n sun = msg.sun.score;\n}\nif(msg.storm !== null)\n{\n storm = msg.storm.score * 0.70;\n}\n\nif((threemast > sun) && (threemast > storm)) {\n \n if(storm > 0.6){\n \n } else{\n if(0 == threemast) {\n newMsg.payload = (sun==0)?(\"/Audio/MP3_new/\" + \"twomastf.mp3\"):(\"/Audio/MP3_new/\" + \"calm.mp3\");\n } else if(0.5 >= threemast) {\n newMsg.payload = (storm<=0.7)?(\"/Audio/MP3_new/\" + \"twomast.mp3\"):(\"/Audio/MP3_new/\" + \"stormf.mp3\");\n } else if(0.91 >= threemast) {\n newMsg.payload = (storm<=0.6)?(\"/Audio/MP3_new/\" + \"twomast-.mp3\"):(\"/Audio/MP3_new/\" + \"storm.mp3\");\n } else if(0.92 >= threemast) {\n newMsg.payload = (sun<=0.8)?(\"/Audio/MP3_new/\" + \"threemast.mp3\"):(\"/Audio/MP3_new/\" + \"calm.mp3\");\n } else if(0.99 >= threemast) {\n newMsg.payload = (sun<=0.9)?(\"/Audio/MP3_new/\" + \"threemastf.mp3\"):(\"/Audio/MP3_new/\" + \"calmf.mp3\");\n }\n }\n}\n\nelse if((sun > threemast) && (sun > storm)) {\n if(0 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"sun-.mp3\";\n } else if(0.3 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"calm.mp3\";\n } else if(0.44 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"sunf.mp3\";\n } else if(0.45 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"calmf.mp3\";\n } else if(0.5 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"sun.mp3\";\n } else if(0.67 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"calm-.mp3\";\n } else if(0.99 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"sunff.mp3\";\n }\n}\n\nelse if((storm > sun) && (storm > sun)) {\n if(sun >= 0.45) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"sunff.mp3\";\n } else if(0.5 >= storm) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"stormf.mp3\";\n } else if(0.65 >= storm) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"storm.mp3\";\n } else if(0.8 >= storm) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"storm-.mp3\";\n }\n}\n\nif (newMsg.payload==0) newMsg.payload = \"/Audio/MP3_new/\" + \"mix.mp3\";\n \nreturn newMsg;","outputs":1,"noerr":0,"x":907.833324432373,"y":741.2037072181702,"wires":[["252098.5937c768","bec83aa1.a0ed98","910b437f.8b384"]]},{"id":"252098.5937c768","type":"delay","z":"26e4310.b9db45","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1088.9631462097168,"y":500.53708124160767,"wires":[["9e4c458b.44579"]]},{"id":"bec83aa1.a0ed98","type":"function","z":"26e4310.b9db45","name":"file name","func":"msg.filename = msg.payload;\n \nreturn msg;","outputs":1,"noerr":0,"x":1111.950023651123,"y":772.8166832923889,"wires":[[]]},{"id":"e1eb3d32.f3ccd","type":"cloudant out","z":"26e4310.b9db45","name":"","cloudant":"","database":"soundofsails_usagedata","service":"sample-node-red-cloudantNoSQLDB","payonly":false,"operation":"insert","x":2089.483386993408,"y":1286.1833629608154,"wires":[]},{"id":"4f5c2090.ee0058","type":"cloudant in","z":"26e4310.b9db45","name":"","cloudant":"","database":"soundofsails_usagedata","service":"sample-node-red-cloudantNoSQLDB","search":"_all_","design":"","index":"","x":2089.316638946533,"y":1331.9834423065186,"wires":[["612dfff3.4b2048"]]},{"id":"830f5a36.686a28","type":"inject","z":"26e4310.b9db45","name":"","topic":"","payload":"{ query: \"*\", limit: 100 }","payloadType":"str","repeat":"","crontab":"","once":false,"x":1792.7811126708984,"y":1333.6358332633972,"wires":[["4f5c2090.ee0058"]]},{"id":"612dfff3.4b2048","type":"debug","z":"26e4310.b9db45","name":"","active":false,"console":"false","complete":"false","x":2243.9833450317383,"y":1396.3835697174072,"wires":[]},{"id":"d30e600.488f32","type":"function","z":"26e4310.b9db45","name":"Timestamp","func":"msg.timestamp = new Date().toISOString().slice(0, 19).replace('T', ' ');\nreturn msg;","outputs":1,"noerr":0,"x":1900.5000495910645,"y":1194.000135421753,"wires":[["70de8cf6.0acd14","e1eb3d32.f3ccd"]]},{"id":"3fd73119.c194ee","type":"inject","z":"26e4310.b9db45","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":1713.3167610168457,"y":1189.9501476287842,"wires":[["d30e600.488f32"]]},{"id":"70de8cf6.0acd14","type":"debug","z":"26e4310.b9db45","name":"","active":false,"console":"false","complete":"true","x":2094.3166999816895,"y":1197.6501598358154,"wires":[]},{"id":"bc5a537d.60ee1","type":"function","z":"26e4310.b9db45","name":"","func":"var newMsg = {payload:msg.payload};\nreturn newMsg;","outputs":1,"noerr":0,"x":248.49998474121094,"y":307,"wires":[["d30e600.488f32"]]},{"id":"543b7aab.b8fd24","type":"template","z":"26e4310.b9db45","name":"Image Detail + Javascript Audio + Gauge","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n\t<head>\n\t\t<title>Sound of Sails</title>\n\t\t<style>\n\t\t\tbody {margin:0;background: #000;text-align:center;}\n\n .image {\n height: 50%;\n\t\t\t margin-left:2em;\n\t\t\t margin-right:2em;\n\t\t\t margin-top: 2em;\n\t\t\t margin-bottom: 2em;\n\t\t\t float: middle;\n\t\t\t}\n\t\t\t\n\t\t\t.header {\n height: 15%;\t\t\n\t\t\t \n\t\t\t}\n\t\t\t\n\t\t\t.footer {\n\t\t\t height: 15%;\n\t\t\t}\n \n\t\t</style>\n\n\t\t</head>\n \t<body>\n \t <p><a href=\"http://{{ip}}/Credits\"><img class=\"header\" alt=\"\" src=\"http://{{ip}}/image?file=/Website/banner.png\"></a></p>\n \t \n\n \t <div>\n <a href=\"http://{{ip}}/sos\"><img class=\"image\" alt=\"\" src=\"http://{{ip}}/image?file={{payload.image}}\"></a>\n </div>\n </div>\n </div>\n </div>\n </div>\n </div>\n \n\n \t \n \t \n \n <p><a href=\"http://{{ip}}/Credits\"><img class=\"footer\" alt=\"\" src=\"http://{{ip}}/image?file=/Website/credits.png\"></a></p>\n\n </body>\n\t\t\n\t\t<script>\n console.log(\"starting audio script!\");\n \n // Websocket\n var connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n \n // When the connection is open, send some data to the server\n connection.onopen = function () {\n connection.send('Ready'); // Send the message 'Ping' to the server\n };\n \n // Log errors\n connection.onerror = function (error) {\n console.log('WebSocket Error ' + error);\n connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n };\n \n connection.onclose = function () {\n console.log('WebSocket Closed' );\n connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n };\n \n // Log messages from the server\n connection.onmessage = function (e) {\n console.log('Server: ' + e.data);\n };\n \n // BufferloaderClass\n function BufferLoader(context, urlList, callback) {\n this.context = context;\n this.urlList = urlList;\n this.onload = callback;\n this.bufferList = new Array();\n this.loadCount = 0;\n }\n \n BufferLoader.prototype.loadBuffer = function(url, index) {\n // Load buffer asynchronously\n var request = new XMLHttpRequest();\n request.open(\"GET\", url, true);\n request.responseType = \"arraybuffer\";\n \n var loader = this;\n \n request.onload = function() {\n // Asynchronously decode the audio file data in request.response\n loader.context.decodeAudioData(\n request.response,\n function(buffer) {\n if (!buffer) {\n alert('error decoding file data: ' + url);\n return;\n }\n loader.bufferList[index] = buffer;\n if (++loader.loadCount == loader.urlList.length)\n loader.onload(loader.bufferList);\n },\n function(error) {\n console.error('decodeAudioData error', error);\n }\n );\n }\n \n request.onerror = function() {\n alert('BufferLoader: XHR error');\n }\n \n request.send();\n }\n \n BufferLoader.prototype.load = function() {\n for (var i = 0; i < this.urlList.length; ++i)\n this.loadBuffer(this.urlList[i], i);\n }\n \n // !BufferloaderClass\n \n function loadPage(href)\n {\n var xmlhttp = new XMLHttpRequest();\n xmlhttp.open(\"GET\", href, false);\n xmlhttp.send();\n return xmlhttp.responseText;\n }\n \n // AudioPlayback ###########\n //window.onload = init;\n var context;\n var bufferLoader;\n var gainNode;\n\n // Log messages from the server\n connection.onmessage = function (e) {\n \n if(String(e.data).includes('mute')) {\n console.log(\"setting gain to 0!\");\n gainNode.gain.value = 0;\n } else if(String(e.data).includes('.mp3')) {\n \n \n console.log('Server: ' + e.data);\n \n //};\n //function init() {\n \n console.log(\"received message: \" + e.data);\n \n // Fix up prefixing\n window.AudioContext = window.AudioContext || window.webkitAudioContext;\n context = new AudioContext();\n \n console.log(\"loading buffer!\");\n bufferLoader = new BufferLoader(\n context,\n [\n 'http://{{ip}}/sound?file=' + e.data // Audio/joy.wav\n // 'http://{{ip}}/sound?file=/Audio/fear.wav',\n ],\n finishedLoading\n );\n \n bufferLoader.load();\n //} else if(JSON.parse(e.data)) {\n // console.log(e.data); \n } else if (String(e.data).includes('http://')) {\n window.location = e.data;\n }\n \n }\n \n function finishedLoading(bufferList) {\n \n console.log(\"done loading, creating audio source!\");\n // Create two sources and play them both together.\n var source1 = context.createBufferSource();\n //var source2 = context.createBufferSource();\n source1.buffer = bufferList[0];\n //source2.buffer = bufferList[1];\n \n console.log(\"creating gain node!\");\n // Create a gain node.\n gainNode = context.createGain();\n // Connect the source to the gain node.\n source1.connect(gainNode);\n //source2.connect(gainNode);\n // Connect the gain node to the destination.\n gainNode.connect(context.destination);\n \n console.log(\"setting gain to 1!\");\n gainNode.gain.value = 1;\n \n console.log(\"starting audio playback!\");\n source1.start(0);\n //source2.start(0);\n \n //window.setInterval(stopCallback, 3000);\n }\n \n \n \n //function stopCallback() {\n // console.log(\"setting gain to 0!\");\n // gainNode.gain.value = 0;\n // }\n </script>\n</html>","x":1224.7778625488281,"y":314.44451904296875,"wires":[["91d1d481.343b88"]]},{"id":"9a1a1086.7a00d","type":"comment","z":"26e4310.b9db45","name":"Collect usage data ","info":"","x":1743.5000495910645,"y":1140.000135421753,"wires":[]},{"id":"5d48cf50.19bde","type":"http in","z":"26e4310.b9db45","name":"","url":"/credits","method":"get","swaggerDoc":"","x":127,"y":168,"wires":[["214a252.25a7bda"]]},{"id":"ea9f2d47.226ef","type":"http response","z":"26e4310.b9db45","name":"","x":895.571533203125,"y":167.99998474121094,"wires":[]},{"id":"1cdf4edd.e10691","type":"template","z":"26e4310.b9db45","name":"Credits Page","field":"payload","fieldType":"msg","format":"html","syntax":"mustache","template":"<html>\n\t<head>\n\t\t<title>Sound of Sails</title>\n\t\t<meta name=\"description\" content=\"Die Altonaer Schiffsgemäldesammlung vertont von IBM Watson Visual Recognition\">\n\n\t\t<style>\n\t\t\tbody {background: #000;text-align:center;}\n\t\t\timg {width: 100%;margin-left:1%;margin-top: 1%;margin-right: 1%;}\n\t\t</style>\n\t</head>\n\t<body>\n <p><a href=\"http://{{ip}}/sos\"><img alt=\"\" src=\"http://{{ip}}/image?file=/Website/sos1.png\"></a></p>\n <p><a href=\"http://{{ip}}/sos\"><img alt=\"\" src=\"http://{{ip}}/image?file=/Website/sos2.png\"></a></p>\n <p><a href=\"http://{{ip}}/sos\"><img alt=\"\" src=\"http://{{ip}}/image?file=/Website/sos3.png\"></a></p>\n <p><a href=\"http://{{ip}}/sos\"><img alt=\"\" src=\"http://{{ip}}/image?file=/Website/sos4.png\"></a></p>\n\t</body>\n</html>\n","x":663.071533203125,"y":173.24998474121094,"wires":[["ea9f2d47.226ef"]]},{"id":"214a252.25a7bda","type":"function","z":"26e4310.b9db45","name":"IP oder Domain und Audio Pfad","func":"msg.ip = \"sound-of-sails.mybluemix.net\"; //your ip here\nmsg.path = \"Schiffsportraits\"\nreturn msg;","outputs":1,"noerr":0,"x":373.071533203125,"y":169.24998474121094,"wires":[["1cdf4edd.e10691"]]},{"id":"910b437f.8b384","type":"delay","z":"26e4310.b9db45","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1116.6666831970215,"y":807.7777371406555,"wires":[["d30e600.488f32"]]},{"id":"921044c5.417ac8","type":"template","z":"26e4310.b9db45","name":"Image Detail + Javascript Audio","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n\t<head>\n\t\t<title>Sound of Sails</title>\n\t\t<style>\n\t\t\tbody {margin:0;background: #000;text-align:center;}\n\t\t\timg {height: 80%;margin-top:5%;}\n\t\t</style>\n\t\t\n\t\t</head>\n \t<body>\n \t\t<a href=\"http://{{ip}}/sos\"><img alt=\"\" src=\"http://{{ip}}/image?file={{payload.image}}\"></a>\n \t</body>\n\t\t\n\t\t<script>\n console.log(\"starting audio script!\");\n \n // Websocket\n var connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n \n // When the connection is open, send some data to the server\n connection.onopen = function () {\n connection.send('Ready'); // Send the message 'Ping' to the server\n };\n \n // Log errors\n connection.onerror = function (error) {\n console.log('WebSocket Error ' + error);\n connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n };\n \n // Log messages from the server\n connection.onmessage = function (e) {\n console.log('Server: ' + e.data);\n };\n \n // BufferloaderClass\n function BufferLoader(context, urlList, callback) {\n this.context = context;\n this.urlList = urlList;\n this.onload = callback;\n this.bufferList = new Array();\n this.loadCount = 0;\n }\n \n BufferLoader.prototype.loadBuffer = function(url, index) {\n // Load buffer asynchronously\n var request = new XMLHttpRequest();\n request.open(\"GET\", url, true);\n request.responseType = \"arraybuffer\";\n \n var loader = this;\n \n request.onload = function() {\n // Asynchronously decode the audio file data in request.response\n loader.context.decodeAudioData(\n request.response,\n function(buffer) {\n if (!buffer) {\n alert('error decoding file data: ' + url);\n return;\n }\n loader.bufferList[index] = buffer;\n if (++loader.loadCount == loader.urlList.length)\n loader.onload(loader.bufferList);\n },\n function(error) {\n console.error('decodeAudioData error', error);\n }\n );\n }\n \n request.onerror = function() {\n alert('BufferLoader: XHR error');\n }\n \n request.send();\n }\n \n BufferLoader.prototype.load = function() {\n for (var i = 0; i < this.urlList.length; ++i)\n this.loadBuffer(this.urlList[i], i);\n }\n \n // !BufferloaderClass\n \n // AudioPlayback\n //window.onload = init;\n var context;\n var bufferLoader;\n var gainNode;\n\n \n // Log messages from the server\n connection.onmessage = function (e) {\n \n if(String(e.data).includes('mute')) {\n console.log(\"setting gain to 0!\");\n gainNode.gain.value = 0;\n } else if(String(e.data).includes('.mp3')) {\n \n \n console.log('Server: ' + e.data);\n \n //};\n //function init() {\n \n console.log(\"received message: \" + e.data);\n \n // Fix up prefixing\n window.AudioContext = window.AudioContext || window.webkitAudioContext;\n context = new AudioContext();\n \n console.log(\"loading buffer!\");\n bufferLoader = new BufferLoader(\n context,\n [\n 'http://{{ip}}/sound?file=' + e.data // Audio/joy.wav\n // 'http://{{ip}}/sound?file=/Audio/fear.wav',\n ],\n finishedLoading\n );\n \n bufferLoader.load();\n } else if(JSON.parse(e.data));\n console.log(e.data);\n \n }\n \n function finishedLoading(bufferList) {\n \n console.log(\"done loading, creating audio source!\");\n // Create two sources and play them both together.\n var source1 = context.createBufferSource();\n //var source2 = context.createBufferSource();\n source1.buffer = bufferList[0];\n //source2.buffer = bufferList[1];\n \n console.log(\"creating gain node!\");\n // Create a gain node.\n gainNode = context.createGain();\n // Connect the source to the gain node.\n source1.connect(gainNode);\n //source2.connect(gainNode);\n // Connect the gain node to the destination.\n gainNode.connect(context.destination);\n \n console.log(\"setting gain to 1!\");\n gainNode.gain.value = 1;\n \n console.log(\"starting audio playback!\");\n source1.start(0);\n //source2.start(0);\n \n //window.setInterval(stopCallback, 3000);\n }\n \n \n \n //function stopCallback() {\n // console.log(\"setting gain to 0!\");\n // gainNode.gain.value = 0;\n // }\n </script>\n</html>","x":1172.0714721679688,"y":189.8571720123291,"wires":[[]]},{"id":"63e58ee6.872bf","type":"template","z":"26e4310.b9db45","name":"Image Detail + Javascript Audio + Gauge","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n\t<head>\n\t\t<title>Sound of Sails</title>\n\t\t<style>\n\t\t\tbody {margin:0;background: #000;text-align:center;}\n\t\t\timg {height: 80%;margin-top:5%;}\n\t\t\t\n\t\t\t#gauge_storm {\n width:200px; height:160px;\n display: inline-block;\n margin: 1em;\n }\n \n #gauge_threemast {\n width:200px; height:160px;\n display: inline-block;\n margin: 1em;\n }\n \n #gauge_twomast {\n width:200px; height:160px;\n display: inline-block;\n margin: 1em;\n }\n \n\t\t</style>\n\t\t<script src=\"http://{{ip}}/image?file=/raphael-2.1.4.min.js\"></script>\n <script src=\"http://{{ip}}/image?file=/justgage.js\"></script>\n\t\t\n\t\t</head>\n \t<body>\n <div style='display: inline-block;'>\n \t \t <a href=\"http://{{ip}}/sos\"><img alt=\"\" src=\"http://{{ip}}/image?file={{payload.image}}\"></a>\n \n </div>\n <div style='display: inline-block;'>\n <div id='wrapper' style='text-align: middle;'>\n <div id=\"gauge_storm\" class=\"200x160px\"></div> \n <div id=\"gauge_threemast\" class=\"200x160px\"></div> \n <div id=\"gauge_twomast\" class=\"200x160px\"></div> \n </div>\n </div>\n </body>\n\t\t\n\t\t<script>\n console.log(\"starting audio script!\");\n \n // Websocket\n var connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n \n // When the connection is open, send some data to the server\n connection.onopen = function () {\n connection.send('Ready'); // Send the message 'Ping' to the server\n };\n \n // Log errors\n connection.onerror = function (error) {\n console.log('WebSocket Error ' + error);\n connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n };\n \n // Log messages from the server\n connection.onmessage = function (e) {\n console.log('Server: ' + e.data);\n };\n \n // BufferloaderClass\n function BufferLoader(context, urlList, callback) {\n this.context = context;\n this.urlList = urlList;\n this.onload = callback;\n this.bufferList = new Array();\n this.loadCount = 0;\n }\n \n BufferLoader.prototype.loadBuffer = function(url, index) {\n // Load buffer asynchronously\n var request = new XMLHttpRequest();\n request.open(\"GET\", url, true);\n request.responseType = \"arraybuffer\";\n \n var loader = this;\n \n request.onload = function() {\n // Asynchronously decode the audio file data in request.response\n loader.context.decodeAudioData(\n request.response,\n function(buffer) {\n if (!buffer) {\n alert('error decoding file data: ' + url);\n return;\n }\n loader.bufferList[index] = buffer;\n if (++loader.loadCount == loader.urlList.length)\n loader.onload(loader.bufferList);\n },\n function(error) {\n console.error('decodeAudioData error', error);\n }\n );\n }\n \n request.onerror = function() {\n alert('BufferLoader: XHR error');\n }\n \n request.send();\n }\n \n BufferLoader.prototype.load = function() {\n for (var i = 0; i < this.urlList.length; ++i)\n this.loadBuffer(this.urlList[i], i);\n }\n \n // !BufferloaderClass\n \n // AudioPlayback ###########\n //window.onload = init;\n var context;\n var bufferLoader;\n var gainNode;\n \n // Gauges \n var g = new JustGage({\n id: \"gauge_storm\",\n value: 0,\n min: 0,\n max: 1,\n title: \"Seegang\"\n });\n \n var g = new JustGage({\n id: \"gauge_threemast\",\n value: 0,\n min: 0,\n max: 1,\n title: \"Sonnenschein\"\n });\n \n var g = new JustGage({\n id: \"gauge_twomast\",\n value: 0,\n min: 0,\n max: 1,\n title: \"Schiffsgröße\"\n });\n \n // Log messages from the server\n connection.onmessage = function (e) {\n \n if(String(e.data).includes('mute')) {\n console.log(\"setting gain to 0!\");\n gainNode.gain.value = 0;\n } else if(String(e.data).includes('.mp3')) {\n \n \n console.log('Server: ' + e.data);\n \n //};\n //function init() {\n \n console.log(\"received message: \" + e.data);\n \n // Fix up prefixing\n window.AudioContext = window.AudioContext || window.webkitAudioContext;\n context = new AudioContext();\n \n console.log(\"loading buffer!\");\n bufferLoader = new BufferLoader(\n context,\n [\n 'http://{{ip}}/sound?file=' + e.data // Audio/joy.wav\n // 'http://{{ip}}/sound?file=/Audio/fear.wav',\n ],\n finishedLoading\n );\n \n bufferLoader.load();\n } else if(JSON.parse(e.data));\n console.log(e.data);\n \n }\n \n function finishedLoading(bufferList) {\n \n console.log(\"done loading, creating audio source!\");\n // Create two sources and play them both together.\n var source1 = context.createBufferSource();\n //var source2 = context.createBufferSource();\n source1.buffer = bufferList[0];\n //source2.buffer = bufferList[1];\n \n console.log(\"creating gain node!\");\n // Create a gain node.\n gainNode = context.createGain();\n // Connect the source to the gain node.\n source1.connect(gainNode);\n //source2.connect(gainNode);\n // Connect the gain node to the destination.\n gainNode.connect(context.destination);\n \n console.log(\"setting gain to 1!\");\n gainNode.gain.value = 1;\n \n console.log(\"starting audio playback!\");\n source1.start(0);\n //source2.start(0);\n \n //window.setInterval(stopCallback, 3000);\n }\n \n \n \n //function stopCallback() {\n // console.log(\"setting gain to 0!\");\n // gainNode.gain.value = 0;\n // }\n </script>\n</html>","x":1208.3125610351562,"y":231.56252479553223,"wires":[[]]},{"id":"dcfbb93c.15ce48","type":"template","z":"26e4310.b9db45","name":"Image Detail + Javascript Audio + Gauge","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n\t<head>\n\t\t<title>Sound of Sails</title>\n <meta name=\"description\" content=\"Die Altonaer Schiffsgemäldesammlung vertont von IBM Watson Visual Recognition\">\n\t\t<style>\n \t\t*{\n padding : 0;\n margin : 0;\n border : 0;\n }\n body{\n background-image : url(' bi-html-background.png ');\n background-attachment : fixed;\n background-size : 100% auto;\n }\n .blended_grid{\n display : block;\n width : 1200px;\n overflow : auto;\n margin : 0 auto;\n }\n .pageHeader{\n background-color : rgb(0, 0, 0);\n float : left;\n clear : none;\n height : 200px;\n width : 1200px;\n }\n .pageBarLeft{\n float : left;\n clear : none;\n min-width : 80px;\n min-height : 80px;\n }\n .pageLeftTop{\n background-color : rgb(0, 0, 0);\n float : none;\n clear : both;\n height : 300px;\n width : 200px;\n }\n .pageLeftMid{\n background-color : rgb(0, 0, 0);\n float : none;\n clear : both;\n height : 300px;\n width : 200px;\n }\n .pageLeftBottom{\n background-color : rgb(0, 0, 0);\n float : none;\n clear : both;\n height : 400px;\n width : 200px;\n }\n .pageContent{\n background-color : rgb(0, 0, 0);\n float : left;\n clear : none;\n height : 1000px;\n width : 800px;\n }\n .pageBarRight{\n float : left;\n clear : none;\n min-width : 80px;\n min-height : 80px;\n }\n .pageRightTop{\n background-color : rgb(0, 0, 0);\n float : none;\n clear : both;\n height : 300px;\n width : 200px;\n }\n .pageRightMid{\n background-color : rgb(0, 0, 0);\n float : none;\n clear : both;\n height : 300px;\n width : 200px;\n }\n .pageRightBottom{\n background-color : rgb(0, 0, 0);\n float : none;\n clear : both;\n height : 400px;\n width : 200px;\n }\n\t\t\timg {height: 80%;margin-top:5%;}\n\t\t\t\n\t\t\t#gauge_storm {\n width:200px; height:160px;\n display: inline-block;\n margin: 1em;\n }\n \n #gauge_threemast {\n width:200px; height:160px;\n display: inline-block;\n margin: 1em;\n }\n \n #gauge_twomast {\n width:200px; height:160px;\n display: inline-block;\n margin: 1em;\n }\n \n\t\t</style>\n\t\t<script src=\"http://{{ip}}/image?file=/raphael-2.1.4.min.js\"></script>\n <script src=\"http://{{ip}}/image?file=/justgage.js\"></script>\n\t\t\n\t\t</head>\n \t<body>\n\n<body>\n<div class=\"blended_grid\">\n<div class=\"pageHeader\">\n</div>\n<div class=\"pageBarLeft\">\n<div class=\"pageLeftTop\">\n</div>\n<div class=\"pageLeftMid\">\n</div>\n<div class=\"pageLeftBottom\">\n</div>\n</div>\n<div class=\"pageContent\">\n <a href=\"http://{{ip}}/sos\"><img alt=\"\" src=\"http://{{ip}}/image?file={{payload.image}}\"></a>\n\n</div>\n<div class=\"pageBarRight\">\n<div class=\"pageRightTop\">\n</div>\n<div class=\"pageRightMid\">\n</div>\n<div class=\"pageRightBottom\">\n</div>\n</div>\n</div>\n</body>\n\n\t\t<script>\n console.log(\"starting audio script!\");\n \n // Websocket\n var connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n \n // When the connection is open, send some data to the server\n connection.onopen = function () {\n connection.send('Ready'); // Send the message 'Ping' to the server\n };\n \n // Log errors\n connection.onerror = function (error) {\n console.log('WebSocket Error ' + error);\n connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n };\n \n // Log messages from the server\n connection.onmessage = function (e) {\n console.log('Server: ' + e.data);\n };\n \n // BufferloaderClass\n function BufferLoader(context, urlList, callback) {\n this.context = context;\n this.urlList = urlList;\n this.onload = callback;\n this.bufferList = new Array();\n this.loadCount = 0;\n }\n \n BufferLoader.prototype.loadBuffer = function(url, index) {\n // Load buffer asynchronously\n var request = new XMLHttpRequest();\n request.open(\"GET\", url, true);\n request.responseType = \"arraybuffer\";\n \n var loader = this;\n \n request.onload = function() {\n // Asynchronously decode the audio file data in request.response\n loader.context.decodeAudioData(\n request.response,\n function(buffer) {\n if (!buffer) {\n alert('error decoding file data: ' + url);\n return;\n }\n loader.bufferList[index] = buffer;\n if (++loader.loadCount == loader.urlList.length)\n loader.onload(loader.bufferList);\n },\n function(error) {\n console.error('decodeAudioData error', error);\n }\n );\n }\n \n request.onerror = function() {\n alert('BufferLoader: XHR error');\n }\n \n request.send();\n }\n \n BufferLoader.prototype.load = function() {\n for (var i = 0; i < this.urlList.length; ++i)\n this.loadBuffer(this.urlList[i], i);\n }\n \n // !BufferloaderClass\n \n // AudioPlayback ###########\n //window.onload = init;\n var context;\n var bufferLoader;\n var gainNode;\n \n /*Gauges \n var g = new JustGage({\n id: \"gauge_storm\",\n value: 0,\n min: 0,\n max: 1,\n title: \"Seegang\"\n });\n \n var g = new JustGage({\n id: \"gauge_threemast\",\n value: 0,\n min: 0,\n max: 1,\n title: \"Sonnenschein\"\n });\n \n var g = new JustGage({\n id: \"gauge_twomast\",\n value: 0,\n min: 0,\n max: 1,\n title: \"Schiffsgröße\"\n });\n */\n // Log messages from the server\n connection.onmessage = function (e) {\n \n if(String(e.data).includes('mute')) {\n console.log(\"setting gain to 0!\");\n gainNode.gain.value = 0;\n } else if(String(e.data).includes('.mp3')) {\n \n \n console.log('Server: ' + e.data);\n \n //};\n //function init() {\n \n console.log(\"received message: \" + e.data);\n \n // Fix up prefixing\n window.AudioContext = window.AudioContext || window.webkitAudioContext;\n context = new AudioContext();\n \n console.log(\"loading buffer!\");\n bufferLoader = new BufferLoader(\n context,\n [\n 'http://{{ip}}/sound?file=' + e.data // Audio/joy.wav\n // 'http://{{ip}}/sound?file=/Audio/fear.wav',\n ],\n finishedLoading\n );\n \n bufferLoader.load();\n } else if(JSON.parse(e.data));\n console.log(e.data);\n \n }\n \n function finishedLoading(bufferList) {\n \n console.log(\"done loading, creating audio source!\");\n // Create two sources and play them both together.\n var source1 = context.createBufferSource();\n //var source2 = context.createBufferSource();\n source1.buffer = bufferList[0];\n //source2.buffer = bufferList[1];\n \n console.log(\"creating gain node!\");\n // Create a gain node.\n gainNode = context.createGain();\n // Connect the source to the gain node.\n source1.connect(gainNode);\n //source2.connect(gainNode);\n // Connect the gain node to the destination.\n gainNode.connect(context.destination);\n \n console.log(\"setting gain to 1!\");\n gainNode.gain.value = 1;\n \n console.log(\"starting audio playback!\");\n source1.start(0);\n //source2.start(0);\n \n //window.setInterval(stopCallback, 3000);\n }\n \n \n \n //function stopCallback() {\n // console.log(\"setting gain to 0!\");\n // gainNode.gain.value = 0;\n // }\n </script>\n</html>","x":1216.5416870117188,"y":268.79168128967285,"wires":[[]]},{"id":"1cd8b22d.9230ee","type":"http in","z":"26e4310.b9db45","name":"","url":"/text","method":"get","swaggerDoc":"","x":168.08717346191406,"y":2729.9998474121094,"wires":[["aaa99af7.013778"]]},{"id":"6c4ec18b.12afe","type":"function","z":"26e4310.b9db45","name":"Set Content-Type header","func":"msg.headers = {\n \"Content-Type\":\"text/javascript\"\n};\nreturn msg;","outputs":1,"noerr":0,"x":790.7298889160156,"y":2795.714080810547,"wires":[["1440aa89.5188a5"]]},{"id":"aaa99af7.013778","type":"switch","z":"26e4310.b9db45","name":"file specified","property":"payload.file","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","outputs":2,"x":370.2298889160156,"y":2730.464080810547,"wires":[["728428a7.db6838"],["3b153162.123a7e"]]},{"id":"728428a7.db6838","type":"function","z":"26e4310.b9db45","name":"not found","func":"msg.payload = \"404 not found\"\nreturn msg;","outputs":1,"noerr":0,"x":591.2298889160156,"y":2724.464080810547,"wires":[["1440aa89.5188a5"]]},{"id":"3b153162.123a7e","type":"function","z":"26e4310.b9db45","name":"file name","func":"msg.filename = msg.payload.file;\nreturn msg;","outputs":1,"noerr":0,"x":448.7298889160156,"y":2795.714080810547,"wires":[["3adc4d3b.e82462"]]},{"id":"1440aa89.5188a5","type":"http response","z":"26e4310.b9db45","name":"","x":1006.7299003601074,"y":2724.214081764221,"wires":[]},{"id":"3adc4d3b.e82462","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"","name":"","x":596.3529281616211,"y":2794.8568992614746,"wires":[["6c4ec18b.12afe"]]},{"id":"5892e962.4293d8","type":"comment","z":"26e4310.b9db45","name":"Serve images from /home/pi/sound_of_sails/","info":"","x":276.6587028503418,"y":2689.9997873306274,"wires":[]},{"id":"44aaddb1.7c1d54","type":"http in","z":"26e4310.b9db45","name":"","url":"/wheel","method":"get","swaggerDoc":"","x":138.18205642700195,"y":1813.651546239853,"wires":[["e5143443.cb88f8","cf5a83b4.13141"]]},{"id":"e5143443.cb88f8","type":"switch","z":"26e4310.b9db45","name":"wheel move","property":"payload.wheel","propertyType":"msg","rules":[{"t":"null"},{"t":"nnull"}],"checkall":"true","outputs":2,"x":323.1820344924927,"y":1814.651519536972,"wires":[["825e1e3d.850d5"],["1dc29eab.301501","21bc1ea2.7292f2"]]},{"id":"825e1e3d.850d5","type":"function","z":"26e4310.b9db45","name":"not found","func":"msg.payload = \"404 not found\"\nreturn msg;","outputs":1,"noerr":0,"x":541.7375831604004,"y":1809.651546239853,"wires":[["a2ba1164.eabbc"]]},{"id":"a2ba1164.eabbc","type":"http response","z":"26e4310.b9db45","name":"","x":789.237678527832,"y":1807.4016015529633,"wires":[]},{"id":"1dc29eab.301501","type":"function","z":"26e4310.b9db45","name":"ok","func":"msg.payload = \"200 OK\"\nreturn msg;","outputs":1,"noerr":0,"x":524.737720489502,"y":1852.6517918109894,"wires":[["6288da31.a96254"]]},{"id":"cf5a83b4.13141","type":"debug","z":"26e4310.b9db45","name":"","active":true,"console":"false","complete":"false","x":305.3973316616482,"y":1865.688541173935,"wires":[]},{"id":"ea889a32.060e28","type":"xml","z":"26e4310.b9db45","name":"","attr":"","chr":"","x":591.8516735500762,"y":1094.8150609334311,"wires":[["da7d6bb4.079858","9cef63ea.51ba6"]]},{"id":"dd6309af.0d3248","type":"function","z":"26e4310.b9db45","name":"file name","func":"msg.filename = \"/Schiffsportraits/altonalisteschiffsportraitslido20160913.xml\";\nglobal.set(\"req\",msg.req);\nglobal.set(\"res\",msg.res);\n\nreturn msg;","outputs":1,"noerr":0,"x":352.7087902492949,"y":1095.1722558339438,"wires":[["a2401021.4c78a","d30e600.488f32"]]},{"id":"a2401021.4c78a","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"","name":"","x":475.3318027920195,"y":1143.3150598605475,"wires":[["ea889a32.060e28"]]},{"id":"4d2837d8.c6eb08","type":"inject","z":"26e4310.b9db45","name":"","topic":"","payload":"http://sound-of-sails.mybluemix.net/show?file=/Schiffsportraits/m57d825218aee2.jpg","payloadType":"str","repeat":"","crontab":"","once":false,"x":173.88897365993944,"y":1126.296704610189,"wires":[["dd6309af.0d3248"]]},{"id":"da7d6bb4.079858","type":"function","z":"26e4310.b9db45","name":"Result Parser Random","func":"var newMsg = {image:new Object}\nnewMsg.image.url = \"\";\n\n// initialise the counter to 0 if it doesn't exist already\n//var count = context.get('imagecount')||0;\nvar count = Math.floor((Math.random() * 35));\ncount += 1;\ncount %= 35;\n// store the value back\ncontext.set('imagecount',count);\n// make it part of the outgoing msg object\nnewMsg.count = count;\n\nif(msg.payload.lidoWrap.lido[0] !== null)\n{\n\n var lido = msg.payload.lidoWrap.lido[count];\n\n if(String(lido.administrativeMetadata[0].resourceWrap[0].resourceSet[0].resourceRepresentation[1].linkResource[0]._).includes(\"http\")) {\n newMsg.image.url = lido.administrativeMetadata[0].resourceWrap[0].resourceSet[0].resourceRepresentation[1].linkResource[0]._;\n }\n if(lido.descriptiveMetadata[0].objectIdentificationWrap[0].titleWrap[0].titleSet[0].appellationValue[0]._ !== null) {\n newMsg.image.title = lido.descriptiveMetadata[0].objectIdentificationWrap[0].titleWrap[0].titleSet[0].appellationValue[0]._;\n } try {\n if(lido.descriptiveMetadata[0].eventWrap[0].eventSet[0].event[0].eventActor[0].displayActorInRole[0] !== null) {\n newMsg.image.artist =lido.descriptiveMetadata[0].eventWrap[0].eventSet[0].event[0].eventActor[0].displayActorInRole[0];\n } } catch (e) {}\n try {\n if(lido.descriptiveMetadata[0].eventWrap[0].eventSet[0].event[0].eventDate[0].date[0].earliestDate[0] !== null) {\n newMsg.image.date =lido.descriptiveMetadata[0].eventWrap[0].eventSet[0].event[0].eventDate[0].date[0].earliestDate[0];\n }\n } catch(e) {}\n if(lido.descriptiveMetadata[0].objectIdentificationWrap[0].objectDescriptionWrap[0].objectDescriptionSet[1].descriptiveNoteValue[0] !== null) {\n newMsg.image.desc = lido.descriptiveMetadata[0].objectIdentificationWrap[0].objectDescriptionWrap[0].objectDescriptionSet[1].descriptiveNoteValue[0];\n }\n newMsg. req = global.get(\"req\")||0;\n newMsg. res = global.get(\"res\")||0;\n \n return newMsg;\n}\nelse {\n newMsg.payload = \"ERROR!\";\n return newMsg;\n}\n\n","outputs":1,"noerr":0,"x":772.9628719753691,"y":1146.6669928630195,"wires":[["67869b10.8ddd74","6860fa15.060af4","1a12c498.9cea6b","72f00e77.a9d81"]]},{"id":"67869b10.8ddd74","type":"debug","z":"26e4310.b9db45","name":"","active":true,"console":"false","complete":"true","x":936.2961315578887,"y":1257.7779515584311,"wires":[]},{"id":"9cef63ea.51ba6","type":"debug","z":"26e4310.b9db45","name":"","active":false,"console":"false","complete":"true","x":696.296223110623,"y":1230.0003894170127,"wires":[]},{"id":"1f5707ac.b5bc08","type":"template","z":"26e4310.b9db45","name":"LangeNacht Baner","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n\t<head>\n\t\t<title>Sound of Sails</title>\n\t\t<style>\n\t\t\tbody {margin:0;background: #000;text-align:center;color: white;}\n\n h1 {\n text-align: center;\n color: white;\n margin-bottom: 10px;\n }\n \n h4 {\n text-align: center;\n color: white;\n margin-top: 0px;\n }\n \n center {\n width: 40%;\n margin-left: 30%;\n\n }\n \n .image {\n height: 50%;\n\t\t\t margin-left:2em;\n\t\t\t margin-right:2em;\n\t\t\t margin-top: 2em;\n\t\t\t margin-bottom: 2em;\n\t\t\t float: middle;\n\t\t\t}\n\t\t\t\n\t\t\t.header {\n height: 15%;\t\t\n\t\t\t \n\t\t\t}\n\t\t\t\n\t\t\t.footer {\n\t\t\t height: 15%;\n\t\t\t}\n \n\t\t</style>\n\n\t\t</head>\n \t<body>\n \t <p><a href=\"http://{{ip}}/Credits\"><img class=\"header\" alt=\"\" src=\"http://{{ip}}/image?file=/Website/banner.png\"></a></p>\n \t \n <h1>{{image.title}}</h1>\n <h4>{{image.artist}} ({{image.date}})</h4>\n <center>{{image.desc}}</center>\n\n \t <div>\n <a href=\"http://{{ip}}/langeNacht\"><img class=\"image\" alt=\"\" src={{image.url}}></a>\n </div>\n \n <p><a href=\"http://{{ip}}/Credits\"><img class=\"footer\" alt=\"\" src=\"http://{{ip}}/image?file=/Website/credits.png\"></a></p>\n\n </body>\n\t\t\n\t\t<script>\n console.log(\"starting audio script!\");\n \n // Websocket\n var timerID = 0; \n var connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n async function keepAlive() { \n var timeout = 3000; \n if (connection.readyState == WebSocket.OPEN) { \n connection.send(''); \n } else {\n connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n }\n timerId = setTimeout(keepAlive, timeout); \n } \n function cancelKeepAlive() { \n if (timerId) { \n clearTimeout(timerId); \n } \n }\n keepAlive();\n // When the connection is open, send some data to the server\n connection.onopen = function () {\n connection.send('Ready'); // Send the message 'Ping' to the server\n };\n \n // Log errors\n connection.onerror = function (error) {\n console.log('WebSocket Error ' + error);\n window.location = \"http://sound-of-sails.mybluemix.net/langeNacht\";\n };\n \n connection.onclose = function () {\n console.log('WebSocket Closed' );\n window.location = \"http://sound-of-sails.mybluemix.net/langeNacht\";\n };\n \n // Log messages from the server\n connection.onmessage = function (e) {\n console.log('Server: ' + e.data);\n };\n \n // BufferloaderClass\n function BufferLoader(context, urlList, callback) {\n this.context = context;\n this.urlList = urlList;\n this.onload = callback;\n this.bufferList = new Array();\n this.loadCount = 0;\n }\n \n BufferLoader.prototype.loadBuffer = function(url, index) {\n // Load buffer asynchronously\n var request = new XMLHttpRequest();\n request.open(\"GET\", url, true);\n request.responseType = \"arraybuffer\";\n \n var loader = this;\n \n request.onload = function() {\n // Asynchronously decode the audio file data in request.response\n loader.context.decodeAudioData(\n request.response,\n function(buffer) {\n if (!buffer) {\n alert('error decoding file data: ' + url);\n return;\n }\n loader.bufferList[index] = buffer;\n if (++loader.loadCount == loader.urlList.length)\n loader.onload(loader.bufferList);\n },\n function(error) {\n console.error('decodeAudioData error', error);\n }\n );\n }\n \n request.onerror = function() {\n alert('BufferLoader: XHR error');\n }\n \n request.send();\n }\n \n BufferLoader.prototype.load = function() {\n for (var i = 0; i < this.urlList.length; ++i)\n this.loadBuffer(this.urlList[i], i);\n }\n \n // !BufferloaderClass\n \n function loadPage(href)\n {\n var xmlhttp = new XMLHttpRequest();\n xmlhttp.open(\"GET\", href, false);\n xmlhttp.send();\n return xmlhttp.responseText;\n }\n \n // AudioPlayback ###########\n //window.onload = init;\n var context;\n var bufferLoader;\n var gainNode;\n\n // Log messages from the server\n connection.onmessage = function (e) {\n \n if(String(e.data).includes('mute')) {\n console.log(\"setting gain to 0!\");\n gainNode.gain.value = 0;\n } else if(String(e.data).includes('.mp3')) {\n \n \n console.log('Server: ' + e.data);\n \n //};\n //function init() {\n \n console.log(\"received message: \" + e.data);\n \n // Fix up prefixing\n window.AudioContext = window.AudioContext || window.webkitAudioContext;\n context = new AudioContext();\n \n console.log(\"loading buffer!\");\n bufferLoader = new BufferLoader(\n context,\n [\n 'http://{{ip}}/sound?file=' + e.data // Audio/joy.wav\n // 'http://{{ip}}/sound?file=/Audio/fear.wav',\n ],\n finishedLoading\n );\n \n bufferLoader.load();\n //} else if(JSON.parse(e.data)) {\n // console.log(e.data); \n } else if (String(e.data).includes('move')) {\n window.location = \"http://sound-of-sails.mybluemix.net/langeNacht\";\n }\n \n }\n \n function finishedLoading(bufferList) {\n \n console.log(\"done loading, creating audio source!\");\n // Create two sources and play them both together.\n var source1 = context.createBufferSource();\n //var source2 = context.createBufferSource();\n source1.buffer = bufferList[0];\n //source2.buffer = bufferList[1];\n \n console.log(\"creating gain node!\");\n // Create a gain node.\n gainNode = context.createGain();\n // Connect the source to the gain node.\n source1.connect(gainNode);\n //source2.connect(gainNode);\n // Connect the gain node to the destination.\n gainNode.connect(context.destination);\n \n console.log(\"setting gain to 1!\");\n gainNode.gain.value = 1;\n \n console.log(\"starting audio playback!\");\n source1.start(0);\n //source2.start(0);\n \n //window.setInterval(stopCallback, 3000);\n }\n \n \n \n //function stopCallback() {\n // console.log(\"setting gain to 0!\");\n // gainNode.gain.value = 0;\n // }\n </script>\n</html>","x":1114.2051544189453,"y":1159.7535576820374,"wires":[[]]},{"id":"6860fa15.060af4","type":"function","z":"26e4310.b9db45","name":"Hier IP eintragen","func":"msg.ip = \"sound-of-sails.mybluemix.net\"; //your ip here\nreturn msg;","outputs":1,"noerr":0,"x":986.9210247463652,"y":1103.086855252584,"wires":[["77c35fb4.5bb51"]]},{"id":"965fd29d.1965f","type":"http in","z":"26e4310.b9db45","name":"","url":"/langeNacht","method":"get","swaggerDoc":"","x":142.4767116970488,"y":1060.8644784291587,"wires":[["dd6309af.0d3248","e286cead.32688"]]},{"id":"e286cead.32688","type":"debug","z":"26e4310.b9db45","name":"","active":true,"console":"false","complete":"true","x":387.0911042955188,"y":1003.1716486612956,"wires":[]},{"id":"9e1d84af.defd88","type":"http response","z":"26e4310.b9db45","name":"","x":1381.1768608093262,"y":1094.4874477386475,"wires":[]},{"id":"fa9e2462.f547c8","type":"function","z":"26e4310.b9db45","name":"Result Parser For Of","func":"var newMsg = {image:new Object}\nnewMsg.image.url = \"\";\n\n// initialise the counter to 0 if it doesn't exist already\nvar count = context.get('imagecount')||0;\ncount += 1;\ncount %= 35;\n// store the value back\ncontext.set('imagecount',count);\n// make it part of the outgoing msg object\nnewMsg.count = count;\n\nif(msg.payload.lidoWrap.lido[0] !== null)\n{\n var loop = 0;\n var lidoWrap = msg.payload.lidoWrap.lido;\n for(var lido of lidoWrap) \n {\n loop += 1;\n if(loop === count)\n {\n if(String(lido.administrativeMetadata[0].resourceWrap[0].resourceSet[0].resourceRepresentation[1].linkResource[0]._).includes(\"http\")) {\n newMsg.image.url = lido.administrativeMetadata[0].resourceWrap[0].resourceSet[0].resourceRepresentation[1].linkResource[0]._;\n }\n if(String(lido.descriptiveMetadata[0].objectIdentificationWrap[0].titleWrap[0].titleSet[0].appellationValue[0]._) ) {\n newMsg.image.title = lido.descriptiveMetadata[0].objectIdentificationWrap[0].titleWrap[0].titleSet[0].appellationValue[0]._;\n }\n if(String(lido.descriptiveMetadata[0].eventWrap[0].eventSet[0].event[0].eventActor[0].displayActorInRole[0]) ) {\n newMsg.image.artist =lido.descriptiveMetadata[0].eventWrap[0].eventSet[0].event[0].eventActor[0].displayActorInRole[0];\n }\n if(String(lido.descriptiveMetadata[0].eventWrap[0].eventSet[0].event[0].eventDate[0].date[0].earliestDate[0]) ) {\n newMsg.image.date =lido.descriptiveMetadata[0].eventWrap[0].eventSet[0].event[0].eventDate[0].date[0].earliestDate[0];\n }\n if(String(lido.descriptiveMetadata[0].objectIdentificationWrap[0].objectDescriptionWrap[0].objectDescriptionSet[0].descriptiveNoteValue[0]) ) {\n newMsg.image.note = lido.descriptiveMetadata[0].objectIdentificationWrap[0].objectDescriptionWrap[0].objectDescriptionSet[0].descriptiveNoteValue[0];\n } \n if(String(lido.descriptiveMetadata[0].objectIdentificationWrap[0].objectDescriptionWrap[0].objectDescriptionSet[1].descriptiveNoteValue[0]) ) {\n newMsg.image.desc = lido.descriptiveMetadata[0].objectIdentificationWrap[0].objectDescriptionWrap[0].objectDescriptionSet[1].descriptiveNoteValue[0];\n }\n newMsg. req = global.get(\"req\")||0;\n newMsg. res = global.get(\"res\")||0;\n \n return newMsg;\n\n }\n }\n newMsg.payload = \"ERROR!\";\n return newMsg;\n}\nelse {\n newMsg.payload = \"ERROR!\";\n return newMsg;\n}\n\n","outputs":1,"noerr":0,"x":788.8988384670683,"y":1016.0320981343589,"wires":[[]]},{"id":"fcd6b80b.0a9448","type":"websocket out","z":"26e4310.b9db45","name":"","server":"b76a1ee4.f1e918","client":"","x":616.2802352905273,"y":1966.2706716060638,"wires":[]},{"id":"286136e2.dc35aa","type":"inject","z":"26e4310.b9db45","name":"","topic":"","payload":"move","payloadType":"str","repeat":"","crontab":"","once":false,"x":372.3913546970912,"y":1979.3855070727209,"wires":[["fcd6b80b.0a9448"]]},{"id":"11e35a81.37e415","type":"comment","z":"26e4310.b9db45","name":"Image Analysis","info":"See corresponding Lab instructions in the link below :\n\n[Watson Visual Recognition](https://github.com/watson-developer-cloud/node-red-labs/tree/master/basic_examples/visual_recognition_v3)\n","x":798.9003601074219,"y":1392.9636249542236,"wires":[]},{"id":"eaa4ed58.03acf","type":"function","z":"26e4310.b9db45","name":"","func":"msg.payload = \"/Audio/MP3/\" + Math.floor((Math.random() * 17) + 1) + \".mp3\";\nreturn msg;\n","outputs":1,"noerr":0,"x":1071.948341369629,"y":1609.5707664489746,"wires":[["d04b39db.d19c98"]]},{"id":"1a12c498.9cea6b","type":"function","z":"26e4310.b9db45","name":"set Classifier","func":"// initialise the counter to 0 if it doesn't exist already\nvar count = context.get('count')||0;\ncount += 1;\ncount %= 40;\n// store the value back\ncontext.set('count',count);\n// make it part of the outgoing msg object\nmsg.count = count;\n\n//msg.filename=\"Ship (\" + (count) + \").jpg\";\nmsg.payload = msg.image.url;\nmsg.params={};\nmsg.params[\"owners\"]=\"me\";\nmsg.params[\"classifier_ids\"]=[\"sun_409678915\",\"threemast_372982515\",\"storm_1384366973\"];\nreturn msg;","outputs":1,"noerr":0,"x":677.6503601074219,"y":1460.7136249542236,"wires":[["9aa088cf.3d0078"]]},{"id":"9aa088cf.3d0078","type":"visual-recognition-v3","z":"26e4310.b9db45","name":"","apikey":"","image-feature":"classifyImage","lang":"en","x":803.6503601074219,"y":1499.7136249542236,"wires":[["88c65248.859e9"]]},{"id":"b1650860.b00688","type":"comment","z":"26e4310.b9db45","name":"Play Audio on SOS Webpage","info":"","x":1519.3648376464844,"y":1425.5707111358643,"wires":[]},{"id":"16705a02.ff0fc6","type":"play audio","z":"26e4310.b9db45","name":"","x":1566.9482192993164,"y":1681.3565940856934,"wires":[]},{"id":"c3f4d5df.1654a8","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"","name":"","x":1456.7338638305664,"y":1639.7137718200684,"wires":[["16705a02.ff0fc6"]]},{"id":"2cd4c024.9df04","type":"comment","z":"26e4310.b9db45","name":"Play Audio in Node RED","info":"https://www.html5rocks.com/en/tutorials/webaudio/intro/","x":1508.0195083618164,"y":1596.4994163513184,"wires":[]},{"id":"f03fb0ee.8832c","type":"websocket out","z":"26e4310.b9db45","name":"","server":"b76a1ee4.f1e918","client":"","x":1459.9183044433594,"y":1470.0052814483643,"wires":[]},{"id":"60cd5ec4.6cb21","type":"websocket out","z":"26e4310.b9db45","name":"","server":"b76a1ee4.f1e918","client":"","x":480.0851650238037,"y":2100.339112520218,"wires":[]},{"id":"3d4de8db.d09b08","type":"inject","z":"26e4310.b9db45","name":"","topic":"","payload":"mute","payloadType":"str","repeat":"","crontab":"","once":false,"x":386.9740810394287,"y":2061.9688732624054,"wires":[["60cd5ec4.6cb21"]]},{"id":"aa5cac.371d7358","type":"comment","z":"26e4310.b9db45","name":"Mute Audio","info":"","x":1471.5018005371094,"y":1532.7552814483643,"wires":[]},{"id":"88c65248.859e9","type":"function","z":"26e4310.b9db45","name":"Result Parser","func":"var newMsg = {payload:\"\"}\nnewMsg.threemast = new Object;\nnewMsg.sun = new Object;\nnewMsg.storm = new Object;\nnewMsg.sun.score = 0;\nnewMsg.storm.score = 0;\nnewMsg.threemast.score = 0;\n\nif(msg.result.images !== null)\n{\n //msg.params[\"classifier_ids\"]=[\"sun_409678915\",\"threemast_372982515\",\"storm_1384366973\"];\n\n if(msg.result.images[0].classifiers !== null)\n {\n var classifiers = msg.result.images[0].classifiers;\n for(var classifier of classifiers) \n {\n if(String(classifier.classifier_id).includes(\"threemast_372982515\"))\n { \n var classes = classifier.classes;\n var middle = 0;\n \n for(var classs of classes) \n {\n middle += classs.score;\n \n }\n middle/= 2;\n newMsg.threemast.score = middle;\n newMsg.threemast.name = classifier.classifier_id;\n } \n else if(String(classifier.classifier_id).includes(\"sun_409678915\"))\n { \n var classes = classifier.classes;\n var middle = 0;\n \n for(var classs of classes) \n {\n middle += classs.score;\n \n }\n middle/= 2;\n \n newMsg.sun.score = middle;\n newMsg.sun.name = classifier.classifier_id;\n } \n else if(String(classifier.classifier_id).includes(\"storm_1384366973\"))\n { \n var classes = classifier.classes;\n var middle = 0;\n \n for(var classs of classes) \n {\n middle += classs.score;\n \n }\n middle/= 2;\n \n newMsg.storm.score = middle;\n newMsg.storm.name = classifier.classifier_id;\n \n\n } \n }\n return newMsg;\n }\n else {\n msg.payload = 0 + \",\";\n return msg;\n }\n}\nelse {\n var newMsg = { payload: \"no image or result\" };\n return msg;\n}\n","outputs":1,"noerr":0,"x":945.1208190917969,"y":1459.6480731964111,"wires":[["7e99465d.cb9418","d30e600.488f32"]]},{"id":"b98b574a.1b7608","type":"comment","z":"26e4310.b9db45","name":"Classifier Mapping Magic","info":"","x":1118.203956604004,"y":1530.314754486084,"wires":[]},{"id":"7e99465d.cb9418","type":"function","z":"26e4310.b9db45","name":"Mapping","func":"var newMsg = {payload:0}\n//newMsg.threemast = new Object;\nvar threemast=0.00;\nvar sun=0.00;\nvar storm=0.00;\n\nif(msg.threemast !== null)\n{\n threemast = msg.threemast.score * 0.85;\n}\nif(msg.sun !== null)\n{\n sun = msg.sun.score;\n}\nif(msg.storm !== null)\n{\n storm = msg.storm.score * 0.70;\n}\n\nif((threemast > sun) && (threemast > storm)) {\n \n if(storm > 0.6){\n \n } else{\n if(0 == threemast) {\n newMsg.payload = (sun==0)?(\"/Audio/MP3_new/\" + \"twomastf.mp3\"):(\"/Audio/MP3_new/\" + \"calm.mp3\");\n } else if(0.5 >= threemast) {\n newMsg.payload = (storm<=0.7)?(\"/Audio/MP3_new/\" + \"twomast.mp3\"):(\"/Audio/MP3_new/\" + \"stormf.mp3\");\n } else if(0.91 >= threemast) {\n newMsg.payload = (storm<=0.6)?(\"/Audio/MP3_new/\" + \"twomast-.mp3\"):(\"/Audio/MP3_new/\" + \"storm.mp3\");\n } else if(0.92 >= threemast) {\n newMsg.payload = (sun<=0.8)?(\"/Audio/MP3_new/\" + \"threemast.mp3\"):(\"/Audio/MP3_new/\" + \"calm.mp3\");\n } else if(0.99 >= threemast) {\n newMsg.payload = (sun<=0.9)?(\"/Audio/MP3_new/\" + \"threemastf.mp3\"):(\"/Audio/MP3_new/\" + \"calmf.mp3\");\n }\n }\n}\n\nelse if((sun > threemast) && (sun > storm)) {\n if(0 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"sun-.mp3\";\n } else if(0.3 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"calm.mp3\";\n } else if(0.44 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"sunf.mp3\";\n } else if(0.45 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"calmf.mp3\";\n } else if(0.5 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"sun.mp3\";\n } else if(0.67 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"calm-.mp3\";\n } else if(0.99 >= sun) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"sunff.mp3\";\n }\n}\n\nelse if((storm > sun) && (storm > sun)) {\n if(sun >= 0.45) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"sunff.mp3\";\n } else if(0.5 >= storm) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"stormf.mp3\";\n } else if(0.65 >= storm) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"storm.mp3\";\n } else if(0.8 >= storm) {\n newMsg.payload = \"/Audio/MP3_new/\" + \"storm-.mp3\";\n }\n}\n\nif (newMsg.payload==0) newMsg.payload = \"/Audio/MP3_new/\" + \"mix.mp3\";\n \nreturn newMsg;","outputs":1,"noerr":0,"x":1075.578956604004,"y":1571.726894378662,"wires":[["b775232b.30677","83f0841.24a9278","d04b39db.d19c98","57070784.dd1098"]]},{"id":"d04b39db.d19c98","type":"delay","z":"26e4310.b9db45","name":"","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1263.3753967285156,"y":1411.0601825714111,"wires":[["f03fb0ee.8832c"]]},{"id":"b775232b.30677","type":"function","z":"26e4310.b9db45","name":"file name","func":"msg.filename = msg.payload;\n \nreturn msg;","outputs":1,"noerr":0,"x":1279.695655822754,"y":1603.3398704528809,"wires":[[]]},{"id":"83f0841.24a9278","type":"delay","z":"26e4310.b9db45","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1284.4123153686523,"y":1638.3009243011475,"wires":[[]]},{"id":"26cbd4ab.3a087c","type":"websocket in","z":"26e4310.b9db45","name":"","server":"b76a1ee4.f1e918","client":"","x":1690.4631004333496,"y":1538.102240562439,"wires":[["37ce65.7c1ff19c"]]},{"id":"37ce65.7c1ff19c","type":"debug","z":"26e4310.b9db45","name":"","active":false,"console":"false","complete":"true","x":1848.9004096984863,"y":1532.9629926681519,"wires":[]},{"id":"f2d9d824.40a1a8","type":"function","z":"26e4310.b9db45","name":"Result Parser Sequenz","func":"var newMsg = {image:new Object}\nnewMsg.image.url = \"\";\n\n// initialise the counter to 0 if it doesn't exist already\nvar count = context.get('imagecount')||0;\ncount += 1;\ncount %= 35;\n// store the value back\ncontext.set('imagecount',count);\n// make it part of the outgoing msg object\nnewMsg.count = count;\n\nif(msg.payload.lidoWrap.lido[0] !== null)\n{\n\n var lido = msg.payload.lidoWrap.lido[count];\n\n if(String(lido.administrativeMetadata[0].resourceWrap[0].resourceSet[0].resourceRepresentation[1].linkResource[0]._).includes(\"http\")) {\n newMsg.image.url = lido.administrativeMetadata[0].resourceWrap[0].resourceSet[0].resourceRepresentation[1].linkResource[0]._;\n }\n if(lido.descriptiveMetadata[0].objectIdentificationWrap[0].titleWrap[0].titleSet[0].appellationValue[0]._ !== null) {\n newMsg.image.title = lido.descriptiveMetadata[0].objectIdentificationWrap[0].titleWrap[0].titleSet[0].appellationValue[0]._;\n }/*\n if(lido.descriptiveMetadata[0].eventWrap[0].eventSet[0].event[0].eventActor[0].displayActorInRole[0] !== null) {\n newMsg.image.artist =lido.descriptiveMetadata[0].eventWrap[0].eventSet[0].event[0].eventActor[0].displayActorInRole[0];\n }*/ try {\n if(lido.descriptiveMetadata[0].eventWrap[0].eventSet[0].event[0].eventDate[0].date[0].earliestDate[0] !== null) {\n newMsg.image.date =lido.descriptiveMetadata[0].eventWrap[0].eventSet[0].event[0].eventDate[0].date[0].earliestDate[0];\n }\n } catch(e) {}\n if(lido.descriptiveMetadata[0].objectIdentificationWrap[0].objectDescriptionWrap[0].objectDescriptionSet[1].descriptiveNoteValue[0] !== null) {\n newMsg.image.desc = lido.descriptiveMetadata[0].objectIdentificationWrap[0].objectDescriptionWrap[0].objectDescriptionSet[1].descriptiveNoteValue[0];\n }\n newMsg. req = global.get(\"req\")||0;\n newMsg. res = global.get(\"res\")||0;\n \n return newMsg;\n}\nelse {\n newMsg.payload = \"ERROR!\";\n return newMsg;\n}\n\n","outputs":1,"noerr":0,"x":787.8795055813262,"y":1061.7861302693686,"wires":[[]]},{"id":"13e84521.22d47b","type":"debug","z":"26e4310.b9db45","name":"","active":true,"console":"false","complete":"false","x":640.348934173584,"y":1919.7502024173737,"wires":[]},{"id":"21bc1ea2.7292f2","type":"function","z":"26e4310.b9db45","name":"","func":"msg.payload= msg.payload.wheel;\nreturn msg;","outputs":1,"noerr":0,"x":467.966121673584,"y":1906.5275461673737,"wires":[["fcd6b80b.0a9448","13e84521.22d47b"]]},{"id":"825bef90.8b36a","type":"function","z":"26e4310.b9db45","name":"","func":"msg.payload = \"/Audio/MP3/\" + Math.floor((Math.random() * 17) + 1) + \".mp3\";\nreturn msg;\n","outputs":1,"noerr":0,"x":627.4323234558105,"y":664.0833458900452,"wires":[["252098.5937c768"]]},{"id":"6288da31.a96254","type":"template","z":"26e4310.b9db45","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n\t<head>\n\t\t<title>Sound of Sails</title>\n\t\t<style>\n\t\t\tbody {margin:0;background: #000;text-align:center;color: white;}\n\n h1 {\n text-align: center;\n color: white;\n margin-bottom: 10px;\n }\n \n h4 {\n text-align: center;\n color: white;\n margin-top: 0px;\n }\n \n center {\n width: 40%;\n margin-left: 30%;\n\n }\n \n .image {\n height: 50%;\n\t\t\t margin-left:2em;\n\t\t\t margin-right:2em;\n\t\t\t margin-top: 2em;\n\t\t\t margin-bottom: 2em;\n\t\t\t float: middle;\n\t\t\t}\n\t\t\t\n\t\t\t.header {\n height: 15%;\t\t\n\t\t\t \n\t\t\t}\n\t\t\t\n\t\t\t.footer {\n\t\t\t height: 15%;\n\t\t\t}\n \n\t\t</style>\n\t\t</head>\n\t \t<body>\n\t <div>\n <a href=\"http://sound-of-sails.mybluemix.net/wheel?wheel=move\"><img class=\"image\" alt=\"\" src=\"http://sound-of-sails.mybluemix.net/image?file=/Website/wheel.png\"></a>\n </div>\n </body>\n</html>","x":663.3451156616211,"y":1843.3831150531769,"wires":[["a2ba1164.eabbc"]]},{"id":"77c35fb4.5bb51","type":"template","z":"26e4310.b9db45","name":"LangeNacht Plain","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<html>\n\t<head>\n\t\t<title>Sound of Sails</title>\n\t\t<style>\n\t\t\tbody {margin:0;background: #000;text-align:center;color: white;}\n\n h1 {\n text-align: center;\n color: white;\n margin-bottom: 20px;\n margin-top: 50px;\n }\n \n h4 {\n text-align: center;\n color: white;\n margin-top: 10px;\n }\n \n center {\n width: 40%;\n margin-left: 30%;\n\n }\n \n .image {\n height: 50%;\n\t\t\t margin-left:2em;\n\t\t\t margin-right:2em;\n\t\t\t margin-top: 2em;\n\t\t\t margin-bottom: 2em;\n\t\t\t float: middle;\n\t\t\t}\n\t\t\t\n\t\t\t.header {\n height: 15%;\t\t\n\t\t\t \n\t\t\t}\n\t\t\t\n\t\t\t.footer {\n\t\t\t height: 15%;\n\t\t\t}\n \n\t\t</style>\n\n\t\t</head>\n \t<body>\n\n <h1>{{image.title}}</h1>\n \t <div>\n <a href=\"http://{{ip}}/langeNacht\"><img class=\"image\" alt=\"\" src={{image.url}}></a>\n </div>\n <h4>{{image.artist}} ({{image.date}})</h4>\n <center>{{image.desc}}</center>\n\n </body>\n\t\t\n\t\t<script>\n console.log(\"starting audio script!\");\n \n // Websocket\n var timerID = 0; \n var connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n async function keepAlive() { \n var timeout = 3000; \n if (connection.readyState == WebSocket.OPEN) { \n connection.send(''); \n } else {\n connection = new WebSocket('ws://sound-of-sails.mybluemix.net/ws', ['soap', 'xmpp']);\n }\n timerId = setTimeout(keepAlive, timeout); \n } \n function cancelKeepAlive() { \n if (timerId) { \n clearTimeout(timerId); \n } \n }\n keepAlive();\n // When the connection is open, send some data to the server\n connection.onopen = function () {\n connection.send('Ready'); // Send the message 'Ping' to the server\n };\n \n // Log errors\n connection.onerror = function (error) {\n console.log('WebSocket Error ' + error);\n window.location = \"http://sound-of-sails.mybluemix.net/langeNacht\";\n };\n \n connection.onclose = function () {\n console.log('WebSocket Closed' );\n window.location = \"http://sound-of-sails.mybluemix.net/langeNacht\";\n };\n \n // Log messages from the server\n connection.onmessage = function (e) {\n console.log('Server: ' + e.data);\n };\n \n // BufferloaderClass\n function BufferLoader(context, urlList, callback) {\n this.context = context;\n this.urlList = urlList;\n this.onload = callback;\n this.bufferList = new Array();\n this.loadCount = 0;\n }\n \n BufferLoader.prototype.loadBuffer = function(url, index) {\n // Load buffer asynchronously\n var request = new XMLHttpRequest();\n request.open(\"GET\", url, true);\n request.responseType = \"arraybuffer\";\n \n var loader = this;\n \n request.onload = function() {\n // Asynchronously decode the audio file data in request.response\n loader.context.decodeAudioData(\n request.response,\n function(buffer) {\n if (!buffer) {\n alert('error decoding file data: ' + url);\n return;\n }\n loader.bufferList[index] = buffer;\n if (++loader.loadCount == loader.urlList.length)\n loader.onload(loader.bufferList);\n },\n function(error) {\n console.error('decodeAudioData error', error);\n }\n );\n }\n \n request.onerror = function() {\n alert('BufferLoader: XHR error');\n }\n \n request.send();\n }\n \n BufferLoader.prototype.load = function() {\n for (var i = 0; i < this.urlList.length; ++i)\n this.loadBuffer(this.urlList[i], i);\n }\n \n // !BufferloaderClass\n \n function loadPage(href)\n {\n var xmlhttp = new XMLHttpRequest();\n xmlhttp.open(\"GET\", href, false);\n xmlhttp.send();\n return xmlhttp.responseText;\n }\n \n // AudioPlayback ###########\n //window.onload = init;\n var context;\n var bufferLoader;\n var gainNode;\n\n // Log messages from the server\n connection.onmessage = function (e) {\n \n if(String(e.data).includes('mute')) {\n console.log(\"setting gain to 0!\");\n gainNode.gain.value = 0;\n } else if(String(e.data).includes('.mp3')) {\n \n \n console.log('Server: ' + e.data);\n \n //};\n //function init() {\n \n console.log(\"received message: \" + e.data);\n \n // Fix up prefixing\n window.AudioContext = window.AudioContext || window.webkitAudioContext;\n context = new AudioContext();\n \n console.log(\"loading buffer!\");\n bufferLoader = new BufferLoader(\n context,\n [\n 'http://{{ip}}/sound?file=' + e.data // Audio/joy.wav\n // 'http://{{ip}}/sound?file=/Audio/fear.wav',\n ],\n finishedLoading\n );\n \n bufferLoader.load();\n //} else if(JSON.parse(e.data)) {\n // console.log(e.data); \n } else if (String(e.data).includes('move')) {\n window.location = \"http://sound-of-sails.mybluemix.net/langeNacht\";\n }\n \n }\n \n function finishedLoading(bufferList) {\n \n console.log(\"done loading, creating audio source!\");\n // Create two sources and play them both together.\n var source1 = context.createBufferSource();\n //var source2 = context.createBufferSource();\n source1.buffer = bufferList[0];\n //source2.buffer = bufferList[1];\n \n console.log(\"creating gain node!\");\n // Create a gain node.\n gainNode = context.createGain();\n // Connect the source to the gain node.\n source1.connect(gainNode);\n //source2.connect(gainNode);\n // Connect the gain node to the destination.\n gainNode.connect(context.destination);\n \n console.log(\"setting gain to 1!\");\n gainNode.gain.value = 1;\n \n console.log(\"starting audio playback!\");\n source1.start(0);\n //source2.start(0);\n \n //window.setInterval(stopCallback, 3000);\n }\n \n \n \n //function stopCallback() {\n // console.log(\"setting gain to 0!\");\n // gainNode.gain.value = 0;\n // }\n </script>\n</html>","x":1112.942626953125,"y":1201.2498779296875,"wires":[["9e1d84af.defd88"]]},{"id":"57070784.dd1098","type":"delay","z":"26e4310.b9db45","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1531.6666259765625,"y":1366.3333740234375,"wires":[["d30e600.488f32"]]},{"id":"72f00e77.a9d81","type":"function","z":"26e4310.b9db45","name":"Prepare Request","func":"msg.payload=msg.image.desc;\nreturn msg;","outputs":1,"noerr":0,"x":577.6666259765625,"y":1676.3333740234375,"wires":[["f8b0465a.db52f8"]]},{"id":"f8b0465a.db52f8","type":"alchemy-feature-extract","z":"26e4310.b9db45","name":"","page-image":true,"image-kw":true,"feed":true,"entity":true,"keyword":true,"title":true,"author":true,"taxonomy":true,"concept":true,"relation":true,"pub-date":true,"doc-sentiment":true,"doc-emotion":false,"entity-sentiment":false,"entity-emotion":false,"x":802.6666259765625,"y":1712.3333740234375,"wires":[["25a1003a.fedeb"]]},{"id":"25a1003a.fedeb","type":"debug","z":"26e4310.b9db45","name":"","active":true,"console":"true","complete":"features","x":999.6666259765625,"y":1710.3333740234375,"wires":[]},{"id":"b76a1ee4.f1e918","type":"websocket-listener","z":"","path":"/ws","wholemsg":"false"}]