top of page

AZSTOKE/ALGAZODIK

GameAudio & Art

3

Track

AZSTOKE_AllTrackOrganize

Delete/naming/coloring selected tracks at the beginning

RANK
SNS SHARE

package.cpath = package.cpath .. ";"..reaper.GetResourcePath() .."/UserPlugins/?.dll"

require("reaper_AZSTOKE_SILVER")


function Msg(param)

 reaper.ShowConsoleMsg(tostring((param)).."\n")

end


_,allCount = reaper.AZ_GetMediaTypeCount(0,"")


--Mute Media Delete

for i = allCount-1,0,-1 do

   _,mute = reaper.AZ_GetMediaMute(0,i)

   if mute then

      reaper.AZ_DeleteMedia(0,i)

   end

end



retval,depthList = AZ_SILVER.AZ_GetTrackDepthList(0)

_,count = reaper.AZ_GetTrackCountSelect(0,0)

track,trackId = reaper.AZ_GetSelectedTrackFirstInfo(0)


for a = 0,1 do 

    for i = count-1,trackId,-1 do

       _,allCount = reaper.AZ_GetTrackMediaTypeCount(0,i,"")

       retval,trackList,trackCount = AZ_SILVER.AZ_GetTrackIdChildList(0,i)

       if allCount == 0 and trackCount == 0 then

          retval = reaper.AZ_DeleteTrackIdSelect(0,i,0)

       end

    end

    _,count = reaper.AZ_GetTrackCountSelect(0,0)

    for i = 0,count-1 do

        track = reaper.AZ_GetTrackItemSelect(0,i,0)

        for e, value in pairs(depthList) do

           if track == depthList[e].Track then

              retval = reaper.AZ_SetTrackItemDepth(track,depthList[e].Depth)

           end

        end

    end

end


retval,count = reaper.AZ_GetTrackCountSelect(0,1)


for i = 0,count-1 do

   retval,masterName = reaper.AZ_GetSelectedTrackIdName(0,i)

   retval,color = reaper.AZ_GetRandomColor()


   reaper.AZ_SetSelectedTrackIdColor(0,i,color)

   retval,trackList = AZ_SILVER.AZ_GetSelectedTrackIdChildList(0,i)

   for e, value in pairs(trackList) do

       reaper.AZ_SetTrackItemColor(trackList[e],color)

       retval,num = reaper.AZ_FormatNumDigit(e,2)

       setName = masterName.."_"..num

       reaper.AZ_SetTrackItemName(trackList[e],setName)

   end


end

package.cpath = package.cpath .. ";"..reaper.GetResourcePath() .."/UserPlugins/?.dll"

require("reaper_AZSTOKE_SILVER")



・Enable SILVERAPI



function Msg(param)

  reaper.ShowConsoleMsg(tostring((param)).."\n")

end



- Prepare console output function for debugging



_,allCount = reaper.AZ_GetMediaTypeCount(0,"")



・Output the number of media in the project and assign it to allCount


--Mute Media Delete

for i = allCount-1,0,-1 do


・For loop from allCount to 0


    _,mute = reaper.AZ_GetMediaMute(0,i)


・Detect mute of each media


    if mute then


・If muted

       reaper.AZ_DeleteMedia(0,i)


・Support to delete media


    end

end


retval,depthList = AZ_SILVER.AZ_GetTrackDepthList(0)

・Get the hierarchy of all tracks and assign it to the depthList array


_,count = reaper.AZ_GetTrackCountSelect(0,0)

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

track,trackId = reaper.AZ_GetSelectedTrackFirstInfo(0)

・Get the first track of the selected track and assign it to track and trackId


for a = 0,1 do

・Loop the following process twice


     for i = count-1,trackId,-1 do

・Loop towards minute 0 of the track


        _,allCount = reaper.AZ_GetTrackMediaTypeCount(0,i,"")

・Get the number of media in the track and assign it to allCount


        retval,trackList,trackCount = AZ_SILVER.AZ_GetTrackIdChildList(0,i)

・Assign the child tracks of the track to trackList. Assign the number of child tracks to trackCount.


        if allCount == 0 and trackCount == 0 then

・When there is no media and no child track

           retval = reaper.AZ_DeleteTrackIdSelect(0,i,0)


・Delete track


        end

     end

     _,count = reaper.AZ_GetTrackCountSelect(0,0)


・Get the track number again after deleting the track and assign it to count


     for i = 0,count-1 do

・For loop for count minutes



         track = reaper.AZ_GetTrackItemSelect(0,i,0)



・Get track items for each ID



         for e, value in pairs(depthList) do



・For loop for hierarchical list



            if track == depthList[e].Track then



・Detect tracks in the hierarchy and tracks with each ID



               retval = reaper.AZ_SetTrackItemDepth(track,depthList[e].Depth)



・Set the hierarchy of the specified track



            end

         end

     end

end



retval,count = reaper.AZ_GetTrackCountSelect(0,1)



・Output the number of tracks and assign it to count



for i = 0,count-1 do



・For loop for count minutes



    retval,masterName = reaper.AZ_GetSelectedTrackIdName(0,i)



・Get the name of the selected track



    retval,color = reaper.AZ_GetRandomColor()



・Get random color value



    reaper.AZ_SetSelectedTrackIdColor(0,i,color)



・Set color to selected track



    retval,trackList = AZ_SILVER.AZ_GetSelectedTrackIdChildList(0,i)



・Get the child array of the selected track and assign it to trackList



    for e, value in pairs(trackList) do



・For loop for trackList



        reaper.AZ_SetTrackItemColor(trackList[e],color)



・Set color to child track item



        retval,num = reaper.AZ_FormatNumDigit(e,2)



・Output string of digits in permutation number 01/02/03/04



        setName = masterName.."_"..num



- Add a digit number to the name of the selected track and assign it to setName



        reaper.AZ_SetTrackItemName(trackList[e],setName)



- Set a name for each child track



    end



end

To use the API, you need to sign up for a plan.

Download the dedicated API

need to do it.

*SILVER is scheduled to be released in May.

  • Select the parent track you want to change


- Script Code -
- Script Image -
- Warm Up -
- Script Detail -
- API -

LUA

​ReaScript File Download 👇

* A dedicated API is required to run this

- Script Image -
bottom of page