View Single Post
Old 08-13-2019, 09:39 AM   #510
pianogineer
Human being with feelings
 
Join Date: Nov 2011
Posts: 105
Default

Wow, thanks for all the quick replies! I think I was able to get something working with a slight modification to look at the filename, since I'm not using multiple project tabs, and it seems like the ReaProj pointer doesn't change if you simply open a new project (not in tab).

Code:
last_ReaProj, last_projfn = reaper.EnumProjects(-1, "")

function main()
  active_ReaProj, active_projfn =  reaper.EnumProjects(-1, "")
  if active_projfn == last_projfn then
    -- save volume state if project is unchanged
    vol = reaper.GetMediaTrackInfo_Value(reaper.GetMasterTrack(0), "D_VOL")
    reaper.SetExtState("josh","master_vol",vol,false)
  
  else
    -- update master volume if project changes
    saved_vol = reaper.GetExtState("josh","master_vol")
    reaper.SetMediaTrackInfo_Value(reaper.GetMasterTrack(0),"D_VOL",saved_vol)
  end
  last_projfn = active_projfn
  reaper.defer(main)
end

main()
Quote:
Originally Posted by nofish View Post
an idea would be to have a dedicated project open in a tab which monitors for active project change in a background script.
..
A drawback for live use may be if you (accidently) close the monitoring project you'd loose the trigger of course, hm..
Why would I need a dedicated project tab open to keep the script running? From what I can tell, scripts run independently of projects, so if I kick off an endless defer, it seems to continue running even as I switch my (only open) project.

This leads to another question -- how do I actually stop endless defer scripts?? I've read elsewhere that ReaScripts act like toggles, and if you run an endless defer script again it'll stop, but this doesn't seem to work for me.

Quote:
Originally Posted by mschnell View Post
AFAIK, routing Midi and/or audio between multiple project tabs is not perfectly provided, hence I doubt that the "multiple projects" way leads to a decently viable solution.
Not sure I follow. I basically have a project per backing track which I'm opening (not in tabs) via SWS Resources. I'm not having to route audio between projects. Perhaps you're referring to a use case where I wanted VST's open continually in one project, while new backing tracks opening in additional projects? Haven't gotten to that need in my workflow yet, but was potentially thinking about multiple reaper instances in that case, or maybe just routing to different channels of my multi-channel interface and mixing things there. Reason for multiple projects is needing to loop over different regions per song controlled by same MIDI CC (foot pedal), but this is becoming a topic for the Live Forum..

Thanks all!
pianogineer is offline   Reply With Quote