diff options
author | Christian Pointner <equinox@spreadspace.org> | 2014-11-18 02:12:53 (GMT) |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2014-11-18 02:12:53 (GMT) |
commit | b4c4f29d6622a51247a6050f2dbd1a75496a452d (patch) | |
tree | 627dc555d741e800d6f50e30502a546d9350412e /Midi_Interface | |
parent | cb56a6f7942ce28d284c5326b330b5f3b3f8a147 (diff) |
added refactored version for Midi Scripting
Diffstat (limited to 'Midi_Interface')
-rw-r--r-- | Midi_Interface/RHMixxx-scripts.js | 145 | ||||
-rw-r--r-- | Midi_Interface/RHMixxx.midi.xml | 171 |
2 files changed, 316 insertions, 0 deletions
diff --git a/Midi_Interface/RHMixxx-scripts.js b/Midi_Interface/RHMixxx-scripts.js new file mode 100644 index 0000000..1708151 --- /dev/null +++ b/Midi_Interface/RHMixxx-scripts.js @@ -0,0 +1,145 @@ +//*********************************************************** +//** Radio Helsinki RHMixxx control script ** +//** CopyLeft 2014, Josef Schauer / Christian Pointner ** +//*********************************************************** + +// *********** Actions *********** + +function RHMixxx() {} + +RHMixxx.num_decks = 2; +RHMixxx.num_sampler = 12; + +RHMixxx.groupNotes = { + "[Channel1]": { play: 0x01, stop: 0x00 }, + "[Channel2]": { play: 0x03, stop: 0x02 }, + "[Sampler1]": 0x04, + "[Sampler2]": 0x05, + "[Sampler3]": 0x06, + "[Sampler4]": 0x07, + "[Sampler5]": 0x08, + "[Sampler6]": 0x09, + "[Sampler7]": 0x0A, + "[Sampler8]": 0x0B, + "[Sampler9]": 0x0C, + "[Sampler10]": 0x0D, + "[Sampler11]": 0x0E, + "[Sampler12]": 0x0F +} + +RHMixxx.init = function (id, debug) { + if(debug) + print("RHMixxx initializing for controller '" + id + + "' (" + RHMixxx.num_decks + " Decks, " + RHMixxx.num_sampler + " Sampler)"); + + var i; + for (i = 1; i <= RHMixxx.num_decks; i++) + RHMixxx.initDeck(i, debug); + for (i = 1; i <= RHMixxx.num_sampler; i++) + RHMixxx.initSampler(i, debug); + + midi.sendShortMsg(0x80, 0x1F, 0x00); +} + +RHMixxx.shutdown = function () { +} + + +RHMixxx.initDeck = function (c, debug) { + var group = "[Channel" + c + "]"; + + engine.setValue(group, "volume", 0); + engine.connectControl(group, "play", "RHMixxx.DeckPlaying"); + engine.trigger(group, "play"); + engine.connectControl(group, "track_samples", "RHMixxx.DeckSamples"); + engine.trigger(group, "track_samples"); + + if(debug) + print("RHMixxx: " + group + " initilized!"); +} + +RHMixxx.initSampler = function (s, debug) { + var group = "[Sampler" + s + "]"; + + engine.setValue(group, "volume", 1.0); + engine.connectControl(group, "play", "RHMixxx.SamplerPlaying"); + engine.trigger(group, "play"); + engine.connectControl(group, "track_samples", "RHMixxx.SamplerSamples"); + engine.trigger(group, "track_samples"); + + if(debug) + print("RHMixxx: " + group + " initilized!"); +} + +// *********** Actions *********** + +RHMixxx.StopDeck = function (channel, control, value, status, group) { + engine.setValue(group, "start_stop", 1); + engine.setValue(group, "start_stop", 0); +} + +RHMixxx.ToggleSampler = function (channel, control, value, status, group) { + print("RHMixxx: ToggleSampler called for " + group); + + if(!engine.getValue(group, "play")) { + engine.setValue(group, "play", 1); + } + else { + engine.setValue(group, "start_stop", 1); + engine.setValue(group, "start_stop", 0); + } +} + + +// *********** Status updates *********** + +RHMixxx.DeckPlaying = function (value, group, control) { + if (!value) { + if(engine.getValue(group, "track_samples") != 0) { + midi.sendShortMsg(0x90, RHMixxx.groupNotes[group].stop, 0x00); + midi.sendShortMsg(0x90, RHMixxx.groupNotes[group].play, 0x00); + } else { + midi.sendShortMsg(0x80, RHMixxx.groupNotes[group].stop, 0x00); + midi.sendShortMsg(0x80, RHMixxx.groupNotes[group].play, 0x00); + } + } else { + midi.sendShortMsg(0x90, RHMixxx.groupNotes[group].stop, 0x00); + midi.sendShortMsg(0x90, RHMixxx.groupNotes[group].play, 0x10); + } +} + +RHMixxx.DeckSamples = function (value, group, control) { + if(!value) { + midi.sendShortMsg(0x80, RHMixxx.groupNotes[group].stop, 0x00); + midi.sendShortMsg(0x80, RHMixxx.groupNotes[group].play, 0x00); + } else { + if(engine.getValue(group, "play") == 0) { + midi.sendShortMsg(0x90, RHMixxx.groupNotes[group].stop, 0x00); + midi.sendShortMsg(0x90, RHMixxx.groupNotes[group].play, 0x00); + } + } +} + +RHMixxx.SamplerPlaying = function (value, group, control) { + if (!value) { + if(engine.getValue(group, "track_samples") != 0) { + midi.sendShortMsg(0x90, RHMixxx.groupNotes[group], 0x00); + engine.setValue(group, "start_stop", 1); + engine.setValue(group, "start_stop", 0); + } else { + midi.sendShortMsg(0x80, RHMixxx.groupNotes[group], 0x00); + } + } + else { + midi.sendShortMsg(0x90, RHMixxx.groupNotes[group], 0x10); + } +} + +RHMixxx.SamplerSamples = function (value, group, control) { + if(!value) { + midi.sendShortMsg(0x80, RHMixxx.groupNotes[group], 0x00); + } else { + if(engine.getValue(group, "play") == 0) + midi.sendShortMsg(0x90, RHMixxx.groupNotes[group], 0x00); + } +} diff --git a/Midi_Interface/RHMixxx.midi.xml b/Midi_Interface/RHMixxx.midi.xml new file mode 100644 index 0000000..c5cbc88 --- /dev/null +++ b/Midi_Interface/RHMixxx.midi.xml @@ -0,0 +1,171 @@ +<MixxxMIDIPreset mixxxVersion="1.10.1+" schemaVersion="1"> + <controller id="rhmixxx midi controller MIDI 1"> + <scriptfiles> + <file filename="RHMixxx-scripts.js" functionprefix="RHMixxx"/> + </scriptfiles> + <controls> + <!-- DECKS --> + <control> + <status>0x90</status> + <midino>0x00</midino> + <group>[Channel1]</group> + <key>RHMixxx.StopDeck</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x01</midino> + <group>[Channel1]</group> + <key>play</key> + <options> + <normal/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x02</midino> + <group>[Channel2]</group> + <key>RHMixxx.StopDeck</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x03</midino> + <group>[Channel2]</group> + <key>play</key> + <description></description> + <options> + <normal/> + </options> + </control> + <!-- SAMPLER --> + <control> + <status>0x90</status> + <midino>0x04</midino> + <group>[Sampler1]</group> + <key>RHMixxx.ToggleSampler</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x05</midino> + <group>[Sampler2]</group> + <key>RHMixxx.ToggleSampler</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x06</midino> + <group>[Sampler3]</group> + <key>RHMixxx.ToggleSampler</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x07</midino> + <group>[Sampler4]</group> + <key>RHMixxx.ToggleSampler</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x08</midino> + <group>[Sampler5]</group> + <key>RHMixxx.ToggleSampler</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x09</midino> + <group>[Sampler6]</group> + <key>RHMixxx.ToggleSampler</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x0a</midino> + <group>[Sampler7]</group> + <key>RHMixxx.ToggleSampler</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x0b</midino> + <group>[Sampler8]</group> + <key>RHMixxx.ToggleSampler</key> + <description></description> + <options>mixxx + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x0c</midino> + <group>[Sampler9]</group> + <key>RHMixxx.ToggleSampler</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x0d</midino> + <group>[Sampler10]</group> + <key>RHMixxx.ToggleSampler</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x0e</midino> + <group>[Sampler11]</group> + <key>RHMixxx.ToggleSampler</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + <control> + <status>0x90</status> + <midino>0x0f</midino> + <group>[Sampler12]</group> + <key>RHMixxx.ToggleSampler</key> + <description></description> + <options> + <Script-Binding/> + </options> + </control> + </controls> + <outputs/> + </controller> +</MixxxMIDIPreset> |