Old 04-14-2013, 01:01 PM   #81
James HE
Human being with feelings
 
James HE's Avatar
 
Join Date: Mar 2007
Location: I'm in a barn
Posts: 4,467
Default

Quote:
Originally Posted by Argitoth View Post
It probably would work if it existed, lol! What you are actually referring to is "explode *takes* of items in place" and it does nothing to the actual items provided they don't have takes.
OK so you have a bunch of overlapping items on one track, correct? I misunderstood.

hmmm....

SO i guess you are making, like, velocity spilts or something, then moving all those to the same start on the track? then rendering to stem tracks?

I guess the track is in free item positioning mode?

If you have items stacked up like that, why not just render the items and be done with it?

there is apply FX, and apply track FX, to items. This also will number the renders in order if they have the same take name. Just use something to take "render" out of the file name.

the first file will have no number, so you might need to deal with that.

Did I help? lol. hopefully not making wrong assumptions about what you are trying to do.
James HE is offline   Reply With Quote
Old 04-14-2013, 01:07 PM   #82
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

[~~~~] = media item

I just need this:
[~~~~][~~~~][~~~~][~~~~][~~~~]

to this:
[~~~~]
_______[~~~~]
______________[~~~~]
_____________________[~~~~]
____________________________[~~~~]

but do not create new tracks like Xenakios "explode items"

Edit: Xenakios "spread items over tracks tracks..." works except that you have to type in a number... I'll use that for now, but would much rather have a hotkey without a menu popping up.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template

Last edited by Argitoth; 04-14-2013 at 01:48 PM.
Argitoth is offline   Reply With Quote
Old 04-15-2013, 04:08 PM   #83
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

Sorry if I'm abusing the script request. I'm done exploding all items. Now I need to implode them. None of the actions for this seem to work.

I've tried imploding items then xenakios "reposition items" but that places the items out of order.

I've tried imploding items into takes and exploding takes in order, but that removes length and snap offset settings per items.

If only "reposition items" worked across tracks, I could offset each item so when I went to implode and explode items, it would explode them in order.

this:
[]
[]
[]
[]

to this:
[]
_[]
__[]
___[]

to this:
[][][][]

edit: wait a minute, a macro is brewing in my head.

GOT IT!

Track: Go to next track
Item: Select all items in track
Move edit cursor forward one beat
Item edit: Move position of item to edit cursor
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template

Last edited by Argitoth; 04-15-2013 at 04:20 PM.
Argitoth is offline   Reply With Quote
Old 04-16-2013, 11:09 AM   #84
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Argitoth View Post
[~~~~] = media item

I just need this:
[~~~~][~~~~][~~~~][~~~~][~~~~]

to this:
[~~~~]
_______[~~~~]
______________[~~~~]
_____________________[~~~~]
____________________________[~~~~]

but do not create new tracks like Xenakios "explode items"

Edit: Xenakios "spread items over tracks tracks..." works except that you have to type in a number... I'll use that for now, but would much rather have a hotkey without a menu popping up.
Maybe this works. It doesn't create new tracks:

Code:
from reaper_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Spread selected items over tracks"):

    def msg(m):
        RPR_ShowConsoleMsg(m)

    selItemIdL = []

    # get first selected item and track index
    firstSelItem =  RPR_GetSelectedMediaItem(0, 0)
    track = RPR_GetMediaItem_Track(firstSelItem)
    trackIndex = int(RPR_GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER"))
    trackItemCount = RPR_CountTrackMediaItems(track)

    # make list from selected items in track
    for i in range(trackItemCount):
        itemId = RPR_GetTrackMediaItem(track, i)
        if int(RPR_GetMediaItemInfo_Value(itemId, "B_UISEL")):
            selItemIdL.append(itemId)

    # check if there are enough tracks for items
    needed = int(RPR_CountTracks(0) - trackIndex + 1 - len(selItemIdL))
    if needed < 0:
        msg("Not enough tracks for items. Add " + str(abs(needed)) + " track(s)")
    else:
        # move each item to its own track
        for j, id in enumerate(selItemIdL):
            destTrack = RPR_CSurf_TrackFromID(trackIndex + j, 0)
            RPR_MoveMediaItemToTrack(id, destTrack)
        RPR_UpdateArrange()
spk77 is offline   Reply With Quote
Old 04-16-2013, 11:54 AM   #85
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

spk77 almost perfect!

Could you make the script add the needed tracks? Yes, I originally said to make a script that doesn't add tracks, but only because I didn't want it to add tracks every freaking time I run the action. But definitely creating the needed tracks would be one less step I have to worry about.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-17-2013, 09:51 AM   #86
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Ok, now it creates new tracks if needed.



Code:
from reaper_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Spread selected items over tracks - add tracks if needed"):

    def msg(m):
        RPR_ShowConsoleMsg(m)

    selItemIdL = []

    # get first selected item and track index
    firstSelItem =  RPR_GetSelectedMediaItem(0, 0)
    track = RPR_GetMediaItem_Track(firstSelItem)
    trackIndex = int(RPR_GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER"))
    trackItemCount = RPR_CountTrackMediaItems(track)

    # make list from selected items in track
    for i in range(trackItemCount):
        itemId = RPR_GetTrackMediaItem(track, i)
        if int(RPR_GetMediaItemInfo_Value(itemId, "B_UISEL")):
            selItemIdL.append(itemId)

    # check if there are enough tracks for items, create more tracks if needed
    needed = int(RPR_CountTracks(0) - trackIndex + 1 - len(selItemIdL))
    if needed < 0:
        for tr in range(abs(needed)):
            RPR_InsertTrackAtIndex(trackIndex, 1)

    # check if next tracks are empty
    for t in range(len(selItemIdL) - 1):
        # create new track if there are already items in "destination" track
        if RPR_CountTrackMediaItems(RPR_GetTrack(0, trackIndex + t)) > 0:
            RPR_InsertTrackAtIndex(trackIndex, 1)

    # move each item to its own track
    for j, id in enumerate(selItemIdL):
        destTrack = RPR_CSurf_TrackFromID(trackIndex + j, 0)
        RPR_MoveMediaItemToTrack(id, destTrack)

    # update view
    RPR_TrackList_AdjustWindows(False)
    RPR_UpdateArrange()
spk77 is offline   Reply With Quote
Old 04-17-2013, 10:22 AM   #87
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

nooooonoonnoononoo, this script will create tracks every time it is run. I need the tracks to be added only if the track is not already there. In other words, don't create new tracks just because there's media items already in the track. This script acts exactly like the Xenakios one at the moment. I'm trying to edit the script myself so it works this way, but any copy and pasting of code just isn't working, still trying to figure it out.

edit: ok got it. I simply removed the block of code that says "check if next tracks are empty". Thank you spk77!

Code:
from reaper_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Spread selected items over tracks - add tracks if needed"):

    def msg(m):
        RPR_ShowConsoleMsg(m)

    selItemIdL = []

    # get first selected item and track index
    firstSelItem =  RPR_GetSelectedMediaItem(0, 0)
    track = RPR_GetMediaItem_Track(firstSelItem)
    trackIndex = int(RPR_GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER"))
    trackItemCount = RPR_CountTrackMediaItems(track)

    # make list from selected items in track
    for i in range(trackItemCount):
        itemId = RPR_GetTrackMediaItem(track, i)
        if int(RPR_GetMediaItemInfo_Value(itemId, "B_UISEL")):
            selItemIdL.append(itemId)

    # check if there are enough tracks for items, create more tracks if needed
    needed = int(RPR_CountTracks(0) - trackIndex + 1 - len(selItemIdL))
    if needed < 0:
        for tr in range(abs(needed)):
            # insert new track(s) at the end
            RPR_InsertTrackAtIndex(RPR_CountTracks(0), 1)

    # move each item to its own track
    for j, id in enumerate(selItemIdL):
        destTrack = RPR_CSurf_TrackFromID(trackIndex + j, 0)
        RPR_MoveMediaItemToTrack(id, destTrack)

    # update view
    RPR_TrackList_AdjustWindows(False)
    RPR_UpdateArrange()
edit: added the below change (blue text) to the above script
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template

Last edited by Argitoth; 04-18-2013 at 12:01 PM.
Argitoth is offline   Reply With Quote
Old 04-17-2013, 10:37 AM   #88
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Oh, I misunderstood. Well, I'm glad that you got it working.

edit: This may work better (new tracks are inserted at the end):

Code:
    # check if there are enough tracks for items, create more tracks if needed
    needed = int(RPR_CountTracks(0) - trackIndex + 1 - len(selItemIdL))
    if needed < 0:
        for tr in range(abs(needed)):
            # insert new track(s) at the end
            RPR_InsertTrackAtIndex(RPR_CountTracks(0), 1)

Last edited by spk77; 04-17-2013 at 11:10 AM.
spk77 is offline   Reply With Quote
Old 04-17-2013, 12:22 PM   #89
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

Ok! So now that I have this
[][][][]

to this
[]
[]
[]
[]

using a macro:
-spk77's explode media items script
-Item navigation: Move cursor to start of items
-SWS: Move selected item(s) left edge to edit cursor

Now I need the opposite script.

this:
[]
[]
[]
[]

to this:
[][][][]

I was able to do it with this:
-Track: Go to next track
-Item: Select all items in track
-Move edit cursor forward one beat
-Item edit: Move position of item to edit cursor

THEN
-Items: Implode items across tracks into items on one track

THEN
-Xenakios/SWS: Reposition selected items...

But it only works on one track at a time and I'd RATHER it work on SELECTED items. Actually, I'd like a version that works per track and another that works per selected item. Here's what it looks like now:
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-17-2013, 07:31 PM   #90
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

I could use a script for this simple action:

"Move edit cursor to nearest marker"
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-18-2013, 11:05 AM   #91
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Here are two more scripts:



Implode items (simple version):
- should work if one item per track is selected
Code:
from reaper_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Implode selected items"):

    selItemCount = RPR_CountSelectedMediaItems(0)

    for i in range(1, selItemCount + 1):
        if i == 1:
            # get first selected item id/start pos/length and track index
            firstSelItem =  RPR_GetSelectedMediaItem(0, 0)
            firstSelItemPos = RPR_GetMediaItemInfo_Value(firstSelItem, "D_POSITION")
            firstSelItemLength = RPR_GetMediaItemInfo_Value(firstSelItem, "D_LENGTH")
            nextItemStart = firstSelItemPos + firstSelItemLength
            track = RPR_GetMediaItem_Track(firstSelItem)
            trackIndex = int(RPR_GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER"))
        else:
            # move items
            itemId = RPR_GetSelectedMediaItem(0, i - 1)
            destTrack = RPR_CSurf_TrackFromID(trackIndex, 0)
            RPR_MoveMediaItemToTrack(itemId, destTrack)
            RPR_SetMediaItemPosition(itemId, nextItemStart, 0)
            nextItemStart = nextItemStart + RPR_GetMediaItemInfo_Value(itemId, "D_LENGTH")

    # update view
    RPR_TrackList_AdjustWindows(False)
    RPR_UpdateArrange()
Explode items:
Code:
from reaper_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Spread selected items over tracks - add tracks if needed"):

    selItemIdL = []

    # get first selected item id/start pos and track index
    firstSelItem =  RPR_GetSelectedMediaItem(0, 0)
    firstSelItemPos = RPR_GetMediaItemInfo_Value(firstSelItem, "D_POSITION")

    track = RPR_GetMediaItem_Track(firstSelItem)
    trackIndex = int(RPR_GetMediaTrackInfo_Value(track, "IP_TRACKNUMBER"))
    trackItemCount = RPR_CountTrackMediaItems(track)

    # make list from selected items in track
    for i in range(trackItemCount):
        itemId = RPR_GetTrackMediaItem(track, i)
        if int(RPR_GetMediaItemInfo_Value(itemId, "B_UISEL")):
            selItemIdL.append(itemId)

    # check if there are enough tracks for items, create more tracks if needed
    needed = int(RPR_CountTracks(0) - trackIndex + 1 - len(selItemIdL))
    if needed < 0:
        for tr in range(abs(needed)):
            # insert new track(s) at the end
            RPR_InsertTrackAtIndex(RPR_CountTracks(0), 1)

    # move each item to its own track
    for j, id in enumerate(selItemIdL):
        destTrack = RPR_CSurf_TrackFromID(trackIndex + j, 0)
        RPR_MoveMediaItemToTrack(id, destTrack)
        # set start pos to first sel item start
        RPR_SetMediaItemPosition(id, firstSelItemPos, 0)

    # update view
    RPR_TrackList_AdjustWindows(False)
    RPR_UpdateArrange()
spk77 is offline   Reply With Quote
Old 04-18-2013, 01:56 PM   #92
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

alright, very nice work spk77! more script requests coming soon, heh. If you could come up with a way to take a txt list of items and apply it to the name of media items in a project, that would be really great.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-18-2013, 05:33 PM   #93
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

Hmm, another simple action is missing. There's an action "Xenakois/SWS: Select items under edit cursor on selected tracks" but I don't want the "on selected tracks" part of it.

I need this:

"Select items under edit cursor"
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-19-2013, 12:20 PM   #94
Tony Ostinato
Human being with feelings
 
Join Date: Apr 2012
Posts: 91
Default

i'm doing this unusual live setup with reaper:

http://youtu.be/l5ar_3nGx2w

i mention i like to be able to use actions to quickly select tracks but i can't go beyond track 99 without climbing up track by track after selecting 99.

would it be possible to do a reacript that mutes all tracks then selects the track number and unmutes it, even if you want to select tracks above 99?

thanks!!!!
Tony Ostinato is offline   Reply With Quote
Old 04-19-2013, 12:28 PM   #95
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

Someone should write you a template script where you can replace the track number at your leisure. So you need:

-Select track 100 (do not keep previous track selection)
-Mute all tracks
-Unmute track 100

The above could be accomplished with a macro, but I understand you don' want to create a million macros just for every track you need above 99. A script would be much better for this.

Your explanation is confusing because it sounds like you want ONE script to select tracks above 99. I guess what you mean is: you need a script per track number above 99.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template

Last edited by Argitoth; 04-19-2013 at 05:03 PM.
Argitoth is offline   Reply With Quote
Old 04-19-2013, 01:03 PM   #96
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Edit.
added: remove trailing \r\n
fixed: newname ->newName (thanks, Argitoth)

Load/apply item names from file (Actually take names because item names don't exist in reaper).

Code:
# Load/apply item names from file

from reaper_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Load/apply item names from file"):

    def msg(m):
        RPR_ShowConsoleMsg(m)

    actTakeIdL = []

    selItemCount = RPR_CountSelectedMediaItems(0)

    for i in range(selItemCount):
        selItemId = RPR_GetSelectedMediaItem(0, i)
        takeId = RPR_GetActiveTake(selItemId)
        actTakeIdL.append(takeId)

    a = RPR_GetUserFileNameForRead("Select item name list", "Load item names from file", ".txt")
    path = a[1]
    if a[0] == 1:
        try:
            f = open(path, "r")
            for i, newName in enumerate(f):
                newName = newName.rstrip("\r\n")  # remove trailing cr(carriage return) and n(new line)
                RPR_GetSetMediaItemTakeInfo_String(actTakeIdL[i], "P_NAME", str(newName), 1)
                if i + 1 == selItemCount:
                    break
            f.close()
        except IOError as e:
            msg(e)

Last edited by spk77; 06-02-2013 at 01:12 AM. Reason: added: remove trailing \r\n and fixed newname ->newName
spk77 is offline   Reply With Quote
Old 04-19-2013, 03:00 PM   #97
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

ALRIGHT YES IT WORKS! Thank you, spk77!! This is a game changer for developing sample libraries.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-19-2013, 11:09 PM   #98
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Tony Ostinato View Post
i'm doing this unusual live setup with reaper:


http://youtu.be/l5ar_3nGx2w

i mention i like to be able to use actions to quickly select tracks but i can't go beyond track 99 without climbing up track by track after selecting 99.

would it be possible to do a reacript that mutes all tracks then selects the track number and unmutes it, even if you want to select tracks above 99?

thanks!!!!
Select/unmute track 100 and mute other tracks:

Code:
from reaper_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Select track / mute others"):

    muteAllTracks = 40341
    unSelectAllTracks = 40297
    selectTrack = 100
    unMuteTracks = 40731
    verticalScrollToSelTrack = 40913

    if selectTrack <= RPR_CountTracks(0):
        RPR_Main_OnCommandEx(muteAllTracks, 0, 0)
        RPR_Main_OnCommandEx(unSelectAllTracks, 0, 0)
        RPR_SetTrackSelected(RPR_GetTrack(0, selectTrack - 1), 1)
        RPR_SetMixerScroll(RPR_GetTrack(0, selectTrack - 1))
        RPR_Main_OnCommandEx(unMuteTracks, 0, 0)
        RPR_Main_OnCommandEx(verticalScrollToSelTrack, 0, 0)

Last edited by spk77; 04-20-2013 at 04:22 AM. Reason: added "vertical scroll to selected tracks"
spk77 is offline   Reply With Quote
Old 04-19-2013, 11:09 PM   #99
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Argitoth View Post
ALRIGHT YES IT WORKS! Thank you, spk77!! This is a game changer for developing sample libraries.
Very nice!
spk77 is offline   Reply With Quote
Old 04-20-2013, 12:53 AM   #100
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Edit: Zip file updated (Undo wasn't working correctly and action "Track: Vertical scroll selected track(s) into view" added)

200 actions for "Select/unmute track and mute other tracks" (tracks 100-300):

https://stash.reaper.fm/16204/Select%...te%20track.zip

Last edited by spk77; 04-20-2013 at 10:24 PM.
spk77 is offline   Reply With Quote
Old 04-20-2013, 02:30 AM   #101
Tony Ostinato
Human being with feelings
 
Join Date: Apr 2012
Posts: 91
Default

wow, thats really something. huge thanks!!

i'll dedicate this coming week to installing pyhton and getting this working.

thanks!!!
Tony Ostinato is offline   Reply With Quote
Old 04-20-2013, 02:57 AM   #102
Tony Ostinato
Human being with feelings
 
Join Date: Apr 2012
Posts: 91
Default

"Your explanation is confusing because it sounds like you want ONE script to select tracks above 99. I guess what you mean is: you need a script per track number above 99."

bingo. thanks for the deconvolution!

and its not like every single track but certain ones for sure.

not every band and not every lead singer but some like to not tell you what song is next before they count it off and if youre supposed to be in on beat 1 and arent there they get all huffy and sometimes even say things over the mic!

and thats just kinda one example. ive been pretty lucky setting things up so i can accommodate that behavior but its gonna get harder as i keep adding tunes and arrangements so the actions will likely keep me going happy for awhile.

thanks yet again.
Tony Ostinato is offline   Reply With Quote
Old 04-20-2013, 04:26 AM   #103
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Tony Ostinato View Post
wow, thats really something. huge thanks!!

i'll dedicate this coming week to installing pyhton and getting this working.

thanks!!!
I updated the zip file (post #109) because undo wasn't working correctly and I also added action "Track: Vertical scroll selected track(s) into view".
spk77 is offline   Reply With Quote
Old 04-20-2013, 06:59 AM   #104
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Argitoth View Post
Hmm, another simple action is missing. There's an action "Xenakois/SWS: Select items under edit cursor on selected tracks" but I don't want the "on selected tracks" part of it.

I need this:

"Select items under edit cursor"
Select items under edit cursor (unselect other items):

Code:
#Select items under edit cursor (unselect other items)

from reaper_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Select items under edit cursor"):

    def msg(m):
        RPR_ShowConsoleMsg(m)

    unSelAllItems = 40289

    RPR_Main_OnCommandEx(unSelAllItems, 0, 0)
    for i in range(RPR_CountMediaItems(0)):
        itemId = RPR_GetMediaItem(0, i)
        itemStartPos = float(RPR_GetMediaItemInfo_Value(itemId, "D_POSITION"))
        itemEndPos = itemStartPos + float(RPR_GetMediaItemInfo_Value(itemId, "D_LENGTH"))
        if itemStartPos <= RPR_GetCursorPositionEx(0) <= itemEndPos:
            RPR_SetMediaItemInfo_Value(itemId, "B_UISEL", 1)

    # update view
    RPR_UpdateArrange()

Last edited by spk77; 04-20-2013 at 11:26 AM.
spk77 is offline   Reply With Quote
Old 04-20-2013, 11:09 AM   #105
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

hey spk77 that script is weird in that you must activate it twice for it to select something, or you must have something already selected.

Edit: Hey actually, could you tell me the command for getting the mouse cursor position so I have a choice of edit cursor or mouse cursor? I can't find anything about mouse cursor in the API.

Edit2: What program do you use for scripting this stuff?
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-20-2013, 12:00 PM   #106
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Argitoth View Post
hey spk77 that script is weird in that you must activate it twice for it to select something, or you must have something already selected.

Edit: Hey actually, could you tell me the command for getting the mouse cursor position so I have a choice of edit cursor or mouse cursor? I can't find anything about mouse cursor in the API.

Edit2: What program do you use for scripting this stuff?
Ok, it should work now (added "RPR_UpdateArrange()" at the end)

Yes, there isn't any function to get mouse cursor position. This is how the script works:
- unselect all items first
- get item count with "RPR_CountMediaItems(0)" (0 for active project)
- loop in range(item count)
- get every item's ID, start position and length
  • ID = RPR_GetMediaItem(0, index)
  • StartPos = float(RPR_GetMediaItemInfo_Value(ID, "D_POSITION"))
  • Length = float(RPR_GetMediaItemInfo_Value(ID, "D_LENGTH"))
  • EndPos = StartPos + Length
- "RPR_GetCursorPositionEx(0)" gets edit cursor position in seconds
- if edit cursor position is between item's StartPos and EndPos, set that item selected. "RPR_SetMediaItemInfo_Value(ID, "B_UISEL", 1)"


Sorry, I cannot explain it better.

I'm using PyScripter:
https://code.google.com/p/pyscripter/

Last edited by spk77; 04-20-2013 at 12:09 PM.
spk77 is offline   Reply With Quote
Old 04-20-2013, 06:10 PM   #107
Tony Ostinato
Human being with feelings
 
Join Date: Apr 2012
Posts: 91
Default

i intalled python, 3.2 cause it wouldnt recognize 3.3 or something, and i got your script mapped to the shift f and it takes me to track 100 and beyond perfectly.

bravo! yeay, useful for me very.

theres one behavior tho id like to change about it if possible, after using that script to select that track when you hit the arrow key to take you to the next track it takes you back to the track you were at before you used the script, plus one.

so if im at track 5 and use the script to select track 100 and then hit the arrow key to try to go to track 101 itll instead go to track 6.

which might be useful in some situations but in most i think id need to be able to go to the next track 101 at that point.

thanks thanks thanks thanks!!!!

oh, and also i dont need undo, on my live laptop i disable undo to make scrolling faster, i never used undo live so it seemed ok to do.

another thing i forgot , when i use the arrow keys theyre mapped to macros to do the mute/slect/unmute thing.

Last edited by Tony Ostinato; 04-20-2013 at 06:29 PM.
Tony Ostinato is offline   Reply With Quote
Old 04-20-2013, 10:23 PM   #108
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Looks like RPR_SetTrackSelected() doesn't work correctly. I replaced it with another function and now the script seems to be working (zip updated in post #109). I checked your video and noticed that you are using:

(up arrow)
- Mute tracks (this mutes only the selected tracks)
- Go to previous track
- Unmute tracks

I guess it should be:
(up arrow)
- Mute all tracks
- Go to previous track
- Unmute tracks

and

(down arrow)
- Mute all tracks
- Go to next track
- Unmute tracks

Last edited by spk77; 04-20-2013 at 11:35 PM.
spk77 is offline   Reply With Quote
Old 04-21-2013, 10:39 AM   #109
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Argitoth View Post
I could use a script for this simple action:

"Move edit cursor to nearest marker"
Move edit cursor to nearest marker:

Code:
# Move edit cursor to nearest marker

from reaper_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Move edit cursor to nearest marker"):

    cursorPos = RPR_GetCursorPositionEx(0)

    i = 0
    while RPR_EnumProjectMarkers3(0, i, 0, 0, 0, "", 0, 0)[0] > 0:
        markerPos = RPR_EnumProjectMarkers3(0, i, 0, 0, 0, "", 0, 0)[4]

        if markerPos == cursorPos:
            break

        # seek next marker after edit cursor
        if markerPos > cursorPos:

            # if cursor is between project start and 1. marker -> move to 1. marker
            if i == 0:
                RPR_SetEditCurPos2(0, markerPos, 1, 0)

            # check which one is closer to edit cursor (marker before cursor or marker after cursor)
            elif abs(cursorPos - prevMarkerPos) < abs(cursorPos - markerPos):

                # if marker before cursor is nearest -> move cursor there
                RPR_SetEditCurPos2(0, prevMarkerPos, 1, 0)
            else:
                # if marker after cursor is nearest -> move cursor there
                RPR_SetEditCurPos2(0, markerPos, 1, 0)

            break

        # if cursor is after the last marker -> move cursor to last marker
        elif markerPos < cursorPos and RPR_EnumProjectMarkers3(0, i + 1, 0, 0, 0, "", 0, 0)[0] == 0:
            RPR_SetEditCurPos2(0, markerPos, 1, 0)

        i += 1
        prevMarkerPos = RPR_EnumProjectMarkers3(0, i - 1, 0, 0, 0, "", 0, 0)[4]

Last edited by spk77; 04-21-2013 at 10:53 AM.
spk77 is offline   Reply With Quote
Old 04-21-2013, 11:16 AM   #110
Tony Ostinato
Human being with feelings
 
Join Date: Apr 2012
Posts: 91
Default

works!! absolutely perfect!

i really appreciate this!!!!!!!!!

i can better keep up with these cats who only play one instrument and one sound all night.

tho even in the old days when i was just playin real trumpet id hate that crap because if they dont tell you what song is next and just start playing the intro and you try quick to play the first notes you end up slamming the mouthpiece right into your teeth or something painful.

anyways i feel like i should pay you. this was a big deal for me.
Tony Ostinato is offline   Reply With Quote
Old 04-21-2013, 11:27 AM   #111
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

Quote:
Originally Posted by Tony Ostinato View Post
this was a big deal for me.
oh yeah. Reaper scripts are just out-of-this-world amazing to support the best and fastest workflow imaginable inside an extremely powerful sequencer.

Hey spk77, does that script ignore time selection? Is it impossible to ignore time selection when moving to the nearest marker/region? Edit: Ok, answered that question. Sweet! It ignores time seleciton. Could you also do a "goto next / goto previous marker" scripts? SWS: Goto next/previous marker has to remove time selection to do it. OH, also include "projest start/end" for the previous/next scripts.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template

Last edited by Argitoth; 04-21-2013 at 11:32 AM.
Argitoth is offline   Reply With Quote
Old 04-21-2013, 11:36 AM   #112
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Tony Ostinato View Post
works!! absolutely perfect!

i really appreciate this!!!!!!!!!

i can better keep up with these cats who only play one instrument and one sound all night.

tho even in the old days when i was just playin real trumpet id hate that crap because if they dont tell you what song is next and just start playing the intro and you try quick to play the first notes you end up slamming the mouthpiece right into your teeth or something painful.

anyways i feel like i should pay you. this was a big deal for me.
I'm glad that you found it useful. Thanks for the payment offer, but this is just like a hobby (and brain exercising ) for me.
spk77 is offline   Reply With Quote
Old 04-21-2013, 11:44 AM   #113
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default

Quote:
Originally Posted by Argitoth View Post
oh yeah. Reaper scripts are just out-of-this-world amazing to support the best and fastest workflow imaginable inside an extremely powerful sequencer.

Hey spk77, does that script ignore time selection? Is it impossible to ignore time selection when moving to the nearest marker/region? Edit: Ok, answered that question. Sweet! It ignores time seleciton. Could you also do a "goto next / goto previous marker" scripts? SWS: Goto next/previous marker has to remove time selection to do it. OH, also include "projest start/end" for the previous/next scripts.
Ok, I'll try to do those next.
spk77 is offline   Reply With Quote
Old 04-21-2013, 12:32 PM   #114
Tony Ostinato
Human being with feelings
 
Join Date: Apr 2012
Posts: 91
Default

such a cool attitude! please have as many kids as you can.

that kinda invites me to ask about a couple other ideas,

in my master track insert slot 4 i have reverberate-x64, would i be able to change the presets with a script?

i use a plate verb all the time but if i could switch with a single keypress id use some of the spring and gate on things.

and thats one that maybe could benefit from the behavior of that first batch of scripts where after you select the master and change the preset hitting the arrow would take you back to (almost) the track where you were.

or maybe if it could just select the verb preset without changing the track youre on, thatd be awesome.

then along the same lines on my track 2 i have guitar rig in insert 5. itd be nice to have a keypress turn that from offline to online and select a preset too.

and another to turn it offline again.

and all without changing the track youre on would again be awesome.

but those are all luxuries and not as maddening as the other problems you fixed for me.

i installed python and your scripts on my for real live laptop after testing on this net one and its working great. soooooo much faster. zoom!!
Tony Ostinato is offline   Reply With Quote
Old 04-21-2013, 01:03 PM   #115
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

Tony, I would recommend being more precise in your explanations, so here's a macro that could work (which also explains the desired script):

-SWS: Save current track selection (53773) (_SWS_SAVESEL)
-Track: Unselect all tracks (40297)
-SWS: Select master track (53798) (_SWS_SELMASTER)

-SWS/S&M: Trigger next preset for FX 04 of select tracks (54441) (_S&M_NEXT_PRESET_FX4)
OR
-SWS/S&M: Trigger previous preset for FX 04 of select tracks (54445) (_S&M_PREVIOUS_PRESET_FX4)

-SWS: Restore saved track selection (53774) (_SWS_RESTORESEL)
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-21-2013, 05:02 PM   #116
Tony Ostinato
Human being with feelings
 
Join Date: Apr 2012
Posts: 91
Default

aha! that certainly gave me verb preset increment buttons and they work well. you can even quick press it 5 times etc to go fast and it works.

thanks!

sorry im confusing. the video i posted might help a little as far as how i have it setup.

you can see where i show the track mixer i have guitar rig on the same track where i have kontakt and guitar rig is turned offline.

ideally id like to press a key and have it turn online with a specific preset, so if i pressed A it would turn on with lead guitar preset and if i pressed B it would turn offline again. if i pressed C it would turn on with rhythm guitar preset. etc etc.

still theres worse things in the world than incrementing/decrementing so again much thanks for that.

that shows me how to fix my verb on/off and echo on/off macros too.
Tony Ostinato is offline   Reply With Quote
Old 04-21-2013, 05:07 PM   #117
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

ok, so you need a script and/or macro combo that turns on a specific preset number RATHER THAN having to scroll through presets to get to the right one? Is that one of your dilemmas right now?

Also if you use cycling actions, you could potentially have 'A' turn on and off something.
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-21-2013, 05:25 PM   #118
Tony Ostinato
Human being with feelings
 
Join Date: Apr 2012
Posts: 91
Default

"ok, so you need a script and/or macro combo that turns on a specific preset number RATHER THAN having to scroll through presets to get to the right one? Is that one of your dilemmas right now?"

indeed, precisely!

what you've provided so far has been massively useful, i've fixed a bunch of my buttons to work much more nicely.

Last edited by Tony Ostinato; 04-21-2013 at 05:31 PM.
Tony Ostinato is offline   Reply With Quote
Old 04-21-2013, 05:36 PM   #119
Argitoth
Human being with feelings
 
Argitoth's Avatar
 
Join Date: Feb 2008
Location: Mesa, AZ
Posts: 2,057
Default

I searched the actions list and there is not one action that allows you to select a specific number of preset. I propose this, if such an action is possible:

Template Script 1: Unbypass # FX on # track
Template Script 2: Bypass # FX on # track
Template Script 3: Trigger # preset for # FX on # track
Template Script 4: ALL OF THE ABOVE IN ONE SCRIPT

I'm getting rid of track selection in this proposal as a way to "get rid of the middle man".
__________________
Soundemote - Home of the chaosfly and pretty oscilloscope.
MyReaperPlugin - Easy-to-use cross-platform C++ REAPER extension template
Argitoth is offline   Reply With Quote
Old 04-22-2013, 07:56 AM   #120
spk77
Human being with feelings
 
Join Date: Aug 2012
Location: Finland
Posts: 2,668
Default



Move edit cursor to next marker or project end (ignore time selection):
Code:
# Move edit cursor to next marker or project end (ignore time selection)

from reaper_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Move edit cursor to next marker/project end"):

    def getProjectEnd():
        RPR_PreventUIRefresh(1)
        RPR_CSurf_GoEnd()
        projectEnd = RPR_GetCursorPositionEx(0)
        RPR_SetEditCurPos2(0, cursorPos, 0, 0)
        RPR_PreventUIRefresh(-1)
        return projectEnd

    cursorPos = RPR_GetCursorPositionEx(0)

    i = 0
    while RPR_EnumProjectMarkers3(0, i, 0, 0, 0, "", 0, 0)[0] > 0:
        markerPos = RPR_EnumProjectMarkers3(0, i, 0, 0, 0, "", 0, 0)[4]

        # seek next marker after edit cursor
        if markerPos > cursorPos:

            # move cursor to next marker or project end
            projectEnd = getProjectEnd()
            if abs(cursorPos - projectEnd) < abs(cursorPos - markerPos) and projectEnd > cursorPos:
                RPR_CSurf_GoEnd()
            else:
                RPR_SetEditCurPos2(0, markerPos, 1, 0)
            break

        # if cursor is after the last marker -> move cursor to end of project...
        # ...if it is after the last marker
        elif markerPos <= cursorPos and RPR_EnumProjectMarkers3(0, i + 1, 0, 0, 0, "", 0, 0)[0] == 0:
            projectEnd = getProjectEnd()
            if projectEnd > cursorPos:
                RPR_CSurf_GoEnd()

        i += 1
Move edit cursor to previous marker or project start/end (ignore time selection):
Code:
# Move edit cursor to previous marker or project start/end (ignore time selection)

from reaper_python import *
from contextlib import contextmanager

@contextmanager
def undoable(message):
    RPR_Undo_BeginBlock2(0)
    try:
        yield
    finally:
        RPR_Undo_EndBlock2(0, message, -1)

with undoable("Move edit cursor to previous marker or project start/end"):

    def getProjectEnd():
        RPR_PreventUIRefresh(1)
        RPR_CSurf_GoEnd()
        projectEnd = RPR_GetCursorPositionEx(0)
        RPR_SetEditCurPos2(0, cursorPos, 0, 0)
        RPR_PreventUIRefresh(-1)
        return projectEnd

    cursorPos = RPR_GetCursorPositionEx(0)

    i = 0
    while RPR_EnumProjectMarkers3(0, i, 0, 0, 0, "", 0, 0)[0] > 0:
        markerPos = RPR_EnumProjectMarkers3(0, i, 0, 0, 0, "", 0, 0)[4]

        # seek next marker after edit cursor
        if markerPos >= cursorPos:
            projectEnd = getProjectEnd()

            # if cursor is between project start and 1. marker -> move to project start...
            # ...or project end if it is between 1. marker and start
            if i == 0 and markerPos >= cursorPos:
                RPR_PreventUIRefresh(1)
                RPR_CSurf_GoStart()
                projectStart = RPR_GetCursorPositionEx(0)
                RPR_SetEditCurPos2(0, cursorPos, 0, 0)
                RPR_PreventUIRefresh(-1)

                if abs(cursorPos - projectEnd) < abs(cursorPos - projectStart) and projectEnd < cursorPos:
                    RPR_CSurf_GoEnd()
                else:
                    RPR_CSurf_GoStart()
                break
            else:
                if abs(cursorPos - projectEnd) < abs(cursorPos - prevMarkerPos) and projectEnd < cursorPos:
                    RPR_CSurf_GoEnd()
                else:
                    RPR_SetEditCurPos2(0, prevMarkerPos, 1, 0)
            break

        # if cursor is after the last marker -> move cursor to end of project...
        # ...if it is after the last marker
        if markerPos < cursorPos and RPR_EnumProjectMarkers3(0, i + 1, 0, 0, 0, "", 0, 0)[0] == 0:
            projectEnd = getProjectEnd()
            if abs(cursorPos - projectEnd) < abs(cursorPos - markerPos) and projectEnd < cursorPos:
                RPR_CSurf_GoEnd()
            else:
                RPR_SetEditCurPos2(0, markerPos, 1, 0)

        i += 1
        prevMarkerPos = RPR_EnumProjectMarkers3(0, i - 1, 0, 0, 0, "", 0, 0)[4]
spk77 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 11:38 PM.


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