top of page
- Script Code -

dofile(reaper.AZ_GetLuaInitPath())

require("reaper_AZSTOKE_BRONZE")

require("reaper_AZSTOKE_SILVER") 


function main()

    retval, imputList = reaper.AZ_GetUserInputList("",  1, "import path", "")

    

    if(retval == false) then

        return

    end


    importPath = imputList[1]

    

    filePathList = reaper.AZ_GetFilePathList(importPath, "wav")

    

    table.sort(filePathList)

    

    insertPos = 0

    preCharID = ""

    

    color, _, _, _ = reaper.AZ_GetRandomColor()


    reaper.AZ_DeleteAllRegion(0)

    

    for i, filePath in pairs(filePathList) do

    

        fileName = reaper.AZ_GetPathInfo(filePath)["FileNameWithoutExtension"]

        

        splitList =reaper.AZ_GetStringSplitList(fileName, "_")

        

        charID = splitList[1]

        voiceType = splitList[2]

        

        charTrack = reaper.AZ_InsertTrackSearchUniqueOnly(0, charID)

        

        reaper.AZ_SetTrackItemDepth(charTrack, 0)

        

        typeTrack = reaper.AZ_InsertUniqueChildTrack(charTrack, splitList[2])

        

           

        if preCharID ~= "" and  preCharID ~= charID then

            insertPos = insertPos + 2

            color, _, _, _ = reaper.AZ_GetRandomColor()

        end

        

        item = reaper.AZ_InsertMediaTrackItemSecond(typeTrack, filePath, 0, insertPos)

        

        

        itemStartPos = reaper.AZ_GetMediaItemStartTimeSeconds(item)

        itemEndPos = reaper.AZ_GetMediaItemEndTime(item)

        

        reaper.AZ_AddRegionMarker(0, itemStartPos, itemEndPos, fileName, -1, color)

        

        insertPos = itemEndPos + 1

        

        preCharID = charID

    

    end

 

end


main()

- Warm Up -

- Script Detail -

dofile(reaper.AZ_GetLuaInitPath())

require("reaper_AZSTOKE_BRONZE")

require("reaper_AZSTOKE_SILVER") 


・Import RIGDOCKS


function main()


・Define the function that contains the main process


    retval, imputList = reaper.AZ_GetUserInputList("",  1, "import path", "")


・Show an empty input dialog and get the path of the folder to import

    

    if(retval == false) then

        return

    end


・If the dialog is canceled, end the process


    importPath = imputList[1]


・Store the import folder path in a variable

    

    filePathList = reaper.AZ_GetFilePathList(importPath, "wav")

    

・Get the paths of the wav files in the specified folder


    table.sort(filePathList)


・Sort the list of file paths


    insertPos = 0

    preCharID = ""


・Initialize the item insertion position and the previous character ID


    color, _, _, _ = reaper.AZ_GetRandomColor()


・Get a random color


    reaper.AZ_DeleteAllRegion(0)


・Delete all regions in the project


    for i, filePath in pairs(filePathList) do

    

・Run for each retrieved file path


        fileName = reaper.AZ_GetPathInfo(filePath)["FileNameWithoutExtension"]


・Get the file name


        splitList =reaper.AZ_GetStringSplitList(fileName, "_")


・Split the file name by "_" into a list

 

        charID = splitList[1]

        voiceType = splitList[2]


・Get the character ID and voice type from the file name

        

        charTrack = reaper.AZ_InsertTrackSearchUniqueOnly(0, charID)


・Create a track named after the character ID (if it already exists, just get it)

        

        reaper.AZ_SetTrackItemDepth(charTrack, 0)


・Set the character track's depth to 0 (make it top-level)

        

        typeTrack = reaper.AZ_InsertUniqueChildTrack(charTrack, splitList[2])


・Create a child track named after the voice type (if it already exists, just get it)

           

        if preCharID ~= "" and  preCharID ~= charID then

            insertPos = insertPos + 2

            color, _, _, _ = reaper.AZ_GetRandomColor()

        end

        

・If the character ID differs from the previous one, advance the insertion position by 2 seconds and change the color


        item = reaper.AZ_InsertMediaTrackItemSecond(typeTrack, filePath, 0, insertPos)


・Insert an item into the specified track

        

        itemStartPos = reaper.AZ_GetMediaItemStartTimeSeconds(item)

        itemEndPos = reaper.AZ_GetMediaItemEndTime(item)

        

・Get the start and end positions of the inserted item


        reaper.AZ_AddRegionMarker(0, itemStartPos, itemEndPos, fileName, -1, color)


・Add a region at the item position

        

        insertPos = itemEndPos + 1


・Advance the next item's insertion position by 1 second

        

        preCharID = charID


・Update the previous character ID

    

    end

 

end


main()


・Run the main process

- API LINK -
- API LINK -

Track

AZSTOKE_InsertTrackMediasFromFileName

Insert tracks taking file names into account

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