-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
105 lines (84 loc) · 3.71 KB
/
index.ts
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import * as waapi from 'waapi-client';
import * as fs from 'fs-extra';
import * as walk from 'klaw-sync';
import { ak } from 'waapi';
import * as path from 'path';
if(process.argv.length != 3){
console.log(`Invalid arguments`);
process.exit();
}
var dir = process.argv[2];
async function main() {
try {
// Connect to WAAPI
// Ensure you enabled WAAPI in Wwise's User Preferences
var connection = await waapi.connect('ws://localhost:8080/waapi');
// Obtain information about Wwise
var wwiseInfo = await connection.call(ak.wwise.core.getInfo, {});
console.log(`Connected to ${wwiseInfo.displayName} ${wwiseInfo.version.displayName}`);
var options = {nodir:true,filter:(f)=>path.extname(f.path).toLowerCase() == '.wav'};
var files = walk(dir, options);
var imports = [];
var containers = new Set<string>();
files.forEach(function(f:walk.Item){
// File names are all structured the same way. They follow the convention:
// <Name>_<Type>_<Surface>_<Variation#>
// ex: Footstep_Crouching_Concrete_01
var filename = path.basename(f.path);
var basename = path.basename(f.path, '.wav');
var matches = filename.match(/^(\w+)_(\w+)_(\w+)_(\d+).wav$/i);
if(matches){
var topName = matches[1];
var typeName = matches[2];
var surfaceName = matches[3];
var rootContainer = `\\Actor-Mixer Hierarchy\\Default Work Unit\\<Switch Container>${topName}`;
var topContainer = `\\Actor-Mixer Hierarchy\\Default Work Unit\\<Switch Container>${topName}\\<Switch Container>${typeName}`;
var middleContainer = `\\Actor-Mixer Hierarchy\\Default Work Unit\\<Switch Container>${topName}\\<Switch Container>${typeName}\\<Random Container>${surfaceName}`;
if(!containers.has(rootContainer)){
containers.add(rootContainer);
// Top switch container
imports.push({
objectPath: rootContainer,
event:'FootStep@Play'
});
}
if(!containers.has(topContainer)){
containers.add(topContainer);
// Top switch container
imports.push({
switchAssignation: `<Switch Group:FootStepType>${typeName}`,
objectPath: topContainer
});
}
if(!containers.has(middleContainer)){
containers.add(middleContainer);
// Middle Switch container
imports.push({
switchAssignation: `<Switch Group:Surface>${surfaceName}`,
objectPath: middleContainer
});
}
// SFX
imports.push({
audioFile: f.path,
objectPath: `\\Actor-Mixer Hierarchy\\Default Work Unit\\<Switch Container>${topName}\\<Switch Container>${typeName}\\<Random Container>${surfaceName}\\<Sound SFX>${basename}`,
});
}
});
let importArgs = {
importOperation: "useExisting",
default: {
importLanguage: "SFX"
},
imports: imports
};
// Import!
var wwiseInfo = await connection.call(ak.wwise.core.audio.import_, importArgs);
await connection.disconnect();
}
catch (e) {
console.log(e);
}
process.exit();
}
main();