top of page
- Script Code -

dofile(reaper.AZ_GetLuaInitPath())

require("reaper_AZSTOKE_SILVER")


trackNameList = {"pl0000","pl1000","pl2000","pl3000","pl4000"}

trackColorList = {33554304,33521664,25165824,16777471,21004543}


retval,inputList = reaper.AZ_GetUserInputList("SourceImportPath",1,"Path :","D:/")


if retval then

--Get Master Select Track 

   masterTrack = reaper.AZ_GetTrackItemSelect(0,0,1)

   masterName = reaper.AZ_GetTrackItemName(masterTrack)

   masterDepth = reaper.AZ_GetTrackItemDepth(masterTrack)


   for i, value in pairs(trackNameList) do

       if masterName == trackNameList[i] then

          reaper.AZ_SetTrackItemColor(masterTrack,trackColorList[i])

          masterColor = trackColorList[i]

       end

   end


--Get FileList

   fileAllList = {}

   fileList = reaper.AZ_GetFilePathList(inputList[1],"Wav")

   for i, value in pairs(fileList) do

       splitList = reaper.AZ_GetStringSplitList(value,"\\")

       splitCount = 0

      for e, sp in pairs(splitList) do

          splitCount = splitCount + 1

      end

      fileAllList[i] = {}

      fileAllList[i]["Path"] = value

      fileAllList[i]["SourceName"] =  reaper.AZ_ReplaceSearchString(splitList[splitCount],".wav","")

   end

   

   

--Get Master Track Children

   childList,masterChildCount = reaper.AZ_GetTrackItemChildList(masterTrack)


   childInfoList = {}

   for i, value in pairs(childList) do

       childInfoList[i] = {}

       childInfoList[i]["TrackName"]= reaper.AZ_GetTrackItemName(value)

       reaper.AZ_SetTrackItemColor(value,masterColor)

       childInfoList[i]["TrackMediaCount"] = reaper.AZ_GetTrackItemMediaTypeCount(value,"")

       childId = reaper.AZ_GetTrackItemIndex(value)

    

       for e = 1,childInfoList[i].TrackMediaCount do

           childInfoList[i][e] = {}

           childInfoList[i][e]["MediaName"] = reaper.AZ_GetTrackMediaName(0,childId,e-1)

           childInfoList[i][e]["MediaPos"]= reaper.AZ_GetTrackMediaStartTimeSeconds(0,childId,e-1)

       end

    end


--delet trackNameList & trackBaseList create 

    trCount = reaper.AZ_GetTrackCountSelect(0,0)

    deletIDList = {}

    idCount = 0


    for i = 0,trCount-1 do

        name = reaper.AZ_GetTrackIdName(0,i)

        for i, value in pairs(trackNameList) do

            if name == value then

               idCount = idCount + 1

               deletIDList[idCount] = i

            end

        end

    end


    table.sort(deletIDList,function(a,b) return (a>b)end)


    for i = 1,idCount do

        table.remove(trackNameList,deletIDList[i])

        table.remove(trackColorList,deletIDList[i])

    end




--InsertTrack

    for i, value in pairs(trackNameList) do

        count = reaper.AZ_GetTrackCountSelect(0,0)

        track = reaper.AZ_InsertTrackId(0,count)

        reaper.AZ_SetTrackItemName(track,value)

        reaper.AZ_SetTrackItemDepth(track,masterDepth)

        reaper.AZ_SetTrackItemColor(track,trackColorList[i])

   

        for e = 1,masterChildCount do

            childTrack = reaper.AZ_InsertChildTrack(track)

            reaper.AZ_SetTrackItemName(childTrack,childInfoList[e].TrackName)

            reaper.AZ_SetTrackItemColor(childTrack,trackColorList[i])

            for x = 1,childInfoList[e].TrackMediaCount do

                newMediaName = reaper.AZ_ReplaceSearchString(childInfoList[e][x].MediaName,string.lower(masterName),string.lower(value))

                for z, value in pairs(fileAllList) do

                    if newMediaName == fileAllList[z].SourceName then

                       reaper.AZ_InsertMediaTrackItemSecond(childTrack,fileAllList[z].Path,0,childInfoList[e][x].MediaPos)

                    end

                end

           

            end

        end

     end

end





- Warm Up -

  • Create a base track/child track

  • Prepare all media for the base pl0000 you are using, with everything matching except the base name.

- Script Detail -

dofile(reaper.AZ_GetLuaInitPath())

require("reaper_AZSTOKE_SILVER")


・Enable SilverAPI


trackNameList = {"pl0000","pl1000","pl2000","pl3000","pl4000"}

trackColorList = {33554304,33521664,25165824,16777471,21004543}



・Set the base name and color to an array


retval,inputList = reaper.AZ_GetUserInputList("SourceImportPath",1,"Path :","D:/")


・Set up text input (allows user to specify folder hierarchy)


if retval then


・If text input is enabled, do the following:


--Get Master Select Track 

   masterTrack = reaper.AZ_GetTrackItemSelect(0,0,1)

   masterName = reaper.AZ_GetTrackItemName(masterTrack)

   masterDepth = reaper.AZ_GetTrackItemDepth(masterTrack)


・Get the selected master track/name/hierarchy and assign it to each variable


   for i, value in pairs(trackNameList) do

       if masterName == trackNameList[i] then

          reaper.AZ_SetTrackItemColor(masterTrack,trackColorList[i])

          masterColor = trackColorList[i]

       end

   end



・Check the contents of the matching array in the master track, find the color, and assign it to a variable


--Get FileList

   fileAllList = {}

   fileList = reaper.AZ_GetFilePathList(inputList[1],"Wav")


・Output the wav files contained in the specified folder path as an array and assign them to fileList.


   for i, value in pairs(fileList) do

       splitList = reaper.AZ_GetStringSplitList(value,"\\")

       splitCount = 0

      for e, sp in pairs(splitList) do

          splitCount = splitCount + 1

      end

      fileAllList[i] = {}

      fileAllList[i]["Path"] = value

      fileAllList[i]["SourceName"] =  reaper.AZ_ReplaceSearchString(splitList[splitCount],".wav","")

   end

 

・Output the source name from filePath and assign it to the fillAllList array

 

--Get Master Track Children

   childList,masterChildCount = reaper.AZ_GetTrackItemChildList(masterTrack)



・Output the child tracks of the master track and assign them to childList, and assign the number of child tracks to masterChildCount.

   childInfoList = {}

   for i, value in pairs(childList) do

       childInfoList[i] = {}

       childInfoList[i]["TrackName"]= reaper.AZ_GetTrackItemName(value)


・Assign the name of each child track to childInfoList


       reaper.AZ_SetTrackItemColor(value,masterColor)


・Child tracks of a master are colored the same as the master


       childInfoList[i]["TrackMediaCount"] = reaper.AZ_GetTrackItemMediaTypeCount(value,"")


・Get the number of media in each child track


       childId = reaper.AZ_GetTrackItemIndex(value)


・各子トラックアイテムからidを取得してchildIdに代入

 

       for e = 1,childInfoList[i].TrackMediaCount do


・Loop playback for each child track's media amount


           childInfoList[i][e] = {}

           childInfoList[i][e]["MediaName"] = reaper.AZ_GetTrackMediaName(0,childId,e-1)

           childInfoList[i][e]["MediaPos"]= reaper.AZ_GetTrackMediaStartTimeSeconds(0,childId,e-1)


・Get the media name and position and assign them to each variable


       end

    end


--delet trackNameList & trackBaseList create 

    trCount = reaper.AZ_GetTrackCountSelect(0,0)

    deletIDList = {}

    idCount = 0


    for i = 0,trCount-1 do

        name = reaper.AZ_GetTrackIdName(0,i)


・Get the names of all tracks and assign them to name


        for i, value in pairs(trackNameList) do


・Loop playback for the sequence of bass names


            if name == value then


・If all track names and base names match, do the following:


               idCount = idCount + 1

               deletIDList[idCount] = i


・If it matches the base name, it will be deleted from the base

 ※Recognize that it has already been made


            end

        end

    end


    table.sort(deletIDList,function(a,b) return (a>b)end)


・Sort deletIDList in descending order


    for i = 1,idCount do

        table.remove(trackNameList,deletIDList[i])

        table.remove(trackColorList,deletIDList[i])


・Delete from the base array


    end




--InsertTrack

    for i, value in pairs(trackNameList) do


・Loop playback for bass


        count = reaper.AZ_GetTrackCountSelect(0,0)


・Get the total number of tracks and assign it to count


        track = reaper.AZ_InsertTrackId(0,count)


・Insert a track at the end of a track


        reaper.AZ_SetTrackItemName(track,value)

        reaper.AZ_SetTrackItemDepth(track,masterDepth)

        reaper.AZ_SetTrackItemColor(track,trackColorList[i])

 

・Set the name, level and color of the insert track


        for e = 1,masterChildCount do


・Supports for loops for the number of child tracks


            childTrack = reaper.AZ_InsertChildTrack(track)


・Insert a child track for each added bass track


            reaper.AZ_SetTrackItemName(childTrack,childInfoList[e].TrackName)

            reaper.AZ_SetTrackItemColor(childTrack,trackColorList[i])


・Name and color child tracks


            for x = 1,childInfoList[e].TrackMediaCount do


・For loop for the number of media in the child track


                newMediaName = reaper.AZ_ReplaceSearchString(childInfoList[e][x].MediaName,string.lower(masterName),string.lower(value))


・Replace the base name with the media name and assign it to newMediaName.


                for z, value in pairs(fileAllList) do

・Loop playback of all files


                    if newMediaName == fileAllList[z].SourceName then


・If sourceName matches newMediaName, execute the following:


                       reaper.AZ_InsertMediaTrackItemSecond(childTrack,fileAllList[z].Path,0,childInfoList[e][x].MediaPos)


・Align the matched media to the specified track and number of seconds


                    end

                end

 

            end

        end

     end

end





- API LINK -

Track

AZSTOKE_AllTrackMediaSetSameAutoSetter

Track/media detection and auto-duplicate same set

01_BRONZE_ss_edited.png
01_SILVER_edited_edited.png
03_GOLD_edited_edited.png
bottom of page