-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReaWwind_CreateNewItemsFromWwiseSelection.lua
More file actions
72 lines (55 loc) · 2 KB
/
Copy pathReaWwind_CreateNewItemsFromWwiseSelection.lua
File metadata and controls
72 lines (55 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
-- Import ReaWwind Module
local path = ({reaper.get_action_context()})[2]:match('^.+[\\//]')
package.path = path .. "?.lua"
local ReaWwind = require("ReaWwind")
reaper.ClearConsole()
-- Check waapi connection
if(not ReaWwind.wwise_connection_ok()) then
return
end
-- Query for wwise selected objects
ReaWwind.get_selected_objects({ "id", "category", "type", "name", "originalFilePath", "ActionType", "Target" })
-- Check query success
if(not ReaWwind.query_successful()) then
reaper.ShowConsoleMsg("Could not get selected object in Wwise\n")
return
end
-- Get selected wwise objects
local objects, num_objects = ReaWwind.get_query_returned_objects()
-- Check if any selected objects
if(num_objects < 1) then
reaper.ShowConsoleMsg("No selected object in Wwise\n")
return
end
-- Get the current cursor position
local cursor_pos = reaper.GetCursorPosition()
-- Get the selected track number
local sel_track = reaper.GetSelectedTrack(0, 0)
-- Check selected track
if(not sel_track) then
reaper.ShowConsoleMsg("No selected track in Reaper\n")
-- TODO: create a new track
return
end
-- Iterate on selected objects
for i=0, num_objects - 1 do
local selected_object = reaper.AK_AkJson_Array_Get(objects, i)
local name_str = ReaWwind.get_AkJson_Map_String(selected_object, "name")
-- Get and check if selected object has a source WAV
local original_file_path_str = ReaWwind.get_AkJson_Map_String(selected_object, "originalFilePath")
if(original_file_path_str == "") then
reaper.ShowConsoleMsg("No source file found for wwise object: " .. name_str .. "\n")
ReaWwind.print_returned_objects()
goto continue
end
-- Create item
local item_length = ReaWwind.create_media_item(sel_track, cursor_pos, name_str, original_file_path_str)
-- Shift position for next item
cursor_pos = cursor_pos + item_length
::continue::
end
-- Cleanup
reaper.AK_AkJson_ClearAll()
reaper.AK_Waapi_Disconnect()
-- Build all missing peaks
reaper.Main_OnCommand(40047, 0)