top of page
- Script Code -

dofile(reaper.AZ_GetLuaInitPath()) 

require("reaper_AZSTOKE_SILVER") 

require("reaper_AZSTOKE_GOLD") 


containerParentPath = "\\Actor-Mixer Hierarchy\\Default Work Unit"

bankParentPath = "\\SoundBanks\\Default Work Unit"

eventParentPath = "\\Events\\Default Work Unit"


--render setting

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

render = {

    OutputDir = path,

    Channels = 1,

    FileName = "$region",

    RenderingRangeType = 5,

    SamplingRate = 48000,

}

   

--render

fileList = reaper.AZ_RenderToAudioFile(0, render)


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


   -- Create RandomContainer

   container = reaper.AZ_Wwise_CreateContainer(containerParentPath, reaper.AZ_Wwise_ContainerType_Random() ,"AZ_se_exp", true)


   reaper.AZ_Wwise_SetProperty(container["ID"], "RandomAvoidRepeating", true)

   reaper.AZ_Wwise_SetProperty(container["ID"], "NormalOrShuffle", 0)


   if #fileList >= 4 then

       reaper.AZ_Wwise_SetProperty(container["ID"], "RandomAvoidRepeatingCount", #fileList - 1)

   else

       reaper.AZ_Wwise_SetProperty(container["ID"], "RandomAvoidRepeatingCount", 1)

   end


   -- Set Random

   reaper.AZ_Wwise_SetRandomizer(container["ID"], "Volume", true, -2.5, 1.5)

   reaper.AZ_Wwise_SetRandomizer(container["ID"], "Pitch", true, -0.4, 0.6)

   reaper.AZ_Wwise_SetRandomizer(container["ID"], "Highpass", true, 0, 20)

   reaper.AZ_Wwise_SetRandomizer(container["ID"], "Lowpass", true, 0, 20)


   for i, filePath in pairs(fileList) do

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

       sound = reaper.AZ_Wwise_CreateSoundSFX(container["ID"], filePath, fileName, "AZ_se", true)

   end


   -- Clear Soundbank

   soundBank = reaper.AZ_Wwise_CreateObject(bankParentPath, "AZ_Bank", "SoundBank", true)

   

   reaper.AZ_Wwise_RemoveObjectFromSoundBank(soundBank["ID"], eventParentPath .. "\\" .. container["Name"])

   

   

   -- Create Event

   reaper.AZ_Wwise_DeleteObject(eventParentPath .. "\\" .. container["Name"])


   event = reaper.AZ_Wwise_CreateEvent(eventParentPath, container["Name"], 0)

   

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


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


   

   -- Set Soundbank

   reaper.AZ_Wwise_AddObjectToSoundBank(soundBank["ID"], event["Path"])


   reaper.AZ_Wwise_SaveProject()

   

   reaper.AZ_Wwise_Disconnect()

end

- Warm Up -

  1. 書き出ししたいファイルをReaperプロジェクト内に並べておく

- Script Detail -

dofile(reaper.AZ_GetLuaInitPath()) 

require("reaper_AZSTOKE_SILVER") 

require("reaper_AZSTOKE_GOLD") 


containerParentPath = "\\Actor-Mixer Hierarchy\\Default Work Unit"

bankParentPath = "\\SoundBanks\\Default Work Unit"

eventParentPath = "\\Events\\Default Work Unit"


・Wwise上でオブジェクトを作成するパスを指定


--render setting

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


・プロジェクトファイルに書き出し先のフォルダを設定


render = {

    OutputDir = path,

    Channels = 1,

    FileName = "$region",

    RenderingRangeType = 5,

    SamplingRate = 48000,

}


・レンダリングの設定を行う

   

--render

fileList = reaper.AZ_RenderToAudioFile(0, render)


・レンダリングを実行してパス情報を取得


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


・Wwiseへ接続


   container = reaper.AZ_Wwise_CreateContainer(containerParentPath, reaper.AZ_Wwise_ContainerType_Random() ,"AZ_se_exp", true)


・AZ_se_expのランダムコンテナを生成


   reaper.AZ_Wwise_SetProperty(container["ID"], "RandomAvoidRepeating", true)


・ランダムコンテナの「Avoid Repeating last」を有効化する


   reaper.AZ_Wwise_SetProperty(container["ID"], "NormalOrShuffle", 0)


・ランダムコンテナの「Play Type」を「Shuffle」にする


   if #fileList >= 4 then

       reaper.AZ_Wwise_SetProperty(container["ID"], "RandomAvoidRepeatingCount", #fileList - 1)

   else

       reaper.AZ_Wwise_SetProperty(container["ID"], "RandomAvoidRepeatingCount", 1)

   end


・ランダムコンテナの「Avoid Repeating last」の値を設定する

 挿入する音声の数が4以上の場合は{音声数 - 1}の値にする。

 音声の数が3以下の場合は1にする


   reaper.AZ_Wwise_SetRandomizer(container["ID"], "Volume", true, -2.5, 1.5)

   reaper.AZ_Wwise_SetRandomizer(container["ID"], "Pitch", true, -0.4, 0.6)

   reaper.AZ_Wwise_SetRandomizer(container["ID"], "Highpass", true, 0, 20)

   reaper.AZ_Wwise_SetRandomizer(container["ID"], "Lowpass", true, 0, 20)


・ランダムコンテナの「Volume」、「Pitch」、「High-pass filter」、「Low-pass filter」にランダム量を設定する


   for i, filePath in pairs(fileList) do


・Reaperで書き出したファイルごとに実行


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


・ファイル名を取得


       sound = reaper.AZ_Wwise_CreateSoundSFX(container["ID"], filePath, fileName, "AZ_se", true)


・ファイル名と同名のサウンドSFXオブジェクトを作成


   end


   soundBank = reaper.AZ_Wwise_CreateObject(bankParentPath, "AZ_Bank", "SoundBank", true)


・[AZ_Bank]のバンクを生成

   

   reaper.AZ_Wwise_RemoveObjectFromSoundBank(soundBank["ID"], eventParentPath .. "\\" .. container["Name"])


・これから作成するイベントと同名のイベントをサウンドバンクから削除しておく


   reaper.AZ_Wwise_DeleteObject(eventParentPath .. "\\" .. container["Name"])


・同名のイベントがあれば削除する


   event = reaper.AZ_Wwise_CreateEvent(eventParentPath, container["Name"], 0)

   

・ワークユニットの以下にEventを生成する

   

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


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


・追加したイベントにランダムコンテナのStopアクションとPlayアクションを追加

   

   parentPath = "\\SoundBanks\\Default Work Unit"


   reaper.AZ_Wwise_AddObjectToSoundBank(soundBank["ID"], event["Path"])


・バンクにイベントの親ワークユニットを追加


   reaper.AZ_Wwise_SaveProject()

   

・プロジェクトを保存

   

   reaper.AZ_Wwise_Disconnect()

   

・Wwiseから切断


end


- API LINK -

Wwise

AZSTOKE_Wwise_RandomContainer_RandomValue_1

ランダムコンテナの作成とランダム値の設定の自動化

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