Skip to content

Commit

Permalink
Add pitch play mode (WIP) (untested)
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiftb0y committed Mar 13, 2023
1 parent bec97da commit c2c475d
Showing 1 changed file with 157 additions and 1 deletion.
158 changes: 157 additions & 1 deletion res/controllers/Reloop-Ready-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,18 @@ ReloopReady.midiToFullColor = function(color) {
};

ReloopReady.padColorPalette = {
Off: 0x000000,
Red: 0xFF0000,
Green: 0x00FF00,
Blue: 0x0000FF,
Yellow: 0xFFFF00,
Cyan: 0x007FFF,
Purple: 0xFF00FF,
White: 0xFFFFFF,
};

ReloopReady.dimColor = function(color) {
return color & 0x3F; // dim color by stripping the "intensity bit"
};

// IIFE for not leaking private variables
Expand All @@ -88,7 +94,7 @@ ReloopReady.padColorPalette = {

ReloopReady.padColorPalette = _.mapValues(ReloopReady.padColorPalette, function(color) {
var litColor = ReloopReady.padColorMapper.getValueForNearestColor(color);
var dimColor = litColor & 0x3F; // dim color by stripping the "intensity bit"
var dimColor = ReloopReady.dimColor(litColor);
return {
lit: litColor,
dim: dimColor,
Expand Down Expand Up @@ -635,6 +641,156 @@ ReloopReady.LoopRollPadMode = function(index) {
ReloopReady.LoopRollPadMode.prototype = Object.create(ReloopReady.PadMode.prototype);


// Pitch Play mode taken from Roland DJ 505 mapping.
ReloopReady.Pitch = function(index) {
components.ComponentContainer.call(this);

var PitchPlayRange = {
UP: 0,
MID: 1,
DOWN: 2,
};

//this.ledControl = DJ505.PadMode.SAMPLER;
var color = ReloopReady.padColorPalette.Purple;
var cuepoint = 1;
var range = PitchPlayRange.MID;
var theContainer = this;

this.PerformancePad = function(n) {
this.midi = [0x94 + index, 0x14 + n];
this.number = n + 1;
this.on = ReloopReady.padColorPalette.Purple.dim;
this.colorMapper = ReloopReady.ColorMapper;
this.colorKey = "hotcue_" + this.number + "_color";
components.Button.call(this);
};
this.PerformancePad.prototype = new components.Button({
shiftOffset: 8,
group: "[Channel" + (index + 1) + "]",
outConnect: false,
off: ReloopReady.padColorPalette.Off.lit,
outputColor: function(colorCode) {
// For colored hotcues (shifted only)
var midiColor = this.colorMapper.getValueForNearestColor(colorCode);
this.send((cuepoint === this.number) ? midiColor : ReloopReady.dimColor(midiColor));
},
unshift: function() {
this.outKey = "pitch_adjust";
this.output = function(_value, _group, _control) {
var midiColor = color.dim;
if ((range === PitchPlayRange.UP && this.number === 5) ||
(range === PitchPlayRange.MID && this.number === 1) ||
(range === PitchPlayRange.DOWN && this.number === 4)) {
midiColor = ReloopReady.padColorPalette.White.lit;
}
this.send(midiColor);
};
this.input = function(_channel, _control, value, _status, _group) {
var pitchAdjust = (function() {
switch (range) {
case PitchPlayRange.UP:
return this.number + ((this.number <= 4) ? 4 : -5);
case PitchPlayRange.MID:
return this.number - ((this.number <= 4) ? 1 : 9);
case PitchPlayRange.DOWN:
return this.number - ((this.number <= 4) ? 4 : 12);
}
})();
engine.setValue(this.group, "pitch_adjust", pitchAdjust);
engine.setValue(this.group, "hotcue_" + cuepoint + "_activate", value);
};
this.connect = function() {
components.Button.prototype.connect.call(this); // call parent connect

if (this.connections[1] !== undefined) {
// Necessary, since trigger() apparently also triggers disconnected connections
this.connections.pop();
}
};
if (this.connections[0] !== undefined) {
this.disconnect();
this.connect();
this.trigger();
}
},
shift: function() {
this.outKey = "hotcue_" + this.number + "_enabled";
this.output = function(value, _group, _control) {
var outval = this.outValueScale(value);
if (this.colorKey !== undefined && outval !== this.off) {
this.outputColor(engine.getValue(this.group, this.colorKey));
} else {
this.send(ReloopReady.padColorPalette.Off.lit);
}
};
this.input = function(_channel, _control, value, _status, _group) {
if (value > 0 && cuepoint !== this.number && engine.getValue(this.group, "hotcue_" + this.number + "_enabled")) {
var previousCuepoint = cuepoint;
cuepoint = this.number;
theContainer.pads[previousCuepoint - 1].trigger();
this.outputColor(engine.getValue(this.group, this.colorKey));
}
};
this.connect = function() {
components.Button.prototype.connect.call(this); // call parent connect
if (undefined !== this.group && this.colorKey !== undefined) {
this.connections[1] = engine.makeConnection(this.group, this.colorKey, function(id) {
if (engine.getValue(this.group, this.outKey)) {
this.outputColor(id);
}
});
}
};
if (this.connections[0] !== undefined) {
this.disconnect();
this.connect();
this.trigger();
}
},
});
this.pads = new components.ComponentContainer();
for (var n = 0; n <= 7; n++) {
this.pads[n] = new this.PerformancePad(n);
}

this.parameterLeft = new components.Button({
midi: [0x94 + index, 0x28],
shiftOffset: 0x2,
input: ReloopReady.makeButtonDownInputHandler(function() {
if (range === PitchPlayRange.UP) {
range = PitchPlayRange.MID;
} else if (range === PitchPlayRange.MID) {
range = PitchPlayRange.DOWN;
} else {
range = PitchPlayRange.UP;
}
theContainer.forEachComponent(function(component) {
component.trigger();
});
}),
});
this.parameterRight = new components.Button({
midi: [0x94 + index, 0x29],
shiftOffset: 0x2,
input: ReloopReady.makeButtonDownInputHandler(function() {
if (range === PitchPlayRange.UP) {
range = PitchPlayRange.DOWN;
} else if (range === PitchPlayRange.MID) {
range = PitchPlayRange.UP;
} else {
range = PitchPlayRange.MID;
}
theContainer.forEachComponent(function(component) {
component.trigger();
});
}),
});
};

ReloopReady.Pitch.prototype = Object.create(ReloopReady.PadMode.prototype);


// There is no such thing as a scratch bank in Mixxx so I'm repurpusing this
// PadMode for beatjumping.
ReloopReady.ScratchBankPadMode = function(index) {
Expand Down

0 comments on commit c2c475d

Please sign in to comment.