- 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 -
Arrange the files you want to export within the Reaper project
- 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"
・Specify the path where the object is created in Wwise
--render setting
path = reaper.AZ_SetProjectPathFolder("Rec", 3)
・Set the export destination folder in the project file
render = {
OutputDir = path,
Channels = 1,
FileName = "$region",
RenderingRangeType = 5,
SamplingRate = 48000,
}
・Configure the render settings
--render
fileList = reaper.AZ_RenderToAudioFile(0, render)
・Run rendering and get the path info
if reaper.AZ_Wwise_Connect("127.0.0.1", 8080) then
・Connect to Wwise
container = reaper.AZ_Wwise_CreateContainer(containerParentPath, reaper.AZ_Wwise_ContainerType_Random() ,"AZ_se_exp", true)
・Generate the AZ_se_exp Random Container
reaper.AZ_Wwise_SetProperty(container["ID"], "RandomAvoidRepeating", true)
・Enable the Random Container's "Avoid Repeating last"
reaper.AZ_Wwise_SetProperty(container["ID"], "NormalOrShuffle", 0)
・Set the Random Container's "Play Type" to "Shuffle"
if #fileList >= 4 then
reaper.AZ_Wwise_SetProperty(container["ID"], "RandomAvoidRepeatingCount", #fileList - 1)
else
reaper.AZ_Wwise_SetProperty(container["ID"], "RandomAvoidRepeatingCount", 1)
end
・Set the value of the Random Container's "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)
・Set a random amount on the Random Container's "Volume", "Pitch", "High-pass filter", and "Low-pass filter"
for i, filePath in pairs(fileList) do
・Run for each file exported from Reaper
fileName = reaper.AZ_GetPathInfo(filePath)["FileNameWithoutExtension"]
・Get the file name
sound = reaper.AZ_Wwise_CreateSoundSFX(container["ID"], filePath, fileName, "AZ_se", true)
・Create a Sound SFX object with the same name as the file
end
soundBank = reaper.AZ_Wwise_CreateObject(bankParentPath, "AZ_Bank", "SoundBank", true)
・Generate the [AZ_Bank] bank
reaper.AZ_Wwise_RemoveObjectFromSoundBank(soundBank["ID"], eventParentPath .. "\\" .. container["Name"])
・Remove any event with the same name as the event about to be created from the SoundBank
reaper.AZ_Wwise_DeleteObject(eventParentPath .. "\\" .. container["Name"])
・Delete an event with the same name if it exists
event = reaper.AZ_Wwise_CreateEvent(eventParentPath, container["Name"], 0)
・Generate an Event under the work unit
reaper.AZ_Wwise_AddActionToEvent(event["ID"], 2, container["ID"])
reaper.AZ_Wwise_AddActionToEvent(event["ID"], 1, container["ID"])
・Add the Random Container's Stop and Play actions to the added event
parentPath = "\\SoundBanks\\Default Work Unit"
reaper.AZ_Wwise_AddObjectToSoundBank(soundBank["ID"], event["Path"])
・Add the event's parent work unit to the bank
reaper.AZ_Wwise_SaveProject()
・Save the project
reaper.AZ_Wwise_Disconnect()
・Disconnect from Wwise
end
- API LINK -
- API LINK -
Wwise
AZSTOKE_Wwise_RandomContainer_RandomValue_1
Automate creating Random Containers and setting random values















