mixxxdj / mixxx

Mixxx is Free DJ software that gives you everything you need to perform live mixes.
http://mixxx.org
Other
4.52k stars 1.28k forks source link

Traktor Kontrol S3 mapping failing since update to 2.4 #12834

Closed zebebop closed 9 months ago

zebebop commented 9 months ago

Bug Description

Hi,

My NI Kontrol S3 mapping doesn't work and is disabled since v2.4 update. Tested on Macbook (intel) MacOS Bigsur and Apple Studio (M2) Sonoma, same results > FAIL.

"Uncaught exception: file:///Applications/Mixxx.app/Contents/Resources/controllers/Traktor-Kontrol-S3-hid-scripts.js:295: TypeError: Property 'from' of object function Uint8Array() { [native code] } is not a function Backtrace: registerInputPackets@file:///Applications/Mixxx.app/Contents/Resources/controllers/Traktor-Kontrol-S3-hid-scripts.js:295 @file:///Applications/Mixxx.app/Contents/Resources/controllers/Traktor-Kontrol-S3-hid-scripts.js:2610"

ni_kontrol_s3_fail

Version

2.4

OS

MacOS Bigsur (Intel) & Sonoma (ARM)

zebebop commented 9 months ago

I have tested my Traktor S3 mapping on a Linux Mint desktop with Mixxx v2.4 and there is no problems. Perhaps a specific Macos Failure...

Capture d’écran du 2024-02-17 18-40-03

JoergAtGithub commented 9 months ago

Could you try if it helps to replace the lines https://github.com/mixxxdj/mixxx/blob/ca8720f8f365853bb80e23714ed89e41b54d536a/res/controllers/Traktor-Kontrol-S3-hid-scripts.js#L290-L303 by the following code:

        // Set each InputReport to the bitwise inverted state first,
        // and than apply the non-inverted initial state.
        // This is done, because the common-hid-packet-parser only triggers
        // the callback functions in case of a delta to the previous data.
        for (let inputReportIdx = 0x01; inputReportIdx <= 0x02; ++inputReportIdx) {
            const reportData = new Uint8Array(controller.getInputReport(inputReportIdx));

            this.incomingData([inputReportIdx, ...reportData.map(x => ~x)]);
            this.incomingData([inputReportIdx, ...reportData]);
        }
zebebop commented 9 months ago

Hi, I applied the code patch but it does not work with a slightly different error message. Does version 2.3 that I reinstalled in parallel work well with the v2.3 mapping of my S3? It's really weird, as if on macos there wasn't "the right version of a framework" or something else like that... which fits with the new version of the S3 mapping JS script from v2. 4. This is just a hypothesis, I'm not a coder. Thanks.

v24_code_patch_vscodium

v24_code_patch_result

JoergAtGithub commented 9 months ago

Can you try

        // Set each InputReport to the bitwise inverted state first,
        // and than apply the non-inverted initial state.
        // This is done, because the common-hid-packet-parser only triggers
        // the callback functions in case of a delta to the previous data.
        for (let inputReportIdx = 0x01; inputReportIdx <= 0x02; ++inputReportIdx) {
            const reportData = new Uint8Array(controller.getInputReport(inputReportIdx));

            TraktorS3.incomingData([inputReportIdx, ...reportData.map(x => ~x)]);
            TraktorS3.incomingData([inputReportIdx, ...reportData]);
        }
zebebop commented 9 months ago

Yes ! It seems to work now. In all, there are no more error messages or deactivation of the mapping. I don't have time to test everything, I have 2 elves to manage today ;) If a few people from the community could validate the patch too that would be cool. In any case, a big thank you to you. Best regards.

JoergAtGithub commented 9 months ago

Great! Does Mixxx read out the correct knob and fader positions at startup? This is what this code section implements.

zebebop commented 9 months ago

Mixxx takes into account the initial positions for the volume sliders A,B,C and D as well as the position of the cross fade. On the other hand, it does not take into account the 2 tempo sliders. I put 1 at the top and the other at the bottom, mixxx saw them both in the middle.

JoergAtGithub commented 9 months ago

Does this work on your Linux Mint system, with the original code?

zebebop commented 9 months ago

I complete it more precisely, all positions are taken into account when starting Mixxx (Gain, EQ x3, FX and Vol) all except the tempo sliders ! For linux ubuntu I was so focused on the disabled mapping problem of S3 that I didn't pay attention... I'll look a little later and let you know. ++

JoergAtGithub commented 9 months ago

Great! Thanks for testing! I guess this is because the tempo-sliders are mapped to work relative and not absolute - can be configured at the top of the mapping file btw.: https://github.com/mixxxdj/mixxx/blob/d7a769ba4a0753861a3cadab1c592ca953326b60/res/controllers/Traktor-Kontrol-S3-hid-scripts.js#L54-L67

zebebop commented 9 months ago

Next, I confirm that a change from True to False allows the pitch fader to take the correct value when starting Mixx and to be able to use the entire scaling range, great!

On Linux Ubuntu, Traktor S3 is recognized directly without applying the patch above. On the other hand, same problem for the pitch fader. So just like on Macos, you just have to change it from True to False! And it's good :)

Edit in SUDO mode of the file at this location: "/usr/share/mixxx/controllers/Traktor-Kontrol-S3-hid-scripts.js"

67 TraktorS3.PitchSliderRelativeMode = true; >>> TraktorS3.PitchSliderRelativeMode = false;

JoergAtGithub commented 9 months ago

The fix is merged into 2.4 branch and will be part of Mixxx 2.4.1. Thanks for reporting and especially testing!