Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 05-06-2012, 04:01 PM   #1
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default [IID#4138] Action: go to start of selection

Link to FR. Please vote here.
Learn more about the Feature Request tracker here

Summary line: An action which goes to the beginning of selected items / envelope points

Quote:
Originally Posted by visa tapani
One of my most used key commands in Cubase is "locate beginning of selection", which, surprisingly is missing from Reaper. This is not the same as "Go to the start of time selection". Instead, I want (and most hosts have) a command that goes to the beginning of any items, envelope points etc I have selected.

For example, if I would select a couple of envelope points and trigger the action, it would go to the first of these. If I'd select a number of items and trigger it, it would go to the beginning of the first of these. Very useful basic feature. I managed to half-do this action with a custom command that consists of 1.) "Time selection: set time selection to items" and 2.) "Go to start of time selection". However, this is not good enough, because: A. it only works for items, not envelope points and B. it unnecessarily changes the time selection.
gofer is offline   Reply With Quote
Old 05-06-2012, 04:03 PM   #2
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default transfer from tracker IID#4138

from the tracker:

Quote:
Originally Posted by Viente
You can update this custom action and add "save time selection/restore saved time selection" (SWS) to keep your time selection
Quote:
Originally Posted by gofer
For items you can use "Move cursor to start of items". It will place the cursor at the left edge of the first selected item. Won't work with envelope points though.
gofer is offline   Reply With Quote
Old 05-06-2012, 05:36 PM   #3
timlloyd
Human being with feelings
 
Join Date: Mar 2010
Posts: 4,713
Default

It's not particularly pretty, but here's a Python script ...

Edit - updated:
- prevent error when context is items but no items are selected
- when context is envelope lane show alert if script can't deal with as many env points as are in the selected lane
- when context is envelope and no points are selected, do nothing instead of locating to last point
Edit - update 2:
- if all envelope points in a lane are selected, go to the second point not the first, as it's perpetually at the project start
- made max_len 1000000 just for the heck of it

Code:
import shlex

# ------------
# locate_start_of_selection.py
#     - if items are selected, move edit cursor to start of first selected item
#     - if envelope is selected, move edit cursor to first selected point
# Should work with a lot of envelope points, if not just increase the value of max_len
# ------------

def msg(m):
    RPR_ShowConsoleMsg(str(m) + "\n")

def cursor_to_start_of_first_sel_item():
    pos_list = [ ]
    num_items = RPR_CountSelectedMediaItems(0)
    if num_items > 0:
        i = 0
        for i in range(0, num_items):
            item = RPR_GetSelectedMediaItem(0, i)
            pos = RPR_GetMediaItemInfo_Value(item, "D_POSITION")
            pos_list.append(pos)
            i += 1
        pos_list.sort()
        RPR_SetEditCurPos2(0, pos_list[0], 1, 0)

def cursor_to_first_sel_env_point():
    try:
        sel_env = RPR_GetSelectedTrackEnvelope(0)
        env_chunk = RPR_GetSetEnvelopeState2(sel_env, "", max_len, 0)
        split_1 = env_chunk[2].split("1\nPT")
        split_2 = split_1[1].split("PT")
        length = len(split_2)
        first_sel_point = split_2[length - 1]
        first_sel_point_list = shlex.split(first_sel_point)
        first_sel_point_pos = float(first_sel_point_list[0])
        if first_sel_point_list[3] == "0":
            if first_sel_point_pos == 0:
                second_sel_point = split_1[2]
                second_sel_point_list = shlex.split(second_sel_point)
                second_sel_point_pos = float(second_sel_point_list[0])
                RPR_SetEditCurPos2(0, second_sel_point_pos, 1, 0)
            else:
                RPR_SetEditCurPos2(0, first_sel_point_pos, 1, 0)
    except IndexError:
        RPR_MB("Script unable to cope with so many envelope points!"
               "Increase the value of \"max_len\" and try again.", "Oops!", 0)
    
# ------------

max_len = 1000000
context = RPR_GetCursorContext()

if context == 1:
    cursor_to_start_of_first_sel_item()
elif context == 2:
    cursor_to_first_sel_env_point()
This is just to keep us ticking over til a native action btw - not trying to undermine the FR! Native is best

Last edited by timlloyd; 05-07-2012 at 04:08 AM.
timlloyd is offline   Reply With Quote
Old 05-08-2012, 05:10 AM   #4
visa tapani
Human being with feelings
 
Join Date: Mar 2012
Posts: 21
Default

Thanks timlloyd! I'll give that a shot once I've installed Python.

Gofer, is there a way of changing the priority of a ticket in the issues tracker? Since you pointed out that this can already be done with items and hence the functionality is only missing for envelope points, I'd like to reduce the priority of the ticket.

Also, where did you see the IID# number for the ticket? Is that something that should be included in the title of a discussions thread relating to a particular ticket? Also, do you think a separate discussion thread should be created in the 'Feature Requests' -forum, even if there are already discussion threads relating to the issue elsewhere (as in, for example this case)?

Last edited by visa tapani; 05-08-2012 at 05:23 AM.
visa tapani is offline   Reply With Quote
Old 05-08-2012, 05:40 AM   #5
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
Default

@ timlloyd

Just did a short test with the script, does what it says without problems (as far as I can tell).
Thanks also from me.
nofish is offline   Reply With Quote
Old 05-08-2012, 10:58 AM   #6
gofer
-blänk-
 
gofer's Avatar
 
Join Date: Jun 2008
Posts: 11,359
Default

I don't know whether there is another place to find out the ID# for your ticket, I just look it up in the address line of the browser. It's not particularly important to have it in the title of a discussion thread, actually it's best practice to have the discussion thread first - to clear up and tighten the issue - before opening the ticket.


Guess it (once more) shows that I am a bit dim-lighted when it comes to the technical part of forum activity... - I can't tell you whether a user can change priority . I have a bunch of triangles in the field where priority and stuff is listed and can change them that way, but I guess it's mods only? Which priority would you like it to have?

If there already is a convenient discussion thread (best with not too much off topic clutter) then it's good enough to use that one (not important whether it is in the FR forum or elsewhere).
gofer 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 12:29 PM.


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