Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Reply
 
Thread Tools Display Modes
Old 08-06-2018, 09:22 AM   #1
o_e
Human being with feelings
 
o_e's Avatar
 
Join Date: May 2016
Posts: 681
Default Script to insert silence of specific length on specific points?

Hi,

I have a track of audio and want to insert silence on certain points. I have a list which contains pairs like:
01:30- 00:30 which means at 1:30 should be a silence of 30 seconds length inserted (and so forth).
Do you think something like this could be scripted?
I'am willing to donate a little bounty, would 20€ be ok?

thanks!
o_e is offline   Reply With Quote
Old 08-06-2018, 10:56 AM   #2
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

Quote:
Originally Posted by o_e View Post
Hi,

I have a track of audio and want to insert silence on certain points. I have a list which contains pairs like:
01:30- 00:30 which means at 1:30 should be a silence of 30 seconds length inserted (and so forth).
Do you think something like this could be scripted?
I'am willing to donate a little bounty, would 20€ be ok?

thanks!
Would this be across all tracks? If so check out this Action:

Time selection: Insert empty space at time selection (moving later items)
__________________
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 08-06-2018, 03:23 PM   #3
o_e
Human being with feelings
 
o_e's Avatar
 
Join Date: May 2016
Posts: 681
Default

Quote:
Originally Posted by Thonex View Post
Would this be across all tracks? If so check out this Action:

Time selection: Insert empty space at time selection (moving later items)
Thanks for your answer! It is only one track and I have multiple points where I want to insert silence (of a specific length) and there is only one time selection at a time, right? So I don't see how that action can help..?
o_e is offline   Reply With Quote
Old 08-07-2018, 10:38 AM   #4
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

Quote:
Originally Posted by o_e View Post
Thanks for your answer! It is only one track and I have multiple points where I want to insert silence (of a specific length) and there is only one time selection at a time, right? So I don't see how that action can help..?
When you say "Silence" do you mean you want to move the item 30 seconds later without anything in front of it? So in essence spacing out the item 30 seconds away from the tail of the previous item?

I wrote a script where you can marquee as many items as you want, type in a "seconds" value and it will create X seconds of space between the items.

Would that help? Or does it have to read from your list?
__________________
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 08-07-2018, 11:56 AM   #5
o_e
Human being with feelings
 
o_e's Avatar
 
Join Date: May 2016
Posts: 681
Default

Quote:
Originally Posted by Thonex View Post
When you say "Silence" do you mean you want to move the item 30 seconds later without anything in front of it? So in essence spacing out the item 30 seconds away from the tail of the previous item?

I wrote a script where you can marquee as many items as you want, type in a "seconds" value and it will create X seconds of space between the items.

Would that help? Or does it have to read from your list?
That sounds great, so I can make all the cuts first (according to the first values of my list) and than marquee the first two items, type in the length of the 'gap' and than move one to the next cut and so forth. Not as elegant as I was hoping but doable..
o_e is offline   Reply With Quote
Old 08-07-2018, 12:57 PM   #6
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

Quote:
Originally Posted by o_e View Post
That sounds great, so I can make all the cuts first (according to the first values of my list) and than marquee the first two items, type in the length of the 'gap' and than move one to the next cut and so forth. Not as elegant as I was hoping but doable..
Do you want cut length values also? So you just marquee the items enter 90 seconds for item length, and 30 seconds for space, then it will make all items 90 seconds with a 30 second space between them.
__________________
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 08-07-2018, 02:20 PM   #7
o_e
Human being with feelings
 
o_e's Avatar
 
Join Date: May 2016
Posts: 681
Default

Quote:
Originally Posted by Thonex View Post
Do you want cut length values also? So you just marquee the items enter 90 seconds for item length, and 30 seconds for space, then it will make all items 90 seconds with a 30 second space between them.
I have files of approx. 50min length and I would make cuts at (different, not equal) points where the space (of a certain length, always different) should be inserted..
I hope this is understandable, sorry for being unclear but english is not my first language..
o_e is offline   Reply With Quote
Old 08-08-2018, 06:34 AM   #8
Neutronic
Human being with feelings
 
Neutronic's Avatar
 
Join Date: Sep 2013
Posts: 657
Default

Quote:
Originally Posted by o_e View Post
Not as elegant as I was hoping but doable..
In case you didn't notice, I PMed you a couple of days ago right when you posted your request. It can be scripted the way you want it and in a timely fashion. You can find all the details in the PM.
If you're interested, please PM / email me directly.
Thanks!
Neutronic is offline   Reply With Quote
Old 08-08-2018, 10:45 AM   #9
Thonex
Human being with feelings
 
Join Date: May 2018
Location: Los Angeles
Posts: 1,721
Default

Hey e_o,

Here is a script I wrote that I use for myself... it is almost what you want. Give it a shot. Otherwise I'm sure Neutronic will be able to help. Note the instructions in the code.




Code:
--[[  Written by Thonex aka Andrew K
      
      Instructions:
      Simply select all the Item you want moved (even across multiple tracks).
      The first selected item on a track will be the “anchor” (meaning it won’t be moved) and
      all the other items will be moved according to the number os seconds you entered in the
      input field.
      You can use decimal also. If you want silence of 1:30 min then enter “90” as your seconds of silence.
--]]


function Add_X_Seconds_Space_Before_Selected_Items ()
  reaper.PreventUIRefresh(1)
  reaper.ClearConsole() 
  reaper.Undo_BeginBlock()


  retval, retvals_csv = reaper.GetUserInputs( "Add Silence Before Selected Items", 1, "X seconds", 2 )

  Num_Sel_Items = reaper.CountSelectedMediaItems(0)

  Sel_Item_ID = {}
  Item_Pos = {}
  Item_ID_Len = {}
  Item_ID_End_Pos ={}
  
  -- log slected items
  for i = 0, Num_Sel_Items - 1 do -- get all original positions and end points
    Sel_Item_ID[i] = reaper.GetSelectedMediaItem(0,i)   -- gets Item's ID
    Item_Pos[i]= reaper.GetMediaItemInfo_Value( Sel_Item_ID[i],"D_POSITION")
    Item_ID_Len[i] =  reaper.GetMediaItemInfo_Value(Sel_Item_ID[i],"D_LENGTH")
    Item_ID_End_Pos[i] =  Item_Pos[i] + Item_ID_Len[i]

  end
  
  -- move items X seconds from previous end
  i=0
  while i < Num_Sel_Items do 
  
    if  i>0 and reaper.GetMediaItemTrack(Sel_Item_ID[i]) ~= reaper.GetMediaItemTrack(Sel_Item_ID[i-1]) then
      i=i+1
    end
  
    if i>0 then
      reaper.SetMediaItemPosition( Sel_Item_ID[i],Item_ID_End_Pos[i-1]+retvals_csv, 1 )

      Item_Pos[i]= reaper.GetMediaItemInfo_Value( Sel_Item_ID[i],"D_POSITION")

      Item_ID_Len[i] =  reaper.GetMediaItemInfo_Value(Sel_Item_ID[i],"D_LENGTH")
      Item_ID_End_Pos[i] =  Item_Pos[i] + Item_ID_Len[i]
    end
  i=i+1
  end

  reaper.PreventUIRefresh(-1)
  reaper.UpdateArrange()
  reaper.Undo_EndBlock("Insert X Seconds between Takes",-1)

end

Add_X_Seconds_Space_Before_Selected_Items ()
__________________
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 08-11-2018, 02:14 AM   #10
o_e
Human being with feelings
 
o_e's Avatar
 
Join Date: May 2016
Posts: 681
Default

Thank you both so far!
o_e is offline   Reply With Quote
Old 10-18-2018, 05:34 AM   #11
SonicAxiom
Human being with feelings
 
SonicAxiom's Avatar
 
Join Date: Dec 2012
Location: Germany
Posts: 3,039
Default

Quote:
Originally Posted by Thonex View Post
Hey e_o,

Here is a script I wrote that I use for myself... it is almost what you want. Give it a shot. Otherwise I'm sure Neutronic will be able to help. Note the instructions in the code.




Code:
--[[  Written by Thonex aka Andrew K
      
      Instructions:
      Simply select all the Item you want moved (even across multiple tracks).
      The first selected item on a track will be the “anchor” (meaning it won’t be moved) and
      all the other items will be moved according to the number os seconds you entered in the
      input field.
      You can use decimal also. If you want silence of 1:30 min then enter “90” as your seconds of silence.
--]]


function Add_X_Seconds_Space_Before_Selected_Items ()
  reaper.PreventUIRefresh(1)
  reaper.ClearConsole() 
  reaper.Undo_BeginBlock()


  retval, retvals_csv = reaper.GetUserInputs( "Add Silence Before Selected Items", 1, "X seconds", 2 )

  Num_Sel_Items = reaper.CountSelectedMediaItems(0)

  Sel_Item_ID = {}
  Item_Pos = {}
  Item_ID_Len = {}
  Item_ID_End_Pos ={}
  
  -- log slected items
  for i = 0, Num_Sel_Items - 1 do -- get all original positions and end points
    Sel_Item_ID[i] = reaper.GetSelectedMediaItem(0,i)   -- gets Item's ID
    Item_Pos[i]= reaper.GetMediaItemInfo_Value( Sel_Item_ID[i],"D_POSITION")
    Item_ID_Len[i] =  reaper.GetMediaItemInfo_Value(Sel_Item_ID[i],"D_LENGTH")
    Item_ID_End_Pos[i] =  Item_Pos[i] + Item_ID_Len[i]

  end
  
  -- move items X seconds from previous end
  i=0
  while i < Num_Sel_Items do 
  
    if  i>0 and reaper.GetMediaItemTrack(Sel_Item_ID[i]) ~= reaper.GetMediaItemTrack(Sel_Item_ID[i-1]) then
      i=i+1
    end
  
    if i>0 then
      reaper.SetMediaItemPosition( Sel_Item_ID[i],Item_ID_End_Pos[i-1]+retvals_csv, 1 )

      Item_Pos[i]= reaper.GetMediaItemInfo_Value( Sel_Item_ID[i],"D_POSITION")

      Item_ID_Len[i] =  reaper.GetMediaItemInfo_Value(Sel_Item_ID[i],"D_LENGTH")
      Item_ID_End_Pos[i] =  Item_Pos[i] + Item_ID_Len[i]
    end
  i=i+1
  end

  reaper.PreventUIRefresh(-1)
  reaper.UpdateArrange()
  reaper.Undo_EndBlock("Insert X Seconds between Takes",-1)

end

Add_X_Seconds_Space_Before_Selected_Items ()
Would it be possible to add a "ripple later items" option to this script? This would allow to insert a specific amount of silence before selected items but then also move later, unselected items preserving their existing distances.

.
__________________
Check out AVConvert (free, super-fast media file manipulation via the right-click context-menu in Windows Explorer) and my free VST plugins.
My Reaper tutorials and studio related videos on youtube.
SonicAxiom 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 04:08 PM.


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