Skip to content

Conversation

@Jojo-Schmitz
Copy link
Contributor

@Jojo-Schmitz Jojo-Schmitz commented Sep 2, 2024

  1. Fix #317188: Allow [Q] and [W] to work on a range selection.
    Port of Fix #317188: Allow [Q] and [W] to work on a range selection #7519 for 3.x

  2. [Cmd: Double/Half Duration] Allow to apply to a list selection - equivalent to pressing a duration toggle. Shift also allowed
    Port of [Cmd: Double/Half Duration] Allow to apply to a list selection - equi… Jojo-Schmitz/MuseScore#609, fixes Enhancement: Allow Q/W to perform duration toggle on a list selection Jojo-Schmitz/MuseScore#608

    Fix #20962: Keep selection when deleting, changing note/rest lengths #20984 Updated so that the selection would retain the chords if the user has a list selection and performs duration changes by way of the pad toggle. Similar to Double/Half like a range selection, but inserts rests in-between the notes when making smaller form

    I (@worldwideweary) figured why not in addition let Q/W (with or without shift) do the same thing with the duration changes. That is

    1. Range based Half/Double exists already (no rests result)
    2. Do the recent up/down chord thing to convert to list and perform a delete, selection retained
    3. Now perform Q/W on the list... with Shift/W showing.
    qwList.webm

@Jojo-Schmitz Jojo-Schmitz force-pushed the Improvement-DoubleHalfListSelection branch 2 times, most recently from 0f85279 to e954bfc Compare September 2, 2024 16:43
@Jojo-Schmitz
Copy link
Contributor Author

Could this get rewiewed (again), please?

@Jojo-Schmitz
Copy link
Contributor Author

What is going to happen with this PR?

@cbjeukendrup
Copy link
Member

Sorry, we're really a bit too much behind with reviewing community PRs. Hopefully we can manage to get through most of them in the coming months. I've added it to 4.6.

@Ash-86
Copy link
Contributor

Ash-86 commented Mar 21, 2025

This is cool. Does shift Q/W also work on range selection? it would be nice if it did.

@Jojo-Schmitz
Copy link
Contributor Author

Jojo-Schmitz commented Mar 22, 2025

It should, but let me rebase, then you can check yourself

@Jojo-Schmitz Jojo-Schmitz force-pushed the Improvement-DoubleHalfListSelection branch from e954bfc to 7780b99 Compare March 22, 2025 17:27
@Ash-86
Copy link
Contributor

Ash-86 commented Mar 22, 2025

Thanks! Indeed, shift Q/W works with range selection but here are some bugs i found:

  • shift Q/W dont work after having extended selection beyond a measure.
  • pressing W on list selection crashes MU or corrupts measure if durations overflow.
  • operating on a single note list selection: pressing shift W first time toggles "dotted note" from the taskbar, you need to press shift W again to actually change duration of the note. [outside note input mode]
  • pressing Q/W on empty measures changes selection to two measures or half measure correspondingly. [not really a bug, but maybe it didn't feel like it was an intended behaviour (?)]
  • shift Q on single note list selection skips undotted values. ex. goes from ¼dotted to ⅛dotted. [outside note input mode]

@Jojo-Schmitz
Copy link
Contributor Author

Interesting, none of this happens with 3.7 Evolution (except your point 4. does, but as you mentioned, that's not really a bug), which contains the changes this PR here ports forward.

@Ash-86
Copy link
Contributor

Ash-86 commented Apr 2, 2025

After a closer look, i pinpointed the correct conditions of the bugs, which ,btw, i also found to be present in 3.7

  • range selection: shift+Q/W dos not work if the selection cointain both dotted and undotted notes.
  • list selection: both Q/W and shift+Q/W don't work if selected notes have different durations.

@Jojo-Schmitz Jojo-Schmitz force-pushed the Improvement-DoubleHalfListSelection branch 4 times, most recently from 260bbae to edbbcae Compare April 2, 2025 06:54
Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Apr 2, 2025
Backport of musescore#24385, commit 3

Co-Authored-By: Ashraf El Droubi <[email protected]>
@Jojo-Schmitz Jojo-Schmitz force-pushed the Improvement-DoubleHalfListSelection branch from edbbcae to 5b2596d Compare April 2, 2025 07:15
@Jojo-Schmitz Jojo-Schmitz force-pushed the Improvement-DoubleHalfListSelection branch from 4737555 to afd7138 Compare August 22, 2025 07:23
@Jojo-Schmitz
Copy link
Contributor Author

Jojo-Schmitz commented Aug 22, 2025

I can't reproduce, not with a rebased version (I had to add a missing last argument m_selection.rangeContainsMultiNoteChords() to deleteRange() in cmd.cpp, line 3324, apparently that method had been changed in the past 4 months)

@zacjansheski
Copy link
Contributor

Similar crash still present, quarter note ties and press "W" twice

Untitled.mp4

@Jojo-Schmitz
Copy link
Contributor Author

Sorry, no crash here, not on Windows and in the MSVC debugger

@Jojo-Schmitz Jojo-Schmitz force-pushed the Improvement-DoubleHalfListSelection branch from afd7138 to 812723b Compare August 22, 2025 12:29
@zacjansheski
Copy link
Contributor

zacjansheski commented Aug 22, 2025

Perhaps it has to do with selection (not ties), I can crash the program when Cmnd+Click after adding a note (already selected) then press w twice

video1161111886.mp4

@Jojo-Schmitz
Copy link
Contributor Author

Maybe you can write down the exact steps?

@zacjansheski
Copy link
Contributor

zacjansheski commented Aug 22, 2025

  1. Create score for flute
  2. Double click on measure 3 to start entering notes
  3. Write a quarter note F on beat one and D beat three
  4. Press "N" to leave note input mode with D still selected
  5. cntrl+click the F to add to list selection
  6. Press W twice

Confirmed on second device, and other instruments

@Jojo-Schmitz
Copy link
Contributor Author

OK, finally, crash confirmed... Debugging session tomorrow

@Jojo-Schmitz Jojo-Schmitz force-pushed the Improvement-DoubleHalfListSelection branch from 3797531 to 2e9a46b Compare August 23, 2025 10:39
@Jojo-Schmitz
Copy link
Contributor Author

OK, crash investigated and fixed (and rebased once again)

Jojo-Schmitz added a commit to Jojo-Schmitz/MuseScore that referenced this pull request Aug 23, 2025
…e different durations

Backport of musescore#24385, commit 3 and 4, including a simplification (removing redundant code), plus fixing clazy warnings

Co-Authored-By: Ashraf El Droubi <[email protected]>
Co-Authored-By: Casper Jeukendrup <[email protected]>
@zacjansheski
Copy link
Contributor

Thank you!

Tested on MacOS 15, Windows 11, Ubuntu 22.04.3. Approved
#24759 FIXED

@Jojo-Schmitz
Copy link
Contributor Author

What prevents it from getting merged then?

@cbjeukendrup
Copy link
Member

I noticed a change in behaviour for full-measure rests: for most time signatures, it no longer decreases the duration of a full-measure rest, but only rewrites it using a non-full-measure rest. Example: in 4/4, a centred full measure rest only changes into a non-centred 4/4 rest, instead of being split into two 2/4 rests. Similar situation in 3/4. I don't know if that's a blocker, but I did want to check it.

Comment on lines +3325 to +3341
? cr->durationType().fraction() * Fraction(3, 3 + nSteps)
: cr->durationType().fraction()* Fraction(3 - nSteps, 3 + nSteps), true);
Copy link
Member

Choose a reason for hiding this comment

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

On second thoughts, this fraction multiplication magic seems not the best implementation to me. A bit risky, and relying heavily on the assumption that nSteps == ±1 (and not 0, or 2), which wasn't the case with the previous implementation.

What is actually the reason for replacing the original implementation with shiftRetainDots and the DurationType::V_MEASURE check?
If it's only that it's a bit verbose, it could be moved into a static Fraction …(…) function.

Copy link
Contributor

@worldwideweary worldwideweary Sep 17, 2025

Choose a reason for hiding this comment

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

I can't speak for the changes not in accord with what I initially provided for 3.x (https://github.com/Jojo-Schmitz/MuseScore/pull/609/files), but I can say that the nSteps assumption was valid given that this function (cmdIncDecDuration) in 3.x is only used for some "wrapped" around functions with the following:

void cmdDoubleDuration()      { cmdIncDecDuration(-1, false); }
void cmdHalfDuration()        { cmdIncDecDuration( 1, false); }
void cmdIncDurationDotted()   { cmdIncDecDuration(-1, true); }
void cmdDecDurationDotted()   { cmdIncDecDuration( 1, true); }

The nSteps will always be ±1 with these. but I don't know if things have changed in the main upstream 4.x branch. It wasn't ever used besides those four functions, but it wouldn't hurt to safeguard just in case there is a change in the future of course.

As for the multiplication magic and the removal of the V_MEASURE test: @Jojo-Schmitz ? The V_MEASURE check still remains at the bottom of this function in 3.7 from what I can tell.

Copy link
Contributor

Choose a reason for hiding this comment

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

The first equation guarntees multiplication by 3/2 or 3/4. (for dotted augmentation/diminishing)
The second eq. sets multiplication by ½ or 2.
Both cases depend on nSteps being ±1.

Copy link
Contributor

@worldwideweary worldwideweary Sep 17, 2025

Choose a reason for hiding this comment

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

@Ash-86 et. al: Not sure, but it seems to me the multiplication isn't necessary since there are shiftRetainDots and shift functions already existing for TDuration (not fractions), like if the code were to do this:

for (auto cr : crs) {
    TDuration odt = cr->durationType();
    TDuration ndt(stepDotted ? odt.shiftRetainDots(nSteps, stepDotted) : odt.shift(nSteps));
    changeCRlen(cr, ndt);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure, whatever's easier to read :)

Copy link
Contributor

@Ash-86 Ash-86 Oct 15, 2025

Choose a reason for hiding this comment

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

Just tested using the shift functions, although they too work fine for most cases, the problem with changing a measure rest persists, with even wierder results...

We could simply disable w/q actions for measure rests. It is not a legit usecase anyway and I don't think it will be missed at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What coded change would be needed then?

Copy link
Contributor

@Ash-86 Ash-86 Oct 16, 2025

Choose a reason for hiding this comment

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

Ah, there was already a check for measure-rests!! Should bring back that, and let's use shift functions instead of doing fraction math, as per worldwideweary's suggestion, this becomes:

        for (ChordRest* cr : crs) {
            // if measure rest is selected as input, then the correct initialDuration will be the
            // duration of the measure's time signature, else is just the ChordRest's duration
            TDuration initialDuration = cr->durationType();
            if (initialDuration == DurationType::V_MEASURE) {
                initialDuration = TDuration(cr->measure()->timesig(), true);

                if (initialDuration.fraction() < cr->measure()->timesig() && nSteps > 0) {
                    // Duration already shortened by truncation; shorten one step less
                    --nSteps;
                }
            }

            TDuration newDuration(stepDotted ? initialDuration.shiftRetainDots(nSteps, stepDotted) : initialDuration.shift(nSteps));

            if (cr->isChord() && (toChord(cr)->noteType() != NoteType::NORMAL)) {
                undoChangeChordRestLen(cr, newDuration);
            } else {
                changeCRlen(cr, newDuration);
            }
        }

In my test, everything seemed to work well.

@Ash-86
Copy link
Contributor

Ash-86 commented Oct 3, 2025

it's a shame this didn't make it to 4.6 :(

@Ash-86
Copy link
Contributor

Ash-86 commented Oct 10, 2025

@Jojo-Schmitz could you rebase this, please?

mattmcclinch and others added 6 commits October 10, 2025 11:39
…valent to pressing a duration toggle. Shift also allowed

Port of #609
…e different durations

Co-Authored-By: Ashraf El Droubi <[email protected]>
Co-Authored-By: Ashraf El Droubi <[email protected]>
Co-Authored-By: Casper Jeukendrup <[email protected]>
@Jojo-Schmitz Jojo-Schmitz force-pushed the Improvement-DoubleHalfListSelection branch from 2e9a46b to 503c206 Compare October 10, 2025 09:41
@Jojo-Schmitz
Copy link
Contributor Author

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

6 participants