Rate to Pitch Rate to Pitch and Preserve

Sometimes in a project you may have some items with

  • “Preserve pitch when changing rate” off, so that you can stretch them and change the pitch.
  • “Preserve pitch when changing rate” on so that you can stretch the item and not change the pitch.
  • Pitch changes via the “Pitch Adjust” parameter.

The following script consolidates the selected items so they retain their length and pitch, but with “Preserve pitch when changing rate” on.

It does this by finding items with “Preserve pitch when changing rate” off, then it translates the rate to pitch, assigns that to the pitch value and turns on “Preserve pitch when changing rate”.

Thanks to Canopy for the idea

The Script

The following code is the script. You can either create a new script via the actions window and drop this in it, or download from here.

To find the location of where to put this:

  • Open Reaper
  • Options menu->Show RESOURCE path in explorer/finder
  • Open the “Scripts” folder
  • Create a new folder (‘AdmiralBumbleBee’ if you wish)
  • Place this file in it
selected_items_count = reaper.CountSelectedMediaItems(0)

reaper.Undo_BeginBlock()

for i = 0, selected_items_count-1  do
  item = reaper.GetSelectedMediaItem(0, i)
  
  take = reaper.GetActiveTake(item)
  
  preserve = reaper.GetMediaItemTakeInfo_Value(take ,"B_PPITCH")
  
  if preserve == 0 then

    rate = reaper.GetMediaItemTakeInfo_Value(take, "D_PLAYRATE")
    newRate = 1
    newPitch = (12/math.log(2)) * math.log(rate)
    reaper.SetMediaItemTakeInfo_Value(take, "D_PITCH", newPitch)
    reaper.SetMediaItemTakeInfo_Value(take, "B_PPITCH", 1)
    
  end
    
end

reaper.Undo_EndBlock("Change Rates to Pitch and Preserve Pitch", -1)

Special Thanks

Thank you to Elan Hickler for the pitch/rate scripts HERE, and ExtremRaym.

I borrowed some ideas from these resources to cobble this together.

Support Me!

This script took only 15 minutes to write. If you appreciate the information presented then please donate!

If you have any questions or comments, please comment below! I read every comment and respond to most.