From 2308bfdeab1e9e85898fded4aa5805108959b591 Mon Sep 17 00:00:00 2001 From: Marc Monka Date: Wed, 19 Nov 2025 12:36:34 +0100 Subject: [PATCH] Pitch slider modification Arduino sends now LSB / MSB to have 14 bit resolution for the pitch slider. Mapping modified. We have now tempo increments of 0,01%. --- arduino/XDJ100SX.ino | 38 +++++++++++++++++++++++++++++++++--- mixxx/MIDI/XDJ100SX.js | 32 ++++++++++++++++++++++++++++-- mixxx/MIDI/XDJ100SX.midi.xml | 23 +++++++++++++++++----- 3 files changed, 83 insertions(+), 10 deletions(-) diff --git a/arduino/XDJ100SX.ino b/arduino/XDJ100SX.ino index a6931db..eb4c9d0 100644 --- a/arduino/XDJ100SX.ino +++ b/arduino/XDJ100SX.ino @@ -41,15 +41,25 @@ elapsedMillis debounceTime_browse; // Temps per filtrar rebots browse¡ Encoder browse(browseA_pin, browseB_pin); long lastPosition_browse = 0; // Última posició llegida -//Pitch slider old +elapsedMillis msec = 0; + + +/* Pitch slider old const int pitch_pin = A0; const int channel_pitch = 3; const int controllerA0 = 7; int previousA0 = -1; -elapsedMillis msec = 0; ResponsiveAnalogRead analog(pitch_pin, true); +*/ +//Pitch new + +const int pitchPin = A0; +ResponsiveAnalogRead analog(pitchPin, true); +int lastMSB = -1; +int lastLSB = -1; + // MIDI OUT - Leds @@ -375,7 +385,7 @@ long newPosition_browse = browse.read(); } } -//Pitch +/* Pitch old if (msec >= 100){ msec = 0; int n0 = analogRead(A0) / 8; @@ -385,6 +395,28 @@ if (msec >= 100){ previousA0 = n0; } } +*/ + +//Pitch 14 bits + +analog.update(); + int raw = analog.getValue(); // valor ja suavitzat + + int value14 = map(raw, 0, 1023, 0, 16383); + + byte msb = (value14 >> 7) & 0x7F; + byte lsb = value14 & 0x7F; + + if (msb != lastMSB) { + usbMIDI.sendControlChange(0, msb, 1); + lastMSB = msb; + } + + if (lsb != lastLSB) { + usbMIDI.sendControlChange(32, lsb, 1); + lastLSB = lsb; + } + diff --git a/mixxx/MIDI/XDJ100SX.js b/mixxx/MIDI/XDJ100SX.js index fac377f..d1afa58 100644 --- a/mixxx/MIDI/XDJ100SX.js +++ b/mixxx/MIDI/XDJ100SX.js @@ -324,8 +324,8 @@ XDJ100SX.cue = function (channel, control, value, status, group){ } - -//Pitch Slider +/* +//Pitch Slider old XDJ100SX.pitchLast = 0; @@ -350,6 +350,34 @@ XDJ100SX.pitch = function (channel, control, value, status, group) { engine.setValue(group, "rate", normalized); } }; +*/ + + + +// Pitch slider new + + +XDJ100SX.pitchMSB = 0; +XDJ100SX.pitchLSB = 0; + +XDJ100SX.pitch = function (channel, control, value, status, group) { + + if (control === 0) { // MSB + XDJ100SX.pitchMSB = value; + } else if (control === 32) { // LSB + XDJ100SX.pitchLSB = value; + } + + // Combinar MSB + LSB + var full = (XDJ100SX.pitchMSB << 7) | XDJ100SX.pitchLSB; // 0–16383 + + // Convertir a rang de Mixxx (-1.0 .. +1.0) + var normalized = - (full - 8192) / 8192; + + engine.setValue(group, "rate", normalized); +}; + + //Browse Encoder (scroll + canviar vista) diff --git a/mixxx/MIDI/XDJ100SX.midi.xml b/mixxx/MIDI/XDJ100SX.midi.xml index 703c62b..4bae985 100644 --- a/mixxx/MIDI/XDJ100SX.midi.xml +++ b/mixxx/MIDI/XDJ100SX.midi.xml @@ -9,16 +9,29 @@ - + + PITCH MSB [Channel1] XDJ100SX.pitch - PITCH - 0xB2 - 0x07 + 0xB0 + 0x00 - + + + [Channel1] + XDJ100SX.pitch + PITCH LSB + 0xB0 + 0x20 + + + + + + + [Channel1] play