|
|
|
01-21-2021, 08:42 PM
|
#1
|
Human being with feelings
Join Date: May 2017
Posts: 371
|
Fill space between items with empty items?
Hi was wondering if this is possible?
|
|
|
01-21-2021, 10:55 PM
|
#2
|
Human being with feelings
Join Date: Sep 2018
Location: China
Posts: 565
|
Totally. Get the right edge position of the left item, save it as pos1. Get the left edge of the right item, save it as pos2. Add an empty item between pos1 and pos2, then repeat.
|
|
|
01-21-2021, 10:56 PM
|
#3
|
Human being with feelings
Join Date: Apr 2020
Posts: 214
|
You could probably make a custom action work. Something like “Insert empty item between current item and the next”.
Or do you need to do this for a lot of item at once?
|
|
|
01-22-2021, 02:08 AM
|
#4
|
Human being with feelings
Join Date: May 2017
Posts: 371
|
Quote:
Originally Posted by poulhoi
You could probably make a custom action work. Something like “Insert empty item between current item and the next”.
Or do you need to do this for a lot of item at once?
|
many items....
I've actually got the inserting empty items part figured out.
It goes something like this
1. Duplicate track with items
2. Select items on the duplicated track and extend item right edge to the next item.
3. SPLIT items on the duplicated track against the original track as reference.
here you would have a new track with empty MIDI items in between the original items. But I'm unable to find a way to select only empty MIDI items. This is different compared to an empty audio take item, so the SWS Select only empty item action does not work in this scenario.
Any idea on how I'd go about selecting just media (MIDI) items with no notes?
EDIT: I tried using the SWS Save Item Selection State, and restore state at the end. But since the original Saved Item State was just extended in length it selects everything on the duplicated track that now has the sliced (SPLIT) empty MIDI items in between the original items.
|
|
|
01-22-2021, 05:41 AM
|
#5
|
Human being with feelings
Join Date: Apr 2013
Location: France
Posts: 9,874
|
The custom action way:
I have a script which split slected items according to items and keep only items at "spaces",
so just insert track, create a long empty items on it, use the script, then put the items a track below (in between the items used as reference).
@dsyrock
The script way woudl be more complex cause of possible overlapping items. :P
|
|
|
01-22-2021, 05:58 AM
|
#6
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Code:
-- should work with overlapping items too..
-- USER SETTINGS ---------------------------------------------
-- to select only the newly inserted items set to true:
local select_new_items = false -- true/false
-- if true then newly inserted items have an empty take
local new_items_have_empty_take = false -- true/false
--------------------------------------------------------------
local item_cnt = reaper.CountSelectedMediaItems( 0 )
if item_cnt < 2 then return end
local prev_item = reaper.GetSelectedMediaItem( 0, 0 )
local prev_track = reaper.GetMediaItemTrack( prev_item )
local cnt = 0
local added = 0
local new_items = {}
for i = 0, item_cnt - 1 do
cnt = cnt + 1
local item = reaper.GetSelectedMediaItem( 0, i )
local track = reaper.GetMediaItemTrack( item )
if track == prev_track then
if cnt > 1 then
local st = reaper.GetMediaItemInfo_Value( prev_item, "D_POSITION") + reaper.GetMediaItemInfo_Value( prev_item, "D_LENGTH")
local cur_st = reaper.GetMediaItemInfo_Value( item, "D_POSITION")
if cur_st > st then
local len = cur_st - st
local new_item = reaper.AddMediaItemToTrack( track )
reaper.SetMediaItemInfo_Value( new_item, "D_POSITION", st )
reaper.SetMediaItemInfo_Value( new_item, "D_LENGTH", len )
added = added + 1
new_items[added] = new_item
end
end
else
prev_track = track
cnt = 1
end
prev_item = item
end
if added > 0 then
if select_new_items then
for i = item_cnt - 1, 0, -1 do
reaper.SetMediaItemSelected( reaper.GetSelectedMediaItem( 0, i ), false )
end
for i = 1, added do
reaper.SetMediaItemSelected( new_items[i], true )
if new_items_have_empty_take then
reaper.AddTakeToMediaItem( new_items[i] )
end
end
end
reaper.Undo_OnStateChange( "Added ".. added .." empty item" ..
(added == 1 and "" or "s") .. " between selected items" )
else
reaper.defer(function() end)
end
Just wondering.. why would you want that? :P
Last edited by amagalma; 01-22-2021 at 08:18 AM.
|
|
|
01-22-2021, 06:07 AM
|
#7
|
Human being with feelings
Join Date: Mar 2016
Posts: 1,239
|
Just wondering if this can be used to insert roomtone between speech which has been cut up...?
I guess you could select all the empty items and then open the Properties and choose a new audio source for them?
|
|
|
01-22-2021, 06:13 AM
|
#8
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
Yes, sure.. I can make the script leave only the newly inserted empty items selected for convenience.
Edit: done.. See code above
Last edited by amagalma; 01-22-2021 at 06:22 AM.
|
|
|
01-22-2021, 06:53 AM
|
#9
|
Human being with feelings
Join Date: May 2017
Posts: 371
|
Quote:
Originally Posted by X-Raym
The custom action way:
I have a script which split slected items according to items and keep only items at "spaces",
so just insert track, create a long empty items on it, use the script, then put the items a track below (in between the items used as reference).
@dsyrock
The script way woudl be more complex cause of possible overlapping items. :P
|
I tried the one you are mention, but when there are many items it seems towards the end of the collection of items will not align properly. Instead of keeping the empty space it will take it away.
Edit : it seems to be working properly now ! My bad
|
|
|
01-22-2021, 07:36 AM
|
#10
|
Human being with feelings
Join Date: Mar 2016
Posts: 1,239
|
Quote:
Originally Posted by amagalma
Yes, sure.. I can make the script leave only the newly inserted empty items selected for convenience.
Edit: done.. See code above
|
Amazing, thanks. I'm stuck working in another DAW at the moment, but when I get back to Reaper I'll give this a try :-)
|
|
|
01-22-2021, 08:21 AM
|
#11
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
I have updated the code above to include two settings (set inside the script):
- set newly inserted items as only selected items (true/false)
- newly inserted items have one empty take (true/false)
Uploaded to ReaPack:
amagalma_Fill space between selected items with empty items
#Fills the space between the selected items with empty items
Inside the script you can set if:
- the newly inserted items will be the only selected items
- the newly inserted items will have an empty take or be really empty items
Last edited by amagalma; 01-22-2021 at 08:28 AM.
|
|
|
01-23-2021, 08:40 AM
|
#12
|
Human being with feelings
Join Date: May 2017
Posts: 371
|
Quote:
Originally Posted by amagalma
I have updated the code above to include two settings (set inside the script):
- set newly inserted items as only selected items (true/false)
- newly inserted items have one empty take (true/false)
Uploaded to ReaPack:
amagalma_Fill space between selected items with empty items
#Fills the space between the selected items with empty items
Inside the script you can set if:
- the newly inserted items will be the only selected items
- the newly inserted items will have an empty take or be really empty items
|
Super ! Thanks!
|
|
|
08-19-2021, 12:45 PM
|
#13
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,416
|
Thanks for this amagalma, something I had a use for right now. And it works great.
I did one tweak to suit me better, though. I added a take to the new empty item. The reason for this is to get the colors to match the other items.
Between lines 47 and 48, I added
Code:
reaper.SetMediaItemInfo_Value( new_item, "D_LENGTH", len ) -- line 47
reaper.AddTakeToMediaItem(new_item) -- new line to add take
added = added + 1 -- old line 48, new line 49
Next tweak I'll do is for it to put empty items at the beginning and end to match up with the time selection, if any. But that's for later, now I just did that manually.
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
08-19-2021, 04:49 PM
|
#14
|
Human being with feelings
Join Date: Apr 2011
Posts: 3,451
|
You didn't have to change anything for this as it is already there
Line 19&20 of the script:
Code:
-- if true then newly inserted items have an empty take
local new_items_have_empty_take = false -- true/false
|
|
|
08-20-2021, 10:34 AM
|
#15
|
Human being with feelings
Join Date: Sep 2008
Location: Sweden
Posts: 7,416
|
Quote:
Originally Posted by amagalma
You didn't have to change anything for this as it is already there
Line 19&20 of the script:
Code:
-- if true then newly inserted items have an empty take
local new_items_have_empty_take = false -- true/false
|
Well... I thought that setting that switch true would add a take, but it didn't. I didn't bother to check further, so I just made the edit and though that I had misunderstood what that switch was for.
Looking now in detail at the code, I see that also the switch on line 17 need to be set true for a new take to be added.
Maybe you should change so that those two switches are independent?
__________________
// MVHMF
I never always did the right thing, but all I did wasn't wrong...
|
|
|
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 11:28 PM.
|