node-red-contrib-music
Version:
Synthesise music with node-red. The beat node creates regular beats at a rate you can control, and which can be sunchronised with other machines. The divider node adds information to beat events, dividing beats into bars, bars into phrases, phrases into s
96 lines (77 loc) • 3.99 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('setting',{
category: 'music',
color: '#a6bbcf',
defaults: {
name: {required: false},
setting: {value: "volume", required: true},
initial: {required: true},
context: {value: "node", required:true},
min: {required: false},
max: {required: false}
},
inputs:1,
inputLabels: "up:,down:,set:",
outputs:1,
outputLabels: ["value"],
icon: "sliders.png",
label: function() {
return this.name || this.setting || "setting";
}
});
</script>
<script type="text/x-red" data-template-name="setting">
<div class="form-row">
<label for="node-input-setting"> Setting</label>
<input type="text" id="node-input-setting" placeholder="e.g. volume">
</div>
<div class="form-row">
<label for="node-input-initial"> Initial Value</label>
<input type="text" id="node-input-initial" placeholder="e.g. 50">
</div>
<div class="form-row">
<label for="node-input-context"> Context</label>
<select id="node-input-context">
<option>node</option>
<option>flow</option>
<option>global</option>
</select>
</div>
<div class="form-row">
<label for="node-input-min"> Minimum Value (if relevant)</label>
<input type="text" id="node-input-min" placeholder="e.g. 0">
</div>
<div class="form-row">
<label for="node-input-max"> Maximum Value (if relevant)</label>
<input type="text" id="node-input-max" placeholder="e.g. 100">
</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="e.g. drums volume">
</div>
</script>
<script type="text/x-red" data-help-name="setting">
<p>Keeps track of a setting that can change, e.g. volume, speed (bpm). If context <code>global</code> is selected then this setting is shared with other nodes, similarly <code>flow</code> will share among nodes on the same flow.</p>
<h3>Inputs</h3>
<dl class="message-properties">
<dt>payload
<span class="property-type">string</span>
</dt>
<dd> the new value to store (or change by, if <code>msg.topic</code> is <code>up</code> or <code>down</code>)</dd>
<dt class="optional">topic <span class="property-type">string</span></dt>
<dd> recognised topics are <code>up</code>, <code>down</code> and <code>set</code> or the name of the setting being tracked</dd>
</dl>
<h3>Outputs</h3>
<dl class="message-properties">
<dt>payload <span class="property-type">string</span></dt>
<dd>the new stored value, sent every time there is an update, and at deployment</dd>
<dt> topic <span class="property-type">string</span></dt>
<dd> the name of the setting</dd>
</dl>
<h3>Details</h3>
<p> The <code>setting</code> node acts as a variable which can have its value changed. If the incoming <code>msg.topic</code> is <code>set</code> or equal to the name of the setting, the incoming <code>msg.payload</code> is taken as the new value. </p>
<p>Also if a message has a property with the same name as the setting then its value will be used to update the setting. E.g. if the setting is <i>volume</i> then the setting will be set to the value of <code>msg.volume</code>.
<p> When the setting value is numeric then it can be varied with incoming with <code>msg.topic</code> as <code>up</code> or <code>down</code>.</p>
<p> The <code>Context</code> property controls if and how the setting is shared with other nodes in the flow or elsewhere. This can be used to control the key the music is playing in with values such as "G major". See the <code>Scale</code> setting of the <code>synth</code> node for a list of possible values.</p>
<p> The node is reset to its intitial configuration when an incoming <code>msg.payload</code> is <code>reset</code>.</p>
</script>