Skip to content

Commit

Permalink
MC7000: Add optional/configurable jog wheel acceleration
Browse files Browse the repository at this point in the history
Cherry-picked from mixxxdj#4684
  • Loading branch information
fwcd committed Aug 22, 2024
1 parent 47be184 commit 94e5c6f
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 10 deletions.
40 changes: 30 additions & 10 deletions res/controllers/Denon-MC7000-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,26 @@ MC7000.scratchParams = {
beta: (1.0/10)/32
};

// Sensitivity factor of the jog wheel (also depends on audio latency)
// 0.5 for half, 2 for double sensitivity - Recommendation:
// set to 0.5 with audio buffer set to 50ms
// set to 1 with audio buffer set to 25ms
// set to 3 with audio buffer set to 5ms
MC7000.jogSensitivity = 1;

// Jog wheel parameters
MC7000.jogParams = {
// Sensitivity factor of the jog wheel (also depends on audio latency)
// 0.5 for half, 2 for double sensitivity - Recommendation:
// set to 0.5 with audio buffer set to 50ms
// set to 1 with audio buffer set to 25ms
// set to 3 with audio buffer set to 5ms
sensitivity: engine.getSetting("jogSensitivity") || 1,
// Acceleration settings for the jog wheel in vinyl mode
// If enabled, the track speed will accelerate faster than the physical jogwheel movement. Be aware that the absolute track position will drift relative to the jogwheel position in this mode!
// (exponent: 0 and coefficient: 1 = no acceleration)
acceleration: {
// Toggles acceleration entirely.
enabled: engine.getSetting("jogAccelerationEnabled") || false,
// Acceleration function exponent
exponent: engine.getSetting("jogAccelerationExponent") || 0.8,
// Acceleration function scaling factor
coefficient: engine.getSetting("jogAccelerationCoefficient") || 1
}
};

/*/////////////////////////////////
// USER VARIABLES END //
Expand Down Expand Up @@ -705,7 +718,8 @@ MC7000.wheelTurn = function(channel, control, value, status, group) {

// A: For a control that centers on 0:
const numTicks = (value < 0x64) ? value : (value - 128);
const adjustedSpeed = numTicks * MC7000.jogSensitivity / 10;
const baseSpeed = numTicks * MC7000.jogParams.sensitivity;
const adjustedSpeed = baseSpeed / 10;
const deckNumber = script.deckFromGroup(group);
const deckIndex = deckNumber - 1;
const libraryMaximized = engine.getValue("[Skin]", "show_maximized_library");
Expand All @@ -714,8 +728,14 @@ MC7000.wheelTurn = function(channel, control, value, status, group) {
} else if (libraryMaximized === 1 && numTicks < 0) {
engine.setValue("[Library]", "MoveUp", 1);
} else if (engine.isScratching(deckNumber)) {
// Scratch!
engine.scratchTick(deckNumber, numTicks * MC7000.jogSensitivity);
// Scratch!
let scratchSpeed = baseSpeed;
const acceleration = MC7000.jogParams.acceleration;
if (acceleration && acceleration.enabled) {
const accelerationFactor = Math.pow(Math.abs(baseSpeed), acceleration.exponent) * acceleration.coefficient;
scratchSpeed *= accelerationFactor;
}
engine.scratchTick(deckNumber, scratchSpeed);
} else {
if (MC7000.shift[deckIndex]) {
// While Shift Button pressed -> Search through track
Expand Down
57 changes: 57 additions & 0 deletions res/controllers/Denon-MC7000.midi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,63 @@
<wiki>https://github.com/mixxxdj/mixxx/wiki/Denon-MC7000</wiki>
<manual>denon_mc7000</manual>
</info>
<settings>
<group label="Jogwheels">
<group label="General">
<option
variable="jogSensitivity"
type="real"
min="0.05"
max="10.0"
default="1.0"
label="Jogwheel sensitivity">
<description>
Sensitivity factor of the jog wheel (also depends on audio latency)
0.5 for half, 2 for double sensitivity - Recommendation:
set to 0.5 with audio buffer set to 50ms
set to 1 with audio buffer set to 25ms
set to 3 with audio buffer set to 5ms
</description>
</option>
</group>
<group label="Acceleration">
<option
variable="jogAccelerationEnabled"
type="boolean"
default="false"
label="Enable jogwheel acceleration">
<description>
If enabled, the track speed will accelerate faster than the physical jogwheel movement. Be aware that the absolute track position will drift relative to the jogwheel position in this mode!
(exponent: 0 and coefficient: 1 = no acceleration)
</description>
</option>
<option
variable="jogAccelerationExponent"
type="real"
min="0"
max="20.0"
default="0.8"
step="0.1"
label="Acceleration exponent">
<description>
The exponent of the acceleration curve
</description>
</option>
<option
variable="jogAccelerationCoefficient"
type="real"
min="0.05"
max="20.0"
step="0.1"
default="1.0"
label="Acceleration coefficient">
<description>
The scaling factor of the acceleration curve
</description>
</option>
</group>
</group>
</settings>
<controller id="DENON MC7000">
<scriptfiles>
<file filename="Denon-MC7000-scripts.js" functionprefix="MC7000"/>
Expand Down

0 comments on commit 94e5c6f

Please sign in to comment.