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

Rubberband: switch between v2 and v3 at runtime #4855

Merged
merged 8 commits into from
Aug 6, 2022

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Jul 13, 2022

Based on @Swiftb0y's #4853

Ready for review, though draft since I'll rebase if necessary / when #4853 is merged.

@ronso0 ronso0 mentioned this pull request Jul 13, 2022
@Swiftb0y
Copy link
Member

Thanks for the commit. It doesn't build unfortunately (fix is trivial). I'll finish #4853 and and then review this. It'll be a couple of days though.

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

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

Thank you. I have left some comments for improvement.

src/engine/bufferscalers/enginebufferscalerubberband.cpp Outdated Show resolved Hide resolved
src/engine/bufferscalers/enginebufferscalerubberband.cpp Outdated Show resolved Hide resolved
src/engine/bufferscalers/enginebufferscalerubberband.h Outdated Show resolved Hide resolved
@@ -62,6 +62,8 @@ constexpr SINT kSamplesPerFrame = 2; // Engine buffer uses Stereo frames only
// Rate at which the playpos slider is updated
constexpr int kPlaypositionUpdateRate = 15; // updates per second

#define RUBBERBANDV3 (RUBBERBAND_API_MINOR_VERSION >= 2 && RUBBERBAND_API_MINOR_VERSION >= 7)
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
#define RUBBERBANDV3 (RUBBERBAND_API_MINOR_VERSION >= 2 && RUBBERBAND_API_MINOR_VERSION >= 7)
#define RUBBERBANDV3 (RUBBERBAND_API_MINOR_VERSION >= 2 && RUBBERBAND_API_MINOR_VERSION >= 7)

Copy link
Member

Choose a reason for hiding this comment

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

But it would be nice to hide the dependency here.

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't spot the difference in your suggestion?

Copy link
Member

Choose a reason for hiding this comment

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

Agree, including the entirety of RubberbandStretcher.h just for RUBBERBAND_API_MAJOR-/MINOR_VERSION is quite a big dependency, but what other choice do we have?

Copy link
Member Author

Choose a reason for hiding this comment

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

would a global const defined in enginebufferscalerubberband.h work?

Copy link
Member

Choose a reason for hiding this comment

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

My original point was that the EngineScaler should handle the dependency not EngineBuffer.
Than EngieBuffer can use a member of EngineScaler to query about that.

Copy link
Member Author

Choose a reason for hiding this comment

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

understood.

We need to differentiate at build time

That as well, thus my naive question about global const (set at compile time in the EngineScaler).

Than EngieBuffer can use a member of EngineScaler to query about that.

and that, too. Though how is that supossed to work for the enum in the EngineBuffer header?

Copy link
Member

Choose a reason for hiding this comment

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

That as well, thus my naive question about global const (set at compile time in the EngineScaler).

The issue with globals consts is that they get to be evaluated after the preprocessor finished. Since we want to do conditional compilation using #if, we need this value sooner, so we need a #define for that then. RubberBandStretcher.h is a pretty lean header (90% is just comments) so I guess its not a big problem to include that a bunch of times.

Copy link
Member

Choose a reason for hiding this comment

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

Though how is that supossed to work for the enum in the EngineBuffer header?

My idea was to remove all the guards from the static code as if we are at a V3 build. If the engine Finer is not available the option need to be hidden from the GUI, that's all.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, but hiding it in the GUI seems more complicated than working with the guards in both EngineBuffer and EngineBufferScaleRubberBand.

Are you suggesting to first populate the keylock combobox with all values, then (probably in
DlgPrefSound::loadSettings) somehow query EngineBuffer / EngineBufferScaleRubberBand to decide if we remove RubberBand finer from the combobox (and also reset the config to RubberBand (faster)) ?

src/engine/enginebuffer.cpp Outdated Show resolved Hide resolved
src/engine/enginebuffer.h Outdated Show resolved Hide resolved
src/engine/enginebuffer.h Outdated Show resolved Hide resolved
src/engine/enginebuffer.h Outdated Show resolved Hide resolved
src/engine/enginebuffer.h Outdated Show resolved Hide resolved
src/engine/bufferscalers/enginebufferscalerubberband.h Outdated Show resolved Hide resolved
@ronso0
Copy link
Member Author

ronso0 commented Jul 16, 2022

Well, this now builds and I fixed the test (adjusted to changed enum).
I got around the guards in EngineBuffer, but as I said, I don't see a way to hide RubberBand finer) from the pref combobox.¹
I guess with a little work it can at least switch back to RubberBand (faster) if (finer) is not available, but that's bad UX iMO

¹of course there are ways, like using a CO/ControlProxy "isRubberBandV3Available" but that's ugly and hacky (even for my taste) and error-prone.

@daschuer
Copy link
Member

Idea:
How about using:
EngineBufferScaleRubberBand::isEngineFinerAvailable()
And populate the "Finer" field only if it is available or if it was selected before.
If we have a Rubberband 2 build we may change pevefix the text with "not installed" or such.

@Swiftb0y
Copy link
Member

Not a fan of hiding options for no apparent reason. How much more effort would it be to grey it out instead and provide a tooltip explaining why its not available?

@daschuer
Copy link
Member

Since we do not dynamically link to V2 and V3 users with V2 have no chance to "ungray" the grayed out option. That's why I have proposed to hide it. If we want to use it as a teaser, we need at least a hint how to ungray it.

The only case where wrongly selected is, if the user has selected it in an experimental build and starts Mixxx without V3. Currently the combo-box is empty, but it uses Rubberband Fast. Here we can actually switch back to Rubberband Fast, or inform the user that the selection is not available. This is really an edge case, not worth to code to much around it. IMHO

What do you think?

@Swiftb0y
Copy link
Member

That's why I have proposed to hide it. If we want to use it as a teaser, we need at least a hint how to ungray it.

Sure, thats what I would've put in tooltip for the greyed out option.

@ronso0
Copy link
Member Author

ronso0 commented Jul 23, 2022

Idea: How about using: EngineBufferScaleRubberBand::isEngineFinerAvailable() And populate the "Finer" field only if it is available or if it was selected before. If we have a Rubberband 2 build we may change pevefix the text with "not installed" or such.

Again: if you have any solution how to do this without hazzle nad hacks, please present it.
IMO no solution is easier and less error-prone than simply using the guards for the enum in enginebuffer. As @Swiftb0y pointed out the rubberband header is actually rather small.

ronso0 added 3 commits July 23, 2022 23:30
now the KeylockEngine enum always contains RUBBERBAND_FINER, thus the selector
in Preferences > Sound Hardware will always show it, too.
@ronso0 ronso0 force-pushed the rubberband3-switch branch from c75e72c to 447543f Compare July 23, 2022 22:10
@daschuer
Copy link
Member

I guess with a little work it can at least switch back to RubberBand (faster) if (finer) is not available, but that's bad UX iMO

In a test branch, I have tried to keep the bad Rubberband value, but since it switches automatically back to default, the value does not persist after another restart. I think the use case is, using Finer in the recent R3 build, test an older Mixxx and go back to the R3 build without loosing the selection of the Finer engine in preference.

With 2.3, the combobox is empty in this case. I think we should display "Unknown (bad value)" for main R2 builds instead and hide the value if a valid value was selected.

@daschuer
Copy link
Member

Here it is: ronso0#26

It displays now "Unknown, using Rubberband (better)" in case of R3 was selected but is not available in the running build.

@ywwg
Copy link
Member

ywwg commented Jul 29, 2022

Is the rubberband library version a compile-time selection? If so, I would vote to hide the option in the UI. Having a grayed-out option in the prefs for a value which literally cannot be enabled by the user does not communicate anything useful.

Other examples of the same approach:

  • on linux, I am not presented with ASIO as a sound card access option because there's no way I could possibly use it.
  • If vinyl control is disabled at compile time, relevant preferences are removed.
  • We do not show effects that are not installed on the system.

@ywwg
Copy link
Member

ywwg commented Jul 29, 2022

(is this PR still a draft?)

@ronso0
Copy link
Member Author

ronso0 commented Jul 29, 2022

@ywwg unavailable engines are hidden in ronso0#26 which brings other improvements as well, please take a look.
Still draft until I merge that and clean up this PR, which I'll probably find time for in the next 2-5 days.

@ronso0
Copy link
Member Author

ronso0 commented Aug 2, 2022

With commits from ronso0#26 this is now ready to roll!

Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

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

I didn't want to put more work on you so I went ahead and implemented all my review suggestions for you: ronso0/pull/27

#27)

refactor(prefs): improve keylockengine-related typesafety
Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

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

lgtm otherwise

src/preferences/dialog/dlgprefsound.cpp Outdated Show resolved Hide resolved
@ronso0
Copy link
Member Author

ronso0 commented Aug 3, 2022

would be nice to have two ✔️ before I hit merge : )

@daschuer
Copy link
Member

daschuer commented Aug 3, 2022

I can do a final test after the build issues are solved.

@Swiftb0y
Copy link
Member

Swiftb0y commented Aug 3, 2022

Sorry. The suggestion I posted contained capitalization typos. Sent you a PR.

…Defaults

Co-authored-by: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com>
@ronso0 ronso0 force-pushed the rubberband3-switch branch from e4c2530 to bdebb6e Compare August 4, 2022 17:28
@ronso0
Copy link
Member Author

ronso0 commented Aug 4, 2022

I don't understand what's wrong with pre-commit
https://github.com/mixxxdj/mixxx/runs/7679981732?check_suite_focus=true
WARNING: The directory '/github/home/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

@Swiftb0y
Copy link
Member

Swiftb0y commented Aug 4, 2022

I think versioning issues. seems to me like distlib is installed as part of the systems python installation but something wants a newer distlib version. So in order to install that, it has to uninstall the older version which is part of system install so it can't remove that. I'm not sure. I'm investigating.

@Swiftb0y
Copy link
Member

Swiftb0y commented Aug 5, 2022

@daschuer pre-commit issues are unrelated. Can you do your final test before merge?

@ronso0 ronso0 added this to the 2.4.0 milestone Aug 5, 2022
@ronso0 ronso0 added the engine label Aug 5, 2022
@daschuer
Copy link
Member

daschuer commented Aug 6, 2022

Just did a brief test and all works as expected. Thank you all for the good collaboration.

@daschuer
Copy link
Member

daschuer commented Aug 6, 2022

@Swiftb0y merge? Your review is still red.

Copy link
Member

@Swiftb0y Swiftb0y left a comment

Choose a reason for hiding this comment

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

whoops, lgtm.

@daschuer
Copy link
Member

daschuer commented Aug 6, 2022

Thank you.

@daschuer daschuer merged commit 828a189 into mixxxdj:main Aug 6, 2022
@ronso0 ronso0 deleted the rubberband3-switch branch August 26, 2022 12:48
napaalm pushed a commit to napaalm/mixxx that referenced this pull request Jul 10, 2023
Rubberband: switch between v2 and v3 at runtime
napaalm pushed a commit to napaalm/mixxx that referenced this pull request Jul 10, 2023
Rubberband: switch between v2 and v3 at runtime
napaalm pushed a commit to napaalm/mixxx that referenced this pull request Jul 10, 2023
Rubberband: switch between v2 and v3 at runtime
napaalm pushed a commit to napaalm/mixxx that referenced this pull request Jul 10, 2023
Rubberband: switch between v2 and v3 at runtime
napaalm pushed a commit to napaalm/mixxx that referenced this pull request Jul 11, 2023
Rubberband: switch between v2 and v3 at runtime
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.

4 participants