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
76 lines (57 loc) • 3.88 kB
HTML
<script type="text/javascript">
RED.nodes.registerType('divider',{
category: 'music',
color: '#a6bbcf',
defaults: {
name: {value: "bar"},
input: {value: "beat"},
output: {value: "bar"},
ratio: {value: 4}
},
inputs:1,
inputLabels: "tick",
outputs:1,
outputLabels: ["tick"],
icon: "divide.png",
label: function() {
return this.name||"divider";
}
});
</script>
<script type="text/x-red" data-template-name="divider">
<div class="form-row">
<label for="node-input-input"> Input event</label>
<input type="text" id="node-input-input" placeholder="e.g. beat">
</div>
<div class="form-row">
<label for="node-input-output"> Output event</label>
<input type="text" id="node-input-output" placeholder="e.g. bar">
</div>
<div class="form-row">
<label for="node-input-ratio"> Ratio of input events per output event (e.g. beats per bar)</label>
<input type="text" id="node-input-ratio" placeholder="e.g. 4">
</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>
</script>
<script type="text/x-red" data-help-name="divider">
<p>The divider takes the output of a beat generator and adds further information to the tick messages, dividing up the ticks into bars, phrases, sections or whatever structures you choose.</p>
<h3>Inputs</h3>
<p>A divider usually gets its input from a <code>beat</code> node or another <code>divider</code>.</p>
<p>A <code>msg.payload</code> input of <code>reset</code> will reset all counters to 0</p>
<p>All input messages that do not have a <code>msg.payload</code> of <code>tick</code> will be sent directly to the output without modification.</p>
<h3>Outputs</h3>
<p>By default the divider counts beats into bars of four beats, so that every four beats a new bar is started. For each input message with <code>msg.payload</code> as <code>tick</code>, the property <code>beat_of_bar</code> is added, which counts from 1 to 4 for subsequent ticks. The value <code>bar</code> is also added, which increments by one every four beats. At the beginning of each bar (when <code>beat_of_bar</code> is 1) the value <code>bar</code> is also added to the array <code>msg.start</code>. On the final beat of the bear, the value <code>bar</code> is added to the array <code>msg.end</code>.</p>
<h3>Configuration</h3>
<p>Divider nodes can also be used to add larger scale structure to the music, by appropriate configuration.</p>
<dl class='message-properties'>
<dt><span class='optional'>Input event</span> <span class='property-type'>string</span></dt>
<dd>controls which events are counted, by default this is <code>beat</code>.</dd>
<dt><span class='optional'>Output event</span> <span class='property-type'>string</span></dt>
<dd>is the event that is created, by default this is <code>bar</code>.</dd>
<dt><span class='optional'>Ratio</span> <span class='property-type'>number</span></dt>
<dd>controls the number of input events per output event, e.g. the number of beats in a bar, and defaults to 4. To count four beats in a bar and eight bars in a phrase you should have two divider nodes, the first one (beats to bars) should have its input connected to the output of a beat generator, and then send its output to the input of the second divider. The second divider should then be configured with the input event as <code>bar</code> and the output event as <code>phrase</code> and a ratio of 8. The tick messages coming from the second divider will then include properties for <code>beat</code>, <code>bar</code>, <code>phrase</code>, <code>beat_of_bar</code>, <code>bar_of_phrase</code>, <code>start</code> (an array) and <code>end</code> (another array).</dd>
</dl>
</script>