View Single Post
Old 03-06-2013, 04:36 PM   #54
timlloyd
Human being with feelings
 
Join Date: Mar 2010
Posts: 4,713
Default

Code:
# -------------------------------------
# Set fade in and/or out length of all
# selected media items to the given
# percentage of their length
#
# (Un)comment lines 25/27 as required
#
# Currently there's no intelligence
# to modify behaviour if both fade
# in and out are given a % > 50 ...
# -------------------------------------

from reaper_python import *

usr_input = RPR_GetUserInputs("Set fade length of item(s)",
                              1, "Percent", "", 1024)

if usr_input[0]:
    RPR_Undo_BeginBlock2(0)
    for i in range(0, RPR_CountSelectedMediaItems(0)):
        item = RPR_GetSelectedMediaItem(0, i)
        length = RPR_GetMediaItemInfo_Value(item, "D_LENGTH")
        fade_len = length * (float(usr_input[4]) / 100.0)
        # set fade in
        # RPR_SetMediaItemInfo_Value(item, "D_FADEINLEN", fade_len)
        # set fade out
        RPR_SetMediaItemInfo_Value(item, "D_FADEOUTLEN", fade_len)
    RPR_Undo_EndBlock2(0, "Set item fade to percentage of length", -1)

RPR_UpdateArrange()

Last edited by timlloyd; 03-06-2013 at 04:49 PM.
timlloyd is offline   Reply With Quote