Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Feature Requests

Reply
 
Thread Tools Display Modes
Old 06-01-2023, 02:46 AM   #1
smandrap
Human being with feelings
 
smandrap's Avatar
 
Join Date: Feb 2021
Location: Right here
Posts: 1,650
Default Insert media with snap offset from media explorer

Hello everyone,

It would be super nice to have the ability to embed the snap offset as some sort of metadata when a render of an item is performed.
A related action in the media explorer would insert the media item at the edit cursor position in the project respecting its snap offset.

This would be useful with sounds like risers or transitions, as long as ambience sounds for example: transitions sounds such as reverse cymbals + kicks usually have a "climax" at the end with a little tail.
The current workflow now is:
  • Insert the media item from the media explorer
  • Manually find the spot where it "hits" and move the item accordingly

This is a manual process that 99% could be automated, since what we usually want is insert that transition/riser/whatever to "hit" at a certain position in the project.

A workaround at the moment is:
  • Render the items with a marker inserted as a media cue at the position of the "hit". We will name it "Snap"
  • Insert it from the media explorer
  • I wrote this script which does the snap offset/move thing
    Code:
    local MEDIA_CUE_NAME = "Snap"
    local MOVE_ITEM = true
    
    local function move_item(item)
      local item_pos = reaper.GetMediaItemInfo_Value(item, 'D_POSITION')
      local snap_offs = reaper.GetMediaItemInfo_Value(item, 'D_SNAPOFFSET')
      
      reaper.SetMediaItemInfo_Value(item, 'D_POSITION', item_pos - snap_offs)
    end
    
    
    local function set_snap_offset(item)
      local take = reaper.GetActiveTake(item)
      if not take then return end
      
      local source = reaper.GetMediaItemTake_Source(take)
      if not source then return end
      
      for i = 0, 255 do
        local rv, cue_time, _, _, cue_name = reaper.CF_EnumMediaSourceCues(source, i)
        if not rv then break end
        
        if cue_name == MEDIA_CUE_NAME then
          reaper.SetMediaItemInfo_Value(item, 'D_SNAPOFFSET', cue_time)
          return
        end
      end
    end
    
    local function main()
      local sel_items_cnt = reaper.CountSelectedMediaItems(0)
      if sel_items_cnt == 0 then return end
      
      for i = 0, sel_items_cnt - 1 do
        local item = reaper.GetSelectedMediaItem(0, i)
        set_snap_offset(item)
        if MOVE_ITEM == true then move_item(item) end
      end
    end
    
    reaper.Undo_BeginBlock()
    main()
    reaper.UpdateArrange()
    reaper.Undo_EndBlock("manup_Set snap offset to named media cues in selected items", 0)

This is quite ok, but it would be much much better if it was a native thing. Something like:
  • Do your sound design
  • Set the snap offset
  • Render it (with the option to embed snap offset)
When you want to reuse it:
  • Place the cursor where you want the item to "hit"
  • Find the item in the media explorer
  • Run action "insert respecting snap offset"

Last edited by smandrap; 06-01-2023 at 03:25 AM. Reason: Messed up the script
smandrap is online now   Reply With Quote
Old 05-15-2024, 10:21 AM   #2
smandrap
Human being with feelings
 
smandrap's Avatar
 
Join Date: Feb 2021
Location: Right here
Posts: 1,650
Default

Bump please
__________________
My Scripts
smandrap is online now   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 08:42 AM.


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