-
-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
285 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
project(vst3puppet CXX) | ||
find_package(${QT_VERSION} OPTIONAL_COMPONENTS WebSockets) | ||
|
||
set(VST3_SDK_ROOT "${3RDPARTY_FOLDER}/vst3") | ||
if(NOT TARGET ${QT_PREFIX}::WebSockets) | ||
message("VST loading requires QtWebSockets.") | ||
return() | ||
endif() | ||
add_executable(ossia-score-vst3puppet vst3puppet.cpp) | ||
|
||
|
||
if(WIN32) | ||
target_sources(ossia-score-vst3puppet PRIVATE | ||
"${VST3_SDK_ROOT}/public.sdk/source/vst/hosting/module_win32.cpp" | ||
) | ||
elseif(APPLE) | ||
target_sources(ossia-score-vst3puppet PRIVATE | ||
"${VST3_SDK_ROOT}/public.sdk/source/vst/hosting/module_mac.mm" | ||
) | ||
else() | ||
target_sources(ossia-score-vst3puppet PRIVATE | ||
"${VST3_SDK_ROOT}/public.sdk/source/vst/hosting/module_linux.cpp" | ||
) | ||
endif() | ||
|
||
target_compile_definitions(ossia-score-vst3puppet PUBLIC HAS_VST3) | ||
target_link_libraries( | ||
ossia-score-vst3puppet | ||
PRIVATE | ||
${QT_PREFIX}::Core | ||
${QT_PREFIX}::Gui | ||
${QT_PREFIX}::WebSockets | ||
${CMAKE_DL_LIBS} | ||
sdk_common sdk_hosting | ||
) | ||
|
||
if(APPLE) | ||
find_library(Foundation_FK Foundation) | ||
target_link_libraries(ossia-score-vst3puppet PRIVATE | ||
${Foundation_FK} | ||
) | ||
endif() | ||
|
||
target_include_directories( | ||
ossia-score-vst3puppet | ||
PRIVATE | ||
"${SCORE_SRC}/plugins/score-plugin-media" | ||
) | ||
|
||
setup_score_common_exe_features(ossia-score-vst3puppet) | ||
|
||
set_target_properties( | ||
ossia-score-vst3puppet | ||
PROPERTIES | ||
DISABLE_PRECOMPILE_HEADERS TRUE | ||
) | ||
|
||
if(APPLE AND DEPLOYMENT_BUILD) | ||
set_target_properties( | ||
ossia-score-vst3puppet | ||
PROPERTIES | ||
MACOSX_BUNDLE TRUE | ||
MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist.in" | ||
RUNTIME_OUTPUT_DIRECTORY score.app/Contents/MacOS) | ||
install( | ||
TARGETS ossia-score-vst3puppet | ||
BUNDLE DESTINATION score.app/Contents/MacOS | ||
COMPONENT OssiaScore) | ||
elseif(WIN32) | ||
install( | ||
TARGETS ossia-score-vst3puppet | ||
RUNTIME DESTINATION . | ||
COMPONENT OssiaScore) | ||
else() | ||
install( | ||
TARGETS ossia-score-vst3puppet | ||
RUNTIME DESTINATION bin | ||
COMPONENT OssiaScore) | ||
endif() | ||
|
||
disable_qt_plugins(ossia-score-vst3puppet) | ||
enable_minimal_qt_plugins(ossia-score-vst3puppet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>English</string> | ||
<key>CFBundleExecutable</key> | ||
<string>ossia-score-vst3puppet</string> | ||
<key>CFBundleGetInfoString</key> | ||
<string>ossia-score-vst3puppet</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>ossia-score-vst3puppet</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleLongVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleName</key> | ||
<string>ossia-score-vst3puppet</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1.0</string> | ||
<key>CSResourcesFileMapped</key> | ||
<true/> | ||
<key>LSRequiresCarbon</key> | ||
<true/> | ||
<key>NSPrincipalClass</key> | ||
<string>NSApplication</string> | ||
<key>NSHighResolutionCapable</key> | ||
<true/> | ||
<key>LSUIElement</key> | ||
<string>1</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>ossia score</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.cs.allow-jit</key> | ||
<true/> | ||
<key>com.apple.security.cs.allow-unsigned-executable-memory</key> | ||
<true/> | ||
<key>com.apple.security.app-sandbox</key> | ||
<false/> | ||
<key>com.apple.security.cs.disable-library-validation</key> | ||
<true/> | ||
<key>com.apple.security.assets.music.read-write</key> | ||
<true/> | ||
<key>com.apple.security.files.downloads.read-write</key> | ||
<true/> | ||
<key>com.apple.security.device.firewire</key> | ||
<true/> | ||
<key>com.apple.security.device.microphone</key> | ||
<true/> | ||
<key>com.apple.security.device.usb</key> | ||
<true/> | ||
<key>com.apple.security.device.audio-input</key> | ||
<true/> | ||
<key>com.apple.security.device.camera</key> | ||
<true/> | ||
<key>com.apple.security.device.bluetooth</key> | ||
<true/> | ||
<key>com.apple.security.network.server</key> | ||
<true/> | ||
<key>com.apple.security.network.client</key> | ||
<true/> | ||
<key>com.apple.security.files.user-selected.read-write</key> | ||
<true/> | ||
<key>com.apple.security.files.bookmarks.app-scope</key> | ||
<true/> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
#include <public.sdk/source/vst/hosting/module.h> | ||
#include <public.sdk/source/vst/hosting/plugprovider.h> | ||
#include <public.sdk/source/vst/hosting/hostclasses.h> | ||
#include <pluginterfaces/base/funknown.h> | ||
#include <pluginterfaces/vst/ivstcomponent.h> | ||
#include <pluginterfaces/vst/ivstaudioprocessor.h> | ||
|
||
#include <QGuiApplication> | ||
#include <QJsonDocument> | ||
#include <QJsonObject> | ||
#include <QJsonArray> | ||
#include <QUrl> | ||
#include <QTimer> | ||
#include <QFile> | ||
#include <QWebSocket> | ||
#include <iostream> | ||
#include <set> | ||
#include <QWindow> | ||
using namespace Steinberg; | ||
QString load_vst(const QString& path, int id) | ||
{ | ||
try | ||
{ | ||
bool isFile = QFile(QUrl(path).toString(QUrl::PreferLocalFile)).exists(); | ||
if (!isFile) | ||
{ | ||
std::cerr << "Invalid path: " << path.toStdString() << std::endl; | ||
return {}; | ||
} | ||
|
||
std::string err; | ||
auto module = VST3::Hosting::Module::create(path.toStdString(), err); | ||
|
||
if (!module) | ||
{ | ||
std::cerr << "Failed to load VST3 " << path.toStdString() << err << std::endl; | ||
} | ||
|
||
const auto& info = module->getFactory().info(); | ||
QJsonArray arr; | ||
for(const auto& cls : module->getFactory().classInfos()) | ||
{ | ||
if (cls.category() == kVstAudioEffectClass) | ||
{ | ||
QJsonObject obj; | ||
|
||
obj["Author"] = QString::fromStdString(cls.vendor()); | ||
obj["PrettyName"] = QString::fromStdString(cls.name()); | ||
obj["Subcategories"] = QString::fromStdString(cls.subCategoriesString()); | ||
obj["Version"] = QString::fromStdString(cls.version()); | ||
obj["UID"] = QString::fromStdString(cls.ID().toString()); | ||
obj["Path"] = path; | ||
obj["Request"] = id; | ||
|
||
arr.push_back(obj); | ||
} | ||
} | ||
return QJsonDocument{arr}.toJson(); | ||
} | ||
catch (const std::runtime_error& e) | ||
{ | ||
std::cerr << e.what() << std::endl; | ||
} | ||
return {}; | ||
} | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
if (argc > 1) | ||
{ | ||
int id = 0; | ||
if(argc > 2) { | ||
id = QString(argv[2]).toInt(); | ||
} | ||
QGuiApplication app(argc, argv); | ||
QWindow w; | ||
w.setWidth(1); | ||
w.setHeight(1); | ||
w.setFlag(Qt::FramelessWindowHint); | ||
w.setFlag(Qt::X11BypassWindowManagerHint); | ||
w.show(); | ||
|
||
QWebSocket socket; | ||
|
||
bool socket_ready{}, vst_ready{}; | ||
QString json_ret; | ||
|
||
auto onReady = [&] { | ||
if(socket_ready && vst_ready) { | ||
socket.sendTextMessage(json_ret); | ||
socket.flush(); | ||
socket.close(); | ||
app.exit(json_ret.isEmpty() ? 1 : 0); | ||
} | ||
}; | ||
|
||
QTimer::singleShot(32, [&] { | ||
json_ret = load_vst(argv[1], id); | ||
std::cout << json_ret.toStdString(); | ||
vst_ready = true; | ||
onReady(); | ||
}); | ||
|
||
QObject::connect(&socket, &QWebSocket::connected, | ||
&app, [&] { | ||
socket_ready = true; | ||
onReady(); | ||
}); | ||
|
||
QObject::connect(&socket, qOverload<QAbstractSocket::SocketError>(&QWebSocket::error), &app, | ||
[&] { qDebug() << socket.errorString(); app.exit(1); }); | ||
QObject::connect(&socket, &QWebSocket::disconnected, &app, | ||
[&] { qDebug() << socket.errorString(); app.exit(1); }); | ||
|
||
QTimer::singleShot(10000, [&] { qDebug() << "timeout"; qApp->exit(1); }); | ||
|
||
socket.open(QUrl("ws://127.0.0.1:37587")); | ||
app.exec(); | ||
} | ||
return 1; | ||
} |