--[[ Install Spleeter Guide Download: https://codeload.github.com/deezer/spleeter/zip/master https://repo.anaconda.com/archive/Anaconda3-2019.10-Windows-x86_64.exe https://repo.anaconda.com/archive/Anaconda3-2019.10-MacOSX-x86_64.pkg Install Anaconda Python using defaults Win (C:\ProgramData) set for all users if you like. Unzip spleeter-master.zip and rename folder to spleeter Copy the spleeter folder to your Reaper Scripts folder or Scripts\ReaTrak\ Open Anaconda Prompt (search for it with Windows Search) At the command change the directory to the spleeter folder location by cd C:\Users\User\AppData\Roaming\REAPER\Scripts\spleeter install using conda with this command conda install -c conda-forge spleeter It will take a while, when it ask to update packages select y (yes) Once done you can insert a song into Reaper select the audio item and run a 2 4 or 5 stems script the first time will download the package for 2stems 4stems or 5stems When done the stem tracks will be inserted into Reaper, they will be in a folder spleeter_output in the same folder as the source media if you get an error Intel MKL FATAL ERROR: Cannot load mkl_intel_thread.dll. remove or rename 'System32\libiomp5md.dll' and 'SysWOW64\libiomp5md.dll' You can get the tempo map from the original item or the drums stem with https://forum.cockos.com/showthread.php?p=2294081#post2294081 Script: ReaTrak get tempo map from item.lua (needs sonic.zip) --]] -- USER CONFIG AREA ----------------------------------------------------------- -- Duplicate and Rename the script if you want to modify this. -- Else, a script update will erase your mods. -- Display a message in the console for debugging function Msg(value) if console then reaper.ShowConsoleMsg(tostring(value) .. "\n") end end console = true -- true/false: display debug messages in the console local info = debug.getinfo(1,'S'); script_path = info.source:match[[^@?(.*[\/])[^\/]-$]] script_path2 = script_path .."spleeter" --Msg("script path2 "..script_path2) end_script = 0 function getPath(str) return str:match("(.*[/\\])") end function get_file_name(file) return file:match("^.+/(.+)$") end --This function finds the filename when given a complete path function GetFilename(path) local start, finish = path:find('[%w%s!-={-|]+[_%.].+') return path:sub(start,#path) end function get_stems() os_type = reaper.GetOS() -- "Win32", "Win64", "OSX32", "OSX64", or "Other". --Msg("os_type ".. os_type) if os_type == "Win32" or os_type == "Win64" then sel_item = reaper.GetSelectedMediaItem( 0, 0 ) if not sel_item then reaper.MB( "Select one audio item", "Select Audio Item", 0 ) end_script = 1 end if sel_item then reaper.Main_OnCommand( 41173, 0 ) item_pos = reaper.GetMediaItemInfo_Value( sel_item, "D_POSITION" ) item_take = reaper.GetMediaItemTake( sel_item, 0 ) source = reaper.GetMediaItemTake_Source( item_take ) filename = reaper.GetMediaSourceFileName(source, "") filepath = getPath(filename) filename_no_ext = string.gsub(filename, '[.]%w%w%w$','') take_type = reaper.TakeIsMIDI( item_take ) if take_type then reaper.MB( "Item is MIDI", "Select Audio Item", 0 ) end_script = 1 end end anaconda_installed = 0 if not take_type and end_script == 0 then if reaper.file_exists("C:\\ProgramData\\Anaconda3\\Scripts\\activate.bat") then ANACONDA_PATH = "C:\\ProgramData\\Anaconda3" anaconda_installed = 1 --Msg("All Users") --Msg("ANACONDA_PATH="..ANACONDA_PATH) end --Msg(os.getenv("HOMEPATH")) HOME_DRIVE = os.getenv("HOMEDRIVE") HOME_PATH = os.getenv( "HOMEPATH" ) ANACONDA = HOME_DRIVE .. HOME_PATH .. "\\Anaconda3\\Scripts\\activate.bat" if reaper.file_exists(ANACONDA) then ANACONDA_PATH = HOME_DRIVE .. HOME_PATH .."\\Anaconda3" anaconda_installed = 1 --Msg("Single User") --Msg("ANACONDA_PATH="..ANACONDA_PATH) end if anaconda_installed == 0 then reaper.MB("Can't find Anaconda","Message",0) goto fininsh end COMMAND = [[cmd.exe /C "]] ..ANACONDA_PATH ..[[\Scripts\activate.bat & echo processing please wait... & cd ]] ..script_path2 ..[[ & spleeter separate -i "]] ..filename ..[[" -p spleeter:5stems -o "]] ..filepath ..[[spleeter_output"]] --Msg("COMMAND="..COMMAND) os.execute(COMMAND) --os.execute([[cmd.exe /C " C:\ProgramData\Anaconda3\Scripts\activate.bat & echo processing please wait... & cd ]] .. script_path2 ..[[ & spleeter separate -i "]] .. filename .. [[" -p spleeter:2stems -o "]] .. filepath .. [[spleeter_output"]]) source_name = GetFilename(filename) if string.find(source_name, '[.]%w%w%w$') then folder_name = string.gsub(source_name, '[.]%w%w%w$','') else folder_name = string.gsub(source_name, '[.]%w%w%w%w$','') end reaper.InsertMedia( filepath .. "spleeter_output//" .. folder_name .. "//bass.wav", 1 ) reaper.InsertMedia( filepath .. "spleeter_output//" .. folder_name .. "//drums.wav", 1 ) reaper.InsertMedia( filepath .. "spleeter_output//" .. folder_name .. "//other.wav", 1 ) reaper.InsertMedia( filepath .. "spleeter_output//" .. folder_name .. "//piano.wav", 1 ) reaper.InsertMedia( filepath .. "spleeter_output//" .. folder_name .. "//vocals.wav", 1 ) end ::fininsh:: end os_type = reaper.GetOS() -- "Win32", "Win64", "OSX32", "OSX64", or "Other". if os_type == "OSX32" or os_type == "OSX64" then sel_item = reaper.GetSelectedMediaItem( 0, 0 ) if not sel_item then reaper.MB( "Select one audio item", "Select Audio Item", 0 ) end_script = 1 end if sel_item then reaper.Main_OnCommand( 41173, 0 ) item_pos = reaper.GetMediaItemInfo_Value( sel_item, "D_POSITION" ) item_take = reaper.GetMediaItemTake( sel_item, 0 ) source = reaper.GetMediaItemTake_Source( item_take ) filename = reaper.GetMediaSourceFileName(source, "") filename_no_ext = string.gsub(filename, '[.]%w%w%w$','') take_type = reaper.TakeIsMIDI( item_take ) if take_type then reaper.MB( "Item is MIDI", "Select Audio Item", 0 ) end_script = 1 end end anaconda_installed = 0 if not take_type and end_script == 0 then --SET PATHS FOR MAC reaper.MB("You need to set Paths in Script for Mac", "Message",0) if reaper.file_exists("C:\\ProgramData\\Anaconda3\\Scripts\\activate.bat") then ANACONDA_PATH = "C:\\ProgramData\\Anaconda3" anaconda_installed = 1 --Msg("All Users") --Msg("ANACONDA_PATH="..ANACONDA_PATH) end --Msg(os.getenv("HOMEPATH")) HOME_DRIVE = os.getenv("HOMEDRIVE") HOME_PATH = os.getenv( "HOMEPATH" ) ANACONDA = HOME_DRIVE .. HOME_PATH .. "\\Anaconda3\\Scripts\\activate.bat" if reaper.file_exists(ANACONDA) then ANACONDA_PATH = HOME_DRIVE .. HOME_PATH .."\\Anaconda3" anaconda_installed = 1 --Msg("Single User") --Msg("ANACONDA_PATH="..ANACONDA_PATH) end if anaconda_installed == 0 then reaper.MB("Can't find Anaconda","Message",0) goto fininsh end --SET FOR MAC TERMINAL reaper.MB("You need to set Command Line in Script for Mac", "Message",0) COMMAND = [[cmd.exe /C "]] ..ANACONDA_PATH ..[[\Scripts\activate.bat & echo processing please wait... & cd ]] ..script_path2 ..[[ & spleeter separate -i "]] ..filename ..[[" -p spleeter:5stems -o "]] ..filepath ..[[spleeter_output"]] --Msg("COMMAND="..COMMAND) os.execute(COMMAND) --os.execute([[cmd.exe /C " C:\ProgramData\Anaconda3\Scripts\activate.bat & echo processing please wait... & cd ]] .. script_path2 ..[[ & spleeter separate -i "]] .. filename .. [[" -p spleeter:2stems -o "]] .. filepath .. [[spleeter_output"]]) source_name = GetFilename(filename) folder_name = string.gsub(source_name, '[.]%w%w%w$','') --INSERT LINES WHEN MAC COMMAN SET)) --reaper.InsertMedia( filepath .. "spleeter_output//" .. folder_name .. "//bass.wav", 1 ) --reaper.InsertMedia( filepath .. "spleeter_output//" .. folder_name .. "//drums.wav", 1 ) --reaper.InsertMedia( filepath .. "spleeter_output//" .. folder_name .. "//other.wav", 1 ) --reaper.InsertMedia( filepath .. "spleeter_output//" .. folder_name .. "//piano.wav", 1 ) --reaper.InsertMedia( filepath .. "spleeter_output//" .. folder_name .. "//vocals.wav", 1 ) end ::fininsh:: end end --end get_stems() --reaper.Undo_EndBlock("ReaTrak spleeter audio item to 5 stems", -1) -- End of the undo block. Leave it at the bottom of your main function. --reaper.UpdateArrange()