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

Update Numark-Mixtrack-3-scripts.js #14180

Open
wants to merge 6 commits into
base: 2.5
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 43 additions & 17 deletions res/controllers/Numark-Mixtrack-3-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ var PADcolors = {
"purple": 127
};

// Two modes for the library controls
const libraryModes = {
focus: 0,
classic: 1,
};
const LibraryMode = libraryModes[engine.getSetting("libraryMode")] || libraryModes.focus;

Comment on lines +192 to +197
Copy link
Member

Choose a reason for hiding this comment

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

you can remove this part entirely if you do the below instead

Copy link
Member

Choose a reason for hiding this comment

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

What's the benefit of querying the settings each time compared to this const?

Copy link
Member

Choose a reason for hiding this comment

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

simplicity. As long as its not done in a tight loop, querying the setting should not be expensive. Doing all of this mapping is unnecessarily weird IMO. Additionally, global consts in mappings are kind off iffy (can suddenly break other things due to the way JS modules work, so thats why its always been encouraged to only add properties to the controller object instead of the global one).

Copy link
Member

Choose a reason for hiding this comment

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

Hmokay.
tight loop = called at high frequency?

So NumarkMixtrack3.libraryMode = engine.getSetting().. would be okay?
And settings is not an object of NumarkMixtrack3 here, right?

Copy link
Member

@Swiftb0y Swiftb0y Jan 27, 2025

Choose a reason for hiding this comment

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

tight loop = called at high frequency?

Yes.

So NumarkMixtrack3.libraryMode = engine.getSetting().. would be okay?

Yes, better than the current one... But I won't insist on this.

// Utilities
// =====================================================================

Expand Down Expand Up @@ -1078,36 +1085,55 @@ NumarkMixtrack3.PlayButton = function(channel, control, value, status, group) {
};

NumarkMixtrack3.BrowseButton = function(channel, control, value, status, group) {
var shifted = (NumarkMixtrack3.decks.D1.shiftKey || NumarkMixtrack3.decks.
D2.shiftKey || NumarkMixtrack3.decks.D3.shiftKey || NumarkMixtrack3.decks.D4.shiftKey);
const shifted = (
NumarkMixtrack3.decks.D1.shiftKey || NumarkMixtrack3.decks.D2.shiftKey ||
NumarkMixtrack3.decks.D3.shiftKey || NumarkMixtrack3.decks.D4.shiftKey
);

if (value === ON) {
if (shifted) {
// SHIFT + BROWSE push : directory mode -- > Open/Close selected side bar item
engine.setValue("[Library]", "GoToItem", true);
} else {
// Browse push : maximize/minimize library view
if (value === ON) {
script.toggleControl("[Skin]", "show_maximized_library");
}
}
if (LibraryMode === libraryModes.focus) {
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
if (LibraryMode === libraryModes.focus) {
if (engine.getSetting("libraryMode") === "focus") {

if (shifted) {
// SHIFT + BROWSE push : maximize/minimize library view
script.toggleControl("[Skin]", "show_maximized_library");
} else {
// Browse push : expand sidebar item or load track when in track table
engine.setValue("[Library]", "GoToItem", true);
}
} else { // Classic mode
if (shifted) {
// SHIFT + BROWSE push : directory mode -- > Open/Close selected side bar item
engine.setValue("[Library]", "GoToItem", true);
} else {
// Browse push : maximize/minimize library view
script.toggleControl("[Skin]", "show_maximized_library");
}
}
}
};

NumarkMixtrack3.BrowseKnob = function(channel, control, value, status, group) {
var shifted = (
const shifted = (
NumarkMixtrack3.decks.D1.shiftKey || NumarkMixtrack3.decks.D2.shiftKey ||
NumarkMixtrack3.decks.D3.shiftKey || NumarkMixtrack3.decks.D4.shiftKey
);

// value = 1 / 2 / 3 ... for positive //value = 1 / 2 / 3
var nval = (value > 0x40 ? value - 0x80 : value);

// SHIFT+Turn BROWSE Knob : directory mode --> select Play List/Side bar item
if (shifted) {
engine.setValue("[Playlist]", "SelectPlaylist", nval);
} else {
engine.setValue("[Playlist]", "SelectTrackKnob", nval);
if (LibraryMode === libraryModes.focus) {
// SHIFT+Turn BROWSE Knob : change focus between search, track table, and sidebar
if (shifted) {
engine.setValue("[Library]", "MoveFocus", nval);
} else {
engine.setValue("[Library]", "MoveVertical", nval);
}
} else { // Classic mode
// SHIFT+Turn BROWSE Knob : directory mode --> select Play List/Side bar item
if (shifted) {
engine.setValue("[Playlist]", "SelectPlaylist", nval);
} else {
engine.setValue("[Playlist]", "SelectTrackKnob", nval);
}
}
};

Expand Down
18 changes: 18 additions & 0 deletions res/controllers/Numark-Mixtrack-3.midi.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@
<forums>https://mixxx.discourse.group/t/mixtrack-pro-3/15165</forums>
<wiki>http://www.mixxx.org/wiki/doku.php/numark_mixtrack_pro_3</wiki>
</info>
<settings>
<group label="Library navigation">
<option
variable="libraryMode"
label="Navigation mode"
type="enum">
<value label="Focus" default="true">focus</value>
<value label="Classic">classic</value>
<description>
In Focus mode the Browse encoder affects the library widget which currently has keyboard focus.
This requires the Mixxx window to have focus and allows to control the searchbar, too.

In Classic mode the Browse encoder can select items in the sidebar and tracks table only, but independent
of keyboadr focus.
Comment on lines +23 to +24
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
In Classic mode the Browse encoder can select items in the sidebar and tracks table only, but independent
of keyboadr focus.
In Classic mode the Browse encoder can select items in the sidebar and tracks table only, but independent
of keyboard focus.

</description>
</option>
</group>
</settings>
<controller id="Mixtrack3">
<scriptfiles>
<file functionprefix="NumarkMixtrack3" filename="Numark-Mixtrack-3-scripts.js" />
Expand Down
Loading