From f8d5fcbc09f82b9a85c7728e5db6991b4dd8af98 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 17 Sep 2021 20:57:40 +0200 Subject: [PATCH 01/23] add functions to fully control the file browser : open folder + : double-tap to close folder + : tap bpm of LEFT track + : tap bpm of RIGHT track : browse library up & down + : toggle focus between Playlist and File-Browser : load track + : open/close folder in file-browser --- res/controllers/Korg-KAOSS-DJ-scripts.js | 109 +++++++++++++++++++++-- 1 file changed, 103 insertions(+), 6 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index bc6bbea65cc..d6139b72d4e 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -1,5 +1,5 @@ // Korg KAOSS DJ controller mapping for Mixxx -// Seb Dooris, Fayaaz Ahmed, Lee Arromba +// Seb Dooris, Fayaaz Ahmed, Lee Arromba, Raphael Quast var KAOSSDJ = {}; var ON = 0x7F, @@ -27,6 +27,10 @@ var led = { 'loopStripR': 0x11, }; +// shift button state variables +var shift_left_pressed = false +var shift_right_pressed = false + // initialise decks KAOSSDJ.deck = function(deckNumber) { this.deckNumber = deckNumber; @@ -155,11 +159,6 @@ KAOSSDJ.scratchMode = function(channel, control, value, status, group) { } }; -KAOSSDJ.browseKnob = function(channel, control, value, status, group) { - var nval = (value > 0x40 ? value - 0x80 : value); - engine.setValue(group, "SelectTrackKnob", nval); -}; - KAOSSDJ.leftFxSwitch = function(channel, control, value, status, group) { var deck = KAOSSDJ.getDeckByChannel(channel); if(value === ON) { @@ -202,3 +201,101 @@ KAOSSDJ.controllerFxTouchUp = function(channel, control, value, status, group) { engine.setValue('[EffectRack1_EffectUnit'+deck.deckNumber +']', 'mix', 0); engine.setValue('[EffectRack1_EffectUnit'+deck.deckNumber +']', 'super1', 0); }; + +// : load track +// + : open/close folder in file-browser +KAOSSDJ.load_callback = function(channel, control, value, status, group) { + var deck = KAOSSDJ.getDeckByChannel(channel); + if(value === ON) { + if ((shift_left_pressed) || (shift_right_pressed)) { + if (deck.deckNumber == 1) { + engine.setValue("[Library]", "MoveLeft", true) + } else { + engine.setValue("[Library]", "MoveRight", true) + } + } else { + engine.setValue(deck.group, "LoadSelectedTrack", true) + } + } +}; + +KAOSSDJ.shift_left_callback = function(channel, control, value, status, group) { + if(value === ON) { + // if (shift_right_pressed == true) { + // TODO add functionality if is active while is pressed? + // } + shift_left_pressed = true + } else + shift_left_pressed = false +}; + +KAOSSDJ.shift_right_callback = function(channel, control, value, status, group) { + if(value === ON) { + // if (shift_left_pressed == true) { + // TODO add functionality if is active while is pressed? + // } + shift_right_pressed = true + } else + shift_right_pressed = false +}; + +KAOSSDJ.change_focus = function(channel, control, value, status, group) { + if(value === ON) { + // toggle focus between Playlist and File-Browser + engine.setValue("[Library]", "MoveFocusForward", true); + } +}; + +// : browse library up & down +// + : toggle focus between Playlist and File-Browser +KAOSSDJ.browseKnob = function(channel, control, value, status, group) { + var nval = (value > 0x40 ? value - 0x80 : value); + if (value > 0x40) { + if ((shift_left_pressed) || (shift_right_pressed)) { + engine.setValue("[Library]", "MoveFocusForward", true); + } else { + engine.setValue("[Library]", "MoveUp", true); + } + } else { + if ((shift_left_pressed) || (shift_right_pressed)) { + engine.setValue("[Library]", "MoveFocusBackward", true); + } else { + engine.setValue("[Library]", "MoveDown", true); + } + }; +}; + +// : open folder +// + : double-tap to close folder +// + : tap bpm of LEFT track +// + : tap bpm of RIGHT track +var double_tap_time; +KAOSSDJ.tap_button_callback = function(channel, control, value, status, group) { + var now = new Date().getTime(); + var timesince = now - double_tap_time; + + /* shift tab to move focus view */ + if ((value === ON) && ((shift_left_pressed))) { + // engine.setValue("[Library]", "MoveFocusForward", true); + engine.setValue("[Channel1]", "bpm_tap", true); + return + } + if ((value === ON) && ((shift_right_pressed))) { + // engine.setValue("[Library]", "MoveFocusForward", true); + engine.setValue("[Channel2]", "bpm_tap", true); + return + } + + /* tap to open folder, double-tap to close folder (twice to undo first tap)*/ + if (value === ON) { + if((timesince < 600) && (timesince > 0)){ + engine.setValue("[Library]", "MoveLeft", true); + engine.setValue("[Library]", "MoveLeft", true); + } else { + engine.setValue("[Library]", "MoveRight", true); + }; + + double_tap_time = new Date().getTime(); + }; +}; + From 57b66d8ae406dc56a75d2820a16f5e42aa842c06 Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 17 Sep 2021 21:00:55 +0200 Subject: [PATCH 02/23] add looping function --- res/controllers/Korg-KAOSS-DJ-scripts.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index d6139b72d4e..275f0730a96 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -202,6 +202,22 @@ KAOSSDJ.controllerFxTouchUp = function(channel, control, value, status, group) { engine.setValue('[EffectRack1_EffectUnit'+deck.deckNumber +']', 'super1', 0); }; +// use loop-button to deactivate an active loop or initialize a beatloop at the current playback position +KAOSSDJ.toggle_loop = function(channel, control, value, status, group) { + var deck = KAOSSDJ.getDeckByChannel(channel); + var loop_enabled = engine.getValue(deck.group, "loop_enabled"); + + if(value === ON) { + if(loop_enabled) { + engine.setValue(deck.group, "reloop_exit", true) + engine.setValue(deck.group, "beatloop_activate", false) + } else { + engine.setValue(deck.group, "beatloop_activate", true) + } + } +}; + + // : load track // + : open/close folder in file-browser KAOSSDJ.load_callback = function(channel, control, value, status, group) { From 68f5e66a182997c1d4b05177bdb43606c9b15c63 Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 18 Sep 2021 20:42:45 +0200 Subject: [PATCH 03/23] add functions to control QuickEffectRack super knobs + : control super knob of QuickEffectRack for deck 1 + : control super knob of QuickEffectRack for deck 2 --- res/controllers/Korg-KAOSS-DJ-scripts.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 275f0730a96..9ce63d09031 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -315,3 +315,21 @@ KAOSSDJ.tap_button_callback = function(channel, control, value, status, group) { }; }; +// + : control super knob of QuickEffectRack for deck 1 +KAOSSDJ.controllerFxTouchMoveVertical_shift = function(channel, control, value, status, group) { + var deck = KAOSSDJ.decks[0]; + if (deck.fx) { + var val = script.absoluteLin(value, 0, 1, 0, 127) + engine.setValue('[QuickEffectRack1_' + deck.group + ']', 'super1', val); + } +}; + +// + : control super knob of QuickEffectRack for deck 2 +KAOSSDJ.controllerFxTouchMoveHorizontal_shift = function(channel, control, value, status, group) { + var deck = KAOSSDJ.decks[1]; + if (deck.fx) { + var val = script.absoluteLin(value, 0, 1, 0, 127) + engine.setValue('[QuickEffectRack1_' + deck.group + ']', 'super1', val); + } +}; + From bd3492a9022c3748174280a2dd070f208ff856fe Mon Sep 17 00:00:00 2001 From: Raphael Date: Sat, 18 Sep 2021 20:54:08 +0200 Subject: [PATCH 04/23] update controller-assignments .xml file --- res/controllers/Korg-KAOSS-DJ.midi.xml | 806 +++++++++++++------------ 1 file changed, 436 insertions(+), 370 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ.midi.xml b/res/controllers/Korg-KAOSS-DJ.midi.xml index ad6f66a97a5..7546a81ccc4 100644 --- a/res/controllers/Korg-KAOSS-DJ.midi.xml +++ b/res/controllers/Korg-KAOSS-DJ.midi.xml @@ -1,105 +1,103 @@ - + Korg KAOSS DJ - Seb Dooris, Fayaaz Ahmed, Lee Arromba + Seb Dooris, Fayaaz Ahmed, Lee Arromba, Raphael Quast Controller mapping for the Korg KAOSS DJ Controller. https://www.mixxx.org/forums/viewtopic.php?f=7&t=8479 - korg_kaoss_dj - + [Channel1] - sync_enabled - Left Sync - 0x97 - 0x1D + KAOSSDJ.change_focus + Change focus between library and playlist + 0x96 + 0x07 - + [Channel1] - KAOSSDJ.wheelTurn - Left Jog Wheel Turn Scratch - 0xB7 - 0x10 + KAOSSDJ.tap_button_callback + 0x96 + 0x0B - [Channel2] - play - Right Play - 0x98 - 0x1B + [Channel1] + KAOSSDJ.controllerFxTouchMoveHorizontal + Fx Control + 0xB8 + 0x0C - + [Channel1] - play - Left Play - 0x97 - 0x1B + KAOSSDJ.controllerFxTouchMoveVertical + Fx Control + 0xB8 + 0x0D - + - [Playlist] - KAOSSDJ.browseKnob - Library Browse - 0xB6 - 0x1E + [Channel1] + KAOSSDJ.load_callback + Load into Deck 1 + 0x97 + 0x0E [Channel2] - LoadSelectedTrack + KAOSSDJ.load_callback Load into Deck 2 0x98 0x0E - + - [Channel2] - KAOSSDJ.rightFxSwitch - Right Fx switch - 0x98 - 0x18 + [Channel1] + KAOSSDJ.wheelTurn + Left Jog Wheel Turn + 0xB7 + 0x0E - [Channel1] - LoadSelectedTrack - Load into Deck 1 - 0x97 + [Channel2] + KAOSSDJ.wheelTurn + Right Jog Wheel Turn + 0xB8 0x0E - + [Channel1] - KAOSSDJ.leftFxSwitch - Left Fx switch + loop_halve + MIDI Learned from 2 messages. 0x97 - 0x18 + 0x0F - + @@ -112,182 +110,250 @@ + + [Channel1] + KAOSSDJ.wheelTurnShift + Left Jog Wheel Turn Shift + 0xB7 + 0x0F + + + + [Channel2] - pfl - Right Headphones Button - 0x98 - 0x19 + KAOSSDJ.wheelTurnShift + Right Jog Wheel Turn Shift + 0xB8 + 0x0F - + [Channel1] - loop_halve + KAOSSDJ.toggle_loop MIDI Learned from 2 messages. 0x97 - 0x0F + 0x10 - + - [EqualizerRack1_[Channel2]_Effect1] - parameter2 - Right Equaliser Mid + [Channel1] + KAOSSDJ.wheelTurn + Left Jog Wheel Turn Scratch + 0x97 + 0x10 + + + + + + [Channel2] + KAOSSDJ.toggle_loop + MIDI Learned from 2 messages. + 0x98 + 0x10 + + + + + + [Channel2] + KAOSSDJ.wheelTurn + Right Jog Wheel Turn SCRATCH 0xB8 - 0x1C + 0x10 - + [Channel1] - pfl - Left Headphones Button + loop_double + MIDI Learned from 4 messages. 0x97 - 0x19 + 0x11 - [EqualizerRack1_[Channel1]_Effect1] - parameter2 - Left Equaliser Mid - 0xB7 - 0x1C + [Channel2] + loop_double + MIDI Learned from 8 messages. + 0x98 + 0x11 - [EqualizerRack1_[Channel2]_Effect1] - parameter1 - Right Equaliser Low - 0xB8 - 0x1D + [Channel1] + KAOSSDJ.controllerFxTouchMoveVertical_shift + 0xB6 + 0x11 - + - [EqualizerRack1_[Channel1]_Effect1] - parameter1 - Left Equaliser Low - 0xB7 - 0x1D + [Channel1] + hotcue_1_activate + Left HotCue 1 + 0x97 + 0x12 [Channel2] - pregain - Right Gain - 0xB8 - 0x1A + hotcue_1_activate + Right HotCue 1 + 0x98 + 0x12 - [Channel2] - pregain - Right Gain - 0xB8 - 0x1A + [Channel1] + KAOSSDJ.controllerFxTouchMoveHorizontal_shift + 0xB6 + 0x12 + + + + + + [Channel1] + hotcue_2_activate + Left HotCue 2 + 0x97 + 0x13 - [Sampler3] - cue_gotoandplay - Sampler 3 Play - 0x96 - 0x4C + [Channel2] + hotcue_2_activate + Right HotCue 2 + 0x98 + 0x13 [Channel1] - pregain - Left Gain - 0xB7 - 0x1A + hotcue_3_activate + Left HotCue 3 + 0x97 + 0x14 - [EqualizerRack1_[Channel2]_Effect1] - parameter3 - Right Equaliser High - 0xB8 - 0x1B + [Channel2] + hotcue_3_activate + Right HotCue 3 + 0x98 + 0x14 - [Sampler4] - cue_gotoandplay - Sampler 4 Play - 0x96 - 0x4D + [Channel1] + rate_temp_down + Nudge (pitch -) + 0x97 + 0x15 - [EqualizerRack1_[Channel1]_Effect1] - parameter3 - Left Equaliser High - 0xB7 - 0x1B + [Channel2] + rate_temp_down + Nudge (pitch-) + 0x98 + 0x15 + + [Channel1] + KAOSSDJ.scratchMode + Scratch mode button + 0x97 + 0x16 + + + + [Channel2] - KAOSSDJ.wheelTurn - Right Jog Wheel Turn - 0xB8 - 0x0E + KAOSSDJ.scratchMode + Scratch mode button + 0x98 + 0x16 + + + + + + [Channel1] + rate_temp_up + Nudge (pitch +) + 0x97 + 0x17 - + [Channel2] - volume - MIDI Learned from 238 messages. - 0xB8 - 0x18 + rate_temp_up + Nudge (pitch+) + 0x98 + 0x17 - [Sampler1] - cue_gotoandplay - Sampler 1 Play - 0x96 - 0x4A + [Master] + crossfader + X-Fader + 0xB6 + 0x17 [Channel1] - KAOSSDJ.wheelTurn - Left Jog Wheel Turn - 0xB7 - 0x0E + KAOSSDJ.leftFxSwitch + Left Fx switch + 0x97 + 0x18 + + + + + + [Channel2] + KAOSSDJ.rightFxSwitch + Right Fx switch + 0x98 + 0x18 @@ -304,44 +370,34 @@ [Channel2] - KAOSSDJ.wheelTurnShift - Right Jog Wheel Turn Shift + volume + MIDI Learned from 238 messages. 0xB8 - 0x0F + 0x18 - + - [Channel2] - rate - Right Pitch Bend - 0xB8 + [Channel1] + pfl + Left Headphones Button + 0x97 0x19 - [Sampler2] - cue_gotoandplay - Sampler 2 Play - 0x96 - 0x4B + [Channel2] + pfl + Right Headphones Button + 0x98 + 0x19 - - [Channel1] - KAOSSDJ.wheelTurnShift - Left Jog Wheel Turn Shift - 0xB7 - 0x0F - - - - [Channel1] rate @@ -354,269 +410,249 @@ [Channel2] - KAOSSDJ.scratchMode - Scratch mode button - 0x98 - 0x16 - - - - - - [Channel1] - KAOSSDJ.controllerFxTouchMoveVertical - Fx Control - 0xB8 - 0x0D - - - - - - [Channel1] - KAOSSDJ.controllerFxTouchMoveHorizontal - Fx Control + rate + Right Pitch Bend 0xB8 - 0x0C + 0x19 - + [Channel1] - KAOSSDJ.controllerFxTouchUp - Fx Control + KAOSSDJ.shift_left_callback + Right shift button 0x97 - 0x20 + 0x1A [Channel2] - KAOSSDJ.controllerFxTouchUp - Fx Control + KAOSSDJ.shift_right_callback + Left shift button 0x98 - 0x20 + 0x1A [Channel1] - KAOSSDJ.scratchMode - Scratch mode button - 0x97 - 0x16 - - - - - - [Channel2] - rate_temp_up - Nudge (pitch+) - 0x98 - 0x17 + pregain + Left Gain + 0xB7 + 0x1A - [Channel1] - rate_temp_up - Nudge (pitch +) - 0x97 - 0x17 + [Channel2] + pregain + Right Gain + 0xB8 + 0x1A [Channel2] - hotcue_3_activate - Right HotCue 3 - 0x98 - 0x14 + pregain + Right Gain + 0xB8 + 0x1A [Channel1] - hotcue_3_activate - Left HotCue 3 + play + Left Play 0x97 - 0x14 + 0x1B [Channel2] - rate_temp_down - Nudge (pitch-) + play + Right Play 0x98 - 0x15 + 0x1B - [Channel1] - rate_temp_down - Nudge (pitch -) - 0x97 - 0x15 + [EqualizerRack1_[Channel1]_Effect1] + parameter3 + Left Equaliser High + 0xB7 + 0x1B - [Channel2] - hotcue_1_activate - Right HotCue 1 - 0x98 - 0x12 + [EqualizerRack1_[Channel2]_Effect1] + parameter3 + Right Equaliser High + 0xB8 + 0x1B - [Channel1] - hotcue_1_activate - Left HotCue 1 - 0x97 - 0x12 + [EqualizerRack1_[Channel1]_Effect1] + parameter2 + Left Equaliser Mid + 0xB7 + 0x1C - [Channel2] - hotcue_2_activate - Right HotCue 2 - 0x98 - 0x13 + [EqualizerRack1_[Channel2]_Effect1] + parameter2 + Right Equaliser Mid + 0xB8 + 0x1C [Channel1] - hotcue_2_activate - Left HotCue 2 + sync_enabled + Left Sync 0x97 - 0x13 + 0x1D [Channel2] - hotcue_2_clear - Right HotCue 2 clear + sync_enabled + Right Sync 0x98 - 0x2C + 0x1D - [Channel2] - reloop_exit - MIDI Learned from 2 messages. - 0x98 - 0x10 + [EqualizerRack1_[Channel1]_Effect1] + parameter1 + Left Equaliser Low + 0xB7 + 0x1D - [Channel1] - hotcue_2_clear - Left HotCue 2 clear - 0x97 - 0x2C + [EqualizerRack1_[Channel2]_Effect1] + parameter1 + Right Equaliser Low + 0xB8 + 0x1D [Channel1] - reloop_exit - MIDI Learned from 2 messages. + cue_default + Left CUE 0x97 - 0x10 + 0x1E [Channel2] - hotcue_3_clear - Right HotCue 3 clear + cue_default + Right CUE 0x98 - 0x2D + 0x1E - [Master] - crossfader - X-Fader + [Playlist] + KAOSSDJ.browseKnob + Library Browse 0xB6 - 0x17 + 0x1E + + + + + + [Channel1] + KAOSSDJ.wheelTouch + Left Jog Wheel Touch + 0x97 + 0x1F - + [Channel2] - loop_double - MIDI Learned from 8 messages. + KAOSSDJ.wheelTouch + Right Jog Wheel Touch 0x98 - 0x11 + 0x1F - + [Channel1] - hotcue_3_clear - Left HotCue 3 clear - 0x97 - 0x2D + KAOSSDJ.MoveFocus + fx knob + 0xB6 + 0x1F [Channel1] - loop_double - MIDI Learned from 4 messages. + KAOSSDJ.controllerFxTouchUp + Fx Control 0x97 - 0x11 + 0x20 - + [Channel2] - loop_out - Right Loop out + KAOSSDJ.controllerFxTouchUp + Fx Control 0x98 - 0x2A + 0x20 - + - [Channel2] + [Channel1] playposition Track Seek - 0xB8 + 0xB7 0x21 @@ -624,62 +660,72 @@ [Channel2] - cue_default - Right CUE - 0x98 - 0x1E + playposition + Track Seek + 0xB8 + 0x21 [Channel1] - loop_out - Left Loop out + loop_in + Left Loop in 0x97 - 0x2A + 0x28 - [Channel1] - playposition - Track Seek - 0xB7 - 0x21 + [Channel2] + loop_in + Right Loop in + 0x98 + 0x28 [Channel1] - cue_default - Left CUE + reloop_toggle + MIDI Learned from 2 messages. 0x97 - 0x1E + 0x29 [Channel2] - hotcue_1_clear - Right HotCue 1 clear + reloop_toggle + MIDI Learned from 4 messages. 0x98 - 0x2B + 0x29 + + + + + + [Channel1] + loop_out + Left Loop out + 0x97 + 0x2A [Channel2] - KAOSSDJ.wheelTouch - Right Jog Wheel Touch + loop_out + Right Loop out 0x98 - 0x1F + 0x2A - + @@ -692,218 +738,238 @@ + + [Channel2] + hotcue_1_clear + Right HotCue 1 clear + 0x98 + 0x2B + + + + [Channel1] - KAOSSDJ.wheelTouch - Left Jog Wheel Touch + hotcue_2_clear + Left HotCue 2 clear 0x97 - 0x1F + 0x2C - + [Channel2] - loop_in - Right Loop in + hotcue_2_clear + Right HotCue 2 clear 0x98 - 0x28 + 0x2C [Channel1] - loop_in - Left Loop in + hotcue_3_clear + Left HotCue 3 clear 0x97 - 0x28 + 0x2D [Channel2] - beatloop_activate - MIDI Learned from 4 messages. + hotcue_3_clear + Right HotCue 3 clear 0x98 - 0x29 + 0x2D - [Channel2] - sync_enabled - Right Sync - 0x98 - 0x1D + [Sampler1] + cue_gotoandplay + Sampler 1 Play + 0x96 + 0x4A - [Channel1] - beatloop_activate - MIDI Learned from 2 messages. - 0x97 - 0x29 + [Sampler2] + cue_gotoandplay + Sampler 2 Play + 0x96 + 0x4B - [Channel2] - KAOSSDJ.wheelTurn - Right Jog Wheel Turn SCRATCH - 0xB8 - 0x10 + [Sampler3] + cue_gotoandplay + Sampler 3 Play + 0x96 + 0x4C - + + + + + [Sampler4] + cue_gotoandplay + Sampler 4 Play + 0x96 + 0x4D + + [Channel1] - loop_enabled + cue_indicator 0x97 - 0x10 + 0x1E 0x00 0x7F 0 - [Channel2] - hotcue_3_enabled - 0x98 - 0x14 + [Channel1] + hotcue_1_enabled + 0x97 + 0x12 0x00 0x7F 0 [Channel1] - play_indicator + hotcue_2_enabled 0x97 - 0x1B + 0x13 0x00 0x7F 0 - [Channel2] - sync_enabled - 0x98 - 0x1D + [Channel1] + hotcue_3_enabled + 0x97 + 0x14 0x00 0x7F 0 [Channel1] - sync_enabled + loop_enabled 0x97 - 0x1D + 0x10 0x00 0x7F 0 - [Channel2] - loop_enabled - 0x98 - 0x10 + [Channel1] + pfl + 0x97 + 0x19 0x00 0x7F 0 [Channel1] - cue_indicator + play_indicator 0x97 - 0x1E + 0x1B 0x00 0x7F 0 [Channel1] - pfl + sync_enabled 0x97 - 0x19 + 0x1D 0x00 0x7F 0 [Channel2] - pfl + cue_indicator 0x98 - 0x19 + 0x1E 0x00 0x7F 0 - [Channel1] - hotcue_3_enabled - 0x97 - 0x14 + [Channel2] + hotcue_1_enabled + 0x98 + 0x12 0x00 0x7F 0 [Channel2] - play_indicator + hotcue_2_enabled 0x98 - 0x1B + 0x13 0x00 0x7F 0 - [Channel1] - hotcue_1_enabled - 0x97 - 0x12 + [Channel2] + hotcue_3_enabled + 0x98 + 0x14 0x00 0x7F 0 [Channel2] - hotcue_1_enabled + loop_enabled 0x98 - 0x12 + 0x10 0x00 0x7F 0 [Channel2] - hotcue_2_enabled + pfl 0x98 - 0x13 + 0x19 0x00 0x7F 0 - [Channel1] - hotcue_2_enabled - 0x97 - 0x13 + [Channel2] + play_indicator + 0x98 + 0x1B 0x00 0x7F 0 [Channel2] - cue_indicator + sync_enabled 0x98 - 0x1E + 0x1D 0x00 0x7F 0 From 431fd7e4162218b4fdb809f0566c9166476beccc Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Sun, 4 Jun 2023 16:03:21 +0200 Subject: [PATCH 05/23] korg-kaoss-dj: Fix Fx knob binding --- res/controllers/Korg-KAOSS-DJ-scripts.js | 4 ++++ res/controllers/Korg-KAOSS-DJ.midi.xml | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 9ce63d09031..21158930e91 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -176,6 +176,10 @@ KAOSSDJ.rightFxSwitch = function(channel, control, value, status, group) { } }; +KAOSSDJ.fxKnob = function(_channel, _control, _value, _status) { + // TODO +}; + KAOSSDJ.controllerFxTouchMoveVertical = function(channel, control, value, status, group) { var decks = KAOSSDJ.decks; for(key in decks) { diff --git a/res/controllers/Korg-KAOSS-DJ.midi.xml b/res/controllers/Korg-KAOSS-DJ.midi.xml index 7546a81ccc4..e39c5cfeaf1 100644 --- a/res/controllers/Korg-KAOSS-DJ.midi.xml +++ b/res/controllers/Korg-KAOSS-DJ.midi.xml @@ -620,8 +620,8 @@ [Channel1] - KAOSSDJ.MoveFocus - fx knob + KAOSSDJ.fxKnob + Fx Knob 0xB6 0x1F From 71e6d1cd9638cb6dd598b2afb1b37c202989d1a5 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Sun, 4 Jun 2023 15:34:57 +0200 Subject: [PATCH 06/23] korg-kaoss-dj: Reformat code and fix eslint issues --- res/controllers/Korg-KAOSS-DJ-scripts.js | 279 +++++++++++------------ res/controllers/Korg-KAOSS-DJ.midi.xml | 20 +- 2 files changed, 147 insertions(+), 152 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 21158930e91..25f5b03dda4 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -7,29 +7,29 @@ var ON = 0x7F, UP = 0x01, DOWN = 0x7F; var ledChannel = { - 'btnsL': 0x97, - 'btnsR': 0x98, - 'knobsL': 0xB7, - 'knobsR': 0xB8, - 'master': 0xB6 + "btnsL": 0x97, + "btnsR": 0x98, + "knobsL": 0xB7, + "knobsR": 0xB8, + "master": 0xB6 }; var led = { - 'cue': 0x1E, - 'sync': 0x1D, - 'play': 0x1B, - 'headphones': 0x19, - 'fx': 0x18, // warning: led is owned by controller - 'stripL': 0x15, - 'stripM': 0x16, - 'stripR': 0x17, - 'loopStripL': 0x0F, - 'loopStripM': 0x10, - 'loopStripR': 0x11, + "cue": 0x1E, + "sync": 0x1D, + "play": 0x1B, + "headphones": 0x19, + "fx": 0x18, // warning: led is owned by controller + "stripL": 0x15, + "stripM": 0x16, + "stripR": 0x17, + "loopStripL": 0x0F, + "loopStripM": 0x10, + "loopStripR": 0x11, }; // shift button state variables -var shift_left_pressed = false -var shift_right_pressed = false +var shiftLeftPressed = false; +var shiftRightPressed = false; // initialise decks KAOSSDJ.deck = function(deckNumber) { @@ -46,13 +46,13 @@ for (var i = 0; i < 4; i++) { // TODO: currently only 2 decks supported. is 4 po // ==== lifecycle ==== -KAOSSDJ.init = function(id, debugging) { +KAOSSDJ.init = function(_id, _debugging) { // turn on main led channels var ledChannels = [ - ledChannel['knobsL'], - ledChannel['knobsR'], - ledChannel['master'] - ] + ledChannel.knobsL, + ledChannel.knobsR, + ledChannel.master + ]; for (var led = 0x00; led <= 0xFF; led++) { for (var i = 0; i < ledChannels.length; i++) { midi.sendShortMsg(ledChannels[i], led, ON); @@ -65,10 +65,10 @@ KAOSSDJ.init = function(id, debugging) { midi.sendSysexMsg(ControllerStatusSysex, ControllerStatusSysex.length); }; -KAOSSDJ.shutdown = function(id, debugging) { +KAOSSDJ.shutdown = function(_id, _debugging) { // turn off all LEDs for (var led = 0x00; led <= 0xFF; led++) { - for (key in ledChannel) { + for (var key in ledChannel) { midi.sendShortMsg(ledChannel[key], led, OFF); } } @@ -77,7 +77,7 @@ KAOSSDJ.shutdown = function(id, debugging) { // ==== helper ==== KAOSSDJ.getDeckIndexFromChannel = function(channel) { - return channel - 7 + return channel - 7; }; KAOSSDJ.getDeckByChannel = function(channel) { @@ -97,10 +97,10 @@ KAOSSDJ.wheelTouch = function(channel, control, value, status, group) { var beta = alpha / 32; var deck = KAOSSDJ.getDeckByChannel(channel); var deckNumber = deck.deckNumber; - var deck_playing = engine.getValue('[Channel' + deckNumber + ']', 'play_indicator'); + var deckPlaying = engine.getValue("[Channel" + deckNumber + "]", "play_indicator"); // If in scratch mode or not playing enable vinyl-like control - if (deck.jogWheelsInScratchMode || !deck_playing ) { + if (deck.jogWheelsInScratchMode || !deckPlaying) { if (value === ON) { // Enable scratching on touch engine.scratchEnable(deckNumber, 128, 33 + 1 / 3, alpha, beta); @@ -123,7 +123,7 @@ KAOSSDJ.wheelTurn = function(channel, control, value, status, group) { if (engine.isScratching(deckNumber)) { engine.scratchTick(deckNumber, newValue); } else { - engine.setValue('[Channel' + deckNumber + ']', 'jog', newValue); // Pitch bend + engine.setValue("[Channel" + deckNumber + "]", "jog", newValue); // Pitch bend } }; @@ -141,10 +141,10 @@ KAOSSDJ.wheelTurnShift = function(channel, control, value, status, group) { engine.scratchTick(deck.deckNumber, newValue); } else { // Move beatgrid - if(value === UP){ - engine.setValue(deck.group, 'beats_translate_later', true); - } else if (value === DOWN){ - engine.setValue(deck.group, 'beats_translate_earlier', true); + if (value === UP) { + engine.setValue(deck.group, "beats_translate_later", true); + } else if (value === DOWN) { + engine.setValue(deck.group, "beats_translate_earlier", true); } } }; @@ -152,27 +152,26 @@ KAOSSDJ.wheelTurnShift = function(channel, control, value, status, group) { KAOSSDJ.scratchMode = function(channel, control, value, status, group) { if (value === ON) { // Turn scratch mode on jogwheel (LED is red) - KAOSSDJ.updateDeckByChannel(channel, 'jogWheelsInScratchMode', true); + KAOSSDJ.updateDeckByChannel(channel, "jogWheelsInScratchMode", true); } else if (value === OFF) { // Turn scratch mode on jogwheel (LED is off) - KAOSSDJ.updateDeckByChannel(channel, 'jogWheelsInScratchMode', false); + KAOSSDJ.updateDeckByChannel(channel, "jogWheelsInScratchMode", false); } }; KAOSSDJ.leftFxSwitch = function(channel, control, value, status, group) { - var deck = KAOSSDJ.getDeckByChannel(channel); - if(value === ON) { - KAOSSDJ.updateDeckByChannel(channel, 'fx', true); + if (value === ON) { + KAOSSDJ.updateDeckByChannel(channel, "fx", true); } else { - KAOSSDJ.updateDeckByChannel(channel, 'fx', false); + KAOSSDJ.updateDeckByChannel(channel, "fx", false); } }; KAOSSDJ.rightFxSwitch = function(channel, control, value, status, group) { - if(value === ON) { - KAOSSDJ.updateDeckByChannel(channel, 'fx', true); + if (value === ON) { + KAOSSDJ.updateDeckByChannel(channel, "fx", true); } else { - KAOSSDJ.updateDeckByChannel(channel, 'fx', false); + KAOSSDJ.updateDeckByChannel(channel, "fx", false); } }; @@ -182,158 +181,154 @@ KAOSSDJ.fxKnob = function(_channel, _control, _value, _status) { KAOSSDJ.controllerFxTouchMoveVertical = function(channel, control, value, status, group) { var decks = KAOSSDJ.decks; - for(key in decks) { + for (var key in decks) { var deck = decks[key]; - if(deck.fx) { - engine.setValue('[EffectRack1_EffectUnit'+deck.deckNumber +']', 'mix', value / 127); + if (deck.fx) { + engine.setValue("[EffectRack1_EffectUnit"+deck.deckNumber +"]", "mix", value / 127); } } }; KAOSSDJ.controllerFxTouchMoveHorizontal = function(channel, control, value, status, group) { var decks = KAOSSDJ.decks; - for(key in decks) { + for (var key in decks) { var deck = decks[key]; - if(deck.fx) { - engine.setValue('[EffectRack1_EffectUnit'+deck.deckNumber +']', 'super1', value / 127); + if (deck.fx) { + engine.setValue("[EffectRack1_EffectUnit"+deck.deckNumber +"]", "super1", value / 127); } } }; KAOSSDJ.controllerFxTouchUp = function(channel, control, value, status, group) { var deck = KAOSSDJ.getDeckByChannel(channel); - engine.setValue('[EffectRack1_EffectUnit'+deck.deckNumber +']', 'mix', 0); - engine.setValue('[EffectRack1_EffectUnit'+deck.deckNumber +']', 'super1', 0); + engine.setValue("[EffectRack1_EffectUnit"+deck.deckNumber +"]", "mix", 0); + engine.setValue("[EffectRack1_EffectUnit"+deck.deckNumber +"]", "super1", 0); }; // use loop-button to deactivate an active loop or initialize a beatloop at the current playback position -KAOSSDJ.toggle_loop = function(channel, control, value, status, group) { - var deck = KAOSSDJ.getDeckByChannel(channel); - var loop_enabled = engine.getValue(deck.group, "loop_enabled"); - - if(value === ON) { - if(loop_enabled) { - engine.setValue(deck.group, "reloop_exit", true) - engine.setValue(deck.group, "beatloop_activate", false) - } else { - engine.setValue(deck.group, "beatloop_activate", true) - } - } +KAOSSDJ.toggleLoop = function(channel, control, value, status, group) { + var deck = KAOSSDJ.getDeckByChannel(channel); + var loopEnabled = engine.getValue(deck.group, "loop_enabled"); + + if (value === ON) { + if (loopEnabled) { + engine.setValue(deck.group, "reloop_exit", true); + engine.setValue(deck.group, "beatloop_activate", false); + } else { + engine.setValue(deck.group, "beatloop_activate", true); + } + } }; // : load track // + : open/close folder in file-browser -KAOSSDJ.load_callback = function(channel, control, value, status, group) { - var deck = KAOSSDJ.getDeckByChannel(channel); - if(value === ON) { - if ((shift_left_pressed) || (shift_right_pressed)) { - if (deck.deckNumber == 1) { - engine.setValue("[Library]", "MoveLeft", true) - } else { - engine.setValue("[Library]", "MoveRight", true) - } - } else { - engine.setValue(deck.group, "LoadSelectedTrack", true) - } - } +KAOSSDJ.loadCallback = function(channel, control, value, status, group) { + var deck = KAOSSDJ.getDeckByChannel(channel); + if (value === ON) { + if ((shiftLeftPressed) || (shiftRightPressed)) { + if (deck.deckNumber === 1) { + engine.setValue("[Library]", "MoveLeft", true); + } else { + engine.setValue("[Library]", "MoveRight", true); + } + } else { + engine.setValue(deck.group, "LoadSelectedTrack", true); + } + } }; -KAOSSDJ.shift_left_callback = function(channel, control, value, status, group) { - if(value === ON) { - // if (shift_right_pressed == true) { - // TODO add functionality if is active while is pressed? - // } - shift_left_pressed = true - } else - shift_left_pressed = false +KAOSSDJ.shiftLeftCallback = function(channel, control, value, status, group) { + if (value === ON) { + // if (shiftRightPressed == true) { + // TODO add functionality if is active while is pressed? + // } + shiftLeftPressed = true; + } else { shiftLeftPressed = false; } }; -KAOSSDJ.shift_right_callback = function(channel, control, value, status, group) { - if(value === ON) { - // if (shift_left_pressed == true) { - // TODO add functionality if is active while is pressed? - // } - shift_right_pressed = true - } else - shift_right_pressed = false +KAOSSDJ.shiftRightCallback = function(channel, control, value, status, group) { + if (value === ON) { + // if (shiftLeftPressed == true) { + // TODO add functionality if is active while is pressed? + // } + shiftRightPressed = true; + } else { shiftRightPressed = false; } }; -KAOSSDJ.change_focus = function(channel, control, value, status, group) { - if(value === ON) { +KAOSSDJ.changeFocus = function(channel, control, value, status, group) { + if (value === ON) { // toggle focus between Playlist and File-Browser engine.setValue("[Library]", "MoveFocusForward", true); - } + } }; // : browse library up & down // + : toggle focus between Playlist and File-Browser KAOSSDJ.browseKnob = function(channel, control, value, status, group) { - var nval = (value > 0x40 ? value - 0x80 : value); - if (value > 0x40) { - if ((shift_left_pressed) || (shift_right_pressed)) { - engine.setValue("[Library]", "MoveFocusForward", true); - } else { - engine.setValue("[Library]", "MoveUp", true); - } - } else { - if ((shift_left_pressed) || (shift_right_pressed)) { - engine.setValue("[Library]", "MoveFocusBackward", true); - } else { - engine.setValue("[Library]", "MoveDown", true); - } - }; + if (value > 0x40) { + if ((shiftLeftPressed) || (shiftRightPressed)) { + engine.setValue("[Library]", "MoveFocusForward", true); + } else { + engine.setValue("[Library]", "MoveUp", true); + } + } else { + if ((shiftLeftPressed) || (shiftRightPressed)) { + engine.setValue("[Library]", "MoveFocusBackward", true); + } else { + engine.setValue("[Library]", "MoveDown", true); + } + } }; // : open folder // + : double-tap to close folder // + : tap bpm of LEFT track // + : tap bpm of RIGHT track -var double_tap_time; -KAOSSDJ.tap_button_callback = function(channel, control, value, status, group) { +var doubleTapTime; +KAOSSDJ.tapButtonCallback = function(channel, control, value, status, group) { var now = new Date().getTime(); - var timesince = now - double_tap_time; - - /* shift tab to move focus view */ - if ((value === ON) && ((shift_left_pressed))) { - // engine.setValue("[Library]", "MoveFocusForward", true); - engine.setValue("[Channel1]", "bpm_tap", true); - return - } - if ((value === ON) && ((shift_right_pressed))) { - // engine.setValue("[Library]", "MoveFocusForward", true); - engine.setValue("[Channel2]", "bpm_tap", true); - return - } - - /* tap to open folder, double-tap to close folder (twice to undo first tap)*/ - if (value === ON) { - if((timesince < 600) && (timesince > 0)){ - engine.setValue("[Library]", "MoveLeft", true); - engine.setValue("[Library]", "MoveLeft", true); - } else { - engine.setValue("[Library]", "MoveRight", true); - }; - - double_tap_time = new Date().getTime(); - }; + var timesince = now - doubleTapTime; + + /* shift tab to move focus view */ + if ((value === ON) && ((shiftLeftPressed))) { + // engine.setValue("[Library]", "MoveFocusForward", true); + engine.setValue("[Channel1]", "bpm_tap", true); + return; + } + if ((value === ON) && ((shiftRightPressed))) { + // engine.setValue("[Library]", "MoveFocusForward", true); + engine.setValue("[Channel2]", "bpm_tap", true); + return; + } + + /* tap to open folder, double-tap to close folder (twice to undo first tap)*/ + if (value === ON) { + if ((timesince < 600) && (timesince > 0)) { + engine.setValue("[Library]", "MoveLeft", true); + engine.setValue("[Library]", "MoveLeft", true); + } else { + engine.setValue("[Library]", "MoveRight", true); + } + + doubleTapTime = new Date().getTime(); + } }; // + : control super knob of QuickEffectRack for deck 1 -KAOSSDJ.controllerFxTouchMoveVertical_shift = function(channel, control, value, status, group) { +KAOSSDJ.controllerFxTouchMoveVerticalShift = function(channel, control, value, status, group) { var deck = KAOSSDJ.decks[0]; if (deck.fx) { - var val = script.absoluteLin(value, 0, 1, 0, 127) - engine.setValue('[QuickEffectRack1_' + deck.group + ']', 'super1', val); + var val = script.absoluteLin(value, 0, 1, 0, 127); + engine.setValue("[QuickEffectRack1_" + deck.group + "]", "super1", val); } }; // + : control super knob of QuickEffectRack for deck 2 -KAOSSDJ.controllerFxTouchMoveHorizontal_shift = function(channel, control, value, status, group) { +KAOSSDJ.controllerFxTouchMoveHorizontalShift = function(channel, control, value, status, group) { var deck = KAOSSDJ.decks[1]; if (deck.fx) { - var val = script.absoluteLin(value, 0, 1, 0, 127) - engine.setValue('[QuickEffectRack1_' + deck.group + ']', 'super1', val); + var val = script.absoluteLin(value, 0, 1, 0, 127); + engine.setValue("[QuickEffectRack1_" + deck.group + "]", "super1", val); } }; - diff --git a/res/controllers/Korg-KAOSS-DJ.midi.xml b/res/controllers/Korg-KAOSS-DJ.midi.xml index e39c5cfeaf1..ac736445d06 100644 --- a/res/controllers/Korg-KAOSS-DJ.midi.xml +++ b/res/controllers/Korg-KAOSS-DJ.midi.xml @@ -13,7 +13,7 @@ [Channel1] - KAOSSDJ.change_focus + KAOSSDJ.changeFocus Change focus between library and playlist 0x96 0x07 @@ -23,7 +23,7 @@ [Channel1] - KAOSSDJ.tap_button_callback + KAOSSDJ.tapButtonCallback 0x96 0x0B @@ -52,7 +52,7 @@ [Channel1] - KAOSSDJ.load_callback + KAOSSDJ.loadCallback Load into Deck 1 0x97 0x0E @@ -62,7 +62,7 @@ [Channel2] - KAOSSDJ.load_callback + KAOSSDJ.loadCallback Load into Deck 2 0x98 0x0E @@ -132,7 +132,7 @@ [Channel1] - KAOSSDJ.toggle_loop + KAOSSDJ.toggleLoop MIDI Learned from 2 messages. 0x97 0x10 @@ -152,7 +152,7 @@ [Channel2] - KAOSSDJ.toggle_loop + KAOSSDJ.toggleLoop MIDI Learned from 2 messages. 0x98 0x10 @@ -192,7 +192,7 @@ [Channel1] - KAOSSDJ.controllerFxTouchMoveVertical_shift + KAOSSDJ.controllerFxTouchMoveVerticalShift 0xB6 0x11 @@ -221,7 +221,7 @@ [Channel1] - KAOSSDJ.controllerFxTouchMoveHorizontal_shift + KAOSSDJ.controllerFxTouchMoveHorizontalShift 0xB6 0x12 @@ -420,7 +420,7 @@ [Channel1] - KAOSSDJ.shift_left_callback + KAOSSDJ.shiftLeftCallback Right shift button 0x97 0x1A @@ -430,7 +430,7 @@ [Channel2] - KAOSSDJ.shift_right_callback + KAOSSDJ.shiftRightCallback Left shift button 0x98 0x1A From 9ce9e04b19be218e21203c8472c70d4b710ce045 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Fri, 9 Jun 2023 21:15:05 +0200 Subject: [PATCH 07/23] korg-kaoss-dj: Rename script binding functions --- res/controllers/Korg-KAOSS-DJ-scripts.js | 10 +++++----- res/controllers/Korg-KAOSS-DJ.midi.xml | 12 ++++++------ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 25f5b03dda4..10e78ed50a6 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -179,7 +179,7 @@ KAOSSDJ.fxKnob = function(_channel, _control, _value, _status) { // TODO }; -KAOSSDJ.controllerFxTouchMoveVertical = function(channel, control, value, status, group) { +KAOSSDJ.fxTouchMoveVertical = function(channel, control, value, status, group) { var decks = KAOSSDJ.decks; for (var key in decks) { var deck = decks[key]; @@ -189,7 +189,7 @@ KAOSSDJ.controllerFxTouchMoveVertical = function(channel, control, value, status } }; -KAOSSDJ.controllerFxTouchMoveHorizontal = function(channel, control, value, status, group) { +KAOSSDJ.fxTouchMoveHorizontal = function(channel, control, value, status, group) { var decks = KAOSSDJ.decks; for (var key in decks) { var deck = decks[key]; @@ -199,7 +199,7 @@ KAOSSDJ.controllerFxTouchMoveHorizontal = function(channel, control, value, stat } }; -KAOSSDJ.controllerFxTouchUp = function(channel, control, value, status, group) { +KAOSSDJ.fxTouch = function(channel, control, value, status, group) { var deck = KAOSSDJ.getDeckByChannel(channel); engine.setValue("[EffectRack1_EffectUnit"+deck.deckNumber +"]", "mix", 0); engine.setValue("[EffectRack1_EffectUnit"+deck.deckNumber +"]", "super1", 0); @@ -316,7 +316,7 @@ KAOSSDJ.tapButtonCallback = function(channel, control, value, status, group) { }; // + : control super knob of QuickEffectRack for deck 1 -KAOSSDJ.controllerFxTouchMoveVerticalShift = function(channel, control, value, status, group) { +KAOSSDJ.fxTouchMoveVerticalShift = function(channel, control, value, status, group) { var deck = KAOSSDJ.decks[0]; if (deck.fx) { var val = script.absoluteLin(value, 0, 1, 0, 127); @@ -325,7 +325,7 @@ KAOSSDJ.controllerFxTouchMoveVerticalShift = function(channel, control, value, s }; // + : control super knob of QuickEffectRack for deck 2 -KAOSSDJ.controllerFxTouchMoveHorizontalShift = function(channel, control, value, status, group) { +KAOSSDJ.fxTouchMoveHorizontalShift = function(channel, control, value, status, group) { var deck = KAOSSDJ.decks[1]; if (deck.fx) { var val = script.absoluteLin(value, 0, 1, 0, 127); diff --git a/res/controllers/Korg-KAOSS-DJ.midi.xml b/res/controllers/Korg-KAOSS-DJ.midi.xml index ac736445d06..bcebc652980 100644 --- a/res/controllers/Korg-KAOSS-DJ.midi.xml +++ b/res/controllers/Korg-KAOSS-DJ.midi.xml @@ -32,7 +32,7 @@ [Channel1] - KAOSSDJ.controllerFxTouchMoveHorizontal + KAOSSDJ.fxTouchMoveHorizontal Fx Control 0xB8 0x0C @@ -42,7 +42,7 @@ [Channel1] - KAOSSDJ.controllerFxTouchMoveVertical + KAOSSDJ.fxTouchMoveVertical Fx Control 0xB8 0x0D @@ -192,7 +192,7 @@ [Channel1] - KAOSSDJ.controllerFxTouchMoveVerticalShift + KAOSSDJ.fxTouchMoveVerticalShift 0xB6 0x11 @@ -221,7 +221,7 @@ [Channel1] - KAOSSDJ.controllerFxTouchMoveHorizontalShift + KAOSSDJ.fxTouchMoveHorizontalShift 0xB6 0x12 @@ -630,7 +630,7 @@ [Channel1] - KAOSSDJ.controllerFxTouchUp + KAOSSDJ.fxTouch Fx Control 0x97 0x20 @@ -640,7 +640,7 @@ [Channel2] - KAOSSDJ.controllerFxTouchUp + KAOSSDJ.fxTouch Fx Control 0x98 0x20 From 4bedd103f75c428832a7ad46255750e033995e55 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Fri, 9 Jun 2023 21:08:30 +0200 Subject: [PATCH 08/23] korg-kaoss-dj: Simplify and reformat code --- res/controllers/Korg-KAOSS-DJ-scripts.js | 61 +++++++++--------------- 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 10e78ed50a6..666f5d0e271 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -97,7 +97,7 @@ KAOSSDJ.wheelTouch = function(channel, control, value, status, group) { var beta = alpha / 32; var deck = KAOSSDJ.getDeckByChannel(channel); var deckNumber = deck.deckNumber; - var deckPlaying = engine.getValue("[Channel" + deckNumber + "]", "play_indicator"); + var deckPlaying = engine.getValue("[Channel" + deckNumber + "]", "play_latched"); // If in scratch mode or not playing enable vinyl-like control if (deck.jogWheelsInScratchMode || !deckPlaying) { @@ -150,13 +150,7 @@ KAOSSDJ.wheelTurnShift = function(channel, control, value, status, group) { }; KAOSSDJ.scratchMode = function(channel, control, value, status, group) { - if (value === ON) { - // Turn scratch mode on jogwheel (LED is red) - KAOSSDJ.updateDeckByChannel(channel, "jogWheelsInScratchMode", true); - } else if (value === OFF) { - // Turn scratch mode on jogwheel (LED is off) - KAOSSDJ.updateDeckByChannel(channel, "jogWheelsInScratchMode", false); - } + KAOSSDJ.updateDeckByChannel(channel, "jogWheelsInScratchMode", value === ON); }; KAOSSDJ.leftFxSwitch = function(channel, control, value, status, group) { @@ -184,7 +178,7 @@ KAOSSDJ.fxTouchMoveVertical = function(channel, control, value, status, group) { for (var key in decks) { var deck = decks[key]; if (deck.fx) { - engine.setValue("[EffectRack1_EffectUnit"+deck.deckNumber +"]", "mix", value / 127); + engine.setValue("[EffectRack1_EffectUnit" + deck.deckNumber + "]", "mix", value / 127); } } }; @@ -194,7 +188,7 @@ KAOSSDJ.fxTouchMoveHorizontal = function(channel, control, value, status, group) for (var key in decks) { var deck = decks[key]; if (deck.fx) { - engine.setValue("[EffectRack1_EffectUnit"+deck.deckNumber +"]", "super1", value / 127); + engine.setValue("[EffectRack1_EffectUnit" + deck.deckNumber + "]", "super1", value / 127); } } }; @@ -226,7 +220,7 @@ KAOSSDJ.toggleLoop = function(channel, control, value, status, group) { KAOSSDJ.loadCallback = function(channel, control, value, status, group) { var deck = KAOSSDJ.getDeckByChannel(channel); if (value === ON) { - if ((shiftLeftPressed) || (shiftRightPressed)) { + if (shiftLeftPressed || shiftRightPressed) { if (deck.deckNumber === 1) { engine.setValue("[Library]", "MoveLeft", true); } else { @@ -239,26 +233,16 @@ KAOSSDJ.loadCallback = function(channel, control, value, status, group) { }; KAOSSDJ.shiftLeftCallback = function(channel, control, value, status, group) { - if (value === ON) { - // if (shiftRightPressed == true) { - // TODO add functionality if is active while is pressed? - // } - shiftLeftPressed = true; - } else { shiftLeftPressed = false; } + shiftLeftPressed = value === ON; }; KAOSSDJ.shiftRightCallback = function(channel, control, value, status, group) { - if (value === ON) { - // if (shiftLeftPressed == true) { - // TODO add functionality if is active while is pressed? - // } - shiftRightPressed = true; - } else { shiftRightPressed = false; } + shiftRightPressed = value === ON; }; KAOSSDJ.changeFocus = function(channel, control, value, status, group) { + // toggle focus between Playlist and File-Browser if (value === ON) { - // toggle focus between Playlist and File-Browser engine.setValue("[Library]", "MoveFocusForward", true); } }; @@ -267,13 +251,13 @@ KAOSSDJ.changeFocus = function(channel, control, value, status, group) { // + : toggle focus between Playlist and File-Browser KAOSSDJ.browseKnob = function(channel, control, value, status, group) { if (value > 0x40) { - if ((shiftLeftPressed) || (shiftRightPressed)) { + if (shiftLeftPressed || shiftRightPressed) { engine.setValue("[Library]", "MoveFocusForward", true); } else { engine.setValue("[Library]", "MoveUp", true); } } else { - if ((shiftLeftPressed) || (shiftRightPressed)) { + if (shiftLeftPressed || shiftRightPressed) { engine.setValue("[Library]", "MoveFocusBackward", true); } else { engine.setValue("[Library]", "MoveDown", true); @@ -287,32 +271,31 @@ KAOSSDJ.browseKnob = function(channel, control, value, status, group) { // + : tap bpm of RIGHT track var doubleTapTime; KAOSSDJ.tapButtonCallback = function(channel, control, value, status, group) { - var now = new Date().getTime(); - var timesince = now - doubleTapTime; + if (value !== ON) { + return; + } /* shift tab to move focus view */ - if ((value === ON) && ((shiftLeftPressed))) { + if ((value === ON) && shiftLeftPressed) { // engine.setValue("[Library]", "MoveFocusForward", true); engine.setValue("[Channel1]", "bpm_tap", true); return; } - if ((value === ON) && ((shiftRightPressed))) { + if ((value === ON) && shiftRightPressed) { // engine.setValue("[Library]", "MoveFocusForward", true); engine.setValue("[Channel2]", "bpm_tap", true); return; } /* tap to open folder, double-tap to close folder (twice to undo first tap)*/ - if (value === ON) { - if ((timesince < 600) && (timesince > 0)) { - engine.setValue("[Library]", "MoveLeft", true); - engine.setValue("[Library]", "MoveLeft", true); - } else { - engine.setValue("[Library]", "MoveRight", true); - } - - doubleTapTime = new Date().getTime(); + var now = new Date().getTime(); + var timesince = now - doubleTapTime; + if ((timesince < 600) && (timesince > 0)) { + engine.setValue("[Library]", "MoveLeft", true); + } else { + engine.setValue("[Library]", "MoveRight", true); } + doubleTapTime = new Date().getTime(); }; // + : control super knob of QuickEffectRack for deck 1 From 138b6cd3370b20c45606d4a3e9ab972aa8b5d624 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Fri, 9 Jun 2023 21:10:35 +0200 Subject: [PATCH 09/23] korg-kaoss-dj: Fix handling of resetting the efx params on release --- res/controllers/Korg-KAOSS-DJ-scripts.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 666f5d0e271..87cf654f397 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -194,9 +194,12 @@ KAOSSDJ.fxTouchMoveHorizontal = function(channel, control, value, status, group) }; KAOSSDJ.fxTouch = function(channel, control, value, status, group) { - var deck = KAOSSDJ.getDeckByChannel(channel); - engine.setValue("[EffectRack1_EffectUnit"+deck.deckNumber +"]", "mix", 0); - engine.setValue("[EffectRack1_EffectUnit"+deck.deckNumber +"]", "super1", 0); + if (value === OFF) { + var deck = KAOSSDJ.getDeckByChannel(channel); + var fxGroup = "[EffectRack1_EffectUnit" + deck.deckNumber + "]"; + engine.setValue(fxGroup, "mix", 0); + engine.setValue(fxGroup, "super1", 0); + } }; // use loop-button to deactivate an active loop or initialize a beatloop at the current playback position From 0b649198dca5b2a40e440f76e652b35fe9624f12 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Fri, 9 Jun 2023 21:12:05 +0200 Subject: [PATCH 10/23] korg-kaoss-dj: Simplify handling of Fx toggle buttons --- res/controllers/Korg-KAOSS-DJ-scripts.js | 16 ++-------------- res/controllers/Korg-KAOSS-DJ.midi.xml | 8 ++++---- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 87cf654f397..b41f43641c8 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -153,20 +153,8 @@ KAOSSDJ.scratchMode = function(channel, control, value, status, group) { KAOSSDJ.updateDeckByChannel(channel, "jogWheelsInScratchMode", value === ON); }; -KAOSSDJ.leftFxSwitch = function(channel, control, value, status, group) { - if (value === ON) { - KAOSSDJ.updateDeckByChannel(channel, "fx", true); - } else { - KAOSSDJ.updateDeckByChannel(channel, "fx", false); - } -}; - -KAOSSDJ.rightFxSwitch = function(channel, control, value, status, group) { - if (value === ON) { - KAOSSDJ.updateDeckByChannel(channel, "fx", true); - } else { - KAOSSDJ.updateDeckByChannel(channel, "fx", false); - } +KAOSSDJ.fxToggleButton = function(channel, control, value, status, group) { + KAOSSDJ.updateDeckByChannel(channel, "fx", value === ON); }; KAOSSDJ.fxKnob = function(_channel, _control, _value, _status) { diff --git a/res/controllers/Korg-KAOSS-DJ.midi.xml b/res/controllers/Korg-KAOSS-DJ.midi.xml index bcebc652980..f7dbbc66b15 100644 --- a/res/controllers/Korg-KAOSS-DJ.midi.xml +++ b/res/controllers/Korg-KAOSS-DJ.midi.xml @@ -340,8 +340,8 @@ [Channel1] - KAOSSDJ.leftFxSwitch - Left Fx switch + KAOSSDJ.fxToggleButton + Left Fx Toggle Button 0x97 0x18 @@ -350,8 +350,8 @@ [Channel2] - KAOSSDJ.rightFxSwitch - Right Fx switch + KAOSSDJ.fxToggleButton + Right Fx Toggle Button 0x98 0x18 From 5c7154e598678932232165e86f2d9de071263fbf Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Sat, 10 Jun 2023 15:57:08 +0200 Subject: [PATCH 11/23] korg-kaoss-dj: Fix eslint issues --- res/controllers/Korg-KAOSS-DJ-scripts.js | 62 ++++++++++++------------ 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index b41f43641c8..7317dcc4ff5 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -13,19 +13,21 @@ var ledChannel = { "knobsR": 0xB8, "master": 0xB6 }; -var led = { - "cue": 0x1E, - "sync": 0x1D, - "play": 0x1B, - "headphones": 0x19, - "fx": 0x18, // warning: led is owned by controller - "stripL": 0x15, - "stripM": 0x16, - "stripR": 0x17, - "loopStripL": 0x0F, - "loopStripM": 0x10, - "loopStripR": 0x11, -}; + +// TODO: Only turn on/off selected LEDs on startup/shutdown +// var led = { +// "cue": 0x1E, +// "sync": 0x1D, +// "play": 0x1B, +// "headphones": 0x19, +// "fx": 0x18, // warning: led is owned by controller +// "stripL": 0x15, +// "stripM": 0x16, +// "stripR": 0x17, +// "loopStripL": 0x0F, +// "loopStripM": 0x10, +// "loopStripR": 0x11, +// }; // shift button state variables var shiftLeftPressed = false; @@ -92,7 +94,7 @@ KAOSSDJ.updateDeckByChannel = function(channel, key, value) { // ==== mapped functions ==== -KAOSSDJ.wheelTouch = function(channel, control, value, status, group) { +KAOSSDJ.wheelTouch = function(channel, _control, value, _status, _group) { var alpha = 1.0 / 8; var beta = alpha / 32; var deck = KAOSSDJ.getDeckByChannel(channel); @@ -111,7 +113,7 @@ KAOSSDJ.wheelTouch = function(channel, control, value, status, group) { } }; -KAOSSDJ.wheelTurn = function(channel, control, value, status, group) { +KAOSSDJ.wheelTurn = function(channel, _control, value, _status, _group) { var deck = KAOSSDJ.getDeckByChannel(channel); var deckNumber = deck.deckNumber; var newValue = 0; @@ -127,7 +129,7 @@ KAOSSDJ.wheelTurn = function(channel, control, value, status, group) { } }; -KAOSSDJ.wheelTurnShift = function(channel, control, value, status, group) { +KAOSSDJ.wheelTurnShift = function(channel, _control, value, _status, _group) { var deck = KAOSSDJ.getDeckByChannel(channel); if (deck.jogWheelsInScratchMode) { // Fast scratch @@ -149,11 +151,11 @@ KAOSSDJ.wheelTurnShift = function(channel, control, value, status, group) { } }; -KAOSSDJ.scratchMode = function(channel, control, value, status, group) { +KAOSSDJ.scratchMode = function(channel, _control, value, _status, _group) { KAOSSDJ.updateDeckByChannel(channel, "jogWheelsInScratchMode", value === ON); }; -KAOSSDJ.fxToggleButton = function(channel, control, value, status, group) { +KAOSSDJ.fxToggleButton = function(channel, _control, value, _status, _group) { KAOSSDJ.updateDeckByChannel(channel, "fx", value === ON); }; @@ -161,7 +163,7 @@ KAOSSDJ.fxKnob = function(_channel, _control, _value, _status) { // TODO }; -KAOSSDJ.fxTouchMoveVertical = function(channel, control, value, status, group) { +KAOSSDJ.fxTouchMoveVertical = function(_channel, _control, value, _status, _group) { var decks = KAOSSDJ.decks; for (var key in decks) { var deck = decks[key]; @@ -171,7 +173,7 @@ KAOSSDJ.fxTouchMoveVertical = function(channel, control, value, status, group) { } }; -KAOSSDJ.fxTouchMoveHorizontal = function(channel, control, value, status, group) { +KAOSSDJ.fxTouchMoveHorizontal = function(_channel, _control, value, _status, _group) { var decks = KAOSSDJ.decks; for (var key in decks) { var deck = decks[key]; @@ -181,7 +183,7 @@ KAOSSDJ.fxTouchMoveHorizontal = function(channel, control, value, status, group) } }; -KAOSSDJ.fxTouch = function(channel, control, value, status, group) { +KAOSSDJ.fxTouch = function(channel, _control, value, _status, _group) { if (value === OFF) { var deck = KAOSSDJ.getDeckByChannel(channel); var fxGroup = "[EffectRack1_EffectUnit" + deck.deckNumber + "]"; @@ -191,7 +193,7 @@ KAOSSDJ.fxTouch = function(channel, control, value, status, group) { }; // use loop-button to deactivate an active loop or initialize a beatloop at the current playback position -KAOSSDJ.toggleLoop = function(channel, control, value, status, group) { +KAOSSDJ.toggleLoop = function(channel, _control, value, _status, _group) { var deck = KAOSSDJ.getDeckByChannel(channel); var loopEnabled = engine.getValue(deck.group, "loop_enabled"); @@ -208,7 +210,7 @@ KAOSSDJ.toggleLoop = function(channel, control, value, status, group) { // : load track // + : open/close folder in file-browser -KAOSSDJ.loadCallback = function(channel, control, value, status, group) { +KAOSSDJ.loadCallback = function(channel, _control, value, _status, _group) { var deck = KAOSSDJ.getDeckByChannel(channel); if (value === ON) { if (shiftLeftPressed || shiftRightPressed) { @@ -223,15 +225,15 @@ KAOSSDJ.loadCallback = function(channel, control, value, status, group) { } }; -KAOSSDJ.shiftLeftCallback = function(channel, control, value, status, group) { +KAOSSDJ.shiftLeftCallback = function(_channel, _control, value, _status, _group) { shiftLeftPressed = value === ON; }; -KAOSSDJ.shiftRightCallback = function(channel, control, value, status, group) { +KAOSSDJ.shiftRightCallback = function(_channel, _control, value, _status, _group) { shiftRightPressed = value === ON; }; -KAOSSDJ.changeFocus = function(channel, control, value, status, group) { +KAOSSDJ.changeFocus = function(_channel, _control, value, _status, _group) { // toggle focus between Playlist and File-Browser if (value === ON) { engine.setValue("[Library]", "MoveFocusForward", true); @@ -240,7 +242,7 @@ KAOSSDJ.changeFocus = function(channel, control, value, status, group) { // : browse library up & down // + : toggle focus between Playlist and File-Browser -KAOSSDJ.browseKnob = function(channel, control, value, status, group) { +KAOSSDJ.browseKnob = function(_channel, _control, value, _status, _group) { if (value > 0x40) { if (shiftLeftPressed || shiftRightPressed) { engine.setValue("[Library]", "MoveFocusForward", true); @@ -261,7 +263,7 @@ KAOSSDJ.browseKnob = function(channel, control, value, status, group) { // + : tap bpm of LEFT track // + : tap bpm of RIGHT track var doubleTapTime; -KAOSSDJ.tapButtonCallback = function(channel, control, value, status, group) { +KAOSSDJ.tapButtonCallback = function(_channel, _control, value, _status, _group) { if (value !== ON) { return; } @@ -290,7 +292,7 @@ KAOSSDJ.tapButtonCallback = function(channel, control, value, status, group) { }; // + : control super knob of QuickEffectRack for deck 1 -KAOSSDJ.fxTouchMoveVerticalShift = function(channel, control, value, status, group) { +KAOSSDJ.fxTouchMoveVerticalShift = function(_channel, _control, value, _status, _group) { var deck = KAOSSDJ.decks[0]; if (deck.fx) { var val = script.absoluteLin(value, 0, 1, 0, 127); @@ -299,7 +301,7 @@ KAOSSDJ.fxTouchMoveVerticalShift = function(channel, control, value, status, gro }; // + : control super knob of QuickEffectRack for deck 2 -KAOSSDJ.fxTouchMoveHorizontalShift = function(channel, control, value, status, group) { +KAOSSDJ.fxTouchMoveHorizontalShift = function(_channel, _control, value, _status, _group) { var deck = KAOSSDJ.decks[1]; if (deck.fx) { var val = script.absoluteLin(value, 0, 1, 0, 127); From 7b8f5878827b327d86b177a88c8da4282a15fde2 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Tue, 4 Jul 2023 13:04:18 +0200 Subject: [PATCH 12/23] korg-kaoss-dj: Simplify JS code by switching to ES7 --- res/controllers/Korg-KAOSS-DJ-scripts.js | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 7317dcc4ff5..cd3168bbf16 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -164,23 +164,15 @@ KAOSSDJ.fxKnob = function(_channel, _control, _value, _status) { }; KAOSSDJ.fxTouchMoveVertical = function(_channel, _control, value, _status, _group) { - var decks = KAOSSDJ.decks; - for (var key in decks) { - var deck = decks[key]; - if (deck.fx) { - engine.setValue("[EffectRack1_EffectUnit" + deck.deckNumber + "]", "mix", value / 127); - } - } + Object.values(KAOSSDJ.decks) + .filter(deck => deck.fx) + .forEach(deck => engine.setValue("[EffectRack1_EffectUnit" + deck.deckNumber + "]", "mix", value / 127)); }; KAOSSDJ.fxTouchMoveHorizontal = function(_channel, _control, value, _status, _group) { - var decks = KAOSSDJ.decks; - for (var key in decks) { - var deck = decks[key]; - if (deck.fx) { - engine.setValue("[EffectRack1_EffectUnit" + deck.deckNumber + "]", "super1", value / 127); - } - } + Object.values(KAOSSDJ.decks) + .filter(deck => deck.fx) + .forEach(deck => engine.setValue("[EffectRack1_EffectUnit" + deck.deckNumber + "]", "super1", value / 127)); }; KAOSSDJ.fxTouch = function(channel, _control, value, _status, _group) { @@ -281,14 +273,14 @@ KAOSSDJ.tapButtonCallback = function(_channel, _control, value, _status, _group) } /* tap to open folder, double-tap to close folder (twice to undo first tap)*/ - var now = new Date().getTime(); + var now = new Date(); var timesince = now - doubleTapTime; if ((timesince < 600) && (timesince > 0)) { engine.setValue("[Library]", "MoveLeft", true); } else { engine.setValue("[Library]", "MoveRight", true); } - doubleTapTime = new Date().getTime(); + doubleTapTime = new Date(); }; // + : control super knob of QuickEffectRack for deck 1 From f4c20b46ae6450cced875f30b6fc4c4db45f3f78 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Tue, 4 Jul 2023 14:39:14 +0200 Subject: [PATCH 13/23] korg-kaoss-dj: Fix ESLint issues --- res/controllers/Korg-KAOSS-DJ-scripts.js | 210 +++++++++++++---------- 1 file changed, 116 insertions(+), 94 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index cd3168bbf16..9b257c1d44d 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -1,39 +1,58 @@ // Korg KAOSS DJ controller mapping for Mixxx // Seb Dooris, Fayaaz Ahmed, Lee Arromba, Raphael Quast -var KAOSSDJ = {}; -var ON = 0x7F, - OFF = 0x00, - UP = 0x01, - DOWN = 0x7F; -var ledChannel = { - "btnsL": 0x97, - "btnsR": 0x98, - "knobsL": 0xB7, - "knobsR": 0xB8, - "master": 0xB6 +var KAOSSDJ = { + // shift button state variables + shiftLeftPressed: false, + shiftRightPressed: false, + lastTapDate: Date.now(), }; -// TODO: Only turn on/off selected LEDs on startup/shutdown -// var led = { -// "cue": 0x1E, -// "sync": 0x1D, -// "play": 0x1B, -// "headphones": 0x19, -// "fx": 0x18, // warning: led is owned by controller -// "stripL": 0x15, -// "stripM": 0x16, -// "stripR": 0x17, -// "loopStripL": 0x0F, -// "loopStripM": 0x10, -// "loopStripR": 0x11, -// }; - -// shift button state variables -var shiftLeftPressed = false; -var shiftRightPressed = false; - -// initialise decks +const MIDI_ON = 0x7F; +const MIDI_OFF = 0x00; + +const MIDI_UP = 0x01; +const MIDI_DOWN = 0x7F; + +const MIDI_CHANNELS = { + BUTTON_LEFT: 0x97, + BUTTON_RIGHT: 0x98, + KNOB_MAIN: 0xB6, + KNOB_LEFT: 0xB7, + KNOB_RIGHT: 0xB8, +}; + +const MIDI_MAIN_KNOB_LEDS = { + MONITOR_LEVEL: 0x14, + MONITOR_MIX: 0x15, + MASTER_LEVEL: 0x16, +}; + +const MIDI_DECK_BUTTON_LEDS = { + // Fx LED (0x18) is owned by the controller + MONITOR: 0x19, + LOOP_L: 0x0F, + LOOP_M: 0x10, + LOOP_R: 0x11, + HOTCUE_L: 0x12, + HOTCUE_M: 0x13, + HOTCUE_R: 0x14, + STRIP_L: 0x15, + STRIP_M: 0x16, + STRIP_R: 0x17, + CUE: 0x1E, + SYNC: 0x1D, + PLAY: 0x1B, +}; + +const MIDI_DECK_KNOB_LEDS = { + GAIN: 0x1A, + EQ_HI: 0x1B, + EQ_MID: 0x1C, + EQ_LO: 0x1D, +}; + +// initialize decks KAOSSDJ.deck = function(deckNumber) { this.deckNumber = deckNumber; this.group = "[Channel" + deckNumber + "]"; @@ -42,38 +61,42 @@ KAOSSDJ.deck = function(deckNumber) { }; KAOSSDJ.decks = []; -for (var i = 0; i < 4; i++) { // TODO: currently only 2 decks supported. is 4 possible? +for (let i = 0; i < 4; i++) { // TODO: currently only 2 decks supported. is 4 possible? KAOSSDJ.decks[i] = new KAOSSDJ.deck(i+1); } // ==== lifecycle ==== +KAOSSDJ.sendAllKnobLeds = function(state) { + Object.values(MIDI_MAIN_KNOB_LEDS) + .forEach(led => midi.sendShortMsg(MIDI_CHANNELS.KNOB_MAIN, led, state)); + Object.values([MIDI_CHANNELS.KNOB_LEFT, MIDI_CHANNELS.KNOB_RIGHT]) + .forEach(channel => Object.values(MIDI_DECK_KNOB_LEDS).forEach( + led => midi.sendShortMsg(channel, led, state))); +}; + +KAOSSDJ.sendAllButtonLeds = function(state) { + Object.values([MIDI_CHANNELS.BUTTON_LEFT, MIDI_CHANNELS.BUTTON_RIGHT]) + .forEach(channel => Object.values(MIDI_DECK_BUTTON_LEDS).forEach( + led => midi.sendShortMsg(channel, led, state))); + +}; + KAOSSDJ.init = function(_id, _debugging) { - // turn on main led channels - var ledChannels = [ - ledChannel.knobsL, - ledChannel.knobsR, - ledChannel.master - ]; - for (var led = 0x00; led <= 0xFF; led++) { - for (var i = 0; i < ledChannels.length; i++) { - midi.sendShortMsg(ledChannels[i], led, ON); - } - } + // Turn on all knob LEDs and turn off all button LEDs. + KAOSSDJ.sendAllKnobLeds(MIDI_ON); + KAOSSDJ.sendAllButtonLeds(MIDI_OFF); // This message was copied from communication with Serato DJ Intro & Midi Monitor // It should setup mixxx from the controller defaults - var ControllerStatusSysex = [0xF0, 0x42, 0x40, 0x00, 0x01, 0x28, 0x00, 0x1F, 0x70, 0x01, 0xF7]; + const ControllerStatusSysex = [0xF0, 0x42, 0x40, 0x00, 0x01, 0x28, 0x00, 0x1F, 0x70, 0x01, 0xF7]; midi.sendSysexMsg(ControllerStatusSysex, ControllerStatusSysex.length); }; KAOSSDJ.shutdown = function(_id, _debugging) { - // turn off all LEDs - for (var led = 0x00; led <= 0xFF; led++) { - for (var key in ledChannel) { - midi.sendShortMsg(ledChannel[key], led, OFF); - } - } + // Turn off all LEDs. + KAOSSDJ.sendAllKnobLeds(MIDI_OFF); + KAOSSDJ.sendAllButtonLeds(MIDI_OFF); }; // ==== helper ==== @@ -83,30 +106,30 @@ KAOSSDJ.getDeckIndexFromChannel = function(channel) { }; KAOSSDJ.getDeckByChannel = function(channel) { - var deckIndex = KAOSSDJ.getDeckIndexFromChannel(channel); + const deckIndex = KAOSSDJ.getDeckIndexFromChannel(channel); return KAOSSDJ.decks[deckIndex]; }; KAOSSDJ.updateDeckByChannel = function(channel, key, value) { - var deckIndex = KAOSSDJ.getDeckIndexFromChannel(channel); + const deckIndex = KAOSSDJ.getDeckIndexFromChannel(channel); KAOSSDJ.decks[deckIndex][key] = value; }; // ==== mapped functions ==== KAOSSDJ.wheelTouch = function(channel, _control, value, _status, _group) { - var alpha = 1.0 / 8; - var beta = alpha / 32; - var deck = KAOSSDJ.getDeckByChannel(channel); - var deckNumber = deck.deckNumber; - var deckPlaying = engine.getValue("[Channel" + deckNumber + "]", "play_latched"); + const alpha = 1.0 / 8; + const beta = alpha / 32; + const deck = KAOSSDJ.getDeckByChannel(channel); + const deckNumber = deck.deckNumber; + const deckPlaying = engine.getValue("[Channel" + deckNumber + "]", "play_latched"); // If in scratch mode or not playing enable vinyl-like control if (deck.jogWheelsInScratchMode || !deckPlaying) { - if (value === ON) { + if (value === MIDI_ON) { // Enable scratching on touch engine.scratchEnable(deckNumber, 128, 33 + 1 / 3, alpha, beta); - } else if (value === OFF) { + } else if (value === MIDI_OFF) { // Disable scratching engine.scratchDisable(deckNumber); } @@ -114,9 +137,9 @@ KAOSSDJ.wheelTouch = function(channel, _control, value, _status, _group) { }; KAOSSDJ.wheelTurn = function(channel, _control, value, _status, _group) { - var deck = KAOSSDJ.getDeckByChannel(channel); - var deckNumber = deck.deckNumber; - var newValue = 0; + const deck = KAOSSDJ.getDeckByChannel(channel); + const deckNumber = deck.deckNumber; + let newValue = 0; if (value < 64) { newValue = value; } else { @@ -130,10 +153,10 @@ KAOSSDJ.wheelTurn = function(channel, _control, value, _status, _group) { }; KAOSSDJ.wheelTurnShift = function(channel, _control, value, _status, _group) { - var deck = KAOSSDJ.getDeckByChannel(channel); + const deck = KAOSSDJ.getDeckByChannel(channel); if (deck.jogWheelsInScratchMode) { // Fast scratch - var newValue = 0; + let newValue = 0; if (value < 64) { newValue = value; } else { @@ -143,20 +166,20 @@ KAOSSDJ.wheelTurnShift = function(channel, _control, value, _status, _group) { engine.scratchTick(deck.deckNumber, newValue); } else { // Move beatgrid - if (value === UP) { + if (value === MIDI_UP) { engine.setValue(deck.group, "beats_translate_later", true); - } else if (value === DOWN) { + } else if (value === MIDI_DOWN) { engine.setValue(deck.group, "beats_translate_earlier", true); } } }; KAOSSDJ.scratchMode = function(channel, _control, value, _status, _group) { - KAOSSDJ.updateDeckByChannel(channel, "jogWheelsInScratchMode", value === ON); + KAOSSDJ.updateDeckByChannel(channel, "jogWheelsInScratchMode", value === MIDI_ON); }; KAOSSDJ.fxToggleButton = function(channel, _control, value, _status, _group) { - KAOSSDJ.updateDeckByChannel(channel, "fx", value === ON); + KAOSSDJ.updateDeckByChannel(channel, "fx", value === MIDI_ON); }; KAOSSDJ.fxKnob = function(_channel, _control, _value, _status) { @@ -176,9 +199,9 @@ KAOSSDJ.fxTouchMoveHorizontal = function(_channel, _control, value, _status, _gr }; KAOSSDJ.fxTouch = function(channel, _control, value, _status, _group) { - if (value === OFF) { - var deck = KAOSSDJ.getDeckByChannel(channel); - var fxGroup = "[EffectRack1_EffectUnit" + deck.deckNumber + "]"; + if (value === MIDI_OFF) { + const deck = KAOSSDJ.getDeckByChannel(channel); + const fxGroup = "[EffectRack1_EffectUnit" + deck.deckNumber + "]"; engine.setValue(fxGroup, "mix", 0); engine.setValue(fxGroup, "super1", 0); } @@ -186,10 +209,10 @@ KAOSSDJ.fxTouch = function(channel, _control, value, _status, _group) { // use loop-button to deactivate an active loop or initialize a beatloop at the current playback position KAOSSDJ.toggleLoop = function(channel, _control, value, _status, _group) { - var deck = KAOSSDJ.getDeckByChannel(channel); - var loopEnabled = engine.getValue(deck.group, "loop_enabled"); + const deck = KAOSSDJ.getDeckByChannel(channel); + const loopEnabled = engine.getValue(deck.group, "loop_enabled"); - if (value === ON) { + if (value === MIDI_ON) { if (loopEnabled) { engine.setValue(deck.group, "reloop_exit", true); engine.setValue(deck.group, "beatloop_activate", false); @@ -203,9 +226,9 @@ KAOSSDJ.toggleLoop = function(channel, _control, value, _status, _group) { // : load track // + : open/close folder in file-browser KAOSSDJ.loadCallback = function(channel, _control, value, _status, _group) { - var deck = KAOSSDJ.getDeckByChannel(channel); - if (value === ON) { - if (shiftLeftPressed || shiftRightPressed) { + const deck = KAOSSDJ.getDeckByChannel(channel); + if (value === MIDI_ON) { + if (KAOSSDJ.shiftLeftPressed || KAOSSDJ.shiftRightPressed) { if (deck.deckNumber === 1) { engine.setValue("[Library]", "MoveLeft", true); } else { @@ -218,16 +241,16 @@ KAOSSDJ.loadCallback = function(channel, _control, value, _status, _group) { }; KAOSSDJ.shiftLeftCallback = function(_channel, _control, value, _status, _group) { - shiftLeftPressed = value === ON; + KAOSSDJ.shiftLeftPressed = value === MIDI_ON; }; KAOSSDJ.shiftRightCallback = function(_channel, _control, value, _status, _group) { - shiftRightPressed = value === ON; + KAOSSDJ.shiftRightPressed = value === MIDI_ON; }; KAOSSDJ.changeFocus = function(_channel, _control, value, _status, _group) { // toggle focus between Playlist and File-Browser - if (value === ON) { + if (value === MIDI_ON) { engine.setValue("[Library]", "MoveFocusForward", true); } }; @@ -236,13 +259,13 @@ KAOSSDJ.changeFocus = function(_channel, _control, value, _status, _group) { // + : toggle focus between Playlist and File-Browser KAOSSDJ.browseKnob = function(_channel, _control, value, _status, _group) { if (value > 0x40) { - if (shiftLeftPressed || shiftRightPressed) { + if (KAOSSDJ.shiftLeftPressed || KAOSSDJ.shiftRightPressed) { engine.setValue("[Library]", "MoveFocusForward", true); } else { engine.setValue("[Library]", "MoveUp", true); } } else { - if (shiftLeftPressed || shiftRightPressed) { + if (KAOSSDJ.shiftLeftPressed || KAOSSDJ.shiftRightPressed) { engine.setValue("[Library]", "MoveFocusBackward", true); } else { engine.setValue("[Library]", "MoveDown", true); @@ -254,49 +277,48 @@ KAOSSDJ.browseKnob = function(_channel, _control, value, _status, _group) { // + : double-tap to close folder // + : tap bpm of LEFT track // + : tap bpm of RIGHT track -var doubleTapTime; KAOSSDJ.tapButtonCallback = function(_channel, _control, value, _status, _group) { - if (value !== ON) { + if (value !== MIDI_ON) { return; } /* shift tab to move focus view */ - if ((value === ON) && shiftLeftPressed) { + if ((value === MIDI_ON) && KAOSSDJ.shiftLeftPressed) { // engine.setValue("[Library]", "MoveFocusForward", true); engine.setValue("[Channel1]", "bpm_tap", true); return; } - if ((value === ON) && shiftRightPressed) { + if ((value === MIDI_ON) && KAOSSDJ.shiftRightPressed) { // engine.setValue("[Library]", "MoveFocusForward", true); engine.setValue("[Channel2]", "bpm_tap", true); return; } /* tap to open folder, double-tap to close folder (twice to undo first tap)*/ - var now = new Date(); - var timesince = now - doubleTapTime; - if ((timesince < 600) && (timesince > 0)) { + const now = new Date(); + const timeSinceLastTap = now - KAOSSDJ.lastTapDate; + KAOSSDJ.lastTapDate = now; + if ((timeSinceLastTap < 600) && (timeSinceLastTap > 0)) { engine.setValue("[Library]", "MoveLeft", true); } else { engine.setValue("[Library]", "MoveRight", true); } - doubleTapTime = new Date(); }; // + : control super knob of QuickEffectRack for deck 1 KAOSSDJ.fxTouchMoveVerticalShift = function(_channel, _control, value, _status, _group) { - var deck = KAOSSDJ.decks[0]; + const deck = KAOSSDJ.decks[0]; if (deck.fx) { - var val = script.absoluteLin(value, 0, 1, 0, 127); + const val = script.absoluteLin(value, 0, 1, 0, 127); engine.setValue("[QuickEffectRack1_" + deck.group + "]", "super1", val); } }; // + : control super knob of QuickEffectRack for deck 2 KAOSSDJ.fxTouchMoveHorizontalShift = function(_channel, _control, value, _status, _group) { - var deck = KAOSSDJ.decks[1]; + const deck = KAOSSDJ.decks[1]; if (deck.fx) { - var val = script.absoluteLin(value, 0, 1, 0, 127); + const val = script.absoluteLin(value, 0, 1, 0, 127); engine.setValue("[QuickEffectRack1_" + deck.group + "]", "super1", val); } }; From 99f4974791a2d56b2acefa67d44edb8d3231a3e4 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Fri, 7 Jul 2023 13:24:27 +0200 Subject: [PATCH 14/23] korg-kaoss-dj: Fix ESLint warning --- res/controllers/Korg-KAOSS-DJ-scripts.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 9b257c1d44d..2a3a32f11a2 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -1,6 +1,8 @@ // Korg KAOSS DJ controller mapping for Mixxx // Seb Dooris, Fayaaz Ahmed, Lee Arromba, Raphael Quast +// Using `const`/`let` causes ReferenceError: KAOSSDJ is not defined +// eslint-disable-next-line no-var var KAOSSDJ = { // shift button state variables shiftLeftPressed: false, From 5e45e1be20c731d47c55b8cf205cff4a6a9391f5 Mon Sep 17 00:00:00 2001 From: Uwe Klotz Date: Fri, 7 Jul 2023 13:24:51 +0200 Subject: [PATCH 15/23] korg-kaoss-dj: use ES6 template literals --- res/controllers/Korg-KAOSS-DJ-scripts.js | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 2a3a32f11a2..e675f882a64 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -57,7 +57,7 @@ const MIDI_DECK_KNOB_LEDS = { // initialize decks KAOSSDJ.deck = function(deckNumber) { this.deckNumber = deckNumber; - this.group = "[Channel" + deckNumber + "]"; + this.group = `[Channel${deckNumber}]`; this.jogWheelsInScratchMode = true; this.fx = false; }; @@ -124,7 +124,7 @@ KAOSSDJ.wheelTouch = function(channel, _control, value, _status, _group) { const beta = alpha / 32; const deck = KAOSSDJ.getDeckByChannel(channel); const deckNumber = deck.deckNumber; - const deckPlaying = engine.getValue("[Channel" + deckNumber + "]", "play_latched"); + const deckPlaying = engine.getValue(`[Channel${deckNumber}]`, "play_latched"); // If in scratch mode or not playing enable vinyl-like control if (deck.jogWheelsInScratchMode || !deckPlaying) { @@ -150,7 +150,7 @@ KAOSSDJ.wheelTurn = function(channel, _control, value, _status, _group) { if (engine.isScratching(deckNumber)) { engine.scratchTick(deckNumber, newValue); } else { - engine.setValue("[Channel" + deckNumber + "]", "jog", newValue); // Pitch bend + engine.setValue(`[Channel${deckNumber}]`, "jog", newValue); // Pitch bend } }; @@ -191,19 +191,18 @@ KAOSSDJ.fxKnob = function(_channel, _control, _value, _status) { KAOSSDJ.fxTouchMoveVertical = function(_channel, _control, value, _status, _group) { Object.values(KAOSSDJ.decks) .filter(deck => deck.fx) - .forEach(deck => engine.setValue("[EffectRack1_EffectUnit" + deck.deckNumber + "]", "mix", value / 127)); + .forEach(deck => engine.setValue(`[EffectRack1_EffectUnit${deck.deckNumber}]`, "mix", value / 127)); }; KAOSSDJ.fxTouchMoveHorizontal = function(_channel, _control, value, _status, _group) { Object.values(KAOSSDJ.decks) .filter(deck => deck.fx) - .forEach(deck => engine.setValue("[EffectRack1_EffectUnit" + deck.deckNumber + "]", "super1", value / 127)); + .forEach(deck => engine.setValue(`[EffectRack1_EffectUnit${deck.deckNumber}]`, "super1", value / 127)); }; KAOSSDJ.fxTouch = function(channel, _control, value, _status, _group) { if (value === MIDI_OFF) { - const deck = KAOSSDJ.getDeckByChannel(channel); - const fxGroup = "[EffectRack1_EffectUnit" + deck.deckNumber + "]"; + const fxGroup = "[EffectRack1_EffectUnit${deck.deckNumber}]"; engine.setValue(fxGroup, "mix", 0); engine.setValue(fxGroup, "super1", 0); } @@ -312,7 +311,7 @@ KAOSSDJ.fxTouchMoveVerticalShift = function(_channel, _control, value, _status, const deck = KAOSSDJ.decks[0]; if (deck.fx) { const val = script.absoluteLin(value, 0, 1, 0, 127); - engine.setValue("[QuickEffectRack1_" + deck.group + "]", "super1", val); + engine.setValue(`[QuickEffectRack1_${deck.group}]`, "super1", val); } }; @@ -321,6 +320,6 @@ KAOSSDJ.fxTouchMoveHorizontalShift = function(_channel, _control, value, _status const deck = KAOSSDJ.decks[1]; if (deck.fx) { const val = script.absoluteLin(value, 0, 1, 0, 127); - engine.setValue("[QuickEffectRack1_" + deck.group + "]", "super1", val); + engine.setValue(`[QuickEffectRack1_${deck.group}]`, "super1", val); } }; From ac7e5d673eac87b16a3bf32f0594039d0e0e4f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 4 Feb 2024 10:54:09 +0100 Subject: [PATCH 16/23] Rename fx to isFx --- res/controllers/Korg-KAOSS-DJ-scripts.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index e675f882a64..380abb534c1 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -59,7 +59,7 @@ KAOSSDJ.deck = function(deckNumber) { this.deckNumber = deckNumber; this.group = `[Channel${deckNumber}]`; this.jogWheelsInScratchMode = true; - this.fx = false; + this.isFx = false; }; KAOSSDJ.decks = []; @@ -190,13 +190,13 @@ KAOSSDJ.fxKnob = function(_channel, _control, _value, _status) { KAOSSDJ.fxTouchMoveVertical = function(_channel, _control, value, _status, _group) { Object.values(KAOSSDJ.decks) - .filter(deck => deck.fx) + .filter(deck => deck.isFx) .forEach(deck => engine.setValue(`[EffectRack1_EffectUnit${deck.deckNumber}]`, "mix", value / 127)); }; KAOSSDJ.fxTouchMoveHorizontal = function(_channel, _control, value, _status, _group) { Object.values(KAOSSDJ.decks) - .filter(deck => deck.fx) + .filter(deck => deck.isFx) .forEach(deck => engine.setValue(`[EffectRack1_EffectUnit${deck.deckNumber}]`, "super1", value / 127)); }; @@ -309,7 +309,7 @@ KAOSSDJ.tapButtonCallback = function(_channel, _control, value, _status, _group) // + : control super knob of QuickEffectRack for deck 1 KAOSSDJ.fxTouchMoveVerticalShift = function(_channel, _control, value, _status, _group) { const deck = KAOSSDJ.decks[0]; - if (deck.fx) { + if (deck.isFx) { const val = script.absoluteLin(value, 0, 1, 0, 127); engine.setValue(`[QuickEffectRack1_${deck.group}]`, "super1", val); } @@ -318,7 +318,7 @@ KAOSSDJ.fxTouchMoveVerticalShift = function(_channel, _control, value, _status, // + : control super knob of QuickEffectRack for deck 2 KAOSSDJ.fxTouchMoveHorizontalShift = function(_channel, _control, value, _status, _group) { const deck = KAOSSDJ.decks[1]; - if (deck.fx) { + if (deck.isFx) { const val = script.absoluteLin(value, 0, 1, 0, 127); engine.setValue(`[QuickEffectRack1_${deck.group}]`, "super1", val); } From bde8811c4a5ff1ecda346367daf541fcf43ef953 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 4 Feb 2024 11:07:37 +0100 Subject: [PATCH 17/23] Remove redundant Object.values() --- res/controllers/Korg-KAOSS-DJ-scripts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 380abb534c1..1cca913d8df 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -72,13 +72,13 @@ for (let i = 0; i < 4; i++) { // TODO: currently only 2 decks supported. is 4 po KAOSSDJ.sendAllKnobLeds = function(state) { Object.values(MIDI_MAIN_KNOB_LEDS) .forEach(led => midi.sendShortMsg(MIDI_CHANNELS.KNOB_MAIN, led, state)); - Object.values([MIDI_CHANNELS.KNOB_LEFT, MIDI_CHANNELS.KNOB_RIGHT]) + [MIDI_CHANNELS.KNOB_LEFT, MIDI_CHANNELS.KNOB_RIGHT] .forEach(channel => Object.values(MIDI_DECK_KNOB_LEDS).forEach( led => midi.sendShortMsg(channel, led, state))); }; KAOSSDJ.sendAllButtonLeds = function(state) { - Object.values([MIDI_CHANNELS.BUTTON_LEFT, MIDI_CHANNELS.BUTTON_RIGHT]) + [MIDI_CHANNELS.BUTTON_LEFT, MIDI_CHANNELS.BUTTON_RIGHT] .forEach(channel => Object.values(MIDI_DECK_BUTTON_LEDS).forEach( led => midi.sendShortMsg(channel, led, state))); From 7e9abd8eb34ecc833ebb2cb7324d5196e18d5fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 4 Feb 2024 11:09:45 +0100 Subject: [PATCH 18/23] Inline loopEnabled --- res/controllers/Korg-KAOSS-DJ-scripts.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 1cca913d8df..df2c86255e1 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -211,10 +211,9 @@ KAOSSDJ.fxTouch = function(channel, _control, value, _status, _group) { // use loop-button to deactivate an active loop or initialize a beatloop at the current playback position KAOSSDJ.toggleLoop = function(channel, _control, value, _status, _group) { const deck = KAOSSDJ.getDeckByChannel(channel); - const loopEnabled = engine.getValue(deck.group, "loop_enabled"); if (value === MIDI_ON) { - if (loopEnabled) { + if (engine.getValue(deck.group, "loop_enabled")) { engine.setValue(deck.group, "reloop_exit", true); engine.setValue(deck.group, "beatloop_activate", false); } else { From 18e81999b7f2bb32898b7ea23308abc7a1907321 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 4 Feb 2024 11:18:26 +0100 Subject: [PATCH 19/23] Update comment --- res/controllers/Korg-KAOSS-DJ-scripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index df2c86255e1..1bb96e4c8c0 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -224,7 +224,7 @@ KAOSSDJ.toggleLoop = function(channel, _control, value, _status, _group) { // : load track -// + : open/close folder in file-browser +// + : Move library left/right KAOSSDJ.loadCallback = function(channel, _control, value, _status, _group) { const deck = KAOSSDJ.getDeckByChannel(channel); if (value === MIDI_ON) { From ab7690da78377202b3ab8d6225fba71914c6aa6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 4 Feb 2024 14:03:24 +0100 Subject: [PATCH 20/23] Use single quotes Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> --- res/controllers/Korg-KAOSS-DJ-scripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 1bb96e4c8c0..226dc552ea3 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -202,7 +202,7 @@ KAOSSDJ.fxTouchMoveHorizontal = function(_channel, _control, value, _status, _gr KAOSSDJ.fxTouch = function(channel, _control, value, _status, _group) { if (value === MIDI_OFF) { - const fxGroup = "[EffectRack1_EffectUnit${deck.deckNumber}]"; + const fxGroup = `[EffectRack1_EffectUnit${deck.deckNumber}]`; engine.setValue(fxGroup, "mix", 0); engine.setValue(fxGroup, "super1", 0); } From b5e78de02c8f09c937fac6661466752795a6a6f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 4 Feb 2024 14:36:25 +0100 Subject: [PATCH 21/23] fix error 'deck' is not defined Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> --- res/controllers/Korg-KAOSS-DJ-scripts.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index 226dc552ea3..eca844553fa 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -200,11 +200,10 @@ KAOSSDJ.fxTouchMoveHorizontal = function(_channel, _control, value, _status, _gr .forEach(deck => engine.setValue(`[EffectRack1_EffectUnit${deck.deckNumber}]`, "super1", value / 127)); }; -KAOSSDJ.fxTouch = function(channel, _control, value, _status, _group) { +KAOSSDJ.fxTouch = function(channel, _control, value, _status, group) { if (value === MIDI_OFF) { - const fxGroup = `[EffectRack1_EffectUnit${deck.deckNumber}]`; - engine.setValue(fxGroup, "mix", 0); - engine.setValue(fxGroup, "super1", 0); + engine.setValue(group, "mix", 0); + engine.setValue(group, "super1", 0); } }; From 6543c80ea764b785763c65247788254e8c621340 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Sun, 4 Feb 2024 14:37:43 +0100 Subject: [PATCH 22/23] Fix xml mappings Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> --- res/controllers/Korg-KAOSS-DJ.midi.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/res/controllers/Korg-KAOSS-DJ.midi.xml b/res/controllers/Korg-KAOSS-DJ.midi.xml index f7dbbc66b15..eaab8360f8b 100644 --- a/res/controllers/Korg-KAOSS-DJ.midi.xml +++ b/res/controllers/Korg-KAOSS-DJ.midi.xml @@ -631,6 +631,7 @@ [Channel1] KAOSSDJ.fxTouch + [EffectRack1_EffectUnit1] Fx Control 0x97 0x20 @@ -641,6 +642,7 @@ [Channel2] KAOSSDJ.fxTouch + [EffectRack1_EffectUnit2] Fx Control 0x98 0x20 From da49233a9e3e1f37ac9a1d6e05b77ef6a15eec50 Mon Sep 17 00:00:00 2001 From: pitscher Date: Thu, 15 Feb 2024 21:11:24 +0100 Subject: [PATCH 23/23] feat: implement fxknob --- res/controllers/Korg-KAOSS-DJ-scripts.js | 29 +++++++++++++++++++++--- res/controllers/Korg-KAOSS-DJ.midi.xml | 2 +- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/res/controllers/Korg-KAOSS-DJ-scripts.js b/res/controllers/Korg-KAOSS-DJ-scripts.js index eca844553fa..0430127cfd5 100644 --- a/res/controllers/Korg-KAOSS-DJ-scripts.js +++ b/res/controllers/Korg-KAOSS-DJ-scripts.js @@ -181,11 +181,34 @@ KAOSSDJ.scratchMode = function(channel, _control, value, _status, _group) { }; KAOSSDJ.fxToggleButton = function(channel, _control, value, _status, _group) { - KAOSSDJ.updateDeckByChannel(channel, "fx", value === MIDI_ON); + KAOSSDJ.updateDeckByChannel(channel, "isFx", value === MIDI_ON); }; -KAOSSDJ.fxKnob = function(_channel, _control, _value, _status) { - // TODO +KAOSSDJ.fxKnob = function(_channel, _control, value, _status, _group) { + if (KAOSSDJ.shiftLeftPressed) { + // If Left Shift is pressed, cycle the effects chains on EffectUnit1 + if (value === MIDI_UP) { + engine.setValue("[EffectRack1_EffectUnit1]", "next_chain", 1); + } else if (value === MIDI_DOWN) { + engine.setValue("[EffectRack1_EffectUnit1]", "prev_chain", 1); + } + } else if (KAOSSDJ.shiftRightPressed) { + // If Right Shift is not pressed, cycle the effects chains on EffectUnit2 + if (value === MIDI_UP) { + engine.setValue("[EffectRack1_EffectUnit2]", "next_chain", 1); + } else if (value === MIDI_DOWN) { + engine.setValue("[EffectRack1_EffectUnit2]", "prev_chain", 1); + } + } else { + // If no shift is pressed, cycle through both QuickEffectRack filters + if (value === MIDI_UP) { + engine.setValue("[QuickEffectRack1_[Channel1]]", "next_chain", 1); + engine.setValue("[QuickEffectRack1_[Channel2]]", "next_chain", 1); + } else if (value === MIDI_DOWN) { + engine.setValue("[QuickEffectRack1_[Channel1]]", "prev_chain", 1); + engine.setValue("[QuickEffectRack1_[Channel2]]", "prev_chain", 1); + } + } }; KAOSSDJ.fxTouchMoveVertical = function(_channel, _control, value, _status, _group) { diff --git a/res/controllers/Korg-KAOSS-DJ.midi.xml b/res/controllers/Korg-KAOSS-DJ.midi.xml index eaab8360f8b..2d7d9133ad2 100644 --- a/res/controllers/Korg-KAOSS-DJ.midi.xml +++ b/res/controllers/Korg-KAOSS-DJ.midi.xml @@ -625,7 +625,7 @@ 0xB6 0x1F - +