- Script Code -
dofile(reaper.AZ_GetLuaInitPath())
require("reaper_AZSTOKE_BRONZE")
require("reaper_AZSTOKE_SILVER")
require("reaper_AZSTOKE_GOLD")
function Main()
retval, inputList = reaper.AZ_GetUserInputList("Character Info", 1, "Character Name", "")
if retval == false then
return
end
characterName = inputList[1]
reaper.AZ_DeleteAllRegion(0)
itemList = reaper.AZ_GetSelectedMediaItemList(0)
color = reaper.AZ_GetRandomColor()
--Region setting
for i, item in pairs(itemList) do
startPos = reaper.AZ_GetMediaItemStartTimeSeconds(item)
endPos = reaper.AZ_GetMediaItemEndTime(item)
name = reaper.AZ_GetMediaItemName(item)
reaper.AZ_AddRegionMarker(0, startPos, endPos, name, 0, color)
end
--render setting
path = reaper.AZ_SetProjectPathFolder("Rec", 3)
render = {
OutputDir = path,
Channels = 1,
FileName = "$region",
RenderingRangeType = 5,
}
--render
fileList = reaper.AZ_RenderToAudioFile(0, render)
-- Wwise
if reaper.AZ_Wwise_Connect("127.0.0.1", 8080) == false then return end
-- Acter-Mixer Hierarchy
rootPath = "\\Actor-Mixer Hierarchy\\Default Work Unit"
characterPath = rootPath .. "\\Characters"
workunit = reaper.AZ_Wwise_CreateWorkUnit(characterPath, characterName, true)
templetePath = rootPath .. "\\Templates\\AZ_vo_tmp"
mixer = reaper.AZ_Wwise_CopyObject(templetePath, workunit["Path"], characterName, true)
-- Events
rootPath = "\\Events\\Default Work Unit"
characterPath = rootPath .. "\\Characters"
workunit = reaper.AZ_Wwise_CreateWorkUnit(characterPath, characterName, true)
templetePath = rootPath .. "\\Templates\\AZ_vo_tmp"
eventFolder = reaper.AZ_Wwise_CopyObject(templetePath, workunit["Path"], characterName, true)
for i, filePath in pairs(fileList) do
fileName = reaper.AZ_GetPathInfo(filePath)["FileNameWithoutExtension"]
voiceType = string.sub(fileName, 1, 3)
type_MixerPath = ""
type_EventFolderPath = ""
if voiceType == "ACT" then
type_MixerPath = mixer["Path"] .. "\\action"
type_EventFolderPath = eventFolder["Path"] .. "\\battle"
elseif voiceType == "DMG" then
type_MixerPath = mixer["Path"] .. "\\damage"
type_EventFolderPath = eventFolder["Path"] .. "\\battle"
else
type_MixerPath = mixer["Path"] .. "\\event"
type_EventFolderPath = eventFolder["Path"] .. "\\senario"
end
sound = reaper.AZ_Wwise_CreateSoundSFX(type_MixerPath, filePath, fileName, characterName, true)
reaper.AZ_Wwise_DeleteObject(type_EventFolderPath .. "\\" .. sound["Name"])
event = reaper.AZ_Wwise_CreateEvent(type_EventFolderPath, sound["Name"], -1)
reaper.AZ_Wwise_AddActionToEvent(event["ID"], 2, sound["ID"])
reaper.AZ_Wwise_AddActionToEvent(event["ID"], 1, sound["ID"])
end
reaper.AZ_Wwise_SaveProject()
reaper.AZ_Wwise_Disconnect()
reaper.AZ_ShowMessageBox_Info("Success!", "", reaper.AZ_WindowType_OK())
return
end
Main()
- Warm Up -
書き出ししたいファイルをReaperプロジェクト内に並べておく
- Script Detail -
require("reaper_AZSTOKE_BRONZE")
require("reaper_AZSTOKE_SILVER")
require("reaper_AZSTOKE_GOLD")
・RIGDOCKSをインポート
function Main()
・メインの処理を記載する関数を定義
retval, inputList = reaper.AZ_GetUserInputList("Character Info", 1, "Character Name", "")
・ユーザー空の入力ダイアログを表示して、キャラクター名を取得
if retval == false then
return
end
・ダイアログがキャンセルされた場合は処理を終了する
characterName = inputList[1]
・キャラクター名を変数に格納
reaper.AZ_DeleteAllRegion(0)
・プロジェクト内のリージョンを全て削除
itemList = reaper.AZ_GetSelectedMediaItemList(0)
・選択されているアイテムを取得
color = reaper.AZ_GetRandomColor()
・ランダムな色を取得
--Region setting
for i, item in pairs(itemList) do
・選択されているアイテムごとに実行
startPos = reaper.AZ_GetMediaItemStartTimeSeconds(item)
endPos = reaper.AZ_GetMediaItemEndTime(item)
name = reaper.AZ_GetMediaItemName(item)
reaper.AZ_AddRegionMarker(0, startPos, endPos, name, 0, color)
・アイテムの位置にリージョンを追加
end
--render setting
path = reaper.AZ_SetProjectPathFolder("Rec", 3)
・プロジェクトファイルに書き出し先のフォルダを設定
render = {
OutputDir = path,
Channels = 1,
FileName = "$region",
RenderingRangeType = 5,
}
・レンダリングの設定を作成
--render
fileList = reaper.AZ_RenderToAudioFile(0, render)
・レンダリングを実行してパス情報を取得
-- Wwise
if reaper.AZ_Wwise_Connect("127.0.0.1", 8080) == false then return end
・Wwiseへ接続 失敗時は処理を終了する
-- Acter-Mixer Hierarchy
rootPath = "\\Actor-Mixer Hierarchy\\Default Work Unit"
・Wwise上のActor-Mixer Hierarchyのパスを指定
characterPath = rootPath .. "\\Characters"
・キャラクター用のフォルダのパスを指定
workunit = reaper.AZ_Wwise_CreateWorkUnit(characterPath, characterName, true)
・キャラクター名のワークユニットを生成
templetePath = rootPath .. "\\Templates\\AZ_vo_tmp"
・テンプレートのパスを指定
mixer = reaper.AZ_Wwise_CopyObject(templetePath, workunit["Path"], characterName, true)
・テンプレートをコピーしてキャラクター名のActor-Mixer Hierarchyを生成
-- Events
rootPath = "\\Events\\Default Work Unit"
・Wwise上のEventsのパスを指定
characterPath = rootPath .. "\\Characters"
・キャラクター用のフォルダのパスを指定
workunit = reaper.AZ_Wwise_CreateWorkUnit(characterPath, characterName, true)
・キャラクター名のワークユニットを生成
templetePath = rootPath .. "\\Templates\\AZ_vo_tmp"
・テンプレートのパスを指定
eventFolder = reaper.AZ_Wwise_CopyObject(templetePath, workunit["Path"], characterName, true)
・テンプレートをコピーしてキャラクター名のフォルダを生成
for i, filePath in pairs(fileList) do
・Reaperで書き出したファイルごとに実行
fileName = reaper.AZ_GetPathInfo(filePath)["FileNameWithoutExtension"]
・ファイル名を取得
voiceType = string.sub(fileName, 1, 3)
・ファイル名の先頭3文字を取得して、ボイスの種類を判別する
type_MixerPath = ""
type_EventFolderPath = ""
if voiceType == "ACT" then
type_MixerPath = mixer["Path"] .. "\\action"
type_EventFolderPath = eventFolder["Path"] .. "\\battle"
・アクションボイスの場合、アクションボイス用のパスを指定
elseif voiceType == "DMG" then
type_MixerPath = mixer["Path"] .. "\\damage"
type_EventFolderPath = eventFolder["Path"] .. "\\battle"
・ダメージボイスの場合、ダメージボイス用のパスを指定
else
type_MixerPath = mixer["Path"] .. "\\event"
type_EventFolderPath = eventFolder["Path"] .. "\\senario"
・それ以外のボイスの場合、イベント用ボイス用のパスを指定
end
sound = reaper.AZ_Wwise_CreateSoundSFX(type_MixerPath, filePath, fileName, characterName, true)
・ファイル名と同名のサウンドSFXオブジェクトを指定のパスに作成
reaper.AZ_Wwise_DeleteObject(type_EventFolderPath .. "\\" .. sound["Name"])
event = reaper.AZ_Wwise_CreateEvent(type_EventFolderPath, sound["Name"], -1)
・同名のイベントがあれば削除してから、サウンドSFXと同名のイベントを指定のパスに生成
reaper.AZ_Wwise_AddActionToEvent(event["ID"], 2, sound["ID"])
reaper.AZ_Wwise_AddActionToEvent(event["ID"], 1, sound["ID"])
・追加したイベントにサウンドSFXのStopアクションとPlayアクションを追加
end
reaper.AZ_Wwise_SaveProject()
・プロジェクトを保存
reaper.AZ_Wwise_Disconnect()
・Wwiseから切断
reaper.AZ_ShowMessageBox_Info("Success!", "", reaper.AZ_WindowType_OK())
・完了のメッセージを表示
return
・関数を終了
end
Main()
・Main関数を実行
- API LINK -
Wwise
AZSTOKE_Wwise_CreateFromTemplete_1
オブジェクトの構成をテンプレートから作成


