 |
|
|
07-01-2020, 03:46 AM
|
#1
|
Human being with feelings
Join Date: Apr 2020
Posts: 44
|
Still cannot get indices of selected FXs in track FX chain view by ReaScript?[SOLVED]
In my script, indices of selected FXs in track FX chain view are needed. And I found this thread.
https://forum.cockos.com/showthread.php?t=168718
Is there still no functions for this? And still impossible to get this information?
Last edited by pigstoe; 07-09-2020 at 04:48 PM.
|
|
|
07-01-2020, 08:06 AM
|
#2
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,191
|
Using CF_GetTrackFXChain and CF_EnumSelectedFX from SWS 2.12:
Code:
function enumSelectedTrackFX(track)
local fxChain = reaper.CF_GetTrackFXChain(track)
local i = -1
return function()
i = reaper.CF_EnumSelectedFX(fxChain, i)
if i < 0 then i = nil end
return i
end
end
local track = reaper.GetTrack(nil, 0)
for i in enumSelectedTrackFX(track) do
reaper.ShowConsoleMsg(string.format('%d\n', i))
end
Last edited by cfillion; 07-01-2020 at 08:12 AM.
|
|
|
07-01-2020, 07:08 PM
|
#3
|
Human being with feelings
Join Date: Apr 2020
Posts: 44
|
Quote:
Originally Posted by cfillion
Using CF_GetTrackFXChain and CF_EnumSelectedFX from SWS 2.12:
Code:
function enumSelectedTrackFX(track)
local fxChain = reaper.CF_GetTrackFXChain(track)
local i = -1
return function()
i = reaper.CF_EnumSelectedFX(fxChain, i)
if i < 0 then i = nil end
return i
end
end
local track = reaper.GetTrack(nil, 0)
for i in enumSelectedTrackFX(track) do
reaper.ShowConsoleMsg(string.format('%d\n', i))
end
|
I tested your code and found a bug for CF_EnumSelectedFX() function. If CF_EnumSelectedFX() is used at the track which has track name, it always returns 0. This function works fine only at unnamed track.
Thank you, anyway. I'm going to report it.
|
|
|
07-01-2020, 07:13 PM
|
#4
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,191
|
|
|
|
07-01-2020, 07:32 PM
|
#5
|
Human being with feelings
Join Date: Apr 2020
Posts: 44
|
Quote:
Originally Posted by cfillion
|
After updated, It always returns 0, even at unnamed track.
|
|
|
07-01-2020, 08:06 PM
|
#6
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,191
|
Indices are zero-based so a return value of 0 means the first FX is selected (above the given starting index). Is that value incorrect?
Last edited by cfillion; 07-01-2020 at 08:21 PM.
|
|
|
07-01-2020, 08:36 PM
|
#7
|
Human being with feelings
Join Date: Apr 2020
Posts: 44
|
Quote:
Originally Posted by cfillion
Indices are zero-based so a return value of 0 means the first FX is selected (above the given starting index). Is that value incorrect?
|
Incorrect. When I select nothing, everything, something and even when there is no fx in track, it always returns 0.
|
|
|
07-01-2020, 08:47 PM
|
#8
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,191
|
Mhh... I can't duplicate that here. Can you share a minimal script (assuming it's not exactly as in the snippet above) and/or a minimal project that produce that? (Also, just in case, which OS?)
EDIT: CF_GetTrackFXChain seems to always returns nil now in REAPER 6.12/macOS. Not sure exactly in which version it broke or why, I'll look into it tomorrow. In the case of a nil fx chain, CF_EnumSelectedFX returns -1, not 0 though...
Last edited by cfillion; 07-01-2020 at 08:58 PM.
|
|
|
07-01-2020, 09:18 PM
|
#9
|
Human being with feelings
Join Date: Apr 2020
Posts: 44
|
Quote:
Originally Posted by cfillion
Mhh... I can't duplicate that here. Can you share a minimal script (assuming it's not exactly as in the snippet above) and/or a minimal project that produce that? (Also, just in case, which OS?)
EDIT: CF_GetTrackFXChain seems to always returns nil now in REAPER 6.12/macOS. Not sure exactly in which version it broke or why, I'll look into it tomorrow. In the case of a nil fx chain, CF_EnumSelectedFX returns -1, not 0 though...
|
Found. In process of minimizing my code to share, I found that PreventUIRefresh(1) prevents CF_EnumSelectedFX works fine. Is that a bug? I can't understand why UI refreshing affects getting indices of selected FXs. But, I should remove preventing to refresh UI in this script.
Anyway, thanks!
|
|
|
07-09-2020, 10:43 AM
|
#10
|
Human being with feelings
Join Date: May 2015
Location: Québec, Canada
Posts: 4,191
|
Quote:
Originally Posted by pigstoe
Found. In process of minimizing my code to share, I found that PreventUIRefresh(1) prevents CF_EnumSelectedFX works fine. Is that a bug? I can't understand why UI refreshing affects getting indices of selected FXs. But, I should remove preventing to refresh UI in this script.
|
Ah yes. It's a limitation of the way the function asks REAPER to synchronously update the title of the FX chain window. PreventUIRefresh inhibits TrackList_AdjustWindows.
I discovered a better way to do that while fixing it for v6 on non-Windows so, in the next SWS update, CF_GetTrackFXChain will be usable along with PreventUIRefresh.
|
|
|
07-09-2020, 04:46 PM
|
#11
|
Human being with feelings
Join Date: Apr 2020
Posts: 44
|
Good news. I'm looking forward to it. Thank you.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 05:24 AM.
|