From 62a9948b9d4dfbf0a8bf45d81100988cd1912d7d Mon Sep 17 00:00:00 2001 From: Cephas Reis Date: Wed, 18 Jan 2017 23:30:54 -0600 Subject: [PATCH 1/7] obs-vst/CMakeLists.txt: Add proper capitalization for "Steinburg" and changed "built-in" text to "bundled" to be more accurate --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 621587447..0f0deaf07 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,13 +7,13 @@ find_package(Qt5Widgets REQUIRED) option(VST_USE_BUNDLED_HEADERS "Build with Bundled Headers" ON) if(VST_USE_BUNDLED_HEADERS) - message(STATUS "Using the built-in VST header.") + message(STATUS "Using the bundled VST header.") include_directories(vst_header) set(vst_HEADER vst_header/aeffectx.h) else() set(VST_INCLUDE_DIR "" CACHE PATH "Path to Steinburg headers (e.g. C:/VST3 SDK/pluginterfaces/vst2.x)") - message(WARNING "You should only use the steinburg headers for debugging or local builds. It is illegal to distribute the steinburg headers with anything, and possibly against the GPL to distribute the binaries from the resultant compile.") + message(WARNING "You should only use the Steinburg headers for debugging or local builds. It is illegal to distribute the Steinburg headers with anything, and possibly against the GPL to distribute the binaries from the resultant compile.") include_directories(${VST_INCLUDE_DIR}) set(vst_HEADER ${VST_INCLUDE_DIR}/aeffectx.h) From 5017091b2a657ff4acf531ee067c07f099cbf579 Mon Sep 17 00:00:00 2001 From: Cephas Reis Date: Wed, 18 Jan 2017 23:32:22 -0600 Subject: [PATCH 2/7] VSTPlugin.h: Add VST_MAX_CHANNEL macro for ease in testing. Change "NULL" for "nullptr" on VS2015 recommendation. --- headers/VSTPlugin.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/headers/VSTPlugin.h b/headers/VSTPlugin.h index 4849d226b..661777c1f 100644 --- a/headers/VSTPlugin.h +++ b/headers/VSTPlugin.h @@ -1,6 +1,8 @@ #ifndef OBS_STUDIO_VSTPLUGIN_H #define OBS_STUDIO_VSTPLUGIN_H +#define VST_MAX_CHANNELS 8 + #include #include "aeffectx.h" #include @@ -14,14 +16,14 @@ class EditorWidget; class VSTPlugin { - AEffect *effect = NULL; + AEffect *effect = nullptr; obs_source_t *sourceContext; std::string pluginPath; float **inputs; float **outputs; - EditorWidget *editorWidget = NULL; + EditorWidget *editorWidget = nullptr; AEffect* loadEffect(); @@ -30,7 +32,7 @@ class VSTPlugin { #ifdef __APPLE__ CFBundleRef bundle = NULL; #elif WIN32 - HINSTANCE dllHandle = NULL; + HINSTANCE dllHandle = nullptr; #endif void unloadLibrary(); From 6aacd3bc743871e75ec9dd9c3c678e7f27ff1491 Mon Sep 17 00:00:00 2001 From: Cephas Reis Date: Wed, 18 Jan 2017 23:34:35 -0600 Subject: [PATCH 3/7] VSTPlugin.cpp: Change "NULL" for "nullptr" on VS2015 recommendation. Use VST_MAX_CHANNEL macro for ease in testing. Change audio data array creation to use VST_MAX_CHANNEL number. --- VSTPlugin.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/VSTPlugin.cpp b/VSTPlugin.cpp index 0ef27d5ea..5af1c62bf 100644 --- a/VSTPlugin.cpp +++ b/VSTPlugin.cpp @@ -1,7 +1,7 @@ #include "headers/VSTPlugin.h" VSTPlugin::VSTPlugin(obs_source_t *sourceContext) : sourceContext{sourceContext} { - int numChannels = 8; + int numChannels = VST_MAX_CHANNELS; int blocksize = 512; inputs = (float **) malloc(sizeof(float **) * numChannels); @@ -27,21 +27,21 @@ void VSTPlugin::loadEffectFromPath(std::string path) { return; } - // Check plugin's magic number + // Check plug-in's magic number // If incorrect, then the file either was not loaded properly, is not a - // real VST plugin, or is otherwise corrupt. + // real VST plug-in, or is otherwise corrupt. if (effect->magic != kEffectMagic) { - blog(LOG_WARNING, "VST Plugin's magic number is bad"); + blog(LOG_WARNING, "VST Plug-in's magic number is bad"); return; } - effect->dispatcher(effect, effOpen, 0, 0, NULL, 0.0f); + effect->dispatcher(effect, effOpen, 0, 0, nullptr, 0.0f); // Set some default properties size_t sampleRate = audio_output_get_sample_rate(obs_get_audio()); - effect->dispatcher(effect, effSetSampleRate, 0, 0, NULL, sampleRate); + effect->dispatcher(effect, effSetSampleRate, 0, 0, nullptr, sampleRate); int blocksize = 512; - effect->dispatcher(effect, effSetBlockSize, 0, blocksize, NULL, 0.0f); + effect->dispatcher(effect, effSetBlockSize, 0, blocksize, nullptr, 0.0f); effect->dispatcher(effect, effMainsChanged, 0, 1, 0, 0); @@ -59,16 +59,16 @@ void silenceChannel(float **channelData, int numChannels, long numFrames) { obs_audio_data *VSTPlugin::process(struct obs_audio_data *audio) { if (effect && effectReady) { - silenceChannel(outputs, 8, audio->frames); + silenceChannel(outputs, VST_MAX_CHANNELS, audio->frames); - float *adata[8] = {(float *) audio->data[0], (float *) audio->data[1], - (float *) audio->data[2], (float *) audio->data[3], - (float *) audio->data[4], (float *) audio->data[5], - (float *) audio->data[6], (float *) audio->data[7]}; + float *adata[VST_MAX_CHANNELS]; + for (size_t d = 0; d < VST_MAX_CHANNELS; d++) { + adata[d] = (float *) audio->data[d]; + }; effect->processReplacing(effect, adata, outputs, audio->frames); - for (size_t c = 0; c < 8; c++) { + for (size_t c = 0; c < VST_MAX_CHANNELS; c++) { if (audio->data[c]) { for (size_t i = 0; i < audio->frames; i++) { adata[c][i] = outputs[c][i]; @@ -84,18 +84,18 @@ void VSTPlugin::unloadEffect() { effectReady = false; if (effect) { - effect->dispatcher(effect, effMainsChanged, 0, 0, 0, 0); - effect->dispatcher(effect, effClose, 0, 0, NULL, 0.0f); + effect->dispatcher(effect, effMainsChanged, 0, 0, nullptr, 0); + effect->dispatcher(effect, effClose, 0, 0, nullptr, 0.0f); } - effect = NULL; + effect = nullptr; unloadLibrary(); } void VSTPlugin::openEditor() { if (effect && !editorWidget) { - editorWidget = new EditorWidget(0, this); + editorWidget = new EditorWidget(nullptr, this); editorWidget->buildEffectContainer(effect); @@ -105,7 +105,7 @@ void VSTPlugin::openEditor() { void VSTPlugin::closeEditor() { if (effect) { - effect->dispatcher(effect, effEditClose, 0, 0, 0, 0); + effect->dispatcher(effect, effEditClose, 0, 0, nullptr, 0); } if (editorWidget) { editorWidget->close(); @@ -151,7 +151,7 @@ std::string VSTPlugin::getChunk() { return ""; } if (effect->flags & effFlagsProgramChunks) { - void *buf = NULL; + void *buf = nullptr; intptr_t chunkSize = effect->dispatcher(effect, effGetChunk, 1, 0, &buf, 0.0); @@ -179,7 +179,7 @@ void VSTPlugin::setChunk(std::string data) { QByteArray base64Data = QByteArray(data.c_str(), data.length()); QByteArray chunkData = QByteArray::fromBase64(base64Data); - void *buf = NULL; + void *buf = nullptr; buf = chunkData.data(); effect->dispatcher(effect, effSetChunk, 0, chunkData.length(), buf, 0); From d3bd82c369059e74667ad9e34a8b08f7fddeb3f2 Mon Sep 17 00:00:00 2001 From: Cephas Reis Date: Wed, 18 Jan 2017 23:35:55 -0600 Subject: [PATCH 4/7] obs-vst.cpp: ALL: Add Blank entry at start to avoid github issue #14 "Potential Crash on Start up". LINUX: Add Linux extension for VST Plug-ins ('.so') LINUX: Add various directories to search for VSTs. --- obs-vst.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/obs-vst.cpp b/obs-vst.cpp index e78a4c67d..fab76c6fe 100644 --- a/obs-vst.cpp +++ b/obs-vst.cpp @@ -91,10 +91,18 @@ static void fill_out_plugins(obs_property_t *list) << "C:/Program Files/VSTPlugins/"; // If VST3 support is added.... // << "C:/Program Files/Common Files/VST3"; + #elif LINUX + dir_list << "/usr/lib/vst" + dir_list << "/usr/lib/lxvst" + dir_list << "/usr/local/lib/vst" + dir_list << "/usr/local/lib/lxvst" + dir_list << "~/.vst" + dir_list << "~/.lxvst"; #endif QStringList filters; - filters << "*.vst" << "*.dll"; + obs_property_list_add_string(list, "{Please select a plugin}", nullptr); + filters << "*.vst" << "*.dll" << "*.so"; for (int a = 0; a < dir_list.size(); ++a) { QDir search_dir(dir_list[a]); From 92167c2b0ee409969e3f665bbcf8149cf7139682 Mon Sep 17 00:00:00 2001 From: Cephas Reis Date: Wed, 18 Jan 2017 23:36:22 -0600 Subject: [PATCH 5/7] OSX/obs-vst.cpp: Add User's Home/Library directory to search for VSTs --- obs-vst.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/obs-vst.cpp b/obs-vst.cpp index fab76c6fe..f2159ae0a 100644 --- a/obs-vst.cpp +++ b/obs-vst.cpp @@ -81,8 +81,10 @@ static struct obs_audio_data *vst_filter_audio(void *data, static void fill_out_plugins(obs_property_t *list) { QStringList dir_list; + #ifdef __APPLE__ dir_list << "/Library/Audio/Plug-Ins/VST/"; + dir_list << "~/Library/Audio/Plug-ins/VST/"; #elif WIN32 dir_list << "C:/Program Files/Steinberg/VstPlugins/" << "C:/Program Files/Common Files/Steinberg/Shared Components/" From 95695b3b9e8fdc89c41d3db15759be29a548c0bc Mon Sep 17 00:00:00 2001 From: Cephas Reis Date: Wed, 18 Jan 2017 23:39:35 -0600 Subject: [PATCH 6/7] VSTPlugin-Win.cpp: Replace "NULL" with "nullptr" based on Vs2015 recommendation. --- win/VSTPlugin-win.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/win/VSTPlugin-win.cpp b/win/VSTPlugin-win.cpp index 7c3fe7022..6d117efa9 100644 --- a/win/VSTPlugin-win.cpp +++ b/win/VSTPlugin-win.cpp @@ -5,26 +5,26 @@ #include AEffect* VSTPlugin::loadEffect() { - AEffect *plugin = NULL; + AEffect *plugin = nullptr; wchar_t *wpath; os_utf8_to_wcs_ptr(pluginPath.c_str(), 0, &wpath); dllHandle = LoadLibraryW(wpath); bfree(wpath); - if(dllHandle == NULL) { + if(dllHandle == nullptr) { printf("Failed trying to load VST from '%s', error %d\n", pluginPath, GetLastError()); - return NULL; + return nullptr; } vstPluginMain mainEntryPoint = (vstPluginMain)GetProcAddress(dllHandle, "VSTPluginMain"); if (!mainEntryPoint) { - return NULL; + return nullptr; } - // Instantiate the plugin + // Instantiate the plug-in plugin = mainEntryPoint(hostCallback_static); plugin->user = this; return plugin; @@ -33,6 +33,6 @@ AEffect* VSTPlugin::loadEffect() { void VSTPlugin::unloadLibrary() { if (dllHandle) { FreeLibrary(dllHandle); - dllHandle = NULL; + dllHandle = nullptr; } } \ No newline at end of file From c9c9b07ea02e12e56b24c8aec01ecbd733235df5 Mon Sep 17 00:00:00 2001 From: Cephas Reis Date: Wed, 18 Jan 2017 23:40:48 -0600 Subject: [PATCH 7/7] win/EditorWidget-win.cpp: Replace "0" with "nullptr" to fix github issue #11 - Line 25 crash. --- win/EditorWidget-win.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/win/EditorWidget-win.cpp b/win/EditorWidget-win.cpp index a3d75c7a3..85c323996 100644 --- a/win/EditorWidget-win.cpp +++ b/win/EditorWidget-win.cpp @@ -22,7 +22,7 @@ void EditorWidget::buildEffectContainer(AEffect *effect) { effect->dispatcher(effect, effEditOpen, 0, 0, hwnd, 0); - VstRect* vstRect = 0; + VstRect* vstRect = nullptr; effect->dispatcher(effect, effEditGetRect, 0, 0, &vstRect, 0); if (vstRect) {