musescore / MuseScore

MuseScore is an open source and free music notation software. For support, contribution, bug reports, visit MuseScore.org. Fork and make pull requests!
https://musescore.org
Other
11.79k stars 2.56k forks source link

Exchange voices command is available with a single or list selection but does nothing #23330

Closed wizofaus closed 4 days ago

wizofaus commented 1 week ago

Issue type

UX/Interaction bug (incorrect behaviour)

Bug description

If you select one or more notes in a list selection (using ctrl+click etc.), the various "exchange voices" commands from Tools|Voices are all enabled but do nothing. Either the command should be disabled, a message should appear explaining why it can't be used, or they should work as expected (ideally the latter!).

Steps to reproduce

  1. Create a score with a single note in voice 1 and a single note in voice 2
  2. Select them both using ctrl+click (list selection, not range)
  3. Choose "Tools|Voices|Exchange Voice 1&2"
  4. Result: nothing happens Expected: either 3. should not be possible because command is disabled, or an appropriate error message shown, or better, it should work.

Screenshots/Screen recordings

No response

MuseScore Version

4.3.1

Regression

I don't know

Operating system

Windows 11

Additional context

Apparently it's even weirder - if you select a range that's not a full measure then the command works, but affects notes you haven't selected elsewhere in the measure. It may make sense to fix it so it can work on any range but still be disabled for single/list selection. Otherwise I would think it should given a warning message if the current selection is anything other than 1 or more complete measures.

wizofaus commented 1 week ago

Happy to fix either way, though the "actually work" option would take somewhat longer than the others. There's no message currently for "Please select a range" (or similar), so would require translation etc.

irwir commented 1 week ago

There should have been Steps 5: ...

  1. Reading the handbook.

Apparently, the function name is dubious. Exchange voices in MuseScore requires that one of the voices in the pair was empty. Disabling menu items for large selection might be too costly.

The reasons for certain design decisions are unclear. Preferable would be straitforward implementation as in Swap voices function of Sibelius.

wizofaus commented 1 week ago

Not sure what reading the handbook has to do with expected behaviour. No command should ever be available and active but do nothing with no information about why nothing happened And, no I use it all the time on passages with notes in both voices, it's not true that one must be empty at all. If it says that in the Handbook then it's evidence that reading the handbook is more often than not a waste of time. The source code is the only source of truth!

irwir commented 1 week ago

The handbook is still recommended; quoting:

These commands work only on full measures (or multiple measures), not on individual notes.

So it was my misreading of your description (plus some false memories).

As for your suggestion, Tools - Voices item could be disabled if selection is not full/multiple measures.

wizofaus commented 1 week ago

Then the handbook is still wrong because it works fine if you select a range that's not a full measure too (though I haven't done extensive testing to see if it handles all scenarios).

MarcSabatella commented 1 week ago

If a partial measure is selected, the command still operates on the full measure. That’s how it handles all scenarios. It’s easy with full measures, often next to impossible otherwise.

So, the handbook is accurate that it only operates on full measures. it just leaves out the detail that it automatically expands to the full measure if you mistakenly select a partial measure.

wizofaus commented 1 week ago

I'd say that's a separate bug then, though I'd fix at the same time

MarcSabatella commented 1 week ago

It’s not a bug, it’s by design as the consensus choice (as of some years ago) from among the several possible ways of handling partial measures. Certainly, though, alternative designs for the handling of partial measures could potentially be proposed, discussed, agreed upon, implemented, and documented.

wizofaus commented 1 week ago

My proposal: if you have a selection is that is NOT a range of 1 or more whole ranges then: a) if doing exchange A-B, first take all the selected notes in voice A and do the equivalent of "Ctrl+Alt+n" to assign to voice 5 (normally not accessible, but useful as a temporary holding voice) b) take all notes selected in voice B and do the equivalent of Ctrl+Alt+ to assign them to voice A c) take all notes in voice 5 and do the equivalent of Ctrl+Alt+B to assign them to voice B

Otherwise, use existing algorithm.

MarcSabatella commented 1 week ago

As discussed in Discord, it's just not that simple. If the voices don't start or end at the same time position, there is no guarantee that you'll be able to do the moves, and you'll end up either doing nothing for some of the notes, or stuck in places where some note has nowhere to go.

Here was one example I noted:

image

Just one of many many possible cases to consider. Your algorithm above will leave the third selected "C" nowhere to go, except maybe back where it started (try it using voice 3 as the temp voice and see). Or you can modify the rhythm to chop the start/end notes up and only move the portions they have in common, but there is no reason to suppose a user would actually expect that either.

I'm not saying it's hard to do something, but almost anything you choose is going to be surprising and almost impossible to document. And not obviously better than the current solution.

So as I said, alternative designs for the handling of partial measures could potentially be proposed, discussed, agreed upon, implemented, and documented, but acknowledging the complexity of the problem I(from a user understanding perspective - not from a code perspective) is definitely part of that.

wizofaus commented 1 week ago

Ok so that brings up another piece of (to me) very unexpected behaviour, that probably deserves a separate bug report, but currently if you do select a note in, say, voice 2 and there's also a note at the same place already in voice 1, then using "Ctrl+Alt+1" or clicking on "voice 1" button in the toolbar does nothing at all with no explanation. I'd prefer to fix that first (again, it's simple in principle - it should delete material to make room for the note, same as changing a note duration etc.). But if there's some reason not to fix that, then sure, exchange voices should give a message if a) the selection is anything other than a range of 1 or more complete measures and b) it's impossible to assign some of the notes to another voice based on the current limitations of that command. On the other hand I don't have an issue with the fact that in some cases, if you have a selection that isn't entire measures, performing "exchange 1-2" twice may or may not return you to what it was before (because material has been deleted etc.).

MarcSabatella commented 1 week ago

This too is by design, the consensus choice as to the best way of handling such cases. Again, it’s possible to propose, discuss, agree upon, implement, and document a new design.

irwir commented 1 week ago

Your algorithm above will leave the third selected "C" nowhere to go, except maybe back where it started

As a fun fact, some OCR/PDF converters actually managed to create voices longer than time signature defines. MuseScore complained on every file open and save.

wizofaus commented 1 week ago

Also, I took your example from above, changed the time signature to 3/8, used exchange voices on the 3 selected notes, then changed back to 4/4:

image

Not that it proves anything, but does demonstrate that the current solution is not necessarily ideal.

(The extra F at the end was something I'd added accidentally before changing time signature)

irwir commented 1 week ago

Also, I took your example from above, changed the time signature to 3/8, used exchange voices on the 3 selected notes, then changed back to 4/4:

IInitial selection with two quarters in lower voice you converted to quater and eighth. This is bad cheating.

wizofaus commented 1 week ago

Exactly, you shouldn't have to resort to that to try to get a useful result. Not that I ever would try to use exchange voices on such a selection. But it's definitely a command that would be useful to use on selections that aren't entire measures. I'm happy to put up a PR so you can play around with it, will probably have to wait till tomorrow or the next day though.