Old 09-14-2019, 11:16 PM   #1
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default New Script: Move selected items by X samples (+/-)

Hi guys,

Didn't see anything like this in Reapack. The script moves selected items by however many samples (+/-) you choose. The script will also take into account the PROJECT sample rate and move the items accordingly.




Based on project sample rate:
Code:
--[[
Written by Thonex

Moves selected items by however many samples you choose. The script will
also take into account the sample rate and move the items accordingly.
--]]


function MOVE_BY_X_SAMPLES ()
  reaper.PreventUIRefresh(1)
  reaper.Undo_BeginBlock()

  num_sel_items =  reaper.CountSelectedMediaItems( 0 )
  
  if not ( num_sel_items > 0) then 
  reaper.ShowMessageBox( "No items were selected!", "Warning", 0 )
  return 
  end
  
  retval, offset = reaper.GetUserInputs( "Move Items By Samples", 1, "Offset Items by X samples:",0 )
  
  if retval == false then return end
  
  sr = reaper.GetSetProjectInfo( 0, "PROJECT_SRATE", 0, false )
  
  for i = 0, num_sel_items-1 do
  
      item = reaper.GetSelectedMediaItem(0, i)
      item_pos = reaper.GetMediaItemInfo_Value(item,"D_POSITION")     
      reaper.SetMediaItemInfo_Value( item, "D_POSITION", item_pos + (offset/sr) )
  
  end
  
  reaper.PreventUIRefresh(-1)
  reaper.Undo_EndBlock("Moved selected items by ".. offset.. " samples.", -1)
  
  
end


MOVE_BY_X_SAMPLES ()


Enjoy.
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.

Last edited by Thonex; 09-15-2019 at 10:17 AM.
Thonex is offline   Reply With Quote
Old 09-14-2019, 11:32 PM   #2
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,984
Default

You probably should use project sample rate instead.

If your sample is 192000 and you move 1 sample forward while your project 44100, I`m not sure the movement would be correct (relative to project of course).
mpl is offline   Reply With Quote
Old 09-15-2019, 01:02 AM   #3
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

Quote:
Originally Posted by mpl View Post
You probably should use project sample rate instead.

If your sample is 192000 and you move 1 sample forward while your project 44100, I`m not sure the movement would be correct (relative to project of course).

That's a good point. I was trying to cover all bases by having it adjust by item's SR... but I think project SR is more real-world. I'll update the original pos.

Thanks (as usual) mpl!
__________________
Cheers... Andrew K
Reaper v6.80+dev0621 - June 21 2023 • Catalina • Mac Mini 2020 6 core i7 • 64GB RAM • OS: Catalina • 4K monitor • RME RayDAT card with Sync Card and extended Light Pipe.
Thonex is offline   Reply With Quote
Old 09-15-2019, 04:20 AM   #4
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,900
Default

@Thonex
My Set item position order scripts already did that feature :P

But yes, good to have it in simple module like that.
X-Raym 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:00 PM.


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