Old 07-13-2018, 07:16 AM   #1
Tod
Human being with feelings
 
Tod's Avatar
 
Join Date: Jan 2010
Location: Kalispell
Posts: 14,745
Default Horizontal zoom to time selection

We've got "SWS: Toggle horizontal zoom to time selection" that's a toggle, but the toggle state can get out of sequence so that it doesn't function properly.

Can just a straight (non-toggle) "Horizontal zoom to time selection" be scripted?

Thanks
Tod is offline   Reply With Quote
Old 07-13-2018, 08:37 AM   #2
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

This should do the magic, if I understood that action correctly. Needs SWS.
Maybe buggy, as I coded it in this forum, not in Reaper, though

Just copy the code into a new script:

Code:
starttime, endtime = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
reaper.BR_SetArrangeView(0, starttime, endtime)
Meo-Ada Mespotine is offline   Reply With Quote
Old 07-13-2018, 09:43 AM   #3
Tod
Human being with feelings
 
Tod's Avatar
 
Join Date: Jan 2010
Location: Kalispell
Posts: 14,745
Default

Quote:
Originally Posted by mespotine View Post
This should do the magic, if I understood that action correctly. Needs SWS.
Maybe buggy, as I coded it in this forum, not in Reaper, though

Just copy the code into a new script:

Code:
starttime, endtime = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
reaper.BR_SetArrangeView(0, starttime, endtime)
Thank you very much mespotine, this works. It does zoom in a little more then I'd like but I just put a zoom out after it and it works perfect.
Tod is offline   Reply With Quote
Old 07-13-2018, 10:35 AM   #4
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

You can change the last line to use starttime - 1, endttime + 1 or something for a bit of padding. (Value is in seconds)
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 07-13-2018, 11:54 AM   #5
Tod
Human being with feelings
 
Tod's Avatar
 
Join Date: Jan 2010
Location: Kalispell
Posts: 14,745
Default

Quote:
Originally Posted by Lokasenna View Post
You can change the last line to use starttime - 1, endttime + 1 or something for a bit of padding. (Value is in seconds)
Ah thanks Lokasenna, do decimals also work? Just thinking I might be able to perfect the zoom.

This could end up to be a much used script, I'm constantly needing to zoom in certain amounts.
Tod is offline   Reply With Quote
Old 07-13-2018, 12:00 PM   #6
Lokasenna
Human being with feelings
 
Lokasenna's Avatar
 
Join Date: Sep 2008
Location: Calgary, AB, Canada
Posts: 6,551
Default

Quote:
Originally Posted by Tod View Post
Ah thanks Lokasenna, do decimals also work? Just thinking I might be able to perfect the zoom.

This could end up to be a much used script, I'm constantly needing to zoom in certain amounts.
Yup, milliseconds work just fine.

However, a percentage-based pad would probably be more useful - if you want to zoom to a small time selection and then your pad was backing out a large ways, etc, absolute values wouldn't be too helpful.

Code:
local pad = 10 -- % of the time selection's length to pad out

local starttime, endtime = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false)
local length = endtime - starttime
local pad_amt = 0.5 * (length * (pad / 100))
reaper.BR_SetArrangeView(0, starttime - pad_amt, endtime + pad_amt)
Edit the amount on the first line to whatever you want.
__________________
I'm no longer using Reaper or working on scripts for it. Sorry. :(
Default 5.0 Nitpicky Edition / GUI library for Lua scripts / Theory Helper / Radial Menu / Donate
Lokasenna is offline   Reply With Quote
Old 07-13-2018, 12:07 PM   #7
Tod
Human being with feelings
 
Tod's Avatar
 
Join Date: Jan 2010
Location: Kalispell
Posts: 14,745
Default

Quote:
Originally Posted by Lokasenna View Post
Yup, milliseconds work just fine.

However, a percentage-based pad would probably be more useful - if you want to zoom to a small time selection and then your pad was backing out a large ways, etc, absolute values wouldn't be too helpful.
Thanks again Lokasenna, I checked the +1 on the endtime and it worked perfect. Milliseconds is good, I'm going to be able to use this script for a lot of things.
Tod is offline   Reply With Quote
Old 07-18-2018, 07:45 AM   #8
Meo-Ada Mespotine
Human being with feelings
 
Meo-Ada Mespotine's Avatar
 
Join Date: May 2017
Location: Leipzig
Posts: 6,621
Default

You're welcome
Meo-Ada Mespotine is offline   Reply With Quote
Old 07-20-2018, 02:21 PM   #9
Tod
Human being with feelings
 
Tod's Avatar
 
Join Date: Jan 2010
Location: Kalispell
Posts: 14,745
Default

Quote:
Originally Posted by mespotine View Post
You're welcome
Thanks again mespotine, I'm getting a lot of use out of it.
Tod is offline   Reply With Quote
Old 07-21-2018, 07:45 PM   #10
jp65535
Human being with feelings
 
jp65535's Avatar
 
Join Date: Jan 2013
Location: San Jose, CA
Posts: 115
Default

Thank You Tod - For asking the question.
Thank You Mespotine - For the initial script.
Thank You Lokasenna - For the script enhancements.

And Thanks to the various website authors who's writings gave me the clues needed to take that raw text and turn it into an actual script. And how to create a custom toolbar button.

This, plus a button for me2beats 'Horizontal Zoom to Project', and I'm already working faster.

Thanks to you all for sharing your knowledge!

~john~
jp65535 is offline   Reply With Quote
Old 07-22-2018, 05:48 AM   #11
Triode
Human being with feelings
 
Triode's Avatar
 
Join Date: Jan 2012
Posts: 1,180
Default

Yes this is really handy for me also.
__________________
Mixing / Brush and Beater Drums Online: www.outoftheboxsounds.com
Triode is online now   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 11:59 AM.


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