Old 05-29-2020, 05:25 AM   #1
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 10,474
Default Multilayer shortcut

SWS NEEDED
Good morning all,
Here is a script that can be derived in many different ways.
In the example here, it concerns the zoom

how does it work ?

add a keyboard shortcut (for example "z") to the script

when you launch it, a User input window appears

enter a number from 1 to 5 followed by ENTER

1 -> zoom on the item
2 -> zoom on the track
3-> zoom on the time selection
4 -> zoom on the project
5 -> zoom tool

The goal is to have a single shortcut that contains several actions to avoid the use of modifiers not always easy to remember

Script can be duplicated and modified to match another keyshorcut

example "S"

1-> split item at cursor
2-> stretch marker at cursor
3-> split at time selection
4 -> split and crossfade
5 -> split and quantize

If you want to customise the script, just replace the red part of the code to fit your need (action ID must be in "" for custom action, cycle action, sws and script.



Code:
local function act(cmdid) 
  if type(cmdid) == "string" then
    cmdid = reaper.NamedCommandLookup(cmdid)
  end
  reaper.Main_OnCommand(cmdid, 0) 
end
------ USER MOD ------------------------------
action1 = "_SWS_TOGZOOMIONLY" -- zoom to item
action2 = 40113 -- zoom to track 
action3 = "_SWS_TOGZOOMHORIZ_TSEL"-- zoom to time selection
action4 = 40295 -- zoom project
action5 = "_SWS_ZOOM" -- zoom tool

-------------------------------------


--------------------------------
function main()
reaper.Undo_BeginBlock()
  _, val = reaper.GetUserInputs("Multilayer Shortcut", 1, "Zoom to", "")
  if val == "1" then
  act (action1)
  end
  if val == "2" then
  act (action2)
  end
  if val == "3" then
  act (action3)
  end
  if val == "4" then
  act (action4)
  end
  if val == "5" then
  act (action5)
  end
end

main()
reaper.UpdateArrange()
reaper.Undo_EndBlock("layer zoom", 0)
__________________
http://www.residenceemilia.com
Reno.thestraws is offline   Reply With Quote
Old 05-29-2020, 10:28 AM   #2
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,528
Default

here is a little more clean code:

Code:
local function act(cmdid) 
  if type(cmdid) == "string" then
    cmdid = reaper.NamedCommandLookup(cmdid)
  end
  reaper.Main_OnCommand(cmdid, 0) 
end
------ USER MOD ------------------------------
actions = { "_SWS_TOGZOOMIONLY" , 
            40113, 
            "_SWS_TOGZOOMHORIZ_TSEL", 
            40295, 
            "_SWS_ZOOM"
          }
function main()
  reaper.Undo_BeginBlock()
  local _, val = reaper.GetUserInputs("Multilayer Shortcut", 1, "Zoom to", "")
  act(actions[tonumber(val)])
end

main()
reaper.UpdateArrange()
reaper.Undo_EndBlock("layer zoom", 0)
table has index (1,2,3,4.... etc)
Sexan is offline   Reply With Quote
Old 05-29-2020, 10:35 AM   #3
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 10,474
Default

Thank you

And is there a way to use table if user prefer use letter instead of number?

Like i for item, t for track, s for selection allowing to do "z,i,enter" for zooming on item or z,s,enter for zoom to selection

Feel free to adapt as your heart content
__________________
http://www.residenceemilia.com
Reno.thestraws is offline   Reply With Quote
Old 05-29-2020, 10:41 AM   #4
Sexan
Human being with feelings
 
Sexan's Avatar
 
Join Date: Jun 2009
Location: Croatia
Posts: 4,528
Default

yeah you can, for example:

Code:
actions = {["1"] = x,
           ["2"] = y,
           ["t"] = z
           ["i"] = xyz
}
With this you do not need to convert val to number you can just use as is (string) since table key is now string (when you use quotation)):

Code:
act(actions[(val)])
Sexan is offline   Reply With Quote
Old 05-29-2020, 10:43 AM   #5
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 10,474
Default

Thanks
__________________
http://www.residenceemilia.com
Reno.thestraws is offline   Reply With Quote
Old 06-03-2020, 01:10 PM   #6
zookthespook
Human being with feelings
 
Join Date: Mar 2015
Location: India Mumbai
Posts: 816
Default

This is a cool idea, will try it out !
On the same idea i have a question to ask,
Is it possible to double or triple tap the same key and do this ?
say when you press C- it splits an item
but if you press CC in quick sucession , it trims the item to time selection ?
zookthespook is offline   Reply With Quote
Old 06-03-2020, 01:18 PM   #7
Reno.thestraws
Human being with feelings
 
Reno.thestraws's Avatar
 
Join Date: Nov 2009
Location: Belgium
Posts: 10,474
Default

As far as i know, it's not possible
__________________
http://www.residenceemilia.com
Reno.thestraws is offline   Reply With Quote
Old 06-04-2020, 07:09 AM   #8
zookthespook
Human being with feelings
 
Join Date: Mar 2015
Location: India Mumbai
Posts: 816
Default

ok thank you for the response reno !
zookthespook is offline   Reply With Quote
Old 06-04-2020, 07:28 AM   #9
amagalma
Human being with feelings
 
amagalma's Avatar
 
Join Date: Apr 2011
Posts: 3,450
Default

Quote:
Originally Posted by zookthespook View Post
This is a cool idea, will try it out !
On the same idea i have a question to ask,
Is it possible to double or triple tap the same key and do this ?
say when you press C- it splits an item
but if you press CC in quick sucession , it trims the item to time selection ?

Maybe this could help
__________________
Most of my scripts can be found in ReaPack.
If you find them useful, a donation would be greatly appreciated! Thank you! :)
amagalma is offline   Reply With Quote
Old 06-06-2020, 04:43 AM   #10
zookthespook
Human being with feelings
 
Join Date: Mar 2015
Location: India Mumbai
Posts: 816
Default

Quote:
Originally Posted by amagalma View Post

Wow,this was exactly i was hoping for !! thank you for pointing towards this !

zook
zookthespook 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 10:16 PM.


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