Skip to content

Commit c2c475d

Browse files
committed
Add pitch play mode (WIP) (untested)
1 parent bec97da commit c2c475d

File tree

1 file changed

+157
-1
lines changed

1 file changed

+157
-1
lines changed

res/controllers/Reloop-Ready-scripts.js

+157-1
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,18 @@ ReloopReady.midiToFullColor = function(color) {
6666
};
6767

6868
ReloopReady.padColorPalette = {
69+
Off: 0x000000,
6970
Red: 0xFF0000,
7071
Green: 0x00FF00,
7172
Blue: 0x0000FF,
7273
Yellow: 0xFFFF00,
7374
Cyan: 0x007FFF,
7475
Purple: 0xFF00FF,
76+
White: 0xFFFFFF,
77+
};
78+
79+
ReloopReady.dimColor = function(color) {
80+
return color & 0x3F; // dim color by stripping the "intensity bit"
7581
};
7682

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

8995
ReloopReady.padColorPalette = _.mapValues(ReloopReady.padColorPalette, function(color) {
9096
var litColor = ReloopReady.padColorMapper.getValueForNearestColor(color);
91-
var dimColor = litColor & 0x3F; // dim color by stripping the "intensity bit"
97+
var dimColor = ReloopReady.dimColor(litColor);
9298
return {
9399
lit: litColor,
94100
dim: dimColor,
@@ -635,6 +641,156 @@ ReloopReady.LoopRollPadMode = function(index) {
635641
ReloopReady.LoopRollPadMode.prototype = Object.create(ReloopReady.PadMode.prototype);
636642

637643

644+
// Pitch Play mode taken from Roland DJ 505 mapping.
645+
ReloopReady.Pitch = function(index) {
646+
components.ComponentContainer.call(this);
647+
648+
var PitchPlayRange = {
649+
UP: 0,
650+
MID: 1,
651+
DOWN: 2,
652+
};
653+
654+
//this.ledControl = DJ505.PadMode.SAMPLER;
655+
var color = ReloopReady.padColorPalette.Purple;
656+
var cuepoint = 1;
657+
var range = PitchPlayRange.MID;
658+
var theContainer = this;
659+
660+
this.PerformancePad = function(n) {
661+
this.midi = [0x94 + index, 0x14 + n];
662+
this.number = n + 1;
663+
this.on = ReloopReady.padColorPalette.Purple.dim;
664+
this.colorMapper = ReloopReady.ColorMapper;
665+
this.colorKey = "hotcue_" + this.number + "_color";
666+
components.Button.call(this);
667+
};
668+
this.PerformancePad.prototype = new components.Button({
669+
shiftOffset: 8,
670+
group: "[Channel" + (index + 1) + "]",
671+
outConnect: false,
672+
off: ReloopReady.padColorPalette.Off.lit,
673+
outputColor: function(colorCode) {
674+
// For colored hotcues (shifted only)
675+
var midiColor = this.colorMapper.getValueForNearestColor(colorCode);
676+
this.send((cuepoint === this.number) ? midiColor : ReloopReady.dimColor(midiColor));
677+
},
678+
unshift: function() {
679+
this.outKey = "pitch_adjust";
680+
this.output = function(_value, _group, _control) {
681+
var midiColor = color.dim;
682+
if ((range === PitchPlayRange.UP && this.number === 5) ||
683+
(range === PitchPlayRange.MID && this.number === 1) ||
684+
(range === PitchPlayRange.DOWN && this.number === 4)) {
685+
midiColor = ReloopReady.padColorPalette.White.lit;
686+
}
687+
this.send(midiColor);
688+
};
689+
this.input = function(_channel, _control, value, _status, _group) {
690+
var pitchAdjust = (function() {
691+
switch (range) {
692+
case PitchPlayRange.UP:
693+
return this.number + ((this.number <= 4) ? 4 : -5);
694+
case PitchPlayRange.MID:
695+
return this.number - ((this.number <= 4) ? 1 : 9);
696+
case PitchPlayRange.DOWN:
697+
return this.number - ((this.number <= 4) ? 4 : 12);
698+
}
699+
})();
700+
engine.setValue(this.group, "pitch_adjust", pitchAdjust);
701+
engine.setValue(this.group, "hotcue_" + cuepoint + "_activate", value);
702+
};
703+
this.connect = function() {
704+
components.Button.prototype.connect.call(this); // call parent connect
705+
706+
if (this.connections[1] !== undefined) {
707+
// Necessary, since trigger() apparently also triggers disconnected connections
708+
this.connections.pop();
709+
}
710+
};
711+
if (this.connections[0] !== undefined) {
712+
this.disconnect();
713+
this.connect();
714+
this.trigger();
715+
}
716+
},
717+
shift: function() {
718+
this.outKey = "hotcue_" + this.number + "_enabled";
719+
this.output = function(value, _group, _control) {
720+
var outval = this.outValueScale(value);
721+
if (this.colorKey !== undefined && outval !== this.off) {
722+
this.outputColor(engine.getValue(this.group, this.colorKey));
723+
} else {
724+
this.send(ReloopReady.padColorPalette.Off.lit);
725+
}
726+
};
727+
this.input = function(_channel, _control, value, _status, _group) {
728+
if (value > 0 && cuepoint !== this.number && engine.getValue(this.group, "hotcue_" + this.number + "_enabled")) {
729+
var previousCuepoint = cuepoint;
730+
cuepoint = this.number;
731+
theContainer.pads[previousCuepoint - 1].trigger();
732+
this.outputColor(engine.getValue(this.group, this.colorKey));
733+
}
734+
};
735+
this.connect = function() {
736+
components.Button.prototype.connect.call(this); // call parent connect
737+
if (undefined !== this.group && this.colorKey !== undefined) {
738+
this.connections[1] = engine.makeConnection(this.group, this.colorKey, function(id) {
739+
if (engine.getValue(this.group, this.outKey)) {
740+
this.outputColor(id);
741+
}
742+
});
743+
}
744+
};
745+
if (this.connections[0] !== undefined) {
746+
this.disconnect();
747+
this.connect();
748+
this.trigger();
749+
}
750+
},
751+
});
752+
this.pads = new components.ComponentContainer();
753+
for (var n = 0; n <= 7; n++) {
754+
this.pads[n] = new this.PerformancePad(n);
755+
}
756+
757+
this.parameterLeft = new components.Button({
758+
midi: [0x94 + index, 0x28],
759+
shiftOffset: 0x2,
760+
input: ReloopReady.makeButtonDownInputHandler(function() {
761+
if (range === PitchPlayRange.UP) {
762+
range = PitchPlayRange.MID;
763+
} else if (range === PitchPlayRange.MID) {
764+
range = PitchPlayRange.DOWN;
765+
} else {
766+
range = PitchPlayRange.UP;
767+
}
768+
theContainer.forEachComponent(function(component) {
769+
component.trigger();
770+
});
771+
}),
772+
});
773+
this.parameterRight = new components.Button({
774+
midi: [0x94 + index, 0x29],
775+
shiftOffset: 0x2,
776+
input: ReloopReady.makeButtonDownInputHandler(function() {
777+
if (range === PitchPlayRange.UP) {
778+
range = PitchPlayRange.DOWN;
779+
} else if (range === PitchPlayRange.MID) {
780+
range = PitchPlayRange.UP;
781+
} else {
782+
range = PitchPlayRange.MID;
783+
}
784+
theContainer.forEachComponent(function(component) {
785+
component.trigger();
786+
});
787+
}),
788+
});
789+
};
790+
791+
ReloopReady.Pitch.prototype = Object.create(ReloopReady.PadMode.prototype);
792+
793+
638794
// There is no such thing as a scratch bank in Mixxx so I'm repurpusing this
639795
// PadMode for beatjumping.
640796
ReloopReady.ScratchBankPadMode = function(index) {

0 commit comments

Comments
 (0)