Skip to content

Commit ea64ba4

Browse files
committed
S4 Mk3: compare scratch functions engine.scratch.. vs engine.setValue(group, "scratch2..")
1 parent 80fd83d commit ea64ba4

File tree

2 files changed

+43
-5
lines changed

2 files changed

+43
-5
lines changed

res/controllers/Traktor Kontrol S4 MK3.hid.xml

+10
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
</devices>
1111
</info>
1212
<settings>
13+
<group label="TEST scratch modes">
14+
<option
15+
variable="scratchModeScratchTick"
16+
type="boolean"
17+
default="false"
18+
label="Use 'engine.scratch..' functions">
19+
<description>Use 'engine.scratchEnable()/disable()' and 'engine.scratchTick()' instead of engine.setValue(group, "scratch2..")</description>
20+
</option>
21+
</group>
22+
1323
<group label="Deck Lighting">
1424
<row orientation="vertical">
1525
<option

res/controllers/Traktor-Kontrol-S4-MK3.js

+33-5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ const DefaultPadLayoutKeyboard = "keyboard";
4848
* Change settings in the preferences
4949
*/
5050

51+
// For testing: switch between engine.scratch.. functions and engine.setValue(.., "scratch2..")
52+
const useEngineScratch = !!engine.getSetting("scratchModeScratchTick");
53+
5154
const DeckColors = [
5255
LedColors[engine.getSetting("deckA")] || LedColors.red,
5356
LedColors[engine.getSetting("deckB")] || LedColors.blue,
@@ -117,6 +120,11 @@ const BeatLoopRolls = [
117120
// the motor if enable. Recommended value are 33 + 1/3 or 45.
118121
// Default: 33 + 1/3
119122
const BaseRevolutionsPerMinute = engine.getSetting("baseRevolutionsPerMinute") || 33 + 1/3;
123+
// alpha and beta are the recommended start values from
124+
// https://github.com/mixxxdj/mixxx/wiki/midi%20scripting#scratching-and-jog-wheels
125+
const ScratchAlpha = 1.0/8;
126+
const ScratchBeta = ScratchAlpha/32;
127+
const ScratchIntervalsPerRev = 6750;
120128

121129
// Define whether or not to use motors.
122130
// This is a BETA feature! Please use at your own risk. Setting this off means that below settings are inactive
@@ -2413,8 +2421,16 @@ class S4Mk3Deck extends Deck {
24132421
this.touched = touched;
24142422
if (this.deck.wheelMode === wheelModes.vinyl || this.deck.wheelMode === wheelModes.motor) {
24152423
if (touched) {
2416-
engine.setValue(this.group, "scratch2_enable", true);
2417-
} else {
2424+
if (useEngineScratch) {
2425+
engine.scratchEnable(this.deck.currentDeckNumber,
2426+
ScratchIntervalsPerRev,
2427+
BaseRevolutionsPerMinute,
2428+
ScratchAlpha,
2429+
ScratchBeta); // ramoing true by default
2430+
} else {
2431+
engine.setValue(this.group, "scratch2_enable", true);
2432+
}
2433+
} else { // release
24182434
this.stopScratchWhenOver();
24192435
}
24202436
}
@@ -2427,9 +2443,17 @@ class S4Mk3Deck extends Deck {
24272443
if (engine.getValue(this.group, "play") &&
24282444
engine.getValue(this.group, "scratch2") < 1.5 * baseRevolutionsPerSecond &&
24292445
engine.getValue(this.group, "scratch2") > 0) {
2430-
engine.setValue(this.group, "scratch2_enable", false);
2446+
if (useEngineScratch) {
2447+
engine.scratchDisable(this.deck.currentDeckNumber);
2448+
} else {
2449+
engine.setValue(this.group, "scratch2_enable", false);
2450+
}
24312451
} else if (engine.getValue(this.group, "scratch2") === 0) {
2432-
engine.setValue(this.group, "scratch2_enable", false);
2452+
if (useEngineScratch) {
2453+
engine.scratchDisable(this.deck.currentDeckNumber);
2454+
} else {
2455+
engine.setValue(this.group, "scratch2_enable", false);
2456+
}
24332457
} else {
24342458
engine.beginTimer(100, this.stopScratchWhenOver.bind(this), true);
24352459
}
@@ -2509,7 +2533,11 @@ class S4Mk3Deck extends Deck {
25092533
break;
25102534
case wheelModes.vinyl:
25112535
if (this.deck.wheelTouch.touched || engine.getValue(this.group, "scratch2") !== 0) {
2512-
engine.setValue(this.group, "scratch2", this.speed);
2536+
if (useEngineScratch) {
2537+
engine.scratchTick(this.deck.currentDeckNumber, diff);
2538+
} else {
2539+
engine.setValue(this.group, "scratch2", this.speed);
2540+
}
25132541
} else {
25142542
engine.setValue(this.group, "jog", this.speed);
25152543
}

0 commit comments

Comments
 (0)