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

Denon MC7000: Add optional jog wheel acceleration to the controller mapping #4684

Merged
merged 8 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Comment on lines +94 to +99
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess for the jog the input-latency matters. Because for the output-latency we have an undocumented CO: engine.getValue("[App]", "output_latency_ms").

// Acceleration settings for the jog wheel in vinyl mode
// If enabled, the track speed will accelerate faster than the physical jogheel 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 jogheel 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