- Script Code -
dofile(reaper.AZ_GetLuaInitPath())
allCount,_ = reaper.AZ_GetTrackMediaTypeCount(0,1,"")
mediaList = {}
mediaInterval = 1
setMediaRate = 0.7
for i = 1,allCount do
mediaList[i] = {}
mediaList[i]["media"]= reaper.AZ_GetMediaTrackItemSelect(0,1,i-1,0)
mediaList[i]["startPos"]= reaper.AZ_GetTrackMediaStartTimeSeconds(0,1,i-1)
reaper.AZ_SetTrackMediaRate(0,1,i-1,setMeidaRate)
mediaList[i]["length"]= reaper.AZ_GetTrackMediaLength(0,1,i-1)
end
for index, value in pairs(mediaList) do
if index == 1 then
startNextPos = mediaList[index].startPos+mediaList[index].length+mediaInterval
else
reaper.AZ_SetMediaItemStartTimeSeconds(mediaList[index].media,startNextPos)
startNextPos = startNextPos+mediaList[index].length+mediaInterval
end
end
- Warm Up -
Multiple media in a project
- Script Detail -
dofile(reaper.AZ_GetLuaInitPath())
allCount,_ = reaper.AZ_GetTrackMediaTypeCount(0,1,"")
Get the number of all media in the specified track (allCount)
mediaList = {}
Define the array (medialist)
mediaInterval = 1
Prepare media interval value as a variable
setMediaRate = 0.7
Prepare media playback speed as a variable
for i = 1,allCount do
Loop from 1 to the variable (allCount)
mediaList[i] = {}
Define an array {} inside the array (mediaList[i]).
mediaList[i]["media"]= reaper.AZ_GetMediaTrackItemSelect(0,1,i-1,0)
Get MediaItem and save it in ["media"] of mediaList[i]
mediaList[i]["startPos"]= reaper.AZ_GetTrackMediaStartTimeSeconds(0,1,i-1)
Get the start position of the media and save it in ["start"] of mediaList[i]
reaper.AZ_SetTrackMediaRate(0,1,i-1,setMeidaRate)
Set the media playback speed to a variable (setMediaRate)
mediaList[i]["length"]= reaper.AZ_GetTrackMediaLength(0,1,i-1)
Get the length of the media and save it in ["length"] of mediaList[i]
end
for index, value in pairs(mediaList) do
Repeat for the number of elements in the array (mediaList)
if index == 1 then
If the variable (index) is 1, it continues below.
startNextPos = mediaList[index].startPos+mediaList[index].length+mediaInterval
Set the start position of the array mediaList[index] + the length of the media in the array mediaList[index] + the media interval value (1 second) to the variable (startNextPos).
else
If statement Check the contents of the variable (index)
If not the first one, continue below
reaper.AZ_SetMediaItemStartTimeSeconds(mediaList[index].media,startNextPos)
Set the media in the array mediaList[index] to the variable (startNextPos).
startNextPos = startNextPos+mediaList[index].length+mediaInterval
Set the variable (startNextPos) + the length of the media in the array mediaList[index] ++ the media interval value (1 second) to the variable (startNextPos)
end
Repeat for the number of arrays (mediaList)
end
All media in the specified track will be played at 0.7x speed, spaced 1 second apart.