top of page

2

Track

AZSTOKE_AllDeleteTopSelectTrackSearchNotUseMediaAndTrack

選択トラックを先頭にミュート削除と未使用トラックを削除

RANK

dofile(reaper.AZ_GetLuaInitPath())

require("reaper_AZSTOKE_SILVER")


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


depthList = reaper.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,"")

       trackList = reaper.AZ_GetTrackIdChildList(0,i)

       if allCount == 0 and retval == false 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

dofile(reaper.AZ_GetLuaInitPath())

require("reaper_AZSTOKE_SILVER")


  • SILVERのAPIを利用可能にする


allCount = reaper.AZ_GetMediaTypeCount(0,"")


  • 全てのメディアの数を出力してallCountに代入


--Mute Media Delete

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


  • allCountから0に向かって逆にループ再生

   mute = reaper.AZ_GetMediaMute(0,i)


  • 各メディアのミュート情報を取得

   if mute then


  • ミュートがTrue(ミュート状態)だった場合以下に続く

      reaper.AZ_DeleteMedia(0,i)


  • [i]のIndexメディアを削除

   end

end


depthList = reaper.AZ_GetTrackDepthList(0)


  • 全トラックの階層情報をリストで取得してdepthListに代入


count = reaper.AZ_GetTrackCountSelect(0,0)


  • 全トラックの数を取得してcountに代入

track,trackId = reaper.AZ_GetSelectedTrackFirstInfo(0)


  • すべての選択トラックの先頭トラックとトラックIDを取得してtrack/trackIdに代入


for a = 0,1 do 

  • 階層が変わって削除できていない場合を防ぐために2回ループ

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


  • トラックの数から選択先頭トラックまでをループ

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


  • 指定トラックIDのメディアの数を取得してallCountに代入


       trackList = reaper.AZ_GetTrackIdChildList(0,i)


・指定トラックIDの子のトラックを取得してtrackListに代入

・子トラックがない場合はretvalにfalseを返す。


       if allCount == 0 and retval == false then


  • もしトラックにメディアが一つもなく子トラックがない場合


          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)


  • 指定IDのトラックを取得してtrackに代入

        for e, value in pairs(depthList) do


  • 階層リストの数分ループ

           if track == depthList[e].Track then


  • もしtrackと階層配列内のtrackが一致したら

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


  • そのトラックの階層を前の状態に戻す


           end

        end

    end

end

APIの利用にはプランに加入し

専用APIをダウンロード

する必要があります。

​※SILVERは5月中の公開を予定しております

  • 削除を開始したい先頭トラックを選択

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

LUA

​ReaScript File Download 👇

​※実行するには専用APIが必要です

- Script Download -
bottom of page