From b4c4f29d6622a51247a6050f2dbd1a75496a452d Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Tue, 18 Nov 2014 02:12:53 +0000 Subject: added refactored version for Midi Scripting 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 @@ + + + + + + + + + 0x90 + 0x00 + [Channel1] + RHMixxx.StopDeck + + + + + + + 0x90 + 0x01 + [Channel1] + play + + + + + + 0x90 + 0x02 + [Channel2] + RHMixxx.StopDeck + + + + + + + 0x90 + 0x03 + [Channel2] + play + + + + + + + + 0x90 + 0x04 + [Sampler1] + RHMixxx.ToggleSampler + + + + + + + 0x90 + 0x05 + [Sampler2] + RHMixxx.ToggleSampler + + + + + + + 0x90 + 0x06 + [Sampler3] + RHMixxx.ToggleSampler + + + + + + + 0x90 + 0x07 + [Sampler4] + RHMixxx.ToggleSampler + + + + + + + 0x90 + 0x08 + [Sampler5] + RHMixxx.ToggleSampler + + + + + + + 0x90 + 0x09 + [Sampler6] + RHMixxx.ToggleSampler + + + + + + + 0x90 + 0x0a + [Sampler7] + RHMixxx.ToggleSampler + + + + + + + 0x90 + 0x0b + [Sampler8] + RHMixxx.ToggleSampler + + mixxx + + + + + 0x90 + 0x0c + [Sampler9] + RHMixxx.ToggleSampler + + + + + + + 0x90 + 0x0d + [Sampler10] + RHMixxx.ToggleSampler + + + + + + + 0x90 + 0x0e + [Sampler11] + RHMixxx.ToggleSampler + + + + + + + 0x90 + 0x0f + [Sampler12] + RHMixxx.ToggleSampler + + + + + + + + + -- cgit v0.10.2