Skip to content

Commit

Permalink
Mapping for Numark iDJ Live II
Browse files Browse the repository at this point in the history
  • Loading branch information
nkorth committed May 25, 2020
1 parent 4f484fd commit 8fc8a34
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 28 deletions.
16 changes: 15 additions & 1 deletion res/controllers/Numark iDJ Live II.midi.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<MixxxControllerPreset mixxxVersion="" schemaVersion="1">
<MixxxControllerPreset mixxxVersion="2.2.3" schemaVersion="1">
<info>
<name>Numark iDJ Live II</name>
<author>Nathan Korth</author>
Expand Down Expand Up @@ -320,6 +320,20 @@
<midino>0x4C</midino>
<minimum>0.5</minimum>
</output>
<output>
<group>[Channel1]</group>
<key>sync_enabled</key>
<status>0x90</status>
<midino>0x40</midino>
<minimum>0.5</minimum>
</output>
<output>
<group>[Channel2]</group>
<key>sync_enabled</key>
<status>0x90</status>
<midino>0x47</midino>
<minimum>0.5</minimum>
</output>
</outputs>
</controller>
</MixxxControllerPreset>
51 changes: 24 additions & 27 deletions res/controllers/Numark-iDJ-Live-II-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Numark.ledOff = function(control) {
};

Numark.init = function() {
this.touching = {
"[Channel1]": false,
"[Channel2]": false,
};
// tell controller to send current state of knobs and crossfader
midi.sendSysexMsg(this.sysex, this.sysex.length);
// change this line to toggle the default scratch mode:
Expand All @@ -45,11 +49,6 @@ Numark.init = function() {
} else {
this.ledOff(this.buttons["[Channel2]"].play);
}
// used for search mode
this.searchAccumulator = {
"[Channel1]": 0,
"[Channel2]": 0,
};
};

Numark.shutdown = function() {
Expand All @@ -70,51 +69,49 @@ Numark.toggleScratchMode = function() {
} else {
this.scratchMode = true;
this.ledOn(this.buttons.scratch);
this.searchAccumulator["[Channel1]"] = 0;
this.searchAccumulator["[Channel2]"] = 0;
}
};

Numark.jogTouch = function(_channel, _control, value, _status, group) {
if (!this.scratchMode) {
return;
}
var deckN = script.deckFromGroup(group);
if (value >= 64) {
var alpha = 1.0/8;
var beta = alpha/32;
engine.scratchEnable(deckN, this.jogResolution, 33+(1.0/3), alpha, beta);
this.touching[group] = true;
if (this.scratchMode) {
var alpha = 1.0/8;
var beta = alpha/32;
engine.scratchEnable(deckN, this.jogResolution, 33+(1.0/3), alpha, beta);
}
} else {
this.touching[group] = false;
engine.scratchDisable(deckN);
}
};

Numark.jog = function(_channel, _control, value, _status, group) {
if (!this.touching[group]) {
return;
}
// value is centered around 0
if (value >= 64) {
value -= 128;
}
var deckN = script.deckFromGroup(group);
if (this.scratchMode && engine.isScratching(deckN)) {
engine.scratchTick(deckN, value);
} else if (!this.scratchMode) {
if (this.scratchMode) {
if (engine.isScratching(deckN)) {
engine.scratchTick(deckN, value);
}
} else {
if (engine.getParameter(group, "play")) {
// pitch bend while playing
engine.setValue(group, "jog", value);
} else {
// search while paused
var threshold = this.jogResolution / 32; // 32 beats per rev
var acc = Numark.searchAccumulator[group];
acc += value;
while (acc >= threshold) {
engine.setValue(group, "beatjump", 1);
acc -= threshold;
}
while (acc <= -threshold) {
engine.setValue(group, "beatjump", -1);
acc += threshold;
var position = engine.getValue(group, "playposition");
position += value * 0.0002;
if (position < 0) {
position = 0;
}
Numark.searchAccumulator[group] = acc;
engine.setValue(group, "playposition", position);
}
}
};

0 comments on commit 8fc8a34

Please sign in to comment.