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

Reply
 
Thread Tools Display Modes
Old 05-21-2022, 10:52 PM   #1
Cloudswim
Human being with feelings
 
Join Date: May 2017
Posts: 372
Default Select track of current focused FX window even if does not already have a fx insert!

Hi, so I set some vst fx to shortcut actions in Reaper so I can insert more quickly without going through the fx browser.

I would like to insert FX directly to the track when its FX window is open. I might have two FX windows open and it would be convenient to just add FX to the FX WINDOW. that is currently in focus.

Last edited by Cloudswim; 05-22-2022 at 08:39 PM. Reason: did not explain the problem I had clearly
Cloudswim is offline   Reply With Quote
Old 05-21-2022, 11:14 PM   #2
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,271
Default

That doesn't make a whole lot of sense to me. You can't have a floating fx window for an fx that doesn't exist yet. Why even click the fx button if you have shortcuts set? Just select the track and use the shortcut.

If you want clicking buttons on the TCP to select the track, that's in prefs/editing behavior/mouse/mouse click...changes track selection but it's all or nothing. I don't like this behavior because I never want to change track selection when I'm clicking the mute button, for example.
__________________
foxyyymusic
foxAsteria is online now   Reply With Quote
Old 05-22-2022, 12:44 AM   #3
Cloudswim
Human being with feelings
 
Join Date: May 2017
Posts: 372
Default

Quote:
Originally Posted by foxAsteria View Post
That doesn't make a whole lot of sense to me. You can't have a floating fx window for an fx that doesn't exist yet. Why even click the fx button if you have shortcuts set? Just select the track and use the shortcut.

If you want clicking buttons on the TCP to select the track, that's in prefs/editing behavior/mouse/mouse click...changes track selection but it's all or nothing. I don't like this behavior because I never want to change track selection when I'm clicking the mute button, for example.
Thanks buddy! That is what I was looking for!

You are also correct that I should click the track and insert, but if I already have a bunch of floating windows on screen its easier for me to just click on the fx button which will be the same gesture to just look for the fx button for all tracks, easier for my brain.

I just find I keep placing plugins on the wrong track for some reason.

Anyways thanks a lot!
Cloudswim is offline   Reply With Quote
Old 05-22-2022, 08:04 AM   #4
Dex
Human being with feelings
 
Join Date: Sep 2017
Posts: 518
Default

Rather than clicking on fx and then your hotkey, why not just click on the track and then your hotkey?
Dex is offline   Reply With Quote
Old 05-22-2022, 08:36 PM   #5
Cloudswim
Human being with feelings
 
Join Date: May 2017
Posts: 372
Default

Quote:
Originally Posted by Dex View Post
Rather than clicking on fx and then your hotkey, why not just click on the track and then your hotkey?
Actually what I would like the track to be selected when the FX window is in focus.

For instance, if I'm working on few tracks and trying out different plugins their FX Window would already be open and it would be convenient to be able to add fx to the FX Window that is in focus. But that is not the case as REAPER will only add fx to the selected track.

I don't really want to go back and forth selecting the track.
Cloudswim is offline   Reply With Quote
Old 05-22-2022, 09:25 PM   #6
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,271
Default

Quote:
Originally Posted by Cloudswim View Post
Actually what I would like the track to be selected when the FX window is in focus.
I had a similar wish and Edgemeal wrote me these scripts. This one has to run in the background to check which track belongs to floating fx, so I add it to my global startup actions.

Code:
-- Save track for focused floating FX(Background).lua

local prev, fgw = nil, nil

function Focused()
  fgw = reaper.JS_Window_GetForeground()
  if fgw then
    if prev ~= fgw then
      prev = fgw
      local track_count = reaper.CountTracks(0)-1 
      for i = 0, track_count do
        local track = reaper.GetTrack(0, i)
        local track_fx_count = reaper.TrackFX_GetCount(track)-1
        for j = 0, track_fx_count do
          if fgw == reaper.TrackFX_GetFloatingWindow(track, j) then
            reaper.SetExtState("Edgemeal", "tr_guid", reaper.GetTrackGUID(track), false) 
            goto fini
          end
        end
      end
    end
  end
  ::fini::
  reaper.defer(Focused)
end

Focused()

Then this one can be run to select the track and scroll it into view. Not automatic, but you can assign a shortcut to select the track of the focused fx. I suppose you could combine it with your add fx shortcuts to make it more seamless. If you don't want the view to scroll, you can just take out those two lines.

Code:
-- Scroll track into view for last focused floating fx

function Restore(guid)
  local track = reaper.BR_GetMediaTrackByGUID(0, guid)
  if track ~= nil then
    reaper.SetOnlyTrackSelected(track)
    reaper.Main_OnCommand(40913, 0) -- Track: Vertical scroll selected tracks into view
    reaper.SetMixerScroll(track) -- scroll mixer
    return true
  end
end

local guid = reaper.GetExtState("Edgemeal", "tr_guid")
if guid ~= "" then
  if not Restore(guid) then reaper.SetExtState("Edgemeal", "tr_guid", "", false) end
end
__________________
foxyyymusic
foxAsteria is online now   Reply With Quote
Old 05-22-2022, 11:07 PM   #7
Cloudswim
Human being with feelings
 
Join Date: May 2017
Posts: 372
Default

Quote:
Originally Posted by foxAsteria View Post
I had a similar wish and Edgemeal wrote me these scripts. This one has to run in the background to check which track belongs to floating fx, so I add it to my global startup actions.

Code:
-- Save track for focused floating FX(Background).lua

local prev, fgw = nil, nil

function Focused()
  fgw = reaper.JS_Window_GetForeground()
  if fgw then
    if prev ~= fgw then
      prev = fgw
      local track_count = reaper.CountTracks(0)-1 
      for i = 0, track_count do
        local track = reaper.GetTrack(0, i)
        local track_fx_count = reaper.TrackFX_GetCount(track)-1
        for j = 0, track_fx_count do
          if fgw == reaper.TrackFX_GetFloatingWindow(track, j) then
            reaper.SetExtState("Edgemeal", "tr_guid", reaper.GetTrackGUID(track), false) 
            goto fini
          end
        end
      end
    end
  end
  ::fini::
  reaper.defer(Focused)
end

Focused()

Then this one can be run to select the track and scroll it into view. Not automatic, but you can assign a shortcut to select the track of the focused fx. I suppose you could combine it with your add fx shortcuts to make it more seamless. If you don't want the view to scroll, you can just take out those two lines.

Code:
-- Scroll track into view for last focused floating fx

function Restore(guid)
  local track = reaper.BR_GetMediaTrackByGUID(0, guid)
  if track ~= nil then
    reaper.SetOnlyTrackSelected(track)
    reaper.Main_OnCommand(40913, 0) -- Track: Vertical scroll selected tracks into view
    reaper.SetMixerScroll(track) -- scroll mixer
    return true
  end
end

local guid = reaper.GetExtState("Edgemeal", "tr_guid")
if guid ~= "" then
  if not Restore(guid) then reaper.SetExtState("Edgemeal", "tr_guid", "", false) end
end

Hi thanks!

The first one is greyed out when I try to import into REAPER actions, says cant import for some reason when I tty to drag the LUA file in directly


Second one nothing happens when the action is triggered....

hmm could you help me? thank!
Cloudswim is offline   Reply With Quote
Old 05-23-2022, 10:27 AM   #8
foxAsteria
Human being with feelings
 
foxAsteria's Avatar
 
Join Date: Dec 2009
Location: Oblivion
Posts: 10,271
Default

Open actions list, click new action, name the action, paste the code text from here into the black window that appears and hit ctrl+s to save it. Easy peasy.

The second script depends on the first one to be running in the background.
__________________
foxyyymusic
foxAsteria is online now   Reply With Quote
Old 05-23-2022, 08:12 PM   #9
Cloudswim
Human being with feelings
 
Join Date: May 2017
Posts: 372
Default

Quote:
Originally Posted by foxAsteria View Post
Open actions list, click new action, name the action, paste the code text from here into the black window that appears and hit ctrl+s to save it. Easy peasy.

The second script depends on the first one to be running in the background.

hmm its not working for me..

the first one is on in the background and nothing happens when I trigger the 2nd action :-(
Cloudswim is offline   Reply With Quote
Old 05-23-2022, 09:20 PM   #10
Cloudswim
Human being with feelings
 
Join Date: May 2017
Posts: 372
Default

https://forums.cockos.com/showthread.php?p=1830901

Found this one , its working for me!

Incase any one needs it in the future!
Cloudswim 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 12:05 PM.


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