forked from nightonmars/FMOD-Organisation-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFindAudioFiles.js
More file actions
80 lines (69 loc) · 2.65 KB
/
FindAudioFiles.js
File metadata and controls
80 lines (69 loc) · 2.65 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
73
74
75
76
77
78
79
80
studio.menu.addMenuItem({
name: "FMOD Examples ...\\Find Duplicate Audio Files",
execute: function () {
var banks = studio.project.model.Bank.findInstances();
var audioFileMap = {};
function trackAudioFile(audioFile, bankName) {
if (!audioFile) return;
var key = audioFile.id;
if (!audioFileMap[key]) {
audioFileMap[key] = {
name: audioFile.assetPath,
banks: []
};
}
if (audioFileMap[key].banks.indexOf(bankName) === -1) {
audioFileMap[key].banks.push(bankName);
}
}
function extractAudioFromInstrument(instrument, bankName) {
if (!instrument) return;
if (instrument.audioFile) {
trackAudioFile(instrument.audioFile, bankName);
}
if (instrument.sounds) {
instrument.sounds.forEach(function (subInstrument) {
extractAudioFromInstrument(subInstrument, bankName);
});
}
if (instrument.sound) {
extractAudioFromInstrument(instrument.sound, bankName)
}
if (instrument.event) {
var subEvent = instrument.event;
if (subEvent.groupTracks) {
subEvent.groupTracks.forEach(function (track) {
if (track.modules) {
track.modules.forEach(function (mod) {
if (mod) {
extractAudioFromInstrument(mod, bankName);
}
});
}
});
}
}
}
banks.forEach(function (bank) {
var events = bank.events;
events.forEach(function (event) {
if (!event.groupTracks) return;
event.groupTracks.forEach(function (track) {
if (!track.modules) return;
track.modules.forEach(function (module) {
if (module) {
extractAudioFromInstrument(module, bank.name);
}
});
});
});
});
console.log("=== Identified Audio Files ===");
Object.keys(audioFileMap).forEach(function (key) {
var entry = audioFileMap[key];
if (entry.banks.length > 1) {
console.log("Audio File: " + entry.name + " used in banks: " + entry.banks.join(", "));
}
});
}
});