-- @description Toggle solo for selected FX
-- @version 1.1
-- @author MPL
-- @website http://forum.cockos.com/member.php?u=70694 
-- @changelog
--    # perform only one FX chain (first track with opened FX chain)
  

  function main()
    for i=1, reaper.CountTracks(0) do
      local track = reaper.GetTrack(0,i-1)
      if track then 
        FX_cnt = reaper.TrackFX_GetCount( track )
        if FX_cnt > 1 then
    local retval,str = reaper.GetTrackStateChunk(track,"",false);
    local             temp_cnt = tonumber(string.match(str,"LASTSEL (%d+)"));
                  reaper.TrackFX_SetEnabled( track, temp_cnt , true )

			retval, fx_name = reaper.TrackFX_GetFXName(track , temp_cnt , "")
            if fx_name  == "" then fx_name = "No fx" end;

			fx_name = fx_name:gsub("DX: ", "")
			fx_name = fx_name:gsub(" %(.-%)", "")
			fx_name = fx_name:gsub("DXi: ", "")
			fx_name = fx_name:gsub(" %(.-%)", "")
			fx_name = fx_name:gsub("VST: ", "")
			fx_name = fx_name:gsub(" %(.-%)", "")
			fx_name = fx_name:gsub("VSTi: ", "")
			fx_name = fx_name:gsub(" %(.-%)", "")
			fx_name = fx_name:gsub("VST3: ", "")
			fx_name = fx_name:gsub(" %(.-%)", "")
			fx_name = fx_name:gsub("VST3i: ", "")
						fx_name = fx_name:gsub(" %(.-%)", "")
			fx_name = fx_name:gsub("JS: ", "")
						fx_name = fx_name:gsub(" %(.-%)", "")
			fx_name = fx_name:gsub("ReWire: ", "")
						fx_name = fx_name:gsub(" %(.-%)", "")
    reaper.osara_outputMessage("Unbypass all FX")


              for i = 1, FX_cnt do

                  reaper.TrackFX_SetEnabled( track, i-1, true )



              -- enable all



            end
          end
          break
        end
      end
    end

  
  reaper.Undo_BeginBlock()
  reaper.Main_OnCommand(reaper.NamedCommandLookup('_BR_FOCUS_ARRANGE_WND'),0)
  main()
  reaper.Undo_EndBlock("Toggle solo for selected FX", 0)