View Single Post
Old 10-14-2017, 09:02 AM   #119
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 2,548
Default

Quote:
Originally Posted by Arthur McArthur View Post
Hi mpl, a few more requests:

-list random samples in directories for RS5K on selected tracks (work with multiple selected tracks)
-export RS5K source on selected tracks as new item on new track (takes the item loaded into RS5K, and exports it to a new item on a new track below the currently selected one)
second is closer to mpl_Convert RS5k MIDI item into source based audio items (drum mode).lua

first something like:
Code:
function main(track)
    --local ret, tracknumberOut, _, fxnumberOut = reaper.GetFocusedFX()
    --local track = reaper.CSurf_TrackFromID( tracknumberOut, false )
    if not track then return end
    fxnumberOut = reaper.TrackFX_GetInstrument( track )
    --fxnumberOut =  reaper.TrackFX_AddByName( track, 'reasamplomatic', false, 0 )
    ret, fn = reaper.TrackFX_GetNamedConfigParm(track, fxnumberOut, "FILE0")
    if not ret then return end
    fn = fn:gsub('\\', '/')
    
    path = fn:reverse():match('[%/]+.*')
    if path then path = path:reverse():sub(0,-2) else return end
    cur_file =     fn:reverse():match('.-[%/]')
    if cur_file then cur_file = cur_file:reverse():sub(2) else return end
    -- get files list
      local files = {}
      local i = 0
      repeat
      local file = reaper.EnumerateFiles( path, i )
      if file then
        files[#files+1] = file
      end
      i = i+1
      until file == nil
      
    -- search file list
      local trig_file
      if #files < 2 then return end
      trig_id = math.floor(math.random(#files-1))+1
      trig_file = path..'/'..files[trig_id] 
        
      
      if trig_file then 
        reaper.TrackFX_SetNamedConfigParm(track, fxnumberOut, "FILE0", trig_file)
        reaper.TrackFX_SetNamedConfigParm(track, fxnumberOut, "DONE", "")
      end
  end



  for i = 1, reaper.CountSelectedTracks(0) do tr = reaper.GetSelectedTrack(0,i-1) main(tr) end
__________________
SoundCloud | MPL Scripts discussion | ReaPack | Donate
mpl is offline   Reply With Quote