- Script Code -
dofile(reaper.AZ_GetLuaInitPath())
require("reaper_AZSTOKE_BRONZE")
require("reaper_AZSTOKE_SILVER")
require("reaper_AZSTOKE_GOLD")
p4URL = "********"
p4UserName = "********"
p4Password = "********"
p4Workspace = "********"
slackProfilePath = reaper.GetResourcePath() .. "\\AZData\\Slack"
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 GenerateSoundBank()
generatedLog = ""
if reaper.AZ_Wwise_Connect("127.0.0.1", 8080)then
generatedLog = reaper.AZ_Wwise_GenerateSoundBank({"Voice"}, {"Windows"}, {"Japanese"})
reaper.AZ_Wwise_Disconnect()
end
return generatedLog
end
function GetSlackUserData()
slackDataPath = reaper.GetResourcePath() .. "\\AZData\\Slack"
token = reaper.AZ_ReadFile(slackDataPath, "slackToken.txt")
userName = reaper.AZ_ReadFile(slackDataPath, "slackUser.txt")
if userName == "" or token == "" then
retval, obj = reaper.AZ_GetUserInputList("SlackInfo", 2, "slackトークン,通知先ユーザー", token..","..userName )
token = obj[1]
userName = obj[2]
reaper.AZ_WriteFile(slackDataPath, "slackToken.txt", token, 0)
reaper.AZ_WriteFile(slackDataPath, "slackUser.txt", userName, 0)
else
token = reaper.AZ_ReplaceSearchString(token, "\n", "")
userName = reaper.AZ_ReplaceSearchString(userName, "\n", "")
end
return token, userName
end
function SendSlackMessage(token, userName, caption, body)
slackMessage = reaper.AZ_Slack_PostDirectMessage(token, userName, caption, false)
if slackMessage ~= nil then
t0 = os.clock()
while os.clock() - t0 <= 5 do end
slackMessage = reaper.AZ_Slack_ReplayMessage(token, slackMessage["Channel"], slackMessage["TimeStamp"], body)
end
end
function main()
token, userName = GetSlackUserData()
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)
Msg("Generate Bank...")
generatedLog = GenerateSoundBank()
if #generatedLog == 0 then
body = "Success!"
else
for i, line in pairs(generatedLog) do
body = body .. line .. "\n"
end
end
Msg(body)
SendSlackMessage(token, userName, "Wwise Generate Result", body)
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 = "********"
slackProfilePath = reaper.GetResourcePath() .. "\\AZData\\Slack"
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を参照 --------
-------- ここから REAPDOCK InsertAndSetLoudnessを参照 --------
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
-------- ここまで REAPDOCK InsertAndSetLoudness を参照 --------
function GenerateSoundBank()
・Define the function to generate the SoundBank
generatedLog = ""
・Initialize the variable for the generation log
if reaper.AZ_Wwise_Connect("127.0.0.1", 8080)then
・Connect to Wwise
generatedLog = reaper.AZ_Wwise_GenerateSoundBank({"Voice"}, {"Windows"}, {"Japanese"})
・Generate the "Voice" SoundBank for the "Windows" platform and "Japanese" language, and get the log
reaper.AZ_Wwise_Disconnect()
・Disconnect from Wwise
end
return generatedLog
・Return the generation log
end
function GetSlackUserData()
・Define the function to get Slack user data
slackDataPath = reaper.GetResourcePath() .. "\\AZData\\Slack"
・Set the save path for the Slack data
token = reaper.AZ_ReadFile(slackDataPath, "slackToken.txt")
・Load the Slack token from a file
userName = reaper.AZ_ReadFile(slackDataPath, "slackUser.txt")
・Load the recipient user name from a file
if userName == "" or token == "" then
・If either is empty, prompt the user for input
retval, obj = reaper.AZ_GetUserInputList("SlackInfo", 2, "slackトークン,通知先ユーザー", token..","..userName )
token = obj[1]
userName = obj[2]
reaper.AZ_WriteFile(slackDataPath, "slackToken.txt", token, 0)
reaper.AZ_WriteFile(slackDataPath, "slackUser.txt", userName, 0)
・Save the entered info to a file
else
token = reaper.AZ_ReplaceSearchString(token, "\n", "")
userName = reaper.AZ_ReplaceSearchString(userName, "\n", "")
・Remove line breaks from the loaded info
end
return token, userName
・Return the token and user name
end
function SendSlackMessage(token, userName, caption, body)
・Define the function to send a message to Slack
slackMessage = reaper.AZ_Slack_PostDirectMessage(token, userName, caption, false)
・Send a direct message to the specified user and get the message info
if slackMessage ~= nil then
・If message info was obtained
t0 = os.clock()
while os.clock() - t0 <= 5 do end
・Wait 5 seconds (because, due to Slack's behavior, it takes time for message edits to reflect)
slackMessage = reaper.AZ_Slack_ReplayMessage(token, slackMessage["Channel"], slackMessage["TimeStamp"], body)
・Send a reply message to the retrieved message
end
end
function main()
token, userName = GetSlackUserData()
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)
Msg("Generate Bank...")
・Show the SoundBank generation start message
generatedLog = GenerateSoundBank()
・Generate the SoundBank and get the log
if #generatedLog == 0 then
body = "Success!"
・If no generation log exists, set the success message
else
for i, line in pairs(generatedLog) do
body = body .. line .. "\n"
・If a generation log exists, set its content as the message body
end
end
Msg(body)
・Show the generation result in the console
SendSlackMessage(token, userName, "Wwise Generate Result", body)
・Send the generation result to Slack
end
main()
- API LINK -
- API LINK -
Excel
AZSTOKE_Excel_GenerateAndSlack
Configure Perforce-managed audio files based on an Excel table and auto-implement them into Wwise (3)













