Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ddj 200 support #3185

Merged
merged 13 commits into from
Oct 20, 2020
Prev Previous commit
Next Next commit
Changes according to pre-commit hook
  • Loading branch information
fkbreitl committed Oct 18, 2020
commit 91e2171702962d19c763149d6dcd7557549e08d0
2 changes: 1 addition & 1 deletion res/controllers/Pioneer DDJ-200.midi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@
<minimum>0.5</minimum>
</output>


<output>
<group>[Channel1]</group>
<key>hotcue_1_enabled</key>
Expand Down
37 changes: 22 additions & 15 deletions res/controllers/Pioneer-DDJ-200-scripts.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,35 @@
var DDJ200 = {
headMix_switch : 0
headMixSwitch: 0,
jogDisabled: new Array(false, false, false, false, false)
};

DDJ200.init = function () {};
DDJ200.init = function() {};

DDJ200.shutdown = function () {};
DDJ200.shutdown = function() {};

DDJ200.scratch = function (channel, control, value, status, group) {
DDJ200.scratch = function(channel, control, value, status, group) {
// For a control that centers on 0x40 (64):
// Convert value down to +1/-1
// Register the movement
engine.scratchTick(script.deckFromGroup(group), value - 64);
};

DDJ200.jog = function (channel, control, value, status, group) {
DDJ200.jog = function(channel, control, value, status, group) {
// For a control that centers on 0x40 (64):
// Convert value down to +1/-1
// Register the movement
engine.setValue(group, 'jog', value - 64);
var deckNumber = script.deckFromGroup(group);
if (DDJ200.jogDisabled[deckNumber]) { return; }
Holzhaus marked this conversation as resolved.
Show resolved Hide resolved
engine.setValue(group, "jog", value - 64);
};

DDJ200.touch = function (channel, control, value, status, group) {
DDJ200.touch = function(channel, control, value, status, group) {
var deckNumber = script.deckFromGroup(group);
if (value == 0) {
if (value === 0) {
// disable jog to not prevent alignment and enable it after 900 ms
DDJ200.jogDisabled[deckNumber] = true;
engine.beginTimer(900, "DDJ200.jogDisabled["+deckNumber+"] = false;",
true);
// disable scratch
engine.scratchDisable(deckNumber);
} else {
Expand All @@ -32,7 +39,7 @@ DDJ200.touch = function (channel, control, value, status, group) {
}
};

DDJ200.seek = function (channel, control, value, status, group) {
DDJ200.seek = function(channel, control, value, status, group) {
var oldPos = engine.getValue(group, "playposition");
// Since ‘playposition’ is normalized to unity, we need to scale by
// song duration in order for the jog wheel to cover the same amount
Expand All @@ -42,12 +49,12 @@ DDJ200.seek = function (channel, control, value, status, group) {
engine.setValue(group, "playposition", newPos); // Strip search
};

DDJ200.headmix = function (channel, control, value) {
if (value == 0) { return; }
DDJ200.headMix_switch = 1 - DDJ200.headMix_switch;
DDJ200.headmix = function(channel, control, value) {
if (value === 0) { return; }
Holzhaus marked this conversation as resolved.
Show resolved Hide resolved
DDJ200.headMixSwitch = 1 - DDJ200.headMixSwitch;
// toggle headMix knob to values of -1 and 1
engine.setValue("[Master]", "headMix", 2 * DDJ200.headMix_switch - 1);
engine.setValue("[Master]", "headMix", 2 * DDJ200.headMixSwitch - 1);

// now switch headMix LED with midi.sendShortMsg(0x96, 0x63, 0x7F or 0);
midi.sendShortMsg(0x90+channel, control, 0x7F * DDJ200.headMix_switch);
midi.sendShortMsg(0x90+channel, control, 0x7F * DDJ200.headMixSwitch);
Holzhaus marked this conversation as resolved.
Show resolved Hide resolved
};