Skip to content

[WiP] Traktor S4 MK2 controller updates#1562

Closed
fayaaz wants to merge 7 commits intomixxxdj:masterfrom
fayaaz:kontrol-s4-mappings
Closed

[WiP] Traktor S4 MK2 controller updates#1562
fayaaz wants to merge 7 commits intomixxxdj:masterfrom
fayaaz:kontrol-s4-mappings

Conversation

@fayaaz
Copy link
Copy Markdown
Contributor

@fayaaz fayaaz commented Mar 25, 2018

Pull request for updates to S4 MK2. WiP.

@fayaaz fayaaz changed the title Traktor S4 MK2 controller updates [WiP] Traktor S4 MK2 controller updates Mar 25, 2018
Copy link
Copy Markdown
Member

@ywwg ywwg left a comment

Choose a reason for hiding this comment

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

There are a few things going on in this PR which makes it harder to know which parts relate to which other parts. If possible I'd prefer to split out the part that displays the loop size because I'd like to make sure that's written in a way that is easier to understand and reuse in the future.

for (k = 0; k < 0x7F; k+=0x05) {
packets[0] = 0x82;
for (j = 0; j < sizesArray[beats].length; j++) {
var hid_msg = start_signal + sizesArray[beats][j]
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hid_msg is only used on the next line so it's ok to inline there

}
start_signal = LoopSizeIndicators[group]

var sizesArray = {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't suppose it's possible to mark this const somehow?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

QtScript 4.8 doesn't support such modern JavaScript keywords.

var hid_msg = start_signal + sizesArray[beats][j]
packets[hid_msg] = k;
}
controller.send(packets, packets.length, 0);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

indent this line please

4: [9,10,11,13],
2: [9,11,12,14,15],
}
var packets = Object();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think it would be safer to declare this object inside the loop so there's no risk of stale data getting reused

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IMO using the Object() constructor is odd. I'd prefer an empty object literal {} instead. But this is a really minor point. If you disagree you can leave it as is.

start_signal = LoopSizeIndicators[group]

var sizesArray = {
64: [1,2,4,5,6,7,9,10,11,13],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are these arrays for lighting specific segments of the LED display? I'd prefer a general function that can display arbitrary integers for easier reading/testing and possible future reuse.

@ywwg
Copy link
Copy Markdown
Member

ywwg commented Mar 25, 2018

sweet! Can you take pictures or a short video of the new features in action? I don't have an S4 (I borrowed one to make the mapping) so I can't test it myself.

@Be-ing Be-ing changed the base branch from master to 2.1 March 25, 2018 22:47
@Be-ing Be-ing changed the base branch from 2.1 to master March 25, 2018 22:47
Copy link
Copy Markdown
Contributor

@Be-ing Be-ing left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! Could you rebase this on the 2.1 branch?

TraktorS4MK2.controller.shift_pressed['deck1'] ||
TraktorS4MK2.controller.shift_pressed['deck2']
) {
if(delta > 0){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

style nitpick: put space after if:
if (delta > 0) {

) {
if(delta > 0){
engine.setValue(group, 'beats_translate_later', true);
} else if (delta < 0){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

} else if (delta < 0) {

engine.setValue(group, 'beats_translate_earlier', true);
}
}
else {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

combine with line above: } else {

engine.setValue(field.group, "loop_halve", 0);
}
}
// TraktorS4MK2.sendLoopSizeMessage(group, engine.getValue(field.group, "beatloop_size"));
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Connect changes in beatloop_size to an output callback function instead of sending the update to the controller when input is received. The former makes sure that the controller stays in sync even if the user changes beatloop_size by clicking on screen.

engine.setValue("[Master]", "maximize_library", !library_maximized);
}

TraktorS4MK2.FXButtonHandler = function(field){
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In the future this should work the same as the Components EffectUnit, but that will be quite a bit of work and I don't know if you can do that in the next few days for 2.1. For now, just getting the enable buttons and metaknobs working would be good. Are you still having trouble with the metaknobs?

@Be-ing Be-ing added this to the 2.1.0 milestone Mar 26, 2018
} else if (value === 0.125){
TraktorS4MK2.sendLoopSizeMessage(deck, '-', 8, false, false);
} else {
TraktorS4MK2.sendLoopSizeMessage(deck, '-', 'n', false, false);
Copy link
Copy Markdown
Contributor

@Be-ing Be-ing Mar 27, 2018

Choose a reason for hiding this comment

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

It's great that you got this working! One of my main motivations for adding beatloop_size in #1187 was to support controllers like this, so I'm really glad this can be in the same Mixxx release.

If you use the dot instead of - to indicate a fraction, you could use both digits of the display for fractional sizes. This is how it is done on the Hercules P32. The code could also be more robust by showing the reciprocal of the loop size (1 / value) instead of checking for specific fractions. How does Traktor show fractional loop sizes?

Copy link
Copy Markdown
Contributor Author

@fayaaz fayaaz Mar 27, 2018

Choose a reason for hiding this comment

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

I'm not sure about Traktor, I haven't actually used it except for with the S2 (for a limited period of time) which doesn't have a loop counter.

Noted - although not sure how to make the code more robust with the fractions.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Try checking if 1/value is an integer. If it is, show that on the LEDs with a dot.

@fayaaz
Copy link
Copy Markdown
Contributor Author

fayaaz commented Mar 27, 2018

Summary of changes:

  • Loop Counter now works
  • Shift + Gain moves the beatgrid
  • Reset button resets the key
  • FX Buttons 1, 2 and 3 turn on and off the FX (toggle)
  • Holding shift with the FX button cycles through Effects on the Effect unit
  • FX meta knobs work
  • Snap button gives a fullscreen library
  • Shift + Browse lets you move through the left hand pane in the library
  • Loop Recorder record button repurposed for recording mix
  • Shift + nudging the wheel while the deck is not playing allows fast search through loaded track

}
// deal with larger Loops
} else if (value.toString().length > 2){
TraktorS4MK2.sendLoopSizeMessage(deck, value.toString().split("")[0], value.toString().split("")[1], true, true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe light up both dots in this case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That is what is happening here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, I see. Sorry, I didn't look at the code close enough before.

@Be-ing
Copy link
Copy Markdown
Contributor

Be-ing commented Mar 28, 2018

You may want to map the new reloop_andstop Control to shift + loop in or shift + loop out.

@Be-ing
Copy link
Copy Markdown
Contributor

Be-ing commented Mar 30, 2018

@fayaaz I have rebased this branch on 2.1 and merged it with the 2.1 branch. If you have time to continue working on this before the 2.1 release, please open a new pull request targeting that branch. Otherwise, you can open a new PR targeted at the master branch after the 2.1 release.

@Be-ing Be-ing closed this Mar 30, 2018
@Be-ing
Copy link
Copy Markdown
Contributor

Be-ing commented Mar 30, 2018

Could you update the wiki page for this controller?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants