|
|
|
08-01-2020, 08:55 AM
|
#1
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
|
Iterate / Select Takes
I can get the number of takes but not sure how to iterate over each vertical lane going from take to take. Is there a way and can I make them active and select them ?
item = reaper.GetSelectedMediaItem( 0, 0)
cnt = reaper.GetMediaItemNumTakes( item )
|
|
|
08-01-2020, 10:01 AM
|
#2
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,844
|
For selecting the next take (of the selected item), you can try one of these two Actions:
Code:
reaper.Main_OnCommand(42349, 0) -- Take: Cycle items to next take
reaper.Main_OnCommand(40125, 0) -- Take: Switch items to next take
|
|
|
08-01-2020, 10:11 AM
|
#3
|
Human being with feelings
Join Date: Oct 2007
Location: home is where the heart is
Posts: 12,096
|
Here's a script first iterating through all items, then the takes within each item:
https://forum.cockos.com/showthread....46#post1851146
For making a take active you can use
SetActiveTake().
edit:
Quote:
Is there a way and can I make them active and select them ?
|
As mentioned in your other recent thread, in the Reaper paradigm takes actually can only be active or not active, it's the media items (containing the takes) which are selected (or not).
Last edited by nofish; 08-01-2020 at 10:35 AM.
|
|
|
08-02-2020, 06:45 AM
|
#4
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
|
Thanks for the reply. The code above does let me get the takes but I'm getting all takes. When I do takes, I might start and stop and end up with a block of takes that have different source files. Once I split the takes into 'parts' of takes to comp together I wanted a way select all the media items again so they can be comped.
Are there functions that will allow me identify the 'related' media items under the mouse and ignore the other takes like the ones to the right (in the below picture) or the ones on other tracks. The only function I'm missing is a way to select all the media items that belong to that block of takes. Thanks for any ideas. :-)
I just want to select all of the "related" media items. All of these, not the takes in the other image below besides this one.
|
|
|
08-03-2020, 09:03 AM
|
#5
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,844
|
Maybe have a look at the X-Raym_Select items with same source as first selected item.lua script by X-Raym (available via ReaPack).
Or are any of the other takes in the screenshot (that should be ignored) also from the same source file?
EDIT:
I somehow missed that the takes in the first screenshot are from different source files (01-013.wav, 01-016.wav, 01-017.wav). So the script I mentioned above won't work in this case.
Maybe a possible solution is to group the items first (Item grouping: Group items). And then use, for instance, the Item grouping: Select all items in groups to select all items/takes from the same group.
Last edited by solger; 08-03-2020 at 09:33 AM.
Reason: typo
|
|
|
08-03-2020, 09:31 AM
|
#6
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
|
Thanks but I'm looking for a way to do it with the api functions solger.
|
|
|
08-03-2020, 09:47 AM
|
#7
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,844
|
Quote:
Originally Posted by Coachz
Thanks but I'm looking for a way to do it with the api functions solger.
|
How are you splitting the takes into 'parts' currently?
My initial idea was this: - Grouping the items before splitting (by calling the 'Group items' Actions via reaper.Main_OnCommand)
- And then calling the 'Select all items in groups' Action before comping (also via reaper.Main_OnCommand)
Another option is perhaps adding the same identifier string to the item name (and then selecting all items by the identifier).
-----------------------------
The 'problem' is that some common reference point is required to determine which items are in the same selection 'group' or area.
Just a few general examples that come to mind: - same source file <-- which we already ruled out as possible option
- same item group
- same item name (part) or identifier
- items that are inside a specific time range (inside a time selection, a region or between markers)
Last edited by solger; 08-03-2020 at 10:14 AM.
|
|
|
08-03-2020, 10:13 AM
|
#8
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
|
Thanks for the great ideas. I'll give it a try when the weather clears up.
|
|
|
08-05-2020, 08:07 AM
|
#9
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
|
Quote:
Originally Posted by solger
How are you splitting the takes into 'parts' currently?
My initial idea was this: - Grouping the items before splitting (by calling the 'Group items' Actions via reaper.Main_OnCommand)
- And then calling the 'Select all items in groups' Action before comping (also via reaper.Main_OnCommand)
Another option is perhaps adding the same identifier string to the item name (and then selecting all items by the identifier).
-----------------------------
The 'problem' is that some common reference point is required to determine which items are in the same selection 'group' or area.
Just a few general examples that come to mind: - same source file <-- which we already ruled out as possible option
- same item group
- same item name (part) or identifier
- items that are inside a specific time range (inside a time selection, a region or between markers)
|
Thanks for the great ideas but no luck. Grouping seems wonky. Even though they are assigned to the group, running "Item grouping: Group items" everytime I split them seems to mess them up.
The source files can be different and there is no name/identifier. I can manually select the takes but was hoping for a way to select them for cropping through code.
Is there a way to time stamp all of the items that are "together" when I do the first split and then check for timestamp on subsequent splits so they don't get a new one. Then is there api code to group them ? Just trying to think of anything. I expect there is a way as Reaper has so many functions. I do a LOT of takes so this would be very helpful if it can be done. Thanks again !
|
|
|
08-05-2020, 10:32 AM
|
#10
|
Human being with feelings
Join Date: May 2020
Posts: 190
|
Like Solger said the issue is that there is no common thread between any of the files. You can try to find every item by your mouse cursor that isn't separated by more than x amount of time or just make a time selection of all the items, but I don't know if those will work for you or not.
As for grouping items via code, the only way I know of doing it (without using Main_OnCommand) is by getting the I_GROUPID value of the first item and then using SetMediaItemInfo_Value(item, "I_GROUPID", newIDNum) to set all the other items to that group ID number.
And the issue with taking a snapshot of all the items pre-split is that splitting an item will create additional ones that aren't in the reference snapshot, so you will have to grab those new items too before the script does what you need it to.
|
|
|
08-05-2020, 02:30 PM
|
#11
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
|
Quote:
Originally Posted by jkooks
Like Solger said the issue is that there is no common thread between any of the files. You can try to find every item by your mouse cursor that isn't separated by more than x amount of time or just make a time selection of all the items, but I don't know if those will work for you or not.
|
Thanks for the reply. Are there any api functions I can use to identify "related" takes? Basically all takes that are the same length above or below? How to get the group id in lua please?
Also, they are called takes when recorded but is there a name for the parts when they are split? Take pieces?
Last edited by Coachz; 08-05-2020 at 04:52 PM.
|
|
|
08-05-2020, 06:13 PM
|
#12
|
Human being with feelings
Join Date: May 2020
Posts: 190
|
You can use reaper.GetMediaItemInfo_Value(item, "D_POSITION") and reaper.GetMediaItemInfo_Value(item, "D_LENGTH") in order to get an item's position and length, but since that is an item value then any takes within the item will share the same info, so I don't think that is exactly what you'd want.
Getting the group ID is relatively easy (same call for getting the position and length of an item, just one parameter is changed). Here is a script that gets the groupID of the first selected item and then sets the other items to it.
Code:
local itemNum = reaper.CountSelectedMediaItems(0)
local groupID = 0
for i = 0, itemNum - 1 do
local thisItem = reaper.GetSelectedMediaItem(0, i)
if i == 0 then
groupID = reaper.GetMediaItemInfo_Value(thisItem, "I_GROUPID")
else
reaper.SetMediaItemInfo_Value(thisItem, "I_GROUPID", groupID)
end
end
That being said, this script doesn't account for the first item's group ID being 0, which means it isn't grouped to anything (and could consequently set all other items to 0 too). You can probably change this by generating a random group ID if the first item's ID is set to 0, but I am not too sure of the requirements for making a new group ID other than it just being a number (I think).
And in the context of your video, splitting takes is interchangeable with splitting items. All that is happening is a new item is created along the mouse cursor, which is technically splitting those takes on the same line as the item.
Reading over your last post, you could technically run two scripts that may do what you need. The first would record the start and end of a time selection that encompasses all of the "similar" items and then the second script would select those items (or do whatever you need them to do). They could look like this:
Script #1
Code:
--record the track that the items are on
local thisItem = reaper.GetSelectedMediaItem(0, 0)
local thisTrack = reaper.GetMediaItem_Track(thisItem)
local trackIndex = reaper.GetMediaTrackInfo_Value(thisTrack, "IP_TRACKNUMBER")
local timeStart, timeEnd = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false) --record the time selection
--store the values so the other script can reference them
reaper.SetExtState("ItemSelections", "timeStart", timeStart, true)
reaper.SetExtState("ItemSelections", "timeEnd", timeEnd, true)
reaper.SetExtState("ItemSelections", "currentTrack", trackIndex, true)
Script #2
Code:
--get the track that the items are on and select it
local trackIndex = tonumber(reaper.GetExtState("ItemSelections", "currentTrack"))
local thisTrack = reaper.GetTrack(0, trackIndex - 1) --subtract one because it is 1 based where track count is 0
reaper.SetOnlyTrackSelected(thisTrack)
--get the time selection ranges
local timeStart = tonumber(reaper.GetExtState("ItemSelections", "timeStart"))
local timeEnd = tonumber(reaper.GetExtState("ItemSelections", "timeEnd"))
local itemCount = reaper.CountTrackMediaItems(thisTrack)
reaper.SelectAllMediaItems(0, false)
--loop through all the items on the track
for i = 0, itemCount - 1 do
local thisItem = reaper.GetTrackMediaItem(thisTrack, i)
local itemStart = reaper.GetMediaItemInfo_Value(thisItem, "D_POSITION")
local itemLen = reaper.GetMediaItemInfo_Value(thisItem, "D_LENGTH")
local itemEnd = itemStart + itemLen
--as long as the items are within the bounds of the time selection then this will select them
if itemStart >= timeStart and itemEnd <= timeEnd then
reaper.SetMediaItemSelected(thisItem, true)
--otherwise the loop will break since it doesn't need to continue
elseif itemEnd > timeEnd then
break
end
end
reaper.UpdateArrange()
With that said though, it would be much easier to just make a time selection after you split the items and then run the other script. But if you want to automate it then you could do something like this. Just some food for thought.
|
|
|
08-06-2020, 10:00 AM
|
#13
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
|
jkooks, thanks for the ideas. I'm making some progress.
|
|
|
08-06-2020, 10:41 AM
|
#14
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
|
I think I got it working.... I'm grouping items to the same group ID from 1 to 32 and splitting them, then when cropping, selecting the groups and cropping. It seems to work so far. Actions and keymaps are below.
Last edited by Coachz; 08-15-2023 at 07:04 AM.
|
|
|
08-06-2020, 11:04 AM
|
#15
|
Human being with feelings
Join Date: May 2020
Posts: 190
|
Awesome! Glad it seems to work!
If you are setting the group IDs manually issues may arise if there are any other items with the same ID (which you can work around by looping through every item in the project to make sure they don't have the same ID), but if you don't think that will occur then there is no need to worry about that.
|
|
|
08-06-2020, 11:17 AM
|
#16
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
|
Quote:
Originally Posted by jkooks
Awesome! Glad it seems to work!
If you are setting the group IDs manually issues may arise if there are any other items with the same ID (which you can work around by looping through every item in the project to make sure they don't have the same ID), but if you don't think that will occur then there is no need to worry about that.
|
My code looks through every item on the screen, gets all the groups being used and identifies the unused groups. Since I don't use groups normally, a dozen is more than enough for my takes because I commit early. So for me, every project starts with 0 groups used and I normally have no more than 10 unrelated takes in my project that need to be in unique groups.
|
|
|
08-06-2020, 12:34 PM
|
#17
|
Human being with feelings
Join Date: May 2020
Posts: 190
|
Alright, just wanted to iterate that one sticking point for setting group IDs.
|
|
|
08-07-2020, 11:33 PM
|
#18
|
Human being with feelings
Join Date: Mar 2013
Posts: 5,844
|
Quote:
Originally Posted by Coachz
I think I got it working...
|
Great to hear that you got it working!
|
|
|
08-08-2020, 03:54 AM
|
#19
|
Human being with feelings
Join Date: Oct 2010
Location: Charleston, SC
Posts: 12,769
|
It kinda works, still a bit wonky.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 09:53 AM.
|