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

DDJ-200: Listen to changes from mixxx #3793

Merged
merged 3 commits into from May 17, 2021
Merged

DDJ-200: Listen to changes from mixxx #3793

merged 3 commits into from May 17, 2021

Conversation

geovannimp
Copy link
Contributor

Those updates listen to changes from mixxx interface to replicate at the controller

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.

Thanks, I left some comments.

@@ -36,6 +48,15 @@ DDJ200.init = function() {
}, true);
};

DDJ200.listemHotcues = function(vgroup) {
Copy link
Member

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.

Copy link
Contributor Author

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

Copy link
Contributor

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?

Copy link
Contributor Author

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) {
Copy link
Member

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.

Copy link
Contributor Author

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);
Copy link
Contributor

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.

Copy link
Contributor Author

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

@Holzhaus
Copy link
Member

@fkbreitl @dan-giddins can one of you verify that this is working as intended?

@geovannimp
Copy link
Contributor Author

I refactored most of the code based on the code review, let me know if there's anything else I can improve.

@dan-giddins
Copy link

dan-giddins commented Apr 18, 2021

@Holzhaus sorry no, I currently don't have access to my ddj-200 controller :(

@fkbreitl looks like its up to you to test this, if you can!

@uklotzde
Copy link
Contributor

As a First-time contributor please also sign our contributor agreement and comment when done.

@uklotzde
Copy link
Contributor

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.

@geovannimp
Copy link
Contributor Author

Agreement signed :)

@geovannimp
Copy link
Contributor Author

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.

Comment on lines +46 to +48
var vDeckNo = script.deckFromGroup(vgroup);
var d = (vDeckNo % 2) ? 0 : 1; // d = deckNo - 1
DDJ200.switchPadLED(d, pad, ch);
Copy link
Member

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:

Suggested change
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

Copy link
Contributor Author

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?

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

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

@geovannimp
Copy link
Contributor Author

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.

Comment on lines +46 to +48
var vDeckNo = script.deckFromGroup(vgroup);
var d = (vDeckNo % 2) ? 0 : 1; // d = deckNo - 1
DDJ200.switchPadLED(d, pad, ch);

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

@dan-giddins
Copy link

dan-giddins commented Apr 19, 2021

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.

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
From the official documentation:

WeDJ for iPhone:
image
image

WeDJ for Andriod
image

djay:
image
image

edjing mix for iOS:
image
image

edjing mix for Andriod:
image
image

rekordbox:
image

@geovannimp
Copy link
Contributor Author

@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.

@dan-giddins
Copy link

Should we follow documentation or delivery a full-featured map to users?

@Holzhaus what do you think?

@fkbreitl
Copy link
Contributor

Hello and sorry for my late response, but I was playing on the weekend.

I have some questions and remarks:

  1. Do I understand correctly that you are changing this code without being able to test it because you don't even have this controller and it is only me who can do the testing?
    Please consider that I am sill not using Mixxx because of some missing features such as marking every first bar of the beatgrid, a status bar (which I reported already and waiting to get fixed), which means it is not easy for me to test this and I am busy at the moment.

  2. Experience says never touch a running system. Since this code was running perfectly fine I am wondering what you try to accomplish that could make it worth going through all the reviewing and testing while there are hundreds of open bugs and feature request desperately waiting for somebody to work on them. Why do you want to change this code instead of https://bugs.launchpad.net/mixxx/+bug/1899759 or https://bugs.launchpad.net/mixxx/+bug/1899759 for example?

  3. I already disagree with some of the proposed changes, but I am hesitating to start the reviewing without convincing reasons. Anyway I will drop some thoughts above.

@Be-ing
Copy link
Contributor

Be-ing commented Apr 19, 2021

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.

Please post in the controller mapping stream on Zulip instead of expanding the scope of this PR.

@geovannimp
Copy link
Contributor Author

@fkbreitl

  1. I have this controller, but this is my first controller and I'm starting DJing as hobby. I tested this changes, but I can submit a video testing to check if everything is ok.

  2. I'm a Javascript developer and this was my first change just to learn mapping script. As this worked I tried to contribute, but I don't think this is something extremely necessary.

  3. I don't agree with a lot of code design of the original mapping, but tried to change less as possible to have less chances of breaking something (Your concern in question 2)

@geovannimp
Copy link
Contributor Author

@Be-ing Thanks, I will post at zulip :D

@fkbreitl
Copy link
Contributor

@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.

@fkbreitl
Copy link
Contributor

fkbreitl commented Apr 19, 2021

Now from looking at Zulip I understand that your motivation for this pull request is to add more functionality to the Transition FX button.
In that case I would suggest to add this functionality first.
Once this is accomplished, you can think about code cosmetics or optimizations.
But doing both at the same time will create too much confusion and should be avoided.
Better do it in different pull requests and try to give it more meaningful names.
It is not clear to me what "Listen to changes from mixxx" is supposed to mean.

@Holzhaus
Copy link
Member

Holzhaus commented Apr 19, 2021

@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.

@geovannimp
Copy link
Contributor Author

@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.

@fkbreitl
Copy link
Contributor

Ok, now I see what you are trying to do and why you are adding these connections.
Yes, this is a useful fix. 👍

@Holzhaus Holzhaus changed the base branch from main to 2.3 April 27, 2021 20:56
@Holzhaus
Copy link
Member

Please rebase on 2.3.

@Holzhaus
Copy link
Member

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

@Holzhaus
Copy link
Member

Holzhaus commented May 5, 2021

Ping @geovannimp

@geovannimp
Copy link
Contributor Author

@Holzhaus Sorry, I forgot to answer.

I will be doing the rebase soon as I have time, probably this weekend.

@uklotzde uklotzde added this to the 2.3.0 milestone May 5, 2021
@uklotzde
Copy link
Contributor

@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
@Holzhaus
Copy link
Member

@geovannimp ticked the "Allow edits from maintainers" checkbox when opening the pull request, so I took care of it. @fkbreitl @dan-giddins please retest.

@geovannimp
Copy link
Contributor Author

I totally forgot to rebase. Thanks @Holzhaus

@uklotzde
Copy link
Contributor

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]);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
var pad = Number(control.split("_")[1]);
var pad = j;

Should have the same effect, but please test.

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member

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.

Copy link
Contributor

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.

@Holzhaus
Copy link
Member

Do we wait for confirmation from @dan-giddins or @fkbreitl or do we merge now?

@dan-giddins
Copy link

@Holzhaus I'm not able to test this right now as I'm not at home and don't have my DDJ-200 to hand. It will need to be up to @fkbreitl

Copy link
Contributor

@uklotzde uklotzde left a 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.

@Holzhaus
Copy link
Member

I don't think this needs manual changes.

@Holzhaus Holzhaus merged commit 915dc2f into mixxxdj:2.3 May 17, 2021
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.

None yet

7 participants