Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 07-01-2020, 03:46 AM   #1
pigstoe
Human being with feelings
 
Join Date: Apr 2020
Posts: 44
Default 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.
pigstoe is offline   Reply With Quote
Old 07-01-2020, 08:06 AM   #2
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,967
Default

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.
cfillion is offline   Reply With Quote
Old 07-01-2020, 07:08 PM   #3
pigstoe
Human being with feelings
 
Join Date: Apr 2020
Posts: 44
Default

Quote:
Originally Posted by cfillion View Post
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.
pigstoe is offline   Reply With Quote
Old 07-01-2020, 07:13 PM   #4
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,967
Default

Update SWS to 2.12. https://www.sws-extension.org/download/pre-release/
cfillion is offline   Reply With Quote
Old 07-01-2020, 07:32 PM   #5
pigstoe
Human being with feelings
 
Join Date: Apr 2020
Posts: 44
Default

Quote:
Originally Posted by cfillion View Post
After updated, It always returns 0, even at unnamed track.
pigstoe is offline   Reply With Quote
Old 07-01-2020, 08:06 PM   #6
cfillion
Human being with feelings
 
cfillion's Avatar
 
Join Date: May 2015
Location: Québec, Canada
Posts: 4,967
Default

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.
cfillion is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:37 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.