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 ImportToWwise(excelPath)


    path = reaper.AZ_SetProjectPathFolder("Rec", 3)

    renderOptions = {

        OutputDir = path,

        Channels = 1,

        FileName = "$region",

        RenderingRangeType = 5,

    }


    renderedFiles = reaper.AZ_RenderToAudioFile(0, renderOptions)

    

    excelDoc = reaper.AZ_Excel_OpenFile(excelPath)

    

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

    

    if reaper.AZ_Wwise_Connect("127.0.0.1",  8080)then


        for i, filePath in pairs(renderedFiles) do

        

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


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

            

            exists = false

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

                if exists == false then

                    exists = true

                    

                    wSoundPath = row["D"]

                    wEventPath = row["E"]

                    wSubFolder = row["F"]

                    

                    

                    sound = reaper.AZ_Wwise_CreateSoundSFX(wSoundPath, filePath, fileName, wSubFolder, true)

 

                    reaper.AZ_Wwise_DeleteObject(wEventPath .. "\\" .. sound["Name"])

                    event = reaper.AZ_Wwise_CreateEvent(wEventPath, sound["Name"], -1)

                    

                    reaper.AZ_Wwise_AddActionToEvent(event["ID"], 2, sound["ID"])

                    reaper.AZ_Wwise_AddActionToEvent(event["ID"], 1, sound["ID"])

                    

                    Msg("SoundPath: " .. sound["Path"])

                    Msg("EventPath: " .. event["Path"])

                    Msg("")

                

                end

            end

        

        end

        

        reaper.AZ_Wwise_SaveProject()

        

        reaper.AZ_Wwise_Disconnect()

        

    end

    

    reaper.AZ_Excel_CloseFile(excelDoc)

    

    return


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)

    

    ImportToWwise(excelPath)

    

end


main()

- Warm Up -

  • Prepare an Excel file

  • Prepare the audio files to import

  • Prepare a Wwise project

- Script Detail -

dofile(reaper.AZ_GetLuaInitPath())

require("reaper_AZSTOKE_BRONZE")

require("reaper_AZSTOKE_SILVER") 

require("reaper_AZSTOKE_GOLD") 


--------  ここから REAPDOCK InsertAndSetLoudnessを参照 --------


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


--------  ここまで REAPDOCK InsertAndSetLoudnessを参照 --------


function ImportToWwise(excelPath)


・Define the function to render the regions and import them into Wwise; the argument is the Excel path


    path = reaper.AZ_SetProjectPathFolder("Rec", 3)


・Create a "Rec" folder in the project folder and get its path


    renderOptions = {

        OutputDir = path,

        Channels = 1,

        FileName = "$region",

        RenderingRangeType = 5,

    }


・Set the rendering options


    renderedFiles = reaper.AZ_RenderToAudioFile(0, renderOptions)


・Render an audio file per region and get the list of their paths

    

    excelDoc = reaper.AZ_Excel_OpenFile(excelPath)


・Open the Excel file

    

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


・Open the "script" worksheet

    

    if reaper.AZ_Wwise_Connect("127.0.0.1",  8080)then


・Connect to Wwise


        for i, filePath in pairs(renderedFiles) do


・Loop over all rendered audio files

        

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


・Get the audio file name


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


・Search whether the worksheet has a row corresponding to the audio file name

            

            exists = false

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

                if exists == false then

                    exists = true


・Get the first row of the search result

                    

                    wSoundPath = row["D"]

                    wEventPath = row["E"]

                    wSubFolder = row["F"]


・If there is a corresponding row, get the Wwise path info in columns D–F

                                       

                    sound = reaper.AZ_Wwise_CreateSoundSFX(wSoundPath, filePath, fileName, wSubFolder, true)


・Create a sound object in Wwise

 

                    reaper.AZ_Wwise_DeleteObject(wEventPath .. "\\" .. sound["Name"])


・If an event object with the same name already exists, delete it


                    event = reaper.AZ_Wwise_CreateEvent(wEventPath, sound["Name"], -1)


・Create an event object in Wwise

                    

                    reaper.AZ_Wwise_AddActionToEvent(event["ID"], 2, sound["ID"])


・Add a Stop action to the event


                    reaper.AZ_Wwise_AddActionToEvent(event["ID"], 1, sound["ID"])


・Add a Play action to the event

                    

                    Msg("SoundPath: " .. sound["Path"])

                    Msg("EventPath: " .. event["Path"])

                    Msg("")


・Show the Wwise path info in the console

                

                end

            end

        

        end

        

        reaper.AZ_Wwise_SaveProject()


・Save the Wwise project

        

        reaper.AZ_Wwise_Disconnect()


・Disconnect from Wwise

        

    end

    

    reaper.AZ_Excel_CloseFile(excelDoc)


・Close the Excel file

    

    return


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)

    

    ImportToWwise(excelPath)


・Run the function to render the regions and import them into Wwise

    

end


main()

- API LINK -
- API LINK -

Excel

AZSTOKE_Excel_ImportToWwise

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

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