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

Samplers: dont create extra empty players during startup #12657

Merged

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Jan 27, 2024

Fixes #9115
If samplers.xml has more empty(!) elements than sampler players have been created by request of either skins or controller mappings, SamplerBank would trigger creation of all these unneeded samplers.
This happened after having shutdown with a 64-samplers skin, and starting with a skin with less samplers, even though none of the additional samplers has a track loaded.

Additionally, I improved the track menu and the control picker menu (MIDI Learning Wizard):
in the "Load To" submenu samplers are now grouped into submenus with 16 samplers each.
image

@github-actions github-actions bot added the ui label Jan 27, 2024
if (samplerNodes.isEmpty()) {
return true;
}
for (int i = 0; i < samplerNodes.size(); i++) {
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 refactored this to avoid n = n.nextSibling(); before each continue.
Unfortunately there is no iterator for QDomNodeList.

@ronso0 ronso0 marked this pull request as ready for review January 27, 2024 17:44
@ronso0 ronso0 linked an issue Jan 27, 2024 that may be closed by this pull request
// We also create new players even if they are not present in the
// GUI to not drop tracks loaded to invisible samplers when saving
// the samplers file.
if (m_pPlayerManager->numSamplers() < (unsigned)samplerNum) {
Copy link
Member

Choose a reason for hiding this comment

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

This way around should be more safe since samplerNum might be read from a corrupt file.

Suggested change
if (m_pPlayerManager->numSamplers() < (unsigned)samplerNum) {
if (static_cast<int>(m_pPlayerManager->numSamplers()) < samplerNum) {

Copy link
Member

Choose a reason for hiding this comment

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

Here is by the way also suspicious casting:

return pCOPNumSamplers ? static_cast<int>(pCOPNumSamplers->get()) : 0;

Maybe we should just use int everywhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean instead of unsigned int?

Copy link
Member

Choose a reason for hiding this comment

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

Yes.

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay, I'll take a look and open another PR.

src/mixer/samplerbank.h Outdated Show resolved Hide resolved
src/mixer/playermanager.cpp Outdated Show resolved Hide resolved
@JoergAtGithub
Copy link
Member

Works for me on Windows11!

src/mixer/samplerbank.cpp Outdated Show resolved Hide resolved
@ronso0 ronso0 force-pushed the samplers-dont-create-extra-empty-players branch from a578814 to 5d299ef Compare January 29, 2024 01:52
@ronso0 ronso0 force-pushed the samplers-dont-create-extra-empty-players branch 2 times, most recently from 87c8342 to 186f166 Compare January 31, 2024 12:22
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.

Works already good. Hers some comments

src/controllers/controlpickermenu.cpp Outdated Show resolved Hide resolved
src/widget/wtrackmenu.cpp Outdated Show resolved Hide resolved
@ronso0 ronso0 force-pushed the samplers-dont-create-extra-empty-players branch from 186f166 to 5a5d206 Compare February 6, 2024 01:36
@ronso0
Copy link
Member Author

ronso0 commented Feb 6, 2024

Now the menu is also updated if samplers or decks are added (skin change for example).

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.

LGTM, Thank you.

@daschuer daschuer merged commit f0587b8 into mixxxdj:2.4 Feb 6, 2024
14 checks passed
@ronso0 ronso0 deleted the samplers-dont-create-extra-empty-players branch February 6, 2024 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

library context menu also shows not supported samplers
3 participants