Skip to content

Commit

Permalink
Controller - Hercules DJControl Jogvision:
Browse files Browse the repository at this point in the history
- Minor code-style changes (use caleCase, use "double quotes" and other if/else styles)
  • Loading branch information
David TV committed Jan 16, 2020
1 parent 15ec1ef commit dff8912
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 52 deletions.
88 changes: 42 additions & 46 deletions res/controllers/Hercules_DJControl_Jogvision-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// ****************************************************************************
// * Mixxx mapping script file for the Hercules DJControl Jogvision.
// * Author: DJ Phatso, contributions by Kerrick Staley and David TV
// * Version 1.6 (January 2020)
// * Version 1.5 (January 2020)
// * Version 1.4 (December 2019)
// * Version 1.3 (November 2019)
Expand All @@ -17,6 +18,9 @@
// * Wiki: https://www.mixxx.org/wiki/doku.php/hercules_dj_control_jogvision
//
// Changes to v1.5
// - Minor code-style changes (use caleCase, use "double quotes" and other if/else styles)
//
// Changes to v1.5
// - Fixed regression not updating the VuMeters
// - Fixed regression not updating the CUE/MIX buttons
//
Expand All @@ -26,8 +30,8 @@
// part of the track, but before the "end of track" Mixxx signal
//
// Changes to v1.3
// - Enabled the creation of beatloop (beatloop_activate) by using SHIFT+LoopON
// - Changed "LOOP SIZE" to adjust the beatjump_size (you still can change size
// - Enabled the creation of beatloop (beatloopActivate) by using SHIFT+LoopON
// - Changed "LOOP SIZE" to adjust the beatjumpSize (you still can change size
// with surrounding buttons: reloop_toggle key)
// - Added SHIFT+"LOOP SIZE" to move loop left or right by N beats (beatjump)
//
Expand All @@ -37,7 +41,7 @@
//
// Changes to v1.1
// - Controller knob/slider values are queried on startup, so MIXXX is synced.
// - Fixed vinyl button behavior the first time it's pressed.
// - Fixed vinyl button behavior the first time it"s pressed.
//
// v1.0 : Original release
//
Expand All @@ -55,17 +59,17 @@ var DJCJV = {};

DJCJV.vinylModeActive = true;
DJCJV.Channel = [];
DJCJV.Channel['[Channel1]'] = { "central": 0x90, "deck": 0xB0, "beatPosition": 1, "rotation": 0x00, "n": 1 };
DJCJV.Channel['[Channel2]'] = { "central": 0x91, "deck": 0xB1, "beatPosition": 1, "rotation": 0x00, "n": 2 };
DJCJV.Channel["[Channel1]"] = { "central": 0x90, "deck": 0xB0, "beatPosition": 1, "rotation": 0x00, "n": 1 };
DJCJV.Channel["[Channel2]"] = { "central": 0x91, "deck": 0xB1, "beatPosition": 1, "rotation": 0x00, "n": 2 };

// Initialization
DJCJV.init = function(id) {

print("Hercules DJControl Jogvision id: \""+id+"\" initializing...");

//Set all LED states to off
midi.sendShortMsg(DJCJV.Channel['[Channel1]'].deck, 0x7F, off);
midi.sendShortMsg(DJCJV.Channel['[Channel2]'].deck, 0x7F, off);
midi.sendShortMsg(DJCJV.Channel["[Channel1]"].deck, 0x7F, off);
midi.sendShortMsg(DJCJV.Channel["[Channel2]"].deck, 0x7F, off);

// Set Vinyl button LED On.
midi.sendShortMsg(masterLeds, 0x45, on);
Expand All @@ -76,8 +80,7 @@ DJCJV.init = function(id) {
if (engine.getValue("[Master]", "headMix") > 0.5) {
midi.sendShortMsg(masterLeds, 0x4C, on); // headset "Mix" button LED
midi.sendShortMsg(masterLeds, 0x4D, off);
}
else {
} else {
midi.sendShortMsg(masterLeds, 0x4C, off);
midi.sendShortMsg(masterLeds, 0x4D, on); // headset "Cue" button LED
}
Expand Down Expand Up @@ -113,21 +116,21 @@ DJCJV.init = function(id) {
engine.connectControl ("[Channel2]", "stop", "DJCJV.beatInactive");

// Set inner jog leds to 0
midi.sendShortMsg(DJCJV.Channel['[Channel1]'].deck, 0x61, 0);
midi.sendShortMsg(DJCJV.Channel['[Channel2]'].deck, 0x61, 0);
midi.sendShortMsg(DJCJV.Channel["[Channel1]"].deck, 0x61, 0);
midi.sendShortMsg(DJCJV.Channel["[Channel2]"].deck, 0x61, 0);
//// Set outer jog leds to 0
midi.sendShortMsg(DJCJV.Channel['[Channel1]'].deck, 0x60, 1);
midi.sendShortMsg(DJCJV.Channel['[Channel2]'].deck, 0x60, 1);
midi.sendShortMsg(DJCJV.Channel["[Channel1]"].deck, 0x60, 1);
midi.sendShortMsg(DJCJV.Channel["[Channel2]"].deck, 0x60, 1);

// Enable wheels' outer leds rotation by timer (when channel is playing)
// Enable wheels" outer leds rotation by timer (when channel is playing)
ledRotationTimer = engine.beginTimer(20, function() {
if (engine.getValue('[Channel1]', "play") === 1) {
midi.sendShortMsg(DJCJV.Channel['[Channel1]'].deck, 0x60, DJCJV.Channel['[Channel1]'].rotation);
DJCJV.Channel['[Channel1]'].rotation = DJCJV.Channel['[Channel1]'].rotation >= 127 ? 1 : DJCJV.Channel['[Channel1]'].rotation + ledRotationSpeed;
if (engine.getValue("[Channel1]", "play") === 1) {
midi.sendShortMsg(DJCJV.Channel["[Channel1]"].deck, 0x60, DJCJV.Channel["[Channel1]"].rotation);
DJCJV.Channel["[Channel1]"].rotation = DJCJV.Channel["[Channel1]"].rotation >= 127 ? 1 : DJCJV.Channel["[Channel1]"].rotation + ledRotationSpeed;
}
if (engine.getValue('[Channel2]', "play") === 1) {
midi.sendShortMsg(DJCJV.Channel['[Channel2]'].deck, 0x60, DJCJV.Channel['[Channel2]'].rotation);
DJCJV.Channel['[Channel2]'].rotation = DJCJV.Channel['[Channel2]'].rotation >= 127 ? 1 : DJCJV.Channel['[Channel2]'].rotation + ledRotationSpeed;
if (engine.getValue("[Channel2]", "play") === 1) {
midi.sendShortMsg(DJCJV.Channel["[Channel2]"].deck, 0x60, DJCJV.Channel["[Channel2]"].rotation);
DJCJV.Channel["[Channel2]"].rotation = DJCJV.Channel["[Channel2]"].rotation >= 127 ? 1 : DJCJV.Channel["[Channel2]"].rotation + ledRotationSpeed;
}
});

Expand All @@ -140,8 +143,8 @@ DJCJV.init = function(id) {
// Finalization
DJCJV.shutdown = function() {
//Set all LED states to off
midi.sendShortMsg(DJCJV.Channel['[Channel1]'].deck, 0x7F, off);
midi.sendShortMsg(DJCJV.Channel['[Channel2]'].deck, 0x7F, off);
midi.sendShortMsg(DJCJV.Channel["[Channel1]"].deck, 0x7F, off);
midi.sendShortMsg(DJCJV.Channel["[Channel2]"].deck, 0x7F, off);
if (ledRotationTimer) {
engine.stopTimer(ledRotationTimer);
ledRotationTimer = 0;
Expand Down Expand Up @@ -175,14 +178,12 @@ DJCJV.wheelInnerUpdate = function(value, group, control) {
var playPos = value * 127;
midi.sendShortMsg(DJCJV.Channel[group].deck, 0x61, playPos);
if (engine.getValue(group, "end_of_track")) {
// Let Mixxx's engine turn flashing red automatically
// Let Mixxx"s engine turn flashing red automatically
return;
}
else if (playPos > 64) {
} else if (playPos > 64) {
// Turn "track" led to orange if position is beyond the half
midi.sendShortMsg(DJCJV.Channel[group].central, 0x45, 0x02);
}
else {
} else {
// Turn "track" led to green if position is in the first half
midi.sendShortMsg(DJCJV.Channel[group].central, 0x45, 0x07);
}
Expand All @@ -202,43 +203,41 @@ DJCJV.headCue = function(midino, control, value, status, group) {
}
};
DJCJV.headMix = function(midino, control, value, status, group) {
if(engine.getValue(group, "headMix") != 1) {
if(engine.getValue(group, "headMix") !== 1) {
engine.setValue(group, "headMix", 0);
midi.sendShortMsg(masterLeds, 0x4D, 0x00);
midi.sendShortMsg(masterLeds, 0x4C, 0x7f);
}
};

// Filter (Hercules' AIR FX)
// Filter (Hercules" AIR FX)
DJCJV.Filter = function(channel, control, value, status, group) {
engine.setValue(group, "super1", 0.5 - value / 255);
};

// Loop section
// SHIFT + Loop ON creates a loop at given point
DJCJV.beatloop_activate = function(channel, control, value, status, group) {
DJCJV.beatloopActivate = function(channel, control, value, status, group) {
engine.setValue(group, "beatloop_activate", value === 0 ? 0 : 1);
};

// SHIFT+FX(Loop) Knob MOVES the existing loop one beat forward/backward
DJCJV.beatjump_move = function(channel, control, value, status, group) {
DJCJV.beatjumpMove = function(channel, control, value, status, group) {
if (value > 64) {
engine.setValue(group, "beatjump_backward", 1);
engine.setValue(group, "beatjump_backward", 0);
}
else {
} else {
engine.setValue(group, "beatjump_forward", 1);
engine.setValue(group, "beatjump_forward", 0);
}
};
// FX(Loop) Knob changes the AMOUNT of beats to move the loop when requested
DJCJV.beatjump_size = function(channel, control, value, status, group) {
var currentValue = engine.getValue(group, "beatjump_size");
DJCJV.beatjumpSize = function(channel, control, value, status, group) {
var currentValue = engine.getValue(group, "beatjumpSize");
if (value > 64) {
engine.setValue(group, "beatjump_size", currentValue /= 2);
}
else {
engine.setValue(group, "beatjump_size", currentValue *= 2);
engine.setValue(group, "beatjumpSize", currentValue /= 2);
} else {
engine.setValue(group, "beatjumpSize", currentValue *= 2);
}
};

Expand All @@ -251,8 +250,7 @@ DJCJV.vinylButton = function(channel, control, value, status, group) {
if (DJCJV.vinylModeActive) {
DJCJV.vinylModeActive = false;
midi.sendShortMsg(masterLeds, 0x46, off);
}
else {
} else {
DJCJV.vinylModeActive = true;
midi.sendShortMsg(masterLeds, 0x46, on);
}
Expand All @@ -262,8 +260,7 @@ DJCJV.vinylButton = function(channel, control, value, status, group) {
DJCJV.wheelTouch = function(channel, control, value, status, group) {
if (value > 0 && (engine.getValue(group, "play") !== 1 || DJCJV.vinylModeActive)) {
engine.scratchEnable(DJCJV.Channel[group].n, 400, 33 + 1 / 3, alpha, beta); // Touching the wheel
}
else {
} else {
engine.scratchDisable(DJCJV.Channel[group].n); // Released the wheel
}
};
Expand All @@ -272,13 +269,12 @@ DJCJV.wheelTouch = function(channel, control, value, status, group) {
DJCJV.scratchWheel = function(channel, control, value, status, group) {
if (engine.isScratching(DJCJV.Channel[group].n)) {
engine.scratchTick(DJCJV.Channel[group].n, (value >= 64) ? value - 128 : value); // Scratch!
}
else {
} else {
DJCJV.bendWheel(channel, control, value, status, group); // Pitch bend
}
};

// Bending by either using the side of wheel, or with the Job surface when not in vinyl-mode
DJCJV.bendWheel = function(channel, control, value, status, group) {
engine.setValue(group, 'jog', (value >= 64) ? value - 128 : value); // Pitch bend
engine.setValue(group, "jog", (value >= 64) ? value - 128 : value); // Pitch bend
};
12 changes: 6 additions & 6 deletions res/controllers/Hercules_DJControl_Jogvision.midi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
</control>
<control>
<group>[Channel1]</group>
<key>DJCJV.beatloop_activate</key>
<key>DJCJV.beatloopActivate</key>
<description>Beatloop activate button</description>
<status>0x90</status>
<midino>0x09</midino>
Expand Down Expand Up @@ -640,7 +640,7 @@
</control>
<control>
<group>[Channel2]</group>
<key>DJCJV.beatloop_activate</key>
<key>DJCJV.beatloopActivate</key>
<description>Beatloop activate button</description>
<status>0x91</status>
<midino>0x09</midino>
Expand Down Expand Up @@ -1137,7 +1137,7 @@
<!-- LOOP section -->
<control>
<group>[Channel1]</group>
<key>DJCJV.beatjump_size</key>
<key>DJCJV.beatjumpSize</key>
<description>Loop Size</description>
<status>0xB0</status>
<midino>0x44</midino>
Expand All @@ -1147,7 +1147,7 @@
</control>
<control>
<group>[Channel1]</group>
<key>DJCJV.beatjump_move</key>
<key>DJCJV.beatjumpMove</key>
<description>Move Loop By N Beats</description>
<status>0xB0</status>
<midino>0x4A</midino>
Expand Down Expand Up @@ -1304,7 +1304,7 @@
<!-- LOOP section -->
<control>
<group>[Channel2]</group>
<key>DJCJV.beatjump_size</key>
<key>DJCJV.beatjumpSize</key>
<description>Loop Size</description>
<status>0xB1</status>
<midino>0x44</midino>
Expand All @@ -1314,7 +1314,7 @@
</control>
<control>
<group>[Channel2]</group>
<key>DJCJV.beatjump_move</key>
<key>DJCJV.beatjumpMove</key>
<description>Move Loop By N Beats</description>
<status>0xB1</status>
<midino>0x4A</midino>
Expand Down

0 comments on commit dff8912

Please sign in to comment.