-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAxevstPlugins.cpp
More file actions
105 lines (78 loc) · 2.52 KB
/
AxevstPlugins.cpp
File metadata and controls
105 lines (78 loc) · 2.52 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// Created by vince on 9/12/25.
//
#include "AxevstPlugins.hpp"
#include "Debug/EditorConsole.hpp"
#include "bx/bx.h"
#include "imgui.h"
#include "json_impl.hpp"
#include <filesystem>
#define EC_THIS "AXE VST"
namespace Shadow::AXE {
AXEVSTPlugins::AXEVSTPlugins() {
EC_NEWCAT(EC_THIS);
reloadVSTPlugins();
}
AXEVSTPlugins::~AXEVSTPlugins() = default;
void AXEVSTPlugins::onUpdate(bool& p_open) {
using namespace ImGui;
if (!p_open) return;
if (!Begin("VST Plugins", &p_open)) {
End();
return;
}
SeparatorText("Available Plugins:");
SameLine();
if (SmallButton("re-scan")) reloadVSTPlugins();
for (auto& vst : indexedVsts) {
Selectable(vst.prettyName.c_str());
SetItemTooltip("%s - %s", vst.version.c_str(), vst.vendor.c_str());
}
End();
}
std::filesystem::path AXEVSTPlugins::getVSTStorageLocation() {
std::string path;
#ifdef BX_PLATFORM_LINUX || BX_PLATFORM_BSD
path = static_cast<std::string>(getenv("HOME")) + "/.vst3/";
#elif BX_PLATFORM_WINDOWS
path = "C:\\Program Files\\Common Files\\VST3";
#else
# error "COMPILATION ERROR: AXE DOESN'T KNOW WHERE VSTs GO ON THIS PLATFORM"
#endif
return std::filesystem::path(path);
}
void AXEVSTPlugins::reloadVSTPlugins() {
// clear existing index cache before re-filling
indexedVsts.clear();
EC_PRINT(EC_THIS, "Discovering plugins:");
for (auto& vstDir : std::filesystem::directory_iterator(getVSTStorageLocation())) {
BasicVstEntry entry;
EC_PRINT(EC_THIS, "- %s", vstDir.path().filename().c_str());
// Validate that the shared lib file exists (probably should have a more extensive check.
// e.g. loading it, grabbing plugin name)
// std::filesystem::exists(vstDir.path() / "Contents" / "");
entry.name = vstDir.path().filename().c_str();
entry.path = vstDir.path();
// Is there a moduleinfo.json we can read?
#if 0
std::filesystem::path moduleInfoPath = vstDir.path() / "Contents" / "Resources" / "moduleinfo.json";
if (std::filesystem::exists(moduleInfoPath)) {
try {
auto moduleInfoData = JSON::readJsonFile(moduleInfoPath);
entry.prettyName = moduleInfoData["Name"];
entry.version = moduleInfoData["Version"];
entry.vendor = moduleInfoData["Factory Info"]["Vendor"];
entry.url = moduleInfoData["Factory Info"]["URL"];
entry.email = moduleInfoData["Factory Info"]["E-Mail"];
} catch ([[maybe_unused]] const std::exception& e) {
entry.prettyName = entry.name;
}
} else {
entry.prettyName = entry.name;
}
#endif
indexedVsts.emplace_back(entry);
}
EC_PRINT(EC_THIS, "-----------------------------------");
}
}