-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
DDJ-200: Listen to changes from mixxx #3793
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I left some comments.
@@ -36,6 +48,15 @@ DDJ200.init = function() { | |||
}, true); | |||
}; | |||
|
|||
DDJ200.listemHotcues = function(vgroup) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"listen"
Also, this method is only called in a single location, so I don't think it's needed at all and can just be I lined there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying just to make the code cleaner, now is inside init
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is listemHotcues supposed to mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was to listen Hotcues changes from mixxx interface and apply to the controller, but already removed the method.
DDJ200.switchHotcueLEDs(vDeckNo); | ||
}; | ||
|
||
DDJ200.switchHotcueLEDs = function(vDeckNo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, no need to put it a separate method if it's only used once. That just makes the code harder to follow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored this whole thing to switch only leds that actually changed
for (var i = 1; i <= 8; i++) { | ||
// run updateDeckLeds after every hotcue update | ||
engine.makeConnection(vgroup, "hotcue_" + i + "_enabled", function(ch, vgroup) { | ||
DDJ200.updateDeckLeds(vgroup); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like it sends a MIDI message for every hotcue when only one of them updates? That's inefficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I refactored this whole thing to switch only leds that actually changed
@fkbreitl @dan-giddins can one of you verify that this is working as intended? |
I refactored most of the code based on the code review, let me know if there's anything else I can improve. |
As a First-time contributor please also sign our contributor agreement and comment when done. |
Nice to see that there is a demand for supporting those popular entry-level controllers in Mixxx, even though they come with Rekordbox. Thanks for contributing your improvements. |
Agreement signed :) |
I started using mixxx before having a controller and I'm a developer and Linux user, those are some reasons to love mixxx and what to contribute. |
var vDeckNo = script.deckFromGroup(vgroup); | ||
var d = (vDeckNo % 2) ? 0 : 1; // d = deckNo - 1 | ||
DDJ200.switchPadLED(d, pad, ch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not use one-character variable names (except i
/j
for counters maybe) and go with something more meaningful:
var vDeckNo = script.deckFromGroup(vgroup); | |
var d = (vDeckNo % 2) ? 0 : 1; // d = deckNo - 1 | |
DDJ200.switchPadLED(d, pad, ch); | |
var deckNo = script.deckFromGroup(vgroup); | |
var deckOffset = (deckNo - 1) % 2; | |
DDJ200.switchPadLED(deckOffset, pad, ch); |
I know the rest of the script does that too, but let's at least fix it for new code :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like one-character variables too, but at same time is good to keep a pattern at the code. Don't you think would be better open a new PR fixing all one-character variables after this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second @Holzhaus, and I think it should probably be done in this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just the new code or a full refactor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var d = (vDeckNo % 2) ? 0 : 1; // d = deckNo - 1
seems clear and short to me.
var deckOffset = (deckNo - 1) % 2;
is neither short nor clear.
It is less obvious that the value is either 0 or 1.
And it is not correct, because it is not an offset. I don't know what to call this, but for sure not offset.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var controllerDeckIndex = (vDeckNo % 2) ? 0 : 1;
?
Case this represents the controller deck and an index starting from 0 to 1
Also, I'm working in a mapping that adds loop/effect mode to pads. But mixxx don't have buttons at the screen as rekordbox and virtual dj, so I replaced the Transition FX of the controller to toggle between those modes. I'm not confident that this should be shipped with mixxx because no other program use Transition FX for that and I'm changing the button function, what can cause confusion to users. I already posted my mapping at the forum to anyone interested, but I want to know what mixxx team think about it. Sorry if this is the wrong place to have this conversation, I was going to post in the issues at github, but it is disabled and lauchpad is just for bugs. |
var vDeckNo = script.deckFromGroup(vgroup); | ||
var d = (vDeckNo % 2) ? 0 : 1; // d = deckNo - 1 | ||
DDJ200.switchPadLED(d, pad, ch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second @Holzhaus, and I think it should probably be done in this PR
My vote would be to try and make the buttons act as accurately as they are labelled. I think this is the auto-dj function, however even this is debatable.... You could argue it should do nothing at all, as we don't have a 'transition fx' feature |
@dan-giddins Following documentation the correct is to do nothing, but we loose one button that could be used to add a ton of functionalities. Should we follow documentation or delivery a full-featured map to users? Please, do not understand this as a criticism. This is the reason why I'm not confident too if this feature should be official. |
@Holzhaus what do you think? |
Hello and sorry for my late response, but I was playing on the weekend. I have some questions and remarks:
|
Please post in the controller mapping stream on Zulip instead of expanding the scope of this PR. |
|
@Be-ing Thanks, I will post at zulip :D |
@geovannimp Ok, I understand now this is an exercise. But things are not as simple as they seem. I will try to explain a bit more about it above or at Zulip. But unfortunately I don't have too much time for code reviews and zulip discussions at the moment. |
Now from looking at Zulip I understand that your motivation for this pull request is to add more functionality to the Transition FX button. |
@fkbreitl this PR is a completely different issue and just a Bugfix. What it does is that if you add/delete a hotcue via mouse, then this PR makes sure that the pad LED is switched on or off. |
@fkbreitl Actually this PR has nothing to do with Transition FX. This was just some improvements I made to learn the "framework". Sorry if this title is not clear, I will try to explain what my changes do: In current implementation if I change the beat sync, play/pause or add/delete a hotcue from mixxx interface, leds from the controller won't change. With this PR, every one of those action in mixxx interface will update controller leds. As I said before, those are not life change fixes, but improve the experience with the controller. |
Ok, now I see what you are trying to do and why you are adding these connections. |
Please rebase on 2.3. |
FYI here's how you can do that: https://github.com/mixxxdj/mixxx/wiki/using%20git#targeting-another-base-branch |
Ping @geovannimp |
@Holzhaus Sorry, I forgot to answer. I will be doing the rebase soon as I have time, probably this weekend. |
@geovannimp Any progress? We should get this ready for 2.3.0. |
Those updates listen to changes from mixxx interface to replicate at the controller
@geovannimp ticked the "Allow edits from maintainers" checkbox when opening the pull request, so I took care of it. @fkbreitl @dan-giddins please retest. |
I totally forgot to rebase. Thanks @Holzhaus |
This should go into 2.3.0 to complete the initial support for the controller. |
for (var j = 1; j <= 8; j++) { | ||
// run switchPadLED after every hotcue update | ||
engine.makeConnection(vgroup, "hotcue_" + j + "_enabled", function(ch, vgroup, control) { | ||
var pad = Number(control.split("_")[1]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
var pad = Number(control.split("_")[1]); | |
var pad = j; |
Should have the same effect, but please test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This don't work cause the callback function is in another context. As the function executes outside the for loop, j
will be always 8.
I could write this instead:
engine.makeConnection(vgroup, "hotcue_" + j + "_enabled", function (pad) {
return function(ch, vgroup, control) {
var vDeckNo = script.deckFromGroup(vgroup);
var d = (vDeckNo % 2) ? 0 : 1; // d = deckNo - 1
DDJ200.switchPadLED(d, pad, ch);
};
}(j));
But I think the code readability would be compromised.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess you are right: Creating closures in loops: A common mistake
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, I figured j
was copied in the loop because its just number. Both of your solutions are fine. You can keep it as is if you like.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Swiftb0y If I had to use JavaScript I would fail miserably. Looked it up out of curiosity and was surprised, unpleasantly of course.
Do we wait for confirmation from @dan-giddins or @fkbreitl or do we merge now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to update the manual? Otherwise let's merge this PR now.
I don't think this needs manual changes. |
Those updates listen to changes from mixxx interface to replicate at the controller