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

Glitch in "SWS/S&M: Move selected FX up/down in chain for selected tracks" when FX chains are open #1791

Closed
Buy-One opened this issue Nov 4, 2023 · 9 comments · Fixed by #1799
Labels

Comments

@Buy-One
Copy link

Buy-One commented Nov 4, 2023

After the first run the index of the selected FX seems to only be updated for the focused FX chain (belonging to the selected track with the greatest index), whereas for the rest the change in the index of the selected FX isn't registered, meaning that if the 1st FX was originally selected, after it has been moved to the 2nd position the 1st FX continues to be treated as selected which of course breaks the sequence.

In the animation the down movement action is used.

'Move selected FX up or down in chain for selected tracks' glitch

@Szapi
Copy link
Contributor

Szapi commented Nov 9, 2023

I cannot reproduce this on MacOS.

@Buy-One
Copy link
Author

Buy-One commented Nov 9, 2023

Yeah, should have mentioned that it's Windows, v7

@Szapi
Copy link
Contributor

Szapi commented Nov 9, 2023

I'll take a look when I have the time.

@Buy-One
Copy link
Author

Buy-One commented Nov 14, 2023

I think the reason, as far as i've been able to figure out, is that in non-focused FX chain window LASTSEL value in the chunk isn't updated even though visually selection seems to follow the FX instance. Looking at the track chunk after applying the action to a non-focused FX chain window (as depicted in the animation below) i always found the last FX index to be associated with LASTSEL token, because it had been selected initially, and LASTSEL value never got actually updated. This is what causes the FX to get stuck in an alternating cycle rather than move.

Incompatibility with SWS-BR Focus arrange2

I can't read C++ code very much but to me it seems that these SWS actions rely on a function which uses chunk to move FX in the chain (SNM_MoveOrRemoveTrackFX) rather than on the dedicated API function TrackFX_CopyToTrack and that's where the problem lies i think.

Because of this in some scenarios these SWS actions cannot be used in a custom action to move FX with the mousewheel if SWS/BR: Focus arrange action is involved meant to keep FX chain window out of focus. A custom action such as this:

Custom: Move track FX up/down with mousewheel
Action: Skip next action if CC parameter <0/mid
SWS/S&M: Move selected FX up in chain for selected tracks
Action: Skip next action if CC parameter >0/mid
SWS/S&M: Move selected FX down in chain for selected tracks
SWS/BR: Focus arrange

Here's comparison of custom actions. one based on these SWS actions (showcased first) and another based on my scripts which move take FX and don't rely on the chunk. As can be seen, mine work without a hitch with non-focused FX chain window.

Incompatibility with SWS-BR Focus arrange

@cfillion
Copy link
Collaborator

LASTSEL should be updated via this line:

SelectTrackFX(_tr, fxId + _what);

Works here (also on macOS):
Take

@Buy-One
Copy link
Author

Buy-One commented Nov 14, 2023

Also just noticed in the first animation from my previous post: when FX 5 (4-Tap Phaser) is moved up, the UI which ends up being open after the movement belongs to FX 4 (4-Band EQ) that takes 4-Tap Phaser's place at position 5 which indicates that this is what is actually selected.
While when i use my scripts to move take FX, the UI which is consistently open in the chain belongs to the FX being moved, that is to 4-Tap Phaser.

@Buy-One
Copy link
Author

Buy-One commented Nov 15, 2023

I replicated cfillion's test and still could replicate the issue. FX 1 and 2 keep alternating with none being able to move further down. In the animation after the custom action is executed the 2nd FX is highlighted in grey as if it were selected but the open UI belongs to the 1st FX which is what actually is selected and which isn't supposed to be.

So the problem seems to affect Windows, version 7 at least.

stuck cycle

@cfillion cfillion added the bug label Nov 15, 2023
@cfillion
Copy link
Collaborator

cfillion commented Nov 15, 2023

Looks like it's a REAPER bug. TrackFX_Show fails to display the desired FX on Windows. It just changes the selected one in the list view if the track chunk was set and the FX chain lost focus.

  1. Add two effect plugins on the first track
  2. Select the first effect in the FX chain window
  3. local track = reaper.GetTrack(nil, 0)
    reaper.SetTrackStateChunk(track, select(2, reaper.GetTrackStateChunk(track, '', false))) -- TRIGGER 1
    reaper.TrackFX_Show(track, 1, 1)
    reaper.SetCursorContext(1, nil) -- TRIGGER 2
  4. The second effect becomes selected but the first one remains visible and LASTSEL in the chunk remains 0
  5. After commenting out the SetTrackStateChunk line: the second effect becomes selected + visible + LASTSEL becomes 1

cfillion added a commit to cfillion/sws that referenced this issue Nov 15, 2023
Small behavior change: the SWS API function of the same name now creates
an undo point on its own if not called within an undo block.

Fixes reaper-oss#1791
@Buy-One
Copy link
Author

Buy-One commented Nov 15, 2023

Thank you, works in the latest build.

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 a pull request may close this issue.

3 participants