top of page
- Script Code -

dofile(reaper.AZ_GetLuaInitPath())

require("reaper_AZSTOKE_BRONZE")

require("reaper_AZSTOKE_SILVER") 

require("reaper_AZSTOKE_GOLD") 


p4URL = "********"

p4UserName = "********"

p4Password = "********"

p4Workspace = "********"


function InsertAndSetLoudness(depotPath, excelPath)


    track, trackID = reaper.AZ_InsertTrackSearchUniqueOnly(0, "voice")

    

    trackCount = reaper.CountTrackMediaItems(track)


    endTime = reaper.AZ_GetTrackMediaEndTime(0, trackID, trackCount - 1)

    

    startPos = endTime + 3

    

    if reaper.AZ_P4_Connect(p4URL, p4UserName, p4Password)then

         

         filePathList = reaper.AZ_P4_ExportAudioToProject(p4Workspace, depotPath, "", -1, "wav")

         

         itemList = reaper.AZ_InsertMediaItems(track, filePathList, startPos, 1)

         

         reaper.AZ_P4_Disconnect()

    end

    

    reaper.AZ_SetMediaItemListHANDAUTOMER(itemList, 2)

    

    excelDoc = reaper.AZ_Excel_OpenFile(excelPath)

    

    sheet = reaper.AZ_Excel_OpenWorksheet(excelDoc, "script")

    

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

    

    for i, item in pairs(itemList) do

        itemName = reaper.AZ_GetMediaItemName(item)

        itemStartPos = reaper.AZ_GetMediaItemStartTimeSeconds(item)

        itemEndPos = reaper.AZ_GetMediaItemEndTime(item)

        

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

        

        result = reaper.AZ_Excel_SearchRowsInWorksheet(sheet, itemName, "A", "", false)

        

        exists = false

        for j, row in pairs(result["Cells"]) do

            exists = true

            

            Msg("name: " .. row["A"])

            Msg("Loudness: " .. row["C"])

            Msg("")

            

            loudness =  tonumber(row["C"])

        end

        

        if exists == true then

             reaper.AZ_SetMediaItemLoudnessMaxMomentary(item, loudness)

        

        end

    end

    

    reaper.AZ_Excel_CloseFile(excelDoc)


end


function main()


    retval, inputList = reaper.AZ_GetUserInputList("", 2, "DeptPath,ExcelPath", "")

    

    if retval == false then return end

    

    deptPath = inputList[1]

    excelPath = inputList[2]

    

    InsertAndSetLoudness(deptPath, excelPath)

    

end


main()

- Warm Up -

  • Prepare an Excel file

  • Prepare the audio files to import

- Script Detail -

dofile(reaper.AZ_GetLuaInitPath())

require("reaper_AZSTOKE_BRONZE")

require("reaper_AZSTOKE_SILVER") 

require("reaper_AZSTOKE_GOLD") 


・Import RIGDOCKS


p4URL = "********"

p4UserName = "********"

p4Password = "********"

p4Workspace = "********"


・Set the Perforce connection info


function InsertAndSetLoudness(depotPath, excelPath)


・Function definition; arguments are the depot path and the Excel path


    track, trackID = reaper.AZ_InsertTrackSearchUniqueOnly(0, "voice")


・Create a track named "voice"

    

    trackCount = reaper.CountTrackMediaItems(track)


・Get the number of media items in the "voice" track


    endTime = reaper.AZ_GetTrackMediaEndTime(0, trackID, trackCount - 1)

    

・Get the end time of the last media item


    startPos = endTime + 3

    

・Set the new insertion position to 3 seconds after the last media item's end time


    if reaper.AZ_P4_Connect(p4URL, p4UserName, p4Password)then

         

・Connect to Perforce


         filePathList = reaper.AZ_P4_ExportAudioToProject(p4Workspace, depotPath, "", -1, "wav")


・Export all audio files under the depot path to the project and get the list of paths

         

         itemList = reaper.AZ_InsertMediaItems(track, filePathList, startPos, 1)


・Insert the audio files into the "voice" track and get the list of media items

         

         reaper.AZ_P4_Disconnect()


・Disconnect from Perforce


    end

    

    reaper.AZ_SetMediaItemListHANDAUTOMER(itemList, 2)


・Run HANDAUTOMER on all inserted media items

    

    excelDoc = reaper.AZ_Excel_OpenFile(excelPath)


・Open the Excel file

    

    sheet = reaper.AZ_Excel_OpenWorksheet(excelDoc, "script")


・Open the "script" worksheet

    

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


・Get a random color

    

    for i, item in pairs(itemList) do


・Loop over all inserted media items


        itemName = reaper.AZ_GetMediaItemName(item)


・Get the media item name


        itemStartPos = reaper.AZ_GetMediaItemStartTimeSeconds(item)

        itemEndPos = reaper.AZ_GetMediaItemEndTime(item)

        

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


・Add a region over the media item's range

        

        result = reaper.AZ_Excel_SearchRowsInWorksheet(sheet, itemName, "A", "", false)


・Search whether the worksheet has a row corresponding to the media item name

        

        exists = false

        for j, row in pairs(result["Cells"]) do


・Get the first row of the search result


            exists = true

            

            Msg("name: " .. row["A"])

            Msg("Loudness: " .. row["C"])

            Msg("")


・Show the media item name and loudness value in the console

            

            loudness =  tonumber(row["C"])


・If there is a corresponding row, get the loudness value in column C


        end

        

        if exists == true then

             reaper.AZ_SetMediaItemLoudnessMaxMomentary(item, loudness)


・Only if a loudness value was obtained, set the media item's loudness to that value

        

        end

    end

    

    reaper.AZ_Excel_CloseFile(excelDoc)


・Close the Excel file


end


function main()


・Define the main function


    retval, inputList = reaper.AZ_GetUserInputList("", 2, "DeptPath,ExcelPath", "")


・Prompt for the required input

    

    if retval == false then return end


・If canceled, abort the process

    

    deptPath = inputList[1]

    excelPath = inputList[2]


・Get the depot path and Excel path from the input values

    

    InsertAndSetLoudness(deptPath, excelPath)


・Run the function

    

end


main()


・Run the main function

- API LINK -
- API LINK -

Excel

AZSTOKE_Excel_InsertAndSetLoudness

Configure Perforce-managed audio files based on an Excel table and auto-implement them into Wwise (1)

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