-
Notifications
You must be signed in to change notification settings - Fork 1
/
SoundOfSails.json
1 lines (1 loc) · 64.3 KB
/
SoundOfSails.json
1
[{"id":"26e4310.b9db45","type":"tab","label":"Sound of Sails"},{"id":"b33df394.0d87b8","type":"http in","z":"26e4310.b9db45","name":"","url":"/image","method":"get","swaggerDoc":"","x":134.09918212890625,"y":870.9405517578125,"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":744.5991821289062,"y":935.6905517578125,"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":324.09918212890625,"y":870.4405517578125,"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":545.0991821289062,"y":864.4405517578125,"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":402.59918212890625,"y":935.6905517578125,"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":960.599193572998,"y":864.1905527114868,"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<style>\n\t\t\tbody {background: #000;text-align:center;}\n\t\t\timg {width: 30%;margin-left:1%;margin-top: 1%;}\n\t\t</style>\n\t</head>\n\t<body>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82520ab637.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82520ab637.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825218aee2.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825218aee2.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825220573b.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825220573b.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82522669eb.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82522669eb.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252278997.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252278997.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82522ec2c3.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82522ec2c3.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825235bab2.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825235bab2.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82523d5894.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82523d5894.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252453730.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252453730.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82524c393b.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82524c393b.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82525410b5.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82525410b5.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825259ffb7.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825259ffb7.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825261ed43.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825261ed43.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825268b3b7.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825268b3b7.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82527054a4.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82527054a4.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82527a2f5e.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82527a2f5e.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82527be687.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82527be687.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82528358b7.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82528358b7.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82528a331f.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82528a331f.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252915847.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252915847.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252999eba.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252999eba.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252a36cc8.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252a36cc8.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252aaa1bb.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252aaa1bb.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252abb541.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252abb541.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252ac8bf3.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252ac8bf3.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252b4ac96.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252b4ac96.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252be0cfc.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252be0cfc.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252c4f6a4.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252c4f6a4.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252cb0859.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252cb0859.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252d291da.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252d291da.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252d9e4fc.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252d9e4fc.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252db1a07.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252db1a07.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252e2606a.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252e2606a.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252e975c0.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252e975c0.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252f0506a.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252f0506a.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252f6322b.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252f6322b.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8252fc4e14.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8252fc4e14.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82530263d0.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82530263d0.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d8253040aa9.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d8253040aa9.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d82530b5005.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d82530b5005.jpg\"></a>\n\t\t<a href=\"http://{{ip}}/show?file=/{{path}}/m57d825311e022.jpg\"><img alt=\"\" src=\"http://{{ip}}/image?file=/{{path}}/m57d825311e022.jpg\"></a>\n\t</body>{{path}}\n</html>{{path}}\n","x":674.6429443359375,"y":114.10712432861328,"wires":[["86dd0531.8f6eb"]]},{"id":"91d1d481.343b88","type":"http response","z":"26e4310.b9db45","name":"","x":1009.0712890625,"y":314.8570556640625,"wires":[]},{"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":699.0714721679688,"y":274.8571472167969,"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"]]},{"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":234.09918212890625,"y":831.6905517578125,"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":[["dcfbb93c.15ce48"]]},{"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":637.8214111328125,"y":439.107177734375,"wires":[]},{"id":"e3261eb0.aca7a8","type":"function","z":"26e4310.b9db45","name":"","func":"if(msg.result.images.classifiers !== null)\n{\n if(msg.result.images[0].classifiers[0] !== undefined) {\n msg.payload = msg.result.images[0].classifiers[0].classes[0].score;\n return msg;\n } else {\n msg.payload = 0;\n return msg;\n }\n} else {\n msg.payload = 0;\n return msg;\n}","outputs":1,"noerr":0,"x":791.00830078125,"y":468.8809814453125,"wires":[["62a3f15c.c6bba8"]]},{"id":"62a3f15c.c6bba8","type":"function","z":"26e4310.b9db45","name":"","func":"\nvar trigger = Math.round(Math.random()*100/13)%5;\n\n\nif(trigger < 1) {\n //msg.payload = \"/home/pi/sound_of_sails/audio/\" + \"ang\" + \"+\" + \".wav\";\n //msg.payload = \"/Audio/\" + \"ang\" + \"\" + \".wav\";\n msg.payload = \"/Audio/MP3/\" + \"ang\" + \"\" + \".mp3\";\n return msg;\n //.payload = \"/home/pi/sound_of_sails/audio/\" + \"ang\" + \"-\" + \".wav\";\n} else if(trigger < 2.5) {\n //msg.payload = \"/home/pi/sound_of_sails/audio/\" + \"disg\" + \"+\" + \".wav\";\n //msg.payload = \"/Audio/\" + \"disg\" + \"\" + \".wav\";\n msg.payload = \"/Audio/MP3/\" + \"disg\" + \"\" + \".mp3\";\n return msg;\n //msg.payload = \"/home/pi/sound_of_sails/audio/\" + \"disg\" + \"-\" + \".wav\";\n} else if(trigger < 4) { \n //msg.payload = \"/home/pi/sound_of_sails/audio/\" + \"fear\" + \"+\" + \".wav\";\n //msg.payload = \"/Audio/\" + \"fear\" + \"\" + \".wav\";\n msg.payload = \"/Audio/MP3/\" + \"fear\" + \"\" + \".mp3\";\n return msg;\n //msg.payload = \"/home/pi/sound_of_sails/audio/\" + \"fear\" + \"-\" + \".wav\";\n} else if(trigger < 4.5) {\n //msg.payload = \"/home/pi/sound_of_sails/audio/\" + \"joy\" + \"+\" + \".wav\";\n //msg.payload = \"/Audio/\" + \"joy\" + \"\" + \".wav\";\n msg.payload = \"/Audio/MP3/\" + \"joy\" + \"\" + \".mp3\";\n return msg;\n} else if(trigger < 5) {\n //msg.payload = \"/home/pi/sound_of_sails/audio/\" + \"sad\" + \"+\" + \".wav\";\n //msg.payload = \"/Audio/\" + \"sad\" + \"\" + \".wav\";\n msg.payload = \"/Audio/MP3/\" + \"sad\" + \"\" + \".mp3\";\n return msg;\n} else {\n //msg.payload = \"/Audio/mix.wav\";\n msg.payload = \"/Audio/MP3/\" + \"mix.mp3\";\n}\n\nreturn msg;","outputs":1,"noerr":0,"x":917.5360107421875,"y":735.7142333984375,"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":516.5714111328125,"y":506.857177734375,"wires":[["ff94d306.bf4d3"]]},{"id":"ff94d306.bf4d3","type":"visual-recognition-v3","z":"26e4310.b9db45","name":"","apikey":"","image-feature":"classifyImage","lang":"en","x":642.5714111328125,"y":545.857177734375,"wires":[["e3261eb0.aca7a8","4c61ad14.42ba04","f57e0abe.4a29d"]]},{"id":"fa7dc402.78684","type":"comment","z":"26e4310.b9db45","name":"Play Audio on SOS Webpage","info":"","x":1358.285888671875,"y":471.7142639160156,"wires":[]},{"id":"3589fbb.8629984","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"","name":"","x":550.2222213745117,"y":934.8333702087402,"wires":[["989b86fa.c93bb8"]]},{"id":"274deffb.60ed1","type":"play audio","z":"26e4310.b9db45","name":"","x":1412.535888671875,"y":807.5000610351562,"wires":[]},{"id":"83672ff.73209d","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"","name":"","x":436.5,"y":470.2499694824219,"wires":[["b4e4a041.b56b"]]},{"id":"aa8c8ff8.8ea63","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"","name":"","x":1302.321533203125,"y":765.8572387695312,"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":1353.607177734375,"y":722.6428833007812,"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":550.872802734375,"y":1321.3890380859375,"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":358.09496307373047,"y":1320.9525718688965,"wires":[["9da61a1c.244cb"]]},{"id":"864aa3f0.20ebd","type":"http in","z":"26e4310.b9db45","name":"","url":"/test","method":"get","swaggerDoc":"","x":124.7615966796875,"y":1321.9049072265625,"wires":[["3f5fa804.8003c8"]]},{"id":"fc254151.98a23","type":"http response","z":"26e4310.b9db45","name":"","x":714.9996948242188,"y":1319.2860107421875,"wires":[]},{"id":"567aecd1.ecddd4","type":"http in","z":"26e4310.b9db45","name":"","url":"/sound","method":"get","swaggerDoc":"","x":134.76181411743164,"y":1111.666808128357,"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":747.4045295715332,"y":1177.3810415267944,"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":326.9045295715332,"y":1112.1310415267944,"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":547.9045295715332,"y":1106.1310415267944,"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":405.4045295715332,"y":1177.3810415267944,"wires":[["4f3554e8.ddeda4"]]},{"id":"f3fd1c23.03a628","type":"http response","z":"26e4310.b9db45","name":"","x":963.404541015625,"y":1105.8810424804688,"wires":[]},{"id":"4f3554e8.ddeda4","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"","name":"","x":553.0275688171387,"y":1176.5238599777222,"wires":[["2e8840e7.9d3708"]]},{"id":"7d5ee8a2.8eaa","type":"comment","z":"26e4310.b9db45","name":"Serve images from /home/pi/sound_of_sails/","info":"","x":233.33334350585938,"y":1071.666748046875,"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":549.2963256835938,"y":1388.0371704101562,"wires":[[]]},{"id":"9e4c458b.44579","type":"websocket out","z":"26e4310.b9db45","name":"","server":"b76a1ee4.f1e918","client":"","x":1298.83935546875,"y":516.1488342285156,"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":626.4583129882812,"y":232.62500762939453,"wires":[[]]},{"id":"58403a6c.f81dd4","type":"websocket out","z":"26e4310.b9db45","name":"","server":"b76a1ee4.f1e918","client":"","x":1384.6728515625,"y":660.1488647460938,"wires":[]},{"id":"b5e2e404.c129b8","type":"inject","z":"26e4310.b9db45","name":"","topic":"","payload":"mute","payloadType":"str","repeat":"","crontab":"","once":false,"x":1291.561767578125,"y":621.7786254882812,"wires":[["58403a6c.f81dd4"]]},{"id":"d342554c.90eb98","type":"comment","z":"26e4310.b9db45","name":"Mute Audio","info":"","x":1310.4228515625,"y":578.8988342285156,"wires":[]},{"id":"26b49bd5.0256cc","type":"debug","z":"26e4310.b9db45","name":"","active":true,"console":"true","complete":"true","x":915.21044921875,"y":432.60711669921875,"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":735.3125610351562,"y":316.5625,"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":784.0418701171875,"y":505.7916259765625,"wires":[["26b49bd5.0256cc","c936390a.f1a61"]]},{"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\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 \t <div id='wrapper' style='text-align: center;'>\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='valign: center;'>\n </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":743.5416870117188,"y":353.7916564941406,"wires":[["91d1d481.343b88"]]},{"id":"20afe682.e6616a","type":"comment","z":"26e4310.b9db45","name":"Classifier Mapping Magic","info":"","x":963.7916259765625,"y":656.4582214355469,"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":"c26d3b60.390b4","type":"xml","z":"26e4310.b9db45","name":"","attr":"","chr":"","x":640.7142944335938,"y":1555.357177734375,"wires":[["9e917976.32b09"]]},{"id":"f36faad.7f31058","type":"comment","z":"26e4310.b9db45","name":"Metadata","info":"","x":152.1428680419922,"y":1509.6429443359375,"wires":[]},{"id":"9bc7019f.c907e8","type":"function","z":"26e4310.b9db45","name":"file name","func":"msg.filename = \"/Schiffsportraits/altonalisteschiffsportraitslido20160913.xml\";\nreturn msg;","outputs":1,"noerr":0,"x":328.57147216796875,"y":1555.71435546875,"wires":[["1da4ad0b.ae886b"]]},{"id":"1da4ad0b.ae886b","type":"dropbox","z":"26e4310.b9db45","dropbox":"","filename":"","name":"","x":476.1945114135742,"y":1554.8571739196777,"wires":[["c26d3b60.390b4"]]},{"id":"15f8e6a2.e347e1","type":"inject","z":"26e4310.b9db45","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"x":158.57142639160156,"y":1553.21435546875,"wires":[["9bc7019f.c907e8"]]},{"id":"9e917976.32b09","type":"change","z":"26e4310.b9db45","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":828.5714721679688,"y":1555.3572387695312,"wires":[["418f49b.cc5d038"]]},{"id":"418f49b.cc5d038","type":"debug","z":"26e4310.b9db45","name":"","active":true,"console":"false","complete":"false","x":1040,"y":1554.9999999999998,"wires":[]},{"id":"4c61ad14.42ba04","type":"debug","z":"26e4310.b9db45","name":"","active":false,"console":"true","complete":"true","x":748.261962890625,"y":603.6666870117188,"wires":[]},{"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":921.1666259765625,"y":697.870361328125,"wires":[["252098.5937c768","bec83aa1.a0ed98","eff8ddaf.4e76"]]},{"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":1102.2964477539062,"y":457.2037353515625,"wires":[["9e4c458b.44579"]]},{"id":"eff8ddaf.4e76","type":"debug","z":"26e4310.b9db45","name":"","active":true,"console":"true","complete":"true","x":1058.6482238769531,"y":796.407470703125,"wires":[]},{"id":"bec83aa1.a0ed98","type":"function","z":"26e4310.b9db45","name":"file name","func":"msg.filename = msg.payload;\n \nreturn msg;","outputs":1,"noerr":0,"x":1125.2833251953125,"y":729.4833374023438,"wires":[["aa8c8ff8.8ea63"]]},{"id":"b76a1ee4.f1e918","type":"websocket-listener","z":"","path":"/ws","wholemsg":"false"}]