node-red-contrib-osc
Version:
Open Sound Control (OSC) support for Node-RED
80 lines (70 loc) • 3.11 kB
HTML
<!--
Copyright 2016 Nicholas Humfrey, Nathanaël Lécaudé.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script type="text/x-red" data-template-name="osc">
<div class="form-row">
<label for="node-input-path"><i class="icon-tasks"></i> Path</label>
<input type="text" id="node-input-path" placeholder="OSC Path">
</div>
<div class="form-row">
<label><i class="fa fa-list"></i> Metadata</span></label>
<input type="checkbox" id="node-input-metadata" style="display: inline-block; width: auto; vertical-align: top;">
Include metadata
</div>
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i> Name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-tips">Tip: leave path blank if you want to set using <b>msg.topic</b>.</div>
</script>
<script type="text/x-red" data-help-name="osc">
<p>Decode and encode messages using the Open Sound Control (OSC) protocol.</p>
<p>The OSC node is transport independant meaning you will need to use it with
Node-RED's built-in input and output objects like udp, tcp, websocket or serial.</p>
<h1>Receiving</h1>
<p>If the node receives a <code>Buffer</code> as <code>msg.payload</code> it will convert
it and place the OSC address in <code>msg.topic</code> and the received arguments
in <code>msg.payload.</code></p>
<p>When "Include metadata" checkbox is checked, the OSC node will send an object
with the type of the value along the value:</p>
<pre>
{
"type": "f",
"value": 33.4
}
</pre>
<h1>Sending</h1>
<p>If the node receives a valid OSC path as <code>msg.topic</code> and data as
<code>msg.payload</code> it will convert the data to a <code>Buffer</code> that can be
sent via tcp, udp, websocket or serial. You can also override <code>msg.topic</code>
by setting the path in the node's properties.</p>
<p>To send or receive via tcp or serial you will need the
<a href="http://flows.nodered.org/node/node-red-contrib-slip" target='blank'>node-red-contrib-slip</a> object.
</script>
<script type="text/javascript">
RED.nodes.registerType('osc',{
category: 'function',
color:"#0099FF",
defaults: {
name: {value:""},
path: {value:""},
metadata: {value: false}
},
inputs:1,
outputs:1,
icon: "bridge-dash.png",
align: "left",
label: function() {
return this.name||"osc";
}
});
</script>