Old 02-22-2019, 10:43 AM   #1
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 427
Default LUA: DisArm all tracks from all projects

Hey guys, Can somebody tell why this doesn't work?
If I run this function, All opened project tabs will play but won't disarm all tracks

Code:
function DisarmAllProjects()
  for p = 0, 1000 do	local proj = reaper.EnumProjects(p, 0)
	if not proj then break
	else
	  reaper.Main_OnCommandEx(40491,0,proj) -- 40491 = UnArm all tracks from project
	  reaper.Main_OnCommandEx(1007,0,proj) -- Start Playback
	end
  end
end
__________________
MP 12 Core 3.46GHZ 48GB OSX10.11.6, MBP 15" 2012 OSX10.12, RME Fireface UFX, MCU,
Reaper 5, SD2, Omnisphere, Wave Altiverb, PSP, VB3, Izotope, Scuffham, Soundtoys 5, Slate All Plugins.
lexaproductions is offline   Reply With Quote
Old 02-22-2019, 10:46 AM   #2
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,555
Default

You need to switch to the other project-tab first for the commands to work in that project-tab as well.

Otherwise, they are just run in the active projecttab, but not in the other ones.

This should help you doing that:

https://mespotin.uber.space/Mespotin...rojectInstance
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 02-22-2019, 10:52 AM   #3
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 427
Default

But then why is the play action working? If I run this script, All tabs start playback (as expected with Main_OnCommandEx command)

But only the frontmost project is UnArmed.
__________________
MP 12 Core 3.46GHZ 48GB OSX10.11.6, MBP 15" 2012 OSX10.12, RME Fireface UFX, MCU,
Reaper 5, SD2, Omnisphere, Wave Altiverb, PSP, VB3, Izotope, Scuffham, Soundtoys 5, Slate All Plugins.
lexaproductions is offline   Reply With Quote
Old 02-22-2019, 10:54 AM   #4
mespotine
Human being with feelings
 
mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig, Germany
Posts: 1,555
Default

It seems like the play-action works on numerous projects, while the unarm-action doesn't.

Can't check it right now, but this should be the case...
__________________
Ultraschall-API - a Lua-functions-library4Reaper: https://forum.cockos.com/showthread....98#post2067798
Reaper Internals - Developerdocs4Reaper: https://forum.cockos.com/showthread.php?t=207635
mespotine is offline   Reply With Quote
Old 02-22-2019, 11:13 AM   #5
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 427
Default

Then how can I make my disarm action Tab-specific? I thought that was what the "for -> do" loop did?
__________________
MP 12 Core 3.46GHZ 48GB OSX10.11.6, MBP 15" 2012 OSX10.12, RME Fireface UFX, MCU,
Reaper 5, SD2, Omnisphere, Wave Altiverb, PSP, VB3, Izotope, Scuffham, Soundtoys 5, Slate All Plugins.
lexaproductions is offline   Reply With Quote
Old 02-22-2019, 02:15 PM   #6
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 1,365
Default

As mentioned, you'll have to select the project.

Since project is selected I used the normal commands and it works here,..

Code:
function DisarmAllProjects()
  for p = 0, 1000 do
    local proj = reaper.EnumProjects(p, 0)
    if not proj then
      break
    else
      reaper.SelectProjectInstance(proj)
      reaper.Main_OnCommand(40491, 0) -- Track: Unarm all tracks for recording 
      reaper.Main_OnCommand(1007, 0) -- Transport: Play 
    end
  end
end
If you need to restore the originally selected project tab look in ReaPack, theres a few scripts to save and restore selected tab.

EDIT Saving and restoring proj tab seems simple enough,....
Code:
function DisarmAllProjects()
  -- save  current selected proj tab
  local cur_proj = reaper.EnumProjects(-1, 0)
   
  for p = 0, 1000 do
    local proj = reaper.EnumProjects(p, 0)
    if not proj then
      break
    else
      reaper.SelectProjectInstance(proj)
      reaper.Main_OnCommand(40491, 0) -- Track: Unarm all tracks for recording 
      reaper.Main_OnCommand(1007, 0) -- Transport: Play 
    end
  end
  
  -- restore original selected proj tab
  if cur_proj then reaper.SelectProjectInstance(cur_proj) end
end

Last edited by Edgemeal; 02-22-2019 at 03:01 PM.
Edgemeal is offline   Reply With Quote
Old 02-22-2019, 03:44 PM   #7
lexaproductions
Human being with feelings
 
Join Date: Jan 2013
Posts: 427
Default

Wow This Works Great!

Now how would you go about always ignoring the first Project tab. By ignoring, I mean leave it alone and don't disarm anything in it.

EDIT:
Never mind I think this works:

Code:
function DisarmAllProjects()
  -- save  current selected proj tab
  local cur_proj = reaper.EnumProjects(-1, 0)
   
  for p = 0, 1000 do
    local proj = reaper.EnumProjects(p, 0)
    if not proj then
      break
    else
		if p > 0 then
    		reaper.SelectProjectInstance(proj)
		    reaper.Main_OnCommand(40491, 0) -- Track: Unarm all tracks for recording 
		end
    end
  end
__________________
MP 12 Core 3.46GHZ 48GB OSX10.11.6, MBP 15" 2012 OSX10.12, RME Fireface UFX, MCU,
Reaper 5, SD2, Omnisphere, Wave Altiverb, PSP, VB3, Izotope, Scuffham, Soundtoys 5, Slate All Plugins.
lexaproductions 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 09:43 AM.


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