- 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 -
Excelファイルを用意する
インポートする音声ファイルを用意する
Wwiseプロジェクトを用意する
- 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)
・リージョンをレンダリングし、Wwiseにインポートする関数を定義、引数はExcelパス
path = reaper.AZ_SetProjectPathFolder("Rec", 3)
・プロジェクトフォルダ内に「Rec」フォルダを作成し、そのパスを取得
renderOptions = {
OutputDir = path,
Channels = 1,
FileName = "$region",
RenderingRangeType = 5,
}
・レンダリングオプションを設定
renderedFiles = reaper.AZ_RenderToAudioFile(0, renderOptions)
・リージョンごとに音声ファイルをレンダリングし、そのパスのリストを取得
excelDoc = reaper.AZ_Excel_OpenFile(excelPath)
・Excelファイルを開く
sheet = reaper.AZ_Excel_OpenWorksheet(excelDoc, "script")
・「script」ワークシートを開く
if reaper.AZ_Wwise_Connect("127.0.0.1", 8080)then
・Wwiseに接続
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"]
・対応する行がある場合、D~F列に記載されたWwiseパス情報を取得
sound = reaper.AZ_Wwise_CreateSoundSFX(wSoundPath, filePath, fileName, wSubFolder, true)
・Wwiseにサウンドオブジェクトを作成
reaper.AZ_Wwise_DeleteObject(wEventPath .. "\\" .. sound["Name"])
・既に同名のイベントオブジェクトが存在する場合は削除
event = reaper.AZ_Wwise_CreateEvent(wEventPath, sound["Name"], -1)
・Wwiseにイベントオブジェクトを作成
reaper.AZ_Wwise_AddActionToEvent(event["ID"], 2, sound["ID"])
・イベントにStopアクションを追加
reaper.AZ_Wwise_AddActionToEvent(event["ID"], 1, sound["ID"])
・イベントにPlayアクションを追加
Msg("SoundPath: " .. sound["Path"])
Msg("EventPath: " .. event["Path"])
Msg("")
・コンソールにWwiseパス情報を表示
end
end
end
reaper.AZ_Wwise_SaveProject()
・Wwiseプロジェクトを保存
reaper.AZ_Wwise_Disconnect()
・Wwiseから切断
end
reaper.AZ_Excel_CloseFile(excelDoc)
・Excelファイルを閉じる
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)
・リージョンをレンダリングし、Wwiseにインポートする関数を実行
end
main()
- API LINK -
Excel
AZSTOKE_Excel_ImportToWwise
Perforceで管理された音声ファイルをExcelの表を基に設定し、Wwiseに自動実装②









