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

(WIP) Mapping for the Traktor Kontrol Z2 #3038

Draft
wants to merge 842 commits into
base: 2.5
Choose a base branch
from

Conversation

JoergAtGithub
Copy link
Member

@JoergAtGithub JoergAtGithub commented Aug 23, 2020

New HID mapping for the Native Instrument Kontrol Z2 mixer.

Note: This mapping requires features from 2.4 or Main branch and can not work with 2.2 or 2.3 builds!

The Documentation PR is mixxxdj/manual#236
Link to the Preview of the Z2 Mapping-Manual: https://deploy-preview-236--mixxx-manual.netlify.app/hardware/controllers/native_instruments_traktor_kontrol_z2.html

@ywwg
Copy link
Member

ywwg commented Aug 23, 2020

cool thanks for basing this on my refactored js :). hopefully it's easier to maintain and debug.

@JoergAtGithub
Copy link
Member Author

It's my first HID mapping, therfore I can't compare. It was easy to get all the knobs and buttons to work, but the LED lights do not show reproduceable behaviour yet.

@ywwg
Copy link
Member

ywwg commented Aug 23, 2020

on the s3, I found that the outgoing HID messages have to be exactly the right length for them to work. I used usblyzer to sniff the outgoing packets from traktor.

@JoergAtGithub
Copy link
Member Author

I could get nearly all LEDs to work, except the last one (an LED in a 7segment display). I'ts byte 95 of a packet of 95 bytes. I get always the following error message (German windows settings):

Debug [Controller]: HID TraktorZ2: debugLights
Debug [Controller]: HID 2

Debug [Controller]: HID i 0 70,70,70,70,70,00,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,FF,00,00,FF,00,00,00,00,00,00,00,00,34,34,34,00,
00,34,00,FF,00,00,00,34,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,70,
Debug [Controller]: HID 95

Debug [Controller]: HID 128 95

Warning [Controller]: Unable to send data to "Traktor Kontrol Z2 13EA_4" serial # "C86013EA" : "Der angegebene Benutzerpuffer ist für den angeforderten Vorgang
nicht zulässig."

Debug [Controller]: HID i 1 FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF,FF
Debug [Controller]: HID 41

Debug [Controller]: HID 129 41

Debug [Controller]: 95 bytes sent to Traktor Kontrol Z2 13EA_4 serial # C86013EA (including report ID of 129 )
Debug [Controller]: HID TraktorZ2: Init done!

If I reduce the size to 94 bytes, the other LEDs can be controlled

TraktorZ2.shutdown = function() {
// Deactivate all LEDs
var dataStrings = [
" 00 00 00 00 00 00 00 00 00 00 00 00 00 00 " +
Copy link
Member

Choose a reason for hiding this comment

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

there is a bug in this code (that was in my code too-- if you have leading spaces, the first item in the list is an empty string so that byte does get set

Copy link
Member

Choose a reason for hiding this comment

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

the fix is to eliminate leading spaces in your strings

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank's for poiting to this! This is the shutdown code, which I've to rework anyway. Currently I'm working on debugLights.

The shutdown code for the Z2 will be tricky anyway, because of the concept of seamless switching between internal and external mixing mode. The idea is:
-At the end of your DJ set, switch one channel from internal to external mixing mode and play an analog vinyl
-DJ1 disconnects his laptop -> Shutdown code must not interfere the music
-DJ2 connects his laptop -> Init code must not interfere the music
-Switch the deck with the analog vinyl back to internal mixing mode

Therefore I will have to decide LED by LED if the shutdown code should reset it, or if the LED represents a still active state.

data[i].length = splitted.length;
for (var j = 0; j < splitted.length; j++) {
var byteStr = splitted[j];
if (byteStr.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

this line will get activated

HIDDebug(splitted.length + "\n");
for (var j = 0; j < splitted.length; j++) {
var byteStr = splitted[j];
if (byteStr.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

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

Add hiddebug here to make sure this isn't happening

@ywwg
Copy link
Member

ywwg commented Aug 24, 2020

looks like a low-level HID error message. I'm not sure why the 95th byte makes it blow up.

@uklotzde uklotzde added this to the 2.3.0 milestone Aug 27, 2020
@JoergAtGithub
Copy link
Member Author

@vbatts
Copy link

vbatts commented Aug 30, 2020

Related work (by the op) for the LEDs on this same board: #3051

@JoergAtGithub
Copy link
Member Author

This will not go into 2.3, because this mapping can't work without #3051, which is targeted for 2.4.

@JoergAtGithub JoergAtGithub changed the base branch from 2.3 to master September 14, 2020 12:14
Copy link
Member

@Holzhaus Holzhaus left a comment

Choose a reason for hiding this comment

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

Thank you.

There are code-style issues. Please click the "Details" link for Travis CI below this PR and check the output of the pre-commit job.

Also, starting with Mixxx 2.3, all controller mappings are now supposed to be documented in the Manual. This is necessary so that other users know how to use this mapping. We also need it to review it properly and check if the mapping makes sense and if the code matches the documentation.

Please fork the mixxxdj/manual repository, check out the manual-2.3.x branch and add documentation to the source/hardware/controllers directory. Open the pull request and add the link to the PR description.

Here's an example how such documentation could look like: https://manual.mixxx.org/2.3/en/hardware/controllers/roland_dj_505.html (If you don't have schematic images and don't want to draw them yourself, just use the same numbering as in the controller's manual and document the buttons like that).

res/controllers/Traktor Kontrol Z2.hid.xml Outdated Show resolved Hide resolved
res/controllers/Traktor Kontrol Z2.hid.xml Outdated Show resolved Hide resolved
<name>Traktor Kontrol Z2</name>
<author>Jörg Wartenberg (based on the Traktor S3 mapping by Owen Williams)</author>
<description>HID Mapping for Traktor Kontrol Z2</description>
<wiki>http://mixxx.org/wiki/doku.php/traktor_z2</wiki>
Copy link
Member

Choose a reason for hiding this comment

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

Please use a github wiki link

Copy link
Member Author

Choose a reason for hiding this comment

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

1.) I removed the link to the non-existing wiki page at all.
2.) I added a link to the manual, and it points to the 2.3 manual, but this PR is rebased to master.

@Holzhaus
Copy link
Member

Pre-commit issues:

codespell................................................................Failed
- hook id: codespell
- exit code: 1
res/controllers/Traktor-Kontrol-Z2-hid-scripts.js:829: inbetween ==> between, in between
res/controllers/Traktor-Kontrol-Z2-hid-scripts.js:1155: swiched ==> switched
eslint...................................................................Failed
- hook id: eslint
- exit code: 1
/home/travis/build/mixxxdj/mixxx/res/controllers/Traktor-Kontrol-Z2-hid-scripts.js
  12:1  error  Parsing error: The keyword 'const' is reserved
✖ 1 problem (1 error, 0 warnings)

@Tim19801
Copy link

Hi, thanks for the mapping. I've tried the setting under Mixxx 2.3 and older versions under Ubuntu. I didn't have luck so far. Mixxx sees the controller and I can indicate which channels I want to use (so it mus recognize my soundcard under the Kontrol Z2 in some sort of way) but it only sends audio over the master output.

I can't control anything either. Maybe I can also check the template under Windows.
In the manual it says the Kontrol Z2 is USB compliant and automatically recognized in Linux but I don't have any luck with it.

Could someone please point me in the right direction? Thanks! Tim

@JoergAtGithub
Copy link
Member Author

The soundcard is independent from this mapping for Buttons, Knobs, Faders and LEDs.
If you can select Traktor Z2 as Audio source, than the operating system has recognized the soundcard. The soundcard settings should be:
grafik
grafik

@JoergAtGithub
Copy link
Member Author

Mixxx 2.3.0 is not sufficient for this mapping. To use this mapping, you need a recent build of the Master tree containing the PR #3051 .

The controller mapping must be selected manually:
grafik

@JoergAtGithub
Copy link
Member Author

Please continue general discussions about Mixxx and the Traktor Z2 here: https://mixxx.zulipchat.com/#narrow/stream/113295-controller-mapping/topic/Traktor.20Kontrol.20Z2

@Be-ing Be-ing changed the base branch from master to main October 23, 2020 23:11
@Tim19801
Copy link

Please continue general discussions about Mixxx and the Traktor Z2 here: https://mixxx.zulipchat.com/#narrow/stream/113295-controller-mapping/topic/Traktor.20Kontrol.20Z2

Thank you for the help so far. Sorry for the late responseI think I'll try to get the controller to work in Windows first with the suggested mapping. Will report back on the above link if it also Worked under Linux. I also need to read a tutorial on how to pull the pr in Mixxx. Don't have experience with that so need to sort that out first ;-)

@JoergAtGithub
Copy link
Member Author

You don't need to build Mixxx yourself, to test this. The CI systems build this automatically for each PR.
To get a Windows download of any PR, click on the continuous-integration/appveyor/pr Details-Link at the bottom of the PR -> Visual Studio 2017... -> Artifacts
In general, this controller mapping contains nothing platform specific. It should run on Linux, MacOS and Windows. The only important thing is, that you use a recent build of the Main development tree.

@JoergAtGithub JoergAtGithub force-pushed the Traktor-Z2-2.3 branch 2 times, most recently from cce8330 to fd485b0 Compare November 1, 2020 20:55
@Tim19801
Copy link

Tim19801 commented Nov 1, 2020

You don't need to build Mixxx yourself, to test this. The CI systems build this automatically for each PR.
To get a Windows download of any PR, click on the continuous-integration/appveyor/pr Details-Link at the bottom of the PR -> Visual Studio 2017... -> Artifacts
In general, this controller mapping contains nothing platform specific. It should run on Linux, MacOS and Windows. The only important thing is, that you use a recent build of the Main development tree.

Hi Joerg,

Thanks for your time to help me out. Sorry for my late responses. Very busy lately. I'm on Linux right now and not Windows. What I tried to do is clone everything and install it. But it indicates there's no makefile. Can imagine cause I don't think it's complete. I'm absolutely not experienced with GIT. I'll try to sort this out when I'm back on Windows. Or I'll just patiently wait for a new version of Mixxx where the Kontrol Z2 is integrated and will learn a thing or two about GIT in the mean time. I'm not sure I follow your explanation; To get a Windows download of any PR, click on the continuous-integration/appveyor/pr Details-Link at the bottom of the PR -> Visual Studio 2017... -> Artifacts but will check it out when I reinstalled Windows on my laptop. Will let you know if I make progress and have tested this. The Z2 seems a very difficult card on Linux. Didn't have luck with it either on xwax so far and it must be USB compliant. Anyway.. thanks. Tim

@Holzhaus
Copy link
Member

Holzhaus commented Nov 1, 2020

Please open a thread on Zulip chat. We can help you with git and compiling on Linux. The PR discussion is not the right place for that.

@Tim19801
Copy link

Tim19801 commented Nov 2, 2020

Sorry for that. Will pay attention to it from now on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In progress
Development

Successfully merging this pull request may close these issues.