Skip to content

common-controller-scripts: add script.getPlaypositionSamples - #16797

Open
gary-gdbsystems wants to merge 1 commit into
mixxxdj:mainfrom
gary-gdbsystems:script-getplaypositionsamples-helper
Open

common-controller-scripts: add script.getPlaypositionSamples#16797
gary-gdbsystems wants to merge 1 commit into
mixxxdj:mainfrom
gary-gdbsystems:script-getplaypositionsamples-helper

Conversation

@gary-gdbsystems

@gary-gdbsystems gary-gdbsystems commented Jul 29, 2026

Copy link
Copy Markdown

Summary

Resolves #12950.

Adds a mapping script helper script.getPlaypositionSamples(group) that returns the current play position of a group as an absolute engine sample position — the same unit as loop_end_position and other absolute position controls — computed from the relative playposition control and track_samples:

script.getPlaypositionSamples = function(group) {
    return engine.getValue(group, "playposition") * engine.getValue(group, "track_samples");
};

Why a script helper (not a ControlObject or C++ API)

In the issue thread, @Holzhaus and @ronso0 explicitly chose a JavaScript helper over adding a new sample-based ControlObject:

@Holzhaus: "I'd rather not add more sample-based COs when we plan to switch to frame-based COs... If this is just about scripts, we could also add a JS helper method instead."
@ronso0: "Agreed, let's go with the script helper."

This PR implements exactly that, and supersedes the closed #16786, which added a C++ engine.getPlaypositionSamples() method instead of the requested script helper.

Changes

  • res/controllers/common-controller-scripts.js — one helper function (+8 lines).

Testing

  • ControllerScriptEngineLegacyTest passes (41/41), including commonScriptHasNoErrors, which evaluates the full common-controller-scripts.js in the JS engine.
  • eslint and the other applicable pre-commit hooks pass.

Add a mapping script helper that returns the current play position of a
group as an absolute engine sample position (the same unit as
loop_end_position and other absolute position controls), computed from
the relative "playposition" control and "track_samples".

In issue mixxxdj#12950 the maintainers (Holzhaus, ronso0) chose a JavaScript
helper over a new sample-based ControlObject or new C++ engine API,
since it is a simple multiplication and they are migrating to
frame-based controls. This implements that decision and supersedes the
closed PR mixxxdj#16786, which added a C++ engine method instead.

Resolves mixxxdj#12950.
@acolombier acolombier added the AI The issue or PR makes heavy use of AI, which requires extra attention and effort to review label Jul 30, 2026
@gary-gdbsystems
gary-gdbsystems force-pushed the script-getplaypositionsamples-helper branch from 98bdd19 to 33337fa Compare August 11, 2026 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AI The issue or PR makes heavy use of AI, which requires extra attention and effort to review controller mappings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add mapping script helper getPlaypositionSamples

2 participants