diff --git a/.gitignore b/.gitignore index 4196b1a0..d232a9b0 100644 --- a/.gitignore +++ b/.gitignore @@ -32,3 +32,6 @@ node_modules/ *.lock *.sublime-* *.code-* + +/vst/download +/vst/external/VST_SDK diff --git a/CMakeLists.txt b/CMakeLists.txt index 91a45430..00adb2e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ endif() option (ENABLE_LTO "Enable Link Time Optimization [default: ON]" ON) option (SFIZZ_JACK "Enable JACK stand-alone build [default: ON]" ON) option (SFIZZ_LV2 "Enable LV2 plug-in build [default: ON]" ON) +option (SFIZZ_VST "Enable VST plug-in build [default: OFF]" OFF) option (SFIZZ_BENCHMARKS "Enable benchmarks build [default: OFF]" OFF) option (SFIZZ_TESTS "Enable tests build [default: OFF]" OFF) option (SFIZZ_SHARED "Enable shared library build [default: ON]" ON) @@ -51,6 +52,10 @@ if (SFIZZ_LV2) add_subdirectory (lv2) endif() +if (SFIZZ_VST) + add_subdirectory (vst) +endif() + if (SFIZZ_BENCHMARKS) add_subdirectory (benchmarks) endif() diff --git a/appveyor.yml b/appveyor.yml index 99b80d33..294068bb 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -6,6 +6,7 @@ platform: - x64 cache: - c:\tools\vcpkg\installed\ -> appveyor.yml + - vst\download install: - cmd: choco install -y innosetup @@ -18,9 +19,7 @@ before_build: - cmd: git submodule update --init - cmd: mkdir CMakeBuild - cmd: cd CMakeBuild -- cmd: if %platform%==Win32 set CMAKE_GENERATOR=Visual Studio 15 2017 -- cmd: if %platform%==x64 set CMAKE_GENERATOR=Visual Studio 15 2017 Win64 -- cmd: cmake .. -G"%CMAKE_GENERATOR%" -DSFIZZ_JACK=OFF -DSFIZZ_BENCHMARKS=OFF -DSFIZZ_TESTS=OFF -DSFIZZ_LV2=ON -DCMAKE_BUILD_TYPE=Release -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET% -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake +- cmd: cmake .. -G"Visual Studio 15 2017" -A"%platform%" -DSFIZZ_JACK=OFF -DSFIZZ_BENCHMARKS=OFF -DSFIZZ_TESTS=OFF -DSFIZZ_LV2=ON -DSFIZZ_VST=ON -DCMAKE_BUILD_TYPE=Release -DVCPKG_TARGET_TRIPLET=%VCPKG_TRIPLET% -DCMAKE_TOOLCHAIN_FILE=C:/Tools/vcpkg/scripts/buildsystems/vcpkg.cmake build_script: - cmd: cmake --build . --config Release -j @@ -31,6 +30,7 @@ after_build: - cmd: if %platform%==Win32 set RELEASE_ARCH=x86 - cmd: if %platform%==x64 set RELEASE_ARCH=x64 - cmd: 7z a sfizz-lv2-%APPVEYOR_REPO_TAG_NAME%-%RELEASE_ARCH%-msvc.zip sfizz.lv2 +- cmd: 7z a sfizz-vst3-%APPVEYOR_REPO_TAG_NAME%-%RELEASE_ARCH%-msvc.zip sfizz.vst3 - cmd: 7z a sfizz-lib-%APPVEYOR_REPO_TAG_NAME%-%RELEASE_ARCH%-msvc.zip src/Release/sfizz* - cmd: iscc.exe /dARCH=%RELEASE_ARCH% innosetup.iss diff --git a/cmake/SfizzConfig.cmake b/cmake/SfizzConfig.cmake index e2be25e1..19215e3a 100644 --- a/cmake/SfizzConfig.cmake +++ b/cmake/SfizzConfig.cmake @@ -12,9 +12,9 @@ set (CMAKE_POSITION_INDEPENDENT_CODE ON) set (CMAKE_CXX_VISIBILITY_PRESET hidden) set (CMAKE_VISIBILITY_INLINES_HIDDEN ON) -# Set Windows compatibility level to Vista +# Set Windows compatibility level to 7 if (WIN32) - add_compile_definitions(_WIN32_WINNT=0x600) + add_compile_definitions(_WIN32_WINNT=0x601) endif() # Add required flags for the builds diff --git a/cmake/VSTConfig.cmake b/cmake/VSTConfig.cmake new file mode 100644 index 00000000..aa3d52f6 --- /dev/null +++ b/cmake/VSTConfig.cmake @@ -0,0 +1,36 @@ +set (VSTPLUGIN_NAME "sfizz") +set (VSTPLUGIN_VENDOR "Paul Ferrand") +set (VSTPLUGIN_URL "http://sfztools.github.io/sfizz") +set (VSTPLUGIN_EMAIL "paul@ferrand.cc") + +# The variable CMAKE_SYSTEM_PROCESSOR is incorrect on Visual studio... +# see https://gitlab.kitware.com/cmake/cmake/issues/15170 + +if(MSVC) + set(VST3_SYSTEM_PROCESSOR "${MSVC_CXX_ARCHITECTURE_ID}") +else() + set(VST3_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}") +endif() + +message(STATUS "The system architecture is: ${VST3_SYSTEM_PROCESSOR}") + +# --- VST3 Bundle architecture --- +if(NOT VST3_PACKAGE_ARCHITECTURE) + if(APPLE) + # VST3 packages are universal on Apple, architecture string not needed + else() + if(VST3_SYSTEM_PROCESSOR MATCHES "^(x86_64|amd64|AMD64|x64|X64)$") + set(VST3_PACKAGE_ARCHITECTURE "x86_64") + elseif(VST3_SYSTEM_PROCESSOR MATCHES "^(i.86|x86|X86)$") + if(WIN32) + set(VST3_PACKAGE_ARCHITECTURE "x86") + else() + set(VST3_PACKAGE_ARCHITECTURE "i386") + endif() + else() + message(FATAL_ERROR "We don't know this architecture for VST3: ${VST3_SYSTEM_PROCESSOR}.") + endif() + endif() +endif() + +message(STATUS "The VST3 architecture is deduced as: ${VST3_PACKAGE_ARCHITECTURE}") diff --git a/scripts/create_mac_icon.sh b/scripts/create_mac_icon.sh new file mode 100755 index 00000000..3467da93 --- /dev/null +++ b/scripts/create_mac_icon.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -e + +svg_file="$1" +test -z "$svg_file" && exit 1 + +sizes="32 48 128 256" + +rm -f "$svg_file".icon.*.png + +for size in $sizes; do + png_file="$svg_file".icon."$size".png + inkscape -e "$png_file" "$svg_file" -w "$size" -h "$size" + optipng "$png_file" +done + +png2icns "$svg_file".icns "$svg_file".icon.*.png +rm -f "$svg_file".icon.*.png diff --git a/scripts/create_windows_icon.sh b/scripts/create_windows_icon.sh new file mode 100755 index 00000000..710fbdc8 --- /dev/null +++ b/scripts/create_windows_icon.sh @@ -0,0 +1,18 @@ +#!/bin/bash +set -e + +svg_file="$1" +test -z "$svg_file" && exit 1 + +sizes="32 48 128 256" + +rm -f "$svg_file".icon.*.png + +for size in $sizes; do + png_file="$svg_file".icon."$size".png + inkscape -e "$png_file" "$svg_file" -w "$size" -h "$size" + optipng "$png_file" +done + +icotool -c -o "$svg_file".ico "$svg_file".icon.*.png +rm -f "$svg_file".icon.*.png diff --git a/scripts/innosetup.iss.in b/scripts/innosetup.iss.in index 92de0abf..d97d3f2b 100644 --- a/scripts/innosetup.iss.in +++ b/scripts/innosetup.iss.in @@ -1,4 +1,5 @@ -#define MyAppName "sfizz-lv2" +; -*- mode: iss; -*- +#define MyAppName "sfizz" #define MyAppVersion "@PROJECT_VERSION@" #define MyAppPublisher "sfizz Team" #define MyAppURL "https://sfztools.github.io/sfizz/" @@ -28,25 +29,35 @@ ArchitecturesInstallIn64BitMode={#Arch} Compression=lzma SolidCompression=yes -DefaultDirName={commoncf}\LV2 +DefaultDirName={commonpf}\{#MyAppName} DefaultGroupName={#MyAppPublisher} -DisableDirPage=yes +;DisableDirPage=yes LicenseFile="sfizz.lv2\LICENSE.md" OutputBaseFileName={#MyAppName}-{#MyAppVersion}-{#Arch}-msvc-setup OutputDir=. -UninstallFilesDir={commonpf}\{#MyAppName} +UninstallFilesDir={app} WizardImageFile="C:\Program Files (x86)\Inno Setup 6\WizModernImage-IS.bmp" WizardSmallImageFile="C:\Program Files (x86)\Inno Setup 6\WizModernSmallImage-IS.bmp" [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" +[Components] +Name: "main"; Description: "Shared files"; Types: full custom; Flags: fixed +Name: "lv2"; Description: "LV2 plugin"; Types: full custom; +Name: "vst3"; Description: "VST3 plugin"; Types: full custom; + [Files] -Source: "sfizz.lv2\sfizz.dll"; DestDir: {commoncf}\LV2\sfizz.lv2; Flags: ignoreversion -Source: "sfizz.lv2\manifest.ttl"; DestDir: {commoncf}\LV2\sfizz.lv2 -Source: "sfizz.lv2\sfizz.ttl"; DestDir: {commoncf}\LV2\sfizz.lv2 -Source: "sfizz.lv2\lgpl-3.0.txt"; DestDir: {commonpf}\{#MyAppName} -Source: "sfizz.lv2\LICENSE.md"; DestDir: {commonpf}\{#MyAppName} +Source: "sfizz.lv2\sfizz.dll"; Components: lv2; DestDir: "{commoncf}\LV2\sfizz.lv2"; Flags: ignoreversion +Source: "sfizz.lv2\manifest.ttl"; Components: lv2; DestDir: "{commoncf}\LV2\sfizz.lv2" +Source: "sfizz.lv2\sfizz.ttl"; Components: lv2; DestDir: "{commoncf}\LV2\sfizz.lv2" +Source: "sfizz.lv2\lgpl-3.0.txt"; Components: main; DestDir: "{app}" +Source: "sfizz.lv2\LICENSE.md"; Components: main; DestDir: "{app}" +Source: "sfizz.vst3\desktop.ini"; Components: vst3; DestDir: "{commoncf}\VST3\sfizz.vst3" +Source: "sfizz.vst3\Contents\@VST3_PACKAGE_ARCHITECTURE@-win\sfizz.vst3"; Components: vst3; DestDir: "{commoncf}\VST3\sfizz.vst3\Contents\@VST3_PACKAGE_ARCHITECTURE@-win"; Flags: ignoreversion +Source: "sfizz.vst3\Contents\Resources\logo.png"; Components: vst3; DestDir: "{commoncf}\VST3\sfizz.vst3\Contents\Resources" +Source: "sfizz.vst3\Plugin.ico"; Components: vst3; DestDir: "{commoncf}\VST3\sfizz.vst3" +Source: "sfizz.vst3\gpl-3.0.txt"; Components: main; DestDir: "{app}" ;Source: "setup\vc_redist.x64.exe"; DestDir: {tmp}; Flags: deleteafterinstall ; NOTE: Don't use "Flags: ignoreversion" on any shared system files diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3580130c..fcaeca79 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -47,7 +47,9 @@ if (NOT MSVC) PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) configure_file (${PROJECT_SOURCE_DIR}/scripts/sfizz.pc.in sfizz.pc @ONLY) -else() +endif() +if(WIN32) + include(VSTConfig) configure_file (${PROJECT_SOURCE_DIR}/scripts/innosetup.iss.in ${PROJECT_BINARY_DIR}/innosetup.iss @ONLY) endif() diff --git a/vst/CMakeLists.txt b/vst/CMakeLists.txt new file mode 100644 index 00000000..83c51154 --- /dev/null +++ b/vst/CMakeLists.txt @@ -0,0 +1,122 @@ +set (VSTPLUGIN_PRJ_NAME "${PROJECT_NAME}_vst3") +set (VSTPLUGIN_BUNDLE_NAME "${PROJECT_NAME}.vst3") + +set (VST3SDK_BASEDIR "${CMAKE_CURRENT_SOURCE_DIR}/external/VST_SDK/VST3_SDK") +set (VST3SDK_ARCHIVE "vst-sdk_3.6.14_build-24_2019-11-29.zip") + +if (NOT EXISTS "${VST3SDK_BASEDIR}") + message (STATUS "VST3 SDK is not found, downloading") + + execute_process ( + COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/download") + + if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/download/${VST3SDK_ARCHIVE}") + file (DOWNLOAD + "https://download.steinberg.net/sdk_downloads/${VST3SDK_ARCHIVE}" + "${CMAKE_CURRENT_SOURCE_DIR}/download/${VST3SDK_ARCHIVE}" + SHOW_PROGRESS) + endif() + + execute_process ( + COMMAND "${CMAKE_COMMAND}" -E make_directory "${CMAKE_CURRENT_SOURCE_DIR}/external" + COMMAND "${CMAKE_COMMAND}" -E tar xf "../download/${VST3SDK_ARCHIVE}" + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/external") +endif() + +# stop trying to include this atrocity.. build it ourselves +#add_subdirectory("${VST3SDK_BASEDIR}" EXCLUDE_FROM_ALL) + +# VST plugin specific settings +include (VSTConfig) + +configure_file (VstPluginDefs.h.in "${CMAKE_CURRENT_BINARY_DIR}/VstPluginDefs.h") + +# Build VST3 SDK +include("cmake/Vst3.cmake") + +# Build the plugin +add_library(${VSTPLUGIN_PRJ_NAME} MODULE + SfizzVstProcessor.cpp + SfizzVstController.cpp + SfizzVstEditor.cpp + SfizzVstState.cpp + GUIComponents.cpp + VstPluginFactory.cpp) + +if(WIN32) + target_sources(${VSTPLUGIN_PRJ_NAME} PRIVATE vst3.def) +endif() +target_link_libraries(${VSTPLUGIN_PRJ_NAME} + PRIVATE ${PROJECT_NAME}::${PROJECT_NAME}) +target_include_directories(${VSTPLUGIN_PRJ_NAME} + PRIVATE "${CMAKE_CURRENT_BINARY_DIR}") +set_target_properties(${VSTPLUGIN_PRJ_NAME} PROPERTIES + OUTPUT_NAME "${PROJECT_NAME}" + PREFIX "") + +plugin_add_vst3sdk(${VSTPLUGIN_PRJ_NAME}) +plugin_add_vstgui(${VSTPLUGIN_PRJ_NAME}) + +if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") + target_link_libraries(${VSTPLUGIN_PRJ_NAME} PRIVATE + "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/vst3.version") +endif() +sfizz_enable_lto_if_needed (${VSTPLUGIN_PRJ_NAME}) +if (MINGW) + set_target_properties (${VSTPLUGIN_PRJ_NAME} PROPERTIES LINK_FLAGS "-static") +endif() + +# Create the bundle (see "VST 3 Locations / Format") +execute_process ( + COMMAND "${CMAKE_COMMAND}" -E make_directory "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/Resources") +file (COPY "${CMAKE_CURRENT_SOURCE_DIR}/resources/logo.png" + DESTINATION "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/Resources") +if(WIN32) + set_target_properties(${VSTPLUGIN_PRJ_NAME} PROPERTIES + SUFFIX ".vst3" + LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/${VST3_PACKAGE_ARCHITECTURE}-win") + foreach(config ${CMAKE_CONFIGURATION_TYPES}) + string(TOUPPER "${config}" config) + set_target_properties(${VSTPLUGIN_PRJ_NAME} PROPERTIES + "LIBRARY_OUTPUT_DIRECTORY_${config}" "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/${VST3_PACKAGE_ARCHITECTURE}-win") + endforeach() + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/win/Plugin.ico" + "${CMAKE_CURRENT_SOURCE_DIR}/win/desktop.ini" + DESTINATION "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}") +elseif(APPLE) + set_target_properties(${VSTPLUGIN_PRJ_NAME} PROPERTIES + SUFFIX "" + LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/MacOS") + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/mac/PkgInfo" + DESTINATION "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents") + set(SFIZZ_VST3_BUNDLE_EXECUTABLE "${PROJECT_NAME}") + set(SFIZZ_VST3_BUNDLE_VERSION "${PROJECT_VERSION}") + configure_file("${CMAKE_CURRENT_SOURCE_DIR}/mac/Info.plist" + "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/Info.plist" @ONLY) + file(COPY "${CMAKE_CURRENT_SOURCE_DIR}/mac/Plugin.icns" + DESTINATION "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/Resources") +else() + set_target_properties(${VSTPLUGIN_PRJ_NAME} PROPERTIES + LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}/Contents/${VST3_PACKAGE_ARCHITECTURE}-linux") +endif() + +file(COPY "gpl-3.0.txt" + DESTINATION "${PROJECT_BINARY_DIR}/${VSTPLUGIN_BUNDLE_NAME}") + +if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + target_compile_options(${VSTPLUGIN_PRJ_NAME} PRIVATE + "-Wno-extra" + "-Wno-multichar" + "-Wno-reorder" + "-Wno-class-memaccess" + "-Wno-ignored-qualifiers" + "-Wno-unknown-pragmas" + "-Wno-unused-function" + "-Wno-unused-parameter" + "-Wno-unused-variable") +endif() + +# To help debugging the link only +if (FALSE) + target_link_options(${VSTPLUGIN_PRJ_NAME} PRIVATE "-Wl,-no-undefined") +endif() diff --git a/vst/GUIComponents.cpp b/vst/GUIComponents.cpp new file mode 100644 index 00000000..314ba642 --- /dev/null +++ b/vst/GUIComponents.cpp @@ -0,0 +1,33 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#include "GUIComponents.h" +#include "vstgui/lib/cdrawcontext.h" + +SimpleSlider::SimpleSlider(const CRect& bounds, IControlListener* listener, int32_t tag) + : CSliderBase(bounds, listener, tag) +{ + setStyle(kHorizontal|kLeft); + + CPoint offsetHandle(2.0, 2.0); + setOffsetHandle(offsetHandle); + + CCoord handleSize = 20.0; + setHandleSizePrivate(handleSize, bounds.bottom - bounds.top - 2 * offsetHandle.y); + setHandleRangePrivate(bounds.right - bounds.left - handleSize - 2 * offsetHandle.x); +} + +void SimpleSlider::draw(CDrawContext* dc) +{ + CRect bounds = getViewSize(); + CRect handle = calculateHandleRect(getValueNormalized()); + + dc->setFrameColor(_frame); + dc->drawRect(bounds, kDrawStroked); + + dc->setFillColor(_fill); + dc->drawRect(handle, kDrawFilled); +} diff --git a/vst/GUIComponents.h b/vst/GUIComponents.h new file mode 100644 index 00000000..003d219b --- /dev/null +++ b/vst/GUIComponents.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#pragma once +#include "vstgui/lib/controls/cslider.h" +#include "vstgui/lib/ccolor.h" + +using namespace VSTGUI; + +class SimpleSlider : public CSliderBase { +public: + SimpleSlider(const CRect& bounds, IControlListener* listener, int32_t tag); + void draw(CDrawContext* dc) override; + + CLASS_METHODS(SimpleSlider, CSliderBase) + +private: + CColor _frame = CColor(0x00, 0x00, 0x00); + CColor _fill = CColor(0x00, 0x00, 0x00); +}; diff --git a/vst/RTSemaphore.h b/vst/RTSemaphore.h new file mode 100644 index 00000000..5ec3c765 --- /dev/null +++ b/vst/RTSemaphore.h @@ -0,0 +1,167 @@ +// Copyright Jean Pierre Cimalando 2018-2020. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#pragma once +#if defined(__APPLE__) +#include +#elif defined(_WIN32) +#include +#include +#else +#include +#include +#endif +#include + +class RTSemaphore { +public: + explicit RTSemaphore(unsigned value = 0); + ~RTSemaphore(); + + RTSemaphore(const RTSemaphore &) = delete; + RTSemaphore &operator=(const RTSemaphore &) = delete; + + void post(); + void wait(); + bool try_wait(); + +private: +#if defined(__APPLE__) + semaphore_t sem_; +#elif defined(_WIN32) + HANDLE sem_; +#else + sem_t sem_; +#endif +}; + +#if defined(__APPLE__) +inline RTSemaphore::RTSemaphore(unsigned value) +{ + if (semaphore_create(mach_task_self(), &sem_, SYNC_POLICY_FIFO, value) != 0) + throw std::runtime_error("RTSemaphore::RTSemaphore"); +} + +inline RTSemaphore::~RTSemaphore() +{ + semaphore_destroy(mach_task_self(), sem_); +} + +inline void RTSemaphore::post() +{ + if (semaphore_signal(sem_) != KERN_SUCCESS) + throw std::runtime_error("RTSemaphore::post"); +} + +inline void RTSemaphore::wait() +{ + do { + switch (semaphore_wait(sem_)) { + case KERN_SUCCESS: + return; + case KERN_ABORTED: + break; + default: + throw std::runtime_error("RTSemaphore::wait"); + } + } while (1); +} + +inline bool RTSemaphore::try_wait() +{ + do { + const mach_timespec_t timeout = {0, 0}; + switch (semaphore_timedwait(sem_, timeout)) { + case KERN_SUCCESS: + return true; + case KERN_OPERATION_TIMED_OUT: + return false; + case KERN_ABORTED: + break; + default: + throw std::runtime_error("RTSemaphore::try_wait"); + } + } while (1); +} +#elif defined(_WIN32) +inline RTSemaphore::RTSemaphore(unsigned value) +{ + sem_ = CreateSemaphore(nullptr, value, LONG_MAX, nullptr); + if (!sem_) + throw std::runtime_error("RTSemaphore::RTSemaphore"); +} + +inline RTSemaphore::~RTSemaphore() +{ + CloseHandle(sem_); +} + +inline void RTSemaphore::post() +{ + if (!ReleaseSemaphore(sem_, 1, nullptr)) + throw std::runtime_error("RTSemaphore::post"); +} + +inline void RTSemaphore::wait() +{ + if (WaitForSingleObject(sem_, INFINITE) != WAIT_OBJECT_0) + throw std::runtime_error("RTSemaphore::wait"); +} + +inline bool RTSemaphore::try_wait() +{ + switch (WaitForSingleObject(sem_, 0)) { + case WAIT_OBJECT_0: + return true; + case WAIT_TIMEOUT: + return false; + default: + throw std::runtime_error("RTSemaphore::try_wait"); + } +} +#else +inline RTSemaphore::RTSemaphore(unsigned value) +{ + if (sem_init(&sem_, 0, value) != 0) + throw std::runtime_error("RTSemaphore::RTSemaphore"); +} + +inline RTSemaphore::~RTSemaphore() +{ + sem_destroy(&sem_); +} + +inline void RTSemaphore::post() +{ + while (sem_post(&sem_) != 0) { + if (errno != EINTR) + throw std::runtime_error("RTSemaphore::post"); + } +} + +inline void RTSemaphore::wait() +{ + while (sem_wait(&sem_) != 0) { + if (errno != EINTR) + throw std::runtime_error("RTSemaphore::wait"); + } +} + +inline bool RTSemaphore::try_wait() +{ + do { + if (sem_trywait(&sem_) == 0) + return true; + switch (errno) { + case EINTR: + break; + case EAGAIN: + return false; + default: + throw std::runtime_error("RTSemaphore::try_wait"); + } + } while (1); +} +#endif diff --git a/vst/SfizzVstController.cpp b/vst/SfizzVstController.cpp new file mode 100644 index 00000000..cc13b355 --- /dev/null +++ b/vst/SfizzVstController.cpp @@ -0,0 +1,248 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#include "SfizzVstController.h" +#include "SfizzVstEditor.h" +#include "base/source/fstreamer.h" +#include "pluginterfaces/vst/ivstmidicontrollers.h" + +tresult PLUGIN_API SfizzVstControllerNoUi::initialize(FUnknown* context) +{ + tresult result = EditController::initialize(context); + if (result != kResultTrue) + return result; + + Vst::ParamID pid = 0; + + // Ordinary parameters + parameters.addParameter( + kParamVolumeRange.createParameter( + Steinberg::String("Volume"), pid++, Steinberg::String("dB"), + 0, Vst::ParameterInfo::kCanAutomate, Vst::kRootUnitId)); + parameters.addParameter( + kParamNumVoicesRange.createParameter( + Steinberg::String("Polyphony"), pid++, nullptr, + 0, Vst::ParameterInfo::kNoFlags, Vst::kRootUnitId)); + parameters.addParameter( + kParamOversamplingRange.createParameter( + Steinberg::String("Oversampling"), pid++, nullptr, + 0, Vst::ParameterInfo::kNoFlags, Vst::kRootUnitId)); + parameters.addParameter( + kParamPreloadSizeRange.createParameter( + Steinberg::String("Preload size"), pid++, nullptr, + 0, Vst::ParameterInfo::kNoFlags, Vst::kRootUnitId)); + + // MIDI special controllers + parameters.addParameter(Steinberg::String("Aftertouch"), nullptr, 0, 0.5, 0, pid++, Vst::kRootUnitId); + parameters.addParameter(Steinberg::String("Pitch Bend"), nullptr, 0, 0.5, 0, pid++, Vst::kRootUnitId); + + // MIDI controllers + for (unsigned i = 0; i < kNumControllerParams; ++i) { + Steinberg::String title; + Steinberg::String shortTitle; + title.printf("Controller %u", i); + shortTitle.printf("CC%u", i); + + parameters.addParameter( + title, nullptr, 0, 0, Vst::ParameterInfo::kCanAutomate, + pid++, Vst::kRootUnitId, shortTitle); + } + + return kResultTrue; +} + +tresult PLUGIN_API SfizzVstControllerNoUi::terminate() +{ + return EditController::terminate(); +} + +tresult PLUGIN_API SfizzVstControllerNoUi::getMidiControllerAssignment(int32 busIndex, int16 channel, Vst::CtrlNumber midiControllerNumber, Vst::ParamID& id) +{ + switch (midiControllerNumber) { + case Vst::kAfterTouch: + id = kPidMidiAftertouch; + return kResultTrue; + + case Vst::kPitchBend: + id = kPidMidiPitchBend; + return kResultTrue; + + default: + if (midiControllerNumber < 0 || midiControllerNumber >= kNumControllerParams) + return kResultFalse; + + id = kPidMidiCC0 + midiControllerNumber; + return kResultTrue; + } +} + +tresult PLUGIN_API SfizzVstControllerNoUi::getParamStringByValue(Vst::ParamID tag, Vst::ParamValue valueNormalized, Vst::String128 string) +{ + switch (tag) { + case kPidOversampling: + { + int factorLog2 = kParamOversamplingRange.denormalize(valueNormalized); + Steinberg::String buf; + buf.printf("%dX", 1 << factorLog2); + buf.copyTo(string); + return kResultTrue; + } + } + + return EditController::getParamStringByValue(tag, valueNormalized, string); +} + +tresult PLUGIN_API SfizzVstControllerNoUi::getParamValueByString(Vst::ParamID tag, Vst::TChar* string, Vst::ParamValue& valueNormalized) +{ + switch (tag) { + case kPidOversampling: + { + int32 factor; + if (!Steinberg::String::scanInt32(string, factor, false) || factor < 1) + factor = 1; + + int32 log2Factor = 0; + for (int32 f = factor; f > 1; f /= 2) + ++log2Factor; + + valueNormalized = kParamOversamplingRange.normalize(log2Factor); + return kResultTrue; + } + } + + return EditController::getParamValueByString(tag, string, valueNormalized); +} + +// --- Controller with UI --- // + +IPlugView* PLUGIN_API SfizzVstController::createView(FIDString _name) +{ + ConstString name(_name); + + fprintf(stderr, "[sfizz] about to create view: %s\n", _name); + + if (name != Vst::ViewType::kEditor) + return nullptr; + + return new SfizzVstEditor(this); +} + +tresult PLUGIN_API SfizzVstController::setParamNormalized(Vst::ParamID tag, Vst::ParamValue normValue) +{ + tresult r = SfizzVstControllerNoUi::setParamNormalized(tag, normValue); + if (r != kResultTrue) + return r; + + float *slotF32 = nullptr; + int32 *slotI32 = nullptr; + float value = 0; + + switch (tag) { + case kPidVolume: { + slotF32 = &_state.volume; + value = kParamVolumeRange.denormalize(normValue); + break; + } + case kPidNumVoices: { + slotI32 = &_state.numVoices; + value = kParamNumVoicesRange.denormalize(normValue); + break; + } + case kPidOversampling: { + slotI32 = &_state.oversamplingLog2; + value = kParamOversamplingRange.denormalize(normValue); + break; + } + case kPidPreloadSize: { + slotI32 = &_state.preloadSize; + value = kParamPreloadSizeRange.denormalize(normValue); + break; + } + } + + bool update = false; + + if (slotF32 && *slotF32 != value) { + *slotF32 = value; + update = true; + } + else if (slotI32 && *slotI32 != (int32)value) { + *slotI32 = (int32)value; + update = true; + } + + if (update) { + for (StateListener* listener : _stateListeners) + listener->onStateChanged(); + } + + return kResultTrue; +} + +tresult PLUGIN_API SfizzVstController::setState(IBStream* state) +{ + SfizzUiState s; + + tresult r = s.load(state); + if (r != kResultTrue) + return r; + + _uiState = s; + + for (StateListener* listener : _stateListeners) + listener->onStateChanged(); + + return kResultTrue; +} + +tresult PLUGIN_API SfizzVstController::getState(IBStream* state) +{ + return _uiState.store(state); +} + +tresult PLUGIN_API SfizzVstController::setComponentState(IBStream* state) +{ + SfizzVstState s; + + tresult r = s.load(state); + if (r != kResultTrue) + return r; + + _state = s; + + setParamNormalized(kPidVolume, kParamVolumeRange.normalize(s.volume)); + setParamNormalized(kPidNumVoices, kParamNumVoicesRange.normalize(s.numVoices)); + setParamNormalized(kPidOversampling, kParamOversamplingRange.normalize(s.oversamplingLog2)); + setParamNormalized(kPidPreloadSize, kParamPreloadSizeRange.normalize(s.preloadSize)); + + for (StateListener* listener : _stateListeners) + listener->onStateChanged(); + + return kResultTrue; +} + +void SfizzVstController::addSfizzStateListener(StateListener* listener) +{ + _stateListeners.push_back(listener); +} + +void SfizzVstController::removeSfizzStateListener(StateListener* listener) +{ + auto it = std::find(_stateListeners.begin(), _stateListeners.end(), listener); + if (it != _stateListeners.end()) + _stateListeners.erase(it); +} + +FUnknown* SfizzVstController::createInstance(void*) +{ + return static_cast(new SfizzVstController); +} + +/* + Note(jpc) Generated at random with uuidgen. + Can't find docs on it... maybe it's to register somewhere? + */ +FUID SfizzVstController::cid(0x7129736c, 0xbc784134, 0xbb899d56, 0x2ebafe4f); diff --git a/vst/SfizzVstController.h b/vst/SfizzVstController.h new file mode 100644 index 00000000..b8455ecd --- /dev/null +++ b/vst/SfizzVstController.h @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#pragma once +#include "SfizzVstState.h" +#include "public.sdk/source/vst/vsteditcontroller.h" +#include "public.sdk/source/vst/vstparameters.h" +#include "vstgui/plugin-bindings/vst3editor.h" +class SfizzVstState; + +using namespace Steinberg; +using namespace VSTGUI; + +class SfizzVstControllerNoUi : public Vst::EditController, + public Vst::IMidiMapping { +public: + virtual ~SfizzVstControllerNoUi() {} + + tresult PLUGIN_API initialize(FUnknown* context) override; + tresult PLUGIN_API terminate() override; + + tresult PLUGIN_API getMidiControllerAssignment(int32 busIndex, int16 channel, Vst::CtrlNumber midiControllerNumber, Vst::ParamID& id) override; + + tresult PLUGIN_API getParamStringByValue(Vst::ParamID tag, Vst::ParamValue valueNormalized, Vst::String128 string) override; + tresult PLUGIN_API getParamValueByString(Vst::ParamID tag, Vst::TChar* string, Vst::ParamValue& valueNormalized) override; + + + // interfaces + OBJ_METHODS(SfizzVstControllerNoUi, Vst::EditController) + DEFINE_INTERFACES + DEF_INTERFACE(Vst::IMidiMapping) + END_DEFINE_INTERFACES(Vst::EditController) + REFCOUNT_METHODS(Vst::EditController) +}; + +class SfizzVstController : public SfizzVstControllerNoUi, public VSTGUI::VST3EditorDelegate { +public: + IPlugView* PLUGIN_API createView(FIDString name) override; + + tresult PLUGIN_API setParamNormalized(Vst::ParamID tag, Vst::ParamValue value) override; + tresult PLUGIN_API setState(IBStream* state) override; + tresult PLUGIN_API getState(IBStream* state) override; + tresult PLUGIN_API setComponentState(IBStream* state) override; + + struct StateListener { + virtual void onStateChanged() = 0; + }; + + const SfizzVstState& getSfizzState() const { return _state; } + + const SfizzUiState& getSfizzUiState() const { return _uiState; } + SfizzUiState& getSfizzUiState() { return _uiState; } + + void addSfizzStateListener(StateListener* listener); + void removeSfizzStateListener(StateListener* listener); + + /// + static FUnknown* createInstance(void*); + + static FUID cid; + +private: + SfizzVstState _state; + SfizzUiState _uiState; + std::vector _stateListeners; +}; diff --git a/vst/SfizzVstEditor.cpp b/vst/SfizzVstEditor.cpp new file mode 100644 index 00000000..826a8930 --- /dev/null +++ b/vst/SfizzVstEditor.cpp @@ -0,0 +1,391 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#include "SfizzVstEditor.h" +#include "SfizzVstState.h" +#include "GUIComponents.h" +#if !defined(__APPLE__) && !defined(_WIN32) +#include "x11runloop.h" +#endif + +using namespace VSTGUI; + +SfizzVstEditor::SfizzVstEditor(void *controller) + : VSTGUIEditor(controller), + _logo("logo.png") +{ + getController()->addSfizzStateListener(this); +} + +SfizzVstEditor::~SfizzVstEditor() +{ + getController()->removeSfizzStateListener(this); +} + +bool PLUGIN_API SfizzVstEditor::open(void* parent, const VSTGUI::PlatformType& platformType) +{ + fprintf(stderr, "[sfizz] about to open view with parent %p\n", parent); + + CRect wsize(0, 0, _logo.getWidth(), _logo.getHeight()); + CFrame *frame = new CFrame(wsize, this); + this->frame = frame; + + IPlatformFrameConfig* config = nullptr; + +#if !defined(__APPLE__) && !defined(_WIN32) + X11::FrameConfig x11config; + x11config.runLoop = VSTGUI::owned(new RunLoop(plugFrame)); + config = &x11config; +#endif + + createFrameContents(); + updateStateDisplay(); + + if (!frame->open(parent, platformType, config)) { + fprintf(stderr, "[sfizz] error opening frame\n"); + return false; + } + + return true; +} + +void PLUGIN_API SfizzVstEditor::close() +{ + CFrame *frame = this->frame; + if (frame) { + frame->forget(); + this->frame = nullptr; + } +} + +/// +void SfizzVstEditor::valueChanged(CControl* ctl) +{ + int32_t tag = ctl->getTag(); + float value = ctl->getValue(); + float valueNorm = ctl->getValueNormalized(); + SfizzVstController* controller = getController(); + + switch (tag) { + case kTagLoadSfzFile: + if (value != 1) + break; + + Call::later([this]() { chooseSfzFile(); }); + break; + + case kTagSetVolume: + controller->setParamNormalized(kPidVolume, valueNorm); + controller->performEdit(kPidVolume, valueNorm); + break; + + case kTagSetNumVoices: + controller->setParamNormalized(kPidNumVoices, valueNorm); + controller->performEdit(kPidNumVoices, valueNorm); + break; + + case kTagSetOversampling: + controller->setParamNormalized(kPidOversampling, valueNorm); + controller->performEdit(kPidOversampling, valueNorm); + break; + + case kTagSetPreloadSize: + controller->setParamNormalized(kPidPreloadSize, valueNorm); + controller->performEdit(kPidPreloadSize, valueNorm); + break; + + default: + if (tag >= kTagFirstChangePanel && tag <= kTagLastChangePanel) + setActivePanel(tag - kTagFirstChangePanel); + break; + } +} + +void SfizzVstEditor::enterOrLeaveEdit(CControl* ctl, bool enter) +{ + int32_t tag = ctl->getTag(); + Vst::ParamID id; + + switch (tag) { + case kTagSetVolume: id = kPidVolume; break; + case kTagSetNumVoices: id = kPidNumVoices; break; + case kTagSetOversampling: id = kPidOversampling; break; + case kTagSetPreloadSize: id = kPidPreloadSize; break; + default: return; + } + + SfizzVstController* controller = getController(); + if (enter) + controller->beginEdit(id); + else + controller->endEdit(id); +} + +void SfizzVstEditor::controlBeginEdit(CControl* ctl) +{ + enterOrLeaveEdit(ctl, true); +} + +void SfizzVstEditor::controlEndEdit(CControl* ctl) +{ + enterOrLeaveEdit(ctl, false); +} + +void SfizzVstEditor::onStateChanged() +{ + updateStateDisplay(); +} + +/// +void SfizzVstEditor::chooseSfzFile() +{ + SharedPointer fs(CNewFileSelector::create(frame)); + + fs->setTitle("Load SFZ file"); + fs->setDefaultExtension(CFileExtension("SFZ", "sfz")); + + if (fs->runModal()) { + UTF8StringPtr file = fs->getSelectedFile(0); + if (file) + loadSfzFile(file); + } +} + +void SfizzVstEditor::loadSfzFile(const std::string& filePath) +{ + SfizzVstController* ctl = getController(); + + Vst::IMessage *msg = ctl->allocateMessage(); + if (!msg) { + fprintf(stderr, "[Sfizz] UI could not allocate message\n"); + return; + } + + msg->setMessageID("LoadSfz"); + Vst::IAttributeList* attr = msg->getAttributes(); + attr->setString("File", Steinberg::String(filePath.c_str()).text()); + ctl->sendMessage(msg); + msg->release(); + + if (_fileLabel) + _fileLabel->setText(("File: " + filePath).c_str()); +} + +void SfizzVstEditor::createFrameContents() +{ + SfizzVstController* controller = getController(); + const SfizzUiState& uiState = controller->getSfizzUiState(); + + CFrame* frame = this->frame; + CRect bounds = frame->getViewSize(); + + frame->setBackgroundColor(CColor(0xff, 0xff, 0xff)); + + CRect bottomRow = bounds; + bottomRow.top = bottomRow.bottom - 30; + + CRect topRow = bounds; + topRow.bottom = topRow.top + 30; + + CViewContainer* panel; + _activePanel = std::max(0, std::min(kNumPanels - 1, static_cast(uiState.activePanel))); + + CRect topLeftLabelBox = topRow; + topLeftLabelBox.right -= 20 * kNumPanels; + + // general panel + { + panel = new CViewContainer(bounds); + frame->addView(panel); + panel->setTransparency(true); + + CKickButton* sfizzButton = new CKickButton(bounds, this, kTagLoadSfzFile, &_logo); + panel->addView(sfizzButton); + + CTextLabel* topLeftLabel = new CTextLabel(topLeftLabelBox, "No file loaded"); + topLeftLabel->setFontColor(CColor(0x00, 0x00, 0x00)); + topLeftLabel->setBackColor(CColor(0x00, 0x00, 0x00, 0x00)); + panel->addView(topLeftLabel); + _fileLabel = topLeftLabel; + + _subPanels[kPanelGeneral] = panel; + } + + // settings panel + { + panel = new CViewContainer(bounds); + frame->addView(panel); + panel->setTransparency(true); + + CTextLabel* topLeftLabel = new CTextLabel(topLeftLabelBox, "Settings"); + topLeftLabel->setFontColor(CColor(0x00, 0x00, 0x00)); + topLeftLabel->setBackColor(CColor(0x00, 0x00, 0x00, 0x00)); + panel->addView(topLeftLabel); + + CRect row = topRow; + row.top += 200.0; + row.bottom += 200.0; + row.left += 100.0; + row.right -= 100.0; + + CCoord interRow = 35.0; + + auto leftSide = [&row]() -> CRect { + CRect div = row; + div.right = 0.5 * (div.left + div.right); + return div; + }; + + auto rightSide = [&row]() -> CRect { + CRect div = row; + div.left = 0.5 * (div.left + div.right); + return div; + }; + + CTextLabel* label; + SimpleSlider* slider; + + label = new CTextLabel(leftSide(), "Volume"); + label->setFontColor(CColor(0x00, 0x00, 0x00)); + label->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00)); + label->setBackColor(CColor(0x00, 0x00, 0x00, 0x00)); + label->setHoriAlign(kLeftText); + panel->addView(label); + slider = new SimpleSlider(rightSide(), this, kTagSetVolume); + panel->addView(slider); + adjustMinMaxToRangeParam(slider, kPidVolume); + _volumeSlider = slider; + + row.top += interRow; + row.bottom += interRow; + + label = new CTextLabel(leftSide(), "Polyphony"); + label->setFontColor(CColor(0x00, 0x00, 0x00)); + label->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00)); + label->setBackColor(CColor(0x00, 0x00, 0x00, 0x00)); + label->setHoriAlign(kLeftText); + panel->addView(label); + slider = new SimpleSlider(rightSide(), this, kTagSetNumVoices); + panel->addView(slider); + adjustMinMaxToRangeParam(slider, kPidNumVoices); + _numVoicesSlider = slider; + + row.top += interRow; + row.bottom += interRow; + + label = new CTextLabel(leftSide(), "Oversampling"); + label->setFontColor(CColor(0x00, 0x00, 0x00)); + label->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00)); + label->setBackColor(CColor(0x00, 0x00, 0x00, 0x00)); + label->setHoriAlign(kLeftText); + panel->addView(label); + slider = new SimpleSlider(rightSide(), this, kTagSetOversampling); + panel->addView(slider); + adjustMinMaxToRangeParam(slider, kPidOversampling); + _oversamplingSlider = slider; + + row.top += interRow; + row.bottom += interRow; + + label = new CTextLabel(leftSide(), "Preload size"); + label->setFontColor(CColor(0x00, 0x00, 0x00)); + label->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00)); + label->setBackColor(CColor(0x00, 0x00, 0x00, 0x00)); + label->setHoriAlign(kLeftText); + panel->addView(label); + slider = new SimpleSlider(rightSide(), this, kTagSetPreloadSize); + panel->addView(slider); + adjustMinMaxToRangeParam(slider, kPidPreloadSize); + _preloadSizeSlider = slider; + + // row.top += interRow; + // row.bottom += interRow; + + // label = new CTextLabel(leftSide(), "Freewheel"); + // label->setFontColor(CColor(0x00, 0x00, 0x00)); + // label->setFrameColor(CColor(0x00, 0x00, 0x00, 0x00)); + // label->setBackColor(CColor(0x00, 0x00, 0x00, 0x00)); + // label->setHoriAlign(kLeftText); + // panel->addView(label); + // slider = new SimpleSlider(rightSide(), this, kTag); + // panel->addView(slider); + // adjustMinMaxToRangeParam(slider, kPid); + // _aSlider = slider; + + _subPanels[kPanelSettings] = panel; + } + + // all panels + for (unsigned currentPanel = 0; currentPanel < kNumPanels; ++currentPanel) { + panel = _subPanels[currentPanel]; + + CTextLabel* descLabel = new CTextLabel( + bottomRow, "Paul Ferrand and the SFZ Tools work group"); + descLabel->setFontColor(CColor(0x00, 0x00, 0x00)); + descLabel->setBackColor(CColor(0x00, 0x00, 0x00, 0x00)); + panel->addView(descLabel); + + for (unsigned i = 0; i < kNumPanels; ++i) { + CRect btnRect = topRow; + btnRect.left = topRow.right - (kNumPanels - i) * 20; + btnRect.right = btnRect.left + 20; + + const char *text; + switch (i) { + case kPanelGeneral: text = "G"; break; + case kPanelSettings: text = "S"; break; + default: text = "?"; break; + } + + CTextButton* changePanelButton = new CTextButton(btnRect, this, kTagFirstChangePanel + i, text); + panel->addView(changePanelButton); + + changePanelButton->setRoundRadius(0.0); + } + + panel->setVisible(currentPanel == _activePanel); + } +} + +void SfizzVstEditor::updateStateDisplay() +{ + if (!frame) + return; + + SfizzVstController* controller = getController(); + const SfizzVstState& state = controller->getSfizzState(); + const SfizzUiState& uiState = controller->getSfizzUiState(); + + if (_fileLabel) + _fileLabel->setText(("File: " + state.sfzFile).c_str()); + if (_volumeSlider) + _volumeSlider->setValue(state.volume); + if (_numVoicesSlider) + _numVoicesSlider->setValue(state.numVoices); + if (_oversamplingSlider) + _oversamplingSlider->setValue(state.oversamplingLog2); + if (_preloadSizeSlider) + _preloadSizeSlider->setValue(state.preloadSize); + + setActivePanel(uiState.activePanel); +} + +void SfizzVstEditor::setActivePanel(unsigned panelId) +{ + panelId = std::max(0, std::min(kNumPanels - 1, static_cast(panelId))); + + getController()->getSfizzUiState().activePanel = panelId; + + if (_activePanel != panelId) { + if (frame) + _subPanels[_activePanel]->setVisible(false); + + _activePanel = panelId; + + if (frame) + _subPanels[panelId]->setVisible(true); + } +} diff --git a/vst/SfizzVstEditor.h b/vst/SfizzVstEditor.h new file mode 100644 index 00000000..7ed9a4dd --- /dev/null +++ b/vst/SfizzVstEditor.h @@ -0,0 +1,78 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#pragma once +#include "SfizzVstController.h" +#include "public.sdk/source/vst/vstguieditor.h" + +using namespace Steinberg; +using namespace VSTGUI; + +class SfizzVstEditor : public Vst::VSTGUIEditor, public IControlListener, public SfizzVstController::StateListener { +public: + explicit SfizzVstEditor(void *controller); + ~SfizzVstEditor(); + + bool PLUGIN_API open(void* parent, const VSTGUI::PlatformType& platformType = VSTGUI::kDefaultNative) override; + void PLUGIN_API close() override; + + SfizzVstController* getController() const + { + return static_cast(Vst::VSTGUIEditor::getController()); + } + + // IControlListener + void valueChanged(CControl* ctl) override; + void enterOrLeaveEdit(CControl* ctl, bool enter); + void controlBeginEdit(CControl* ctl) override; + void controlEndEdit(CControl* ctl) override; + + // SfizzVstController::StateListener + void onStateChanged() override; + +private: + void chooseSfzFile(); + void loadSfzFile(const std::string& filePath); + + void createFrameContents(); + void updateStateDisplay(); + void setActivePanel(unsigned panelId); + + template + void adjustMinMaxToRangeParam(Control* c, Vst::ParamID id) + { + auto* p = static_cast(getController()->getParameterObject(id)); + c->setMin(p->getMin()); + c->setMax(p->getMax()); + } + + enum { + kPanelGeneral, + // kPanelControls, + kPanelSettings, + kNumPanels, + }; + + unsigned _activePanel = 0; + CViewContainer* _subPanels[kNumPanels] = {}; + + enum { + kTagLoadSfzFile, + kTagSetVolume, + kTagSetNumVoices, + kTagSetOversampling, + kTagSetPreloadSize, + kTagFirstChangePanel, + kTagLastChangePanel = kTagFirstChangePanel + kNumPanels - 1, + }; + + CBitmap _logo; + CTextLabel* _fileLabel = nullptr; + CSliderBase *_volumeSlider = nullptr; + CSliderBase *_numVoicesSlider = nullptr; + CSliderBase *_oversamplingSlider = nullptr; + CSliderBase *_preloadSizeSlider = nullptr; +}; diff --git a/vst/SfizzVstProcessor.cpp b/vst/SfizzVstProcessor.cpp new file mode 100644 index 00000000..ff2839fb --- /dev/null +++ b/vst/SfizzVstProcessor.cpp @@ -0,0 +1,398 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#include "SfizzVstProcessor.h" +#include "SfizzVstController.h" +#include "SfizzVstState.h" +#include "base/source/fstreamer.h" +#include "pluginterfaces/vst/ivstevents.h" +#include "pluginterfaces/vst/ivstparameterchanges.h" +#include + +#pragma message("TODO: send tempo") + +SfizzVstProcessor::SfizzVstProcessor() + : _fifoToWorker(1024) +{ + setControllerClass(SfizzVstController::cid); +} + +SfizzVstProcessor::~SfizzVstProcessor() +{ + setActive(false); // to be sure +} + +tresult PLUGIN_API SfizzVstProcessor::initialize(FUnknown* context) +{ + tresult result = AudioEffect::initialize(context); + if (result != kResultTrue) + return result; + + addAudioOutput(STR16("Audio Output"), Vst::SpeakerArr::kStereo); + addEventInput(STR16("Event Input"), 1); + + _state = SfizzVstState(); + + return result; +} + +tresult PLUGIN_API SfizzVstProcessor::setBusArrangements(Vst::SpeakerArrangement* inputs, int32 numIns, Vst::SpeakerArrangement* outputs, int32 numOuts) +{ + bool isStereo = numIns == 0 && numOuts == 1 && outputs[0] == Vst::SpeakerArr::kStereo; + + if (!isStereo) + return kResultFalse; + + return AudioEffect::setBusArrangements(inputs, numIns, outputs, numOuts); +} + +tresult PLUGIN_API SfizzVstProcessor::setState(IBStream* stream) +{ + SfizzVstState s; + + tresult r = s.load(stream); + if (r != kResultTrue) + return r; + + std::lock_guard lock(_processMutex); + _state = s; + + syncStateToSynth(); + + return r; +} + +tresult PLUGIN_API SfizzVstProcessor::getState(IBStream* stream) +{ + std::lock_guard lock(_processMutex); + return _state.store(stream); +} + +void SfizzVstProcessor::syncStateToSynth() +{ + sfz::Sfizz* synth = _synth.get(); + + if (!synth) + return; + + synth->loadSfzFile(_state.sfzFile); + synth->setVolume(_state.volume); + synth->setNumVoices(_state.numVoices); + synth->setOversamplingFactor(1 << _state.oversamplingLog2); + synth->setPreloadSize(_state.preloadSize); +} + +tresult PLUGIN_API SfizzVstProcessor::canProcessSampleSize(int32 symbolicSampleSize) +{ + if (symbolicSampleSize != Vst::kSample32) + return kResultFalse; + + return kResultTrue; +} + +tresult PLUGIN_API SfizzVstProcessor::setActive(TBool state) +{ + stopBackgroundWork(); + _synth.reset(); + + if (state) { + fprintf(stderr, "[Sfizz] new synth\n"); + sfz::Sfizz* synth = new sfz::Sfizz; + _synth.reset(synth); + + synth->setSampleRate(processSetup.sampleRate); + synth->setSamplesPerBlock(processSetup.maxSamplesPerBlock); + + syncStateToSynth(); + + _workRunning = true; + _worker = std::thread([this]() { doBackgroundWork(); }); + } + + return kResultTrue; +} + +tresult PLUGIN_API SfizzVstProcessor::process(Vst::ProcessData& data) +{ + sfz::Sfizz& synth = *_synth; + + if (Vst::IParameterChanges* pc = data.inputParameterChanges) + processParameterChanges(*pc); + + if (data.numOutputs < 1) // flush mode + return kResultTrue; + + uint32 numFrames = data.numSamples; + constexpr uint32 numChannels = 2; + float* outputs[numChannels]; + + assert(numChannels == data.outputs[0].numChannels); + + for (unsigned c = 0; c < numChannels; ++c) + outputs[c] = data.outputs[0].channelBuffers32[c]; + + std::unique_lock lock(_processMutex, std::try_to_lock); + + if (!lock.owns_lock()) { + for (unsigned c = 0; c < numChannels; ++c) + std::memset(outputs[c], 0, numFrames * sizeof(float)); + data.outputs[0].silenceFlags = 3; + return kResultTrue; + } + + if (data.processMode == Vst::kOffline) + synth.enableFreeWheeling(); + else + synth.disableFreeWheeling(); + + if (Vst::IParameterChanges* pc = data.inputParameterChanges) + processControllerChanges(*pc); + + if (Vst::IEventList* events = data.inputEvents) + processEvents(*events); + + synth.setVolume(_state.volume); + + synth.renderBlock(outputs, numFrames, numChannels); + return kResultTrue; +} + +void SfizzVstProcessor::processParameterChanges(Vst::IParameterChanges& pc) +{ + uint32 paramCount = pc.getParameterCount(); + + for (uint32 paramIndex = 0; paramIndex < paramCount; ++paramIndex) { + Vst::IParamValueQueue* vq = pc.getParameterData(paramIndex); + if (!vq) + continue; + + Vst::ParamID id = vq->getParameterId(); + uint32 pointCount = vq->getPointCount(); + int32 sampleOffset; + Vst::ParamValue value; + + switch (id) { + case kPidVolume: + if (pointCount > 0 && vq->getPoint(pointCount - 1, sampleOffset, value) == kResultTrue) + _state.volume = kParamVolumeRange.denormalize(value); + break; + case kPidNumVoices: + if (pointCount > 0 && vq->getPoint(pointCount - 1, sampleOffset, value) == kResultTrue) { + Vst::IMessage* msg = allocateMessage(); + if (!msg) + break; + msg->setMessageID("SetNumVoices"); + Vst::IAttributeList* attr = msg->getAttributes(); + attr->setInt("NumVoices", kParamNumVoicesRange.denormalize(value)); + if (!_fifoToWorker.push(msg)) { + msg->release(); + break; + } + _semaToWorker.post(); + } + break; + case kPidOversampling: + if (pointCount > 0 && vq->getPoint(pointCount - 1, sampleOffset, value) == kResultTrue) { + Vst::IMessage* msg = allocateMessage(); + if (!msg) + break; + msg->setMessageID("SetOversampling"); + Vst::IAttributeList* attr = msg->getAttributes(); + attr->setInt("Oversampling", kParamOversamplingRange.denormalize(value)); + if (!_fifoToWorker.push(msg)) { + msg->release(); + break; + } + _semaToWorker.post(); + } + break; + case kPidPreloadSize: + if (pointCount > 0 && vq->getPoint(pointCount - 1, sampleOffset, value) == kResultTrue) { + Vst::IMessage* msg = allocateMessage(); + if (!msg) + break; + msg->setMessageID("SetPreloadSize"); + Vst::IAttributeList* attr = msg->getAttributes(); + attr->setInt("PreloadSize", kParamPreloadSizeRange.denormalize(value)); + if (!_fifoToWorker.push(msg)) { + msg->release(); + break; + } + _semaToWorker.post(); + } + break; + } + } +} + +void SfizzVstProcessor::processControllerChanges(Vst::IParameterChanges& pc) +{ + sfz::Sfizz& synth = *_synth; + uint32 paramCount = pc.getParameterCount(); + + for (uint32 paramIndex = 0; paramIndex < paramCount; ++paramIndex) { + Vst::IParamValueQueue* vq = pc.getParameterData(paramIndex); + if (!vq) + continue; + + Vst::ParamID id = vq->getParameterId(); + uint32 pointCount = vq->getPointCount(); + int32 sampleOffset; + Vst::ParamValue value; + + switch (id) { + default: + if (id >= kPidMidiCC0 && id <= kPidMidiCCLast) { + int ccNumber = id - kPidMidiCC0; + for (uint32 pointIndex = 0; pointIndex < pointCount; ++pointIndex) { + if (vq->getPoint(pointIndex, sampleOffset, value) == kResultTrue) + synth.cc(sampleOffset, ccNumber, (int)(0.5 + value * 127.0)); + } + } + break; + + case kPidMidiAftertouch: + for (uint32 pointIndex = 0; pointIndex < pointCount; ++pointIndex) { + if (vq->getPoint(pointIndex, sampleOffset, value) == kResultTrue) + synth.aftertouch(sampleOffset, (int)(0.5 + value * 127.0)); + } + break; + + case kPidMidiPitchBend: + for (uint32 pointIndex = 0; pointIndex < pointCount; ++pointIndex) { + if (vq->getPoint(pointIndex, sampleOffset, value) == kResultTrue) + synth.pitchWheel(sampleOffset, (int)(0.5 + value * 16383) - 8192); + } + break; + } + } +} + +void SfizzVstProcessor::processEvents(Vst::IEventList& events) +{ + sfz::Sfizz& synth = *_synth; + uint32 numEvents = events.getEventCount(); + + for (uint32 i = 0; i < numEvents; i++) { + Vst::Event e; + if (events.getEvent(i, e) != kResultTrue) + continue; + + switch (e.type) { + case Vst::Event::kNoteOnEvent: + synth.noteOn(e.sampleOffset, e.noteOn.pitch, convertVelocityFromFloat(e.noteOn.velocity)); + break; + case Vst::Event::kNoteOffEvent: + synth.noteOff(e.sampleOffset, e.noteOff.pitch, convertVelocityFromFloat(e.noteOff.velocity)); + break; + // case Vst::Event::kPolyPressureEvent: + // synth.aftertouch(e.sampleOffset, convertVelocityFromFloat(e.polyPressure.pressure)); + // break; + } + } +} + +int SfizzVstProcessor::convertVelocityFromFloat(float x) +{ + return std::min(127, std::max(0, (int)(x * 127.0f))); +} + +tresult PLUGIN_API SfizzVstProcessor::notify(Vst::IMessage* message) +{ + tresult result = AudioEffect::notify(message); + if (result != kResultFalse) + return result; + + if (!_fifoToWorker.push(message)) + return kOutOfMemory; + + message->addRef(); + _semaToWorker.post(); + + return kResultTrue; +} + +FUnknown* SfizzVstProcessor::createInstance(void*) +{ + return static_cast(new SfizzVstProcessor); +} + +void SfizzVstProcessor::doBackgroundWork() +{ + constexpr uint32 maxPathLen = 32768; + + for (;;) { + _semaToWorker.wait(); + + if (!_workRunning) + break; + + Vst::IMessage* msg; + if (!_fifoToWorker.pop(msg)) { + fprintf(stderr, "[Sfizz] message synchronization error in worker\n"); + std::abort(); + } + + const char* id = msg->getMessageID(); + Vst::IAttributeList* attr = msg->getAttributes(); + + if (!std::strcmp(id, "LoadSfz")) { + std::vector path(maxPathLen + 1); + if (attr->getString("File", path.data(), maxPathLen) == kResultTrue) { + _state.sfzFile = Steinberg::String(path.data()).text8(); + _synth->loadSfzFile(_state.sfzFile); + } + } + else if (!std::strcmp(id, "SetNumVoices")) { + int64 value; + if (attr->getInt("NumVoices", value) == kResultTrue) { + _state.numVoices = value; + _synth->setNumVoices(value); + } + } + else if (!std::strcmp(id, "SetOversampling")) { + int64 value; + if (attr->getInt("Oversampling", value) == kResultTrue) { + _state.oversamplingLog2 = value; + _synth->setOversamplingFactor(1 << value); + } + } + else if (!std::strcmp(id, "SetPreloadSize")) { + int64 value; + if (attr->getInt("PreloadSize", value) == kResultTrue) { + _state.preloadSize = value; + _synth->setPreloadSize(value); + } + } + + msg->release(); + } +} + +void SfizzVstProcessor::stopBackgroundWork() +{ + if (!_workRunning) + return; + + _workRunning = false; + _semaToWorker.post(); + _worker.join(); + + while (_semaToWorker.try_wait()) { + Vst::IMessage* msg; + if (!_fifoToWorker.pop(msg)) { + fprintf(stderr, "[Sfizz] message synchronization error in processor\n"); + std::abort(); + } + msg->release(); + } +} + +/* + Note(jpc) Generated at random with uuidgen. + Can't find docs on it... maybe it's to register somewhere? + */ +FUID SfizzVstProcessor::cid(0xe8fab718, 0x15ed46e3, 0x8b598310, 0x1e12993f); diff --git a/vst/SfizzVstProcessor.h b/vst/SfizzVstProcessor.h new file mode 100644 index 00000000..86811e75 --- /dev/null +++ b/vst/SfizzVstProcessor.h @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#pragma once +#include "SfizzVstState.h" +#include "RTSemaphore.h" +#include "public.sdk/source/vst/vstaudioeffect.h" +#include "public.sdk/source/vst/utility/ringbuffer.h" +#include +#include +#include +#include + +using namespace Steinberg; + +class SfizzVstProcessor : public Vst::AudioEffect { +public: + SfizzVstProcessor(); + ~SfizzVstProcessor(); + + tresult PLUGIN_API initialize(FUnknown* context) override; + tresult PLUGIN_API setBusArrangements(Vst::SpeakerArrangement* inputs, int32 numIns, Vst::SpeakerArrangement* outputs, int32 numOuts) override; + + tresult PLUGIN_API setState(IBStream* stream) override; + tresult PLUGIN_API getState(IBStream* stream) override; + void syncStateToSynth(); + + tresult PLUGIN_API canProcessSampleSize(int32 symbolicSampleSize) override; + tresult PLUGIN_API setActive(TBool state) override; + tresult PLUGIN_API process(Vst::ProcessData& data) override; + void processParameterChanges(Vst::IParameterChanges& pc); + void processControllerChanges(Vst::IParameterChanges& pc); + void processEvents(Vst::IEventList& events); + static int convertVelocityFromFloat(float x); + + tresult PLUGIN_API notify(Vst::IMessage* message) override; + + static FUnknown* createInstance(void*); + + static FUID cid; + + // --- Sfizz stuff here below --- +private: + // synth state. acquire processMutex before accessing + std::unique_ptr _synth; + SfizzVstState _state; + + // worker and thread sync + std::thread _worker; + volatile bool _workRunning = false; + Steinberg::OneReaderOneWriter::RingBuffer _fifoToWorker; + RTSemaphore _semaToWorker; + std::mutex _processMutex; + + // worker + void doBackgroundWork(); + void stopBackgroundWork(); +}; diff --git a/vst/SfizzVstState.cpp b/vst/SfizzVstState.cpp new file mode 100644 index 00000000..17240921 --- /dev/null +++ b/vst/SfizzVstState.cpp @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#include "SfizzVstState.h" +#include +#include +#include + +tresult SfizzVstState::load(IBStream* state) +{ + IBStreamer s(state, kLittleEndian); + + uint64 version = 0; + if (!s.readInt64u(version)) + return kResultFalse; + + if (const char* str = s.readStr8()) + sfzFile = str; + else + return kResultFalse; + + if (!s.readFloat(volume)) + return kResultFalse; + + if (!s.readInt32(numVoices)) + return kResultFalse; + + if (!s.readInt32(oversamplingLog2)) + return kResultFalse; + + if (!s.readInt32(preloadSize)) + return kResultFalse; + + return kResultTrue; +} + +tresult SfizzVstState::store(IBStream* state) const +{ + IBStreamer s(state, kLittleEndian); + + if (!s.writeInt64u(currentStateVersion)) + return kResultFalse; + + if (!s.writeStr8(sfzFile.c_str())) + return kResultFalse; + + if (!s.writeFloat(volume)) + return kResultFalse; + + if (!s.writeInt32(numVoices)) + return kResultFalse; + + if (!s.writeInt32(oversamplingLog2)) + return kResultFalse; + + if (!s.writeInt32(preloadSize)) + return kResultFalse; + + return kResultTrue; +} + +tresult SfizzUiState::load(IBStream* state) +{ + IBStreamer s(state, kLittleEndian); + + uint64 version = 0; + if (!s.readInt64u(version)) + return kResultFalse; + + if (!s.readInt32u(activePanel)) + return kResultFalse; + + return kResultTrue; +} + +tresult SfizzUiState::store(IBStream* state) const +{ + IBStreamer s(state, kLittleEndian); + + if (!s.writeInt64u(currentStateVersion)) + return kResultFalse; + + if (!s.writeInt32u(activePanel)) + return kResultFalse; + + return kResultTrue; +} diff --git a/vst/SfizzVstState.h b/vst/SfizzVstState.h new file mode 100644 index 00000000..5f3a0fb0 --- /dev/null +++ b/vst/SfizzVstState.h @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#pragma once +#include "base/source/fstreamer.h" +#include "public.sdk/source/vst/vstparameters.h" +#include + +using namespace Steinberg; + +// number of MIDI CC +enum { + kNumControllerParams = 128, +}; + +// parameters +enum { + kPidVolume, + kPidNumVoices, + kPidOversampling, + kPidPreloadSize, + kPidMidiAftertouch, + kPidMidiPitchBend, + kPidMidiCC0, + kPidMidiCCLast = kPidMidiCC0 + kNumControllerParams - 1, + /* Reserved */ +}; + +class SfizzVstState { +public: + std::string sfzFile; + float volume = 0; + int32 numVoices = 64; + int32 oversamplingLog2 = 0; + int32 preloadSize = 8192; + + static constexpr uint64 currentStateVersion = 0; + + tresult load(IBStream* state); + tresult store(IBStream* state) const; +}; + +class SfizzUiState { +public: + uint32 activePanel = 0; + + static constexpr uint64 currentStateVersion = 0; + + tresult load(IBStream* state); + tresult store(IBStream* state) const; +}; + +struct SfizzParameterRange { + float def = 0.0; + float min = 0.0; + float max = 1.0; + + constexpr SfizzParameterRange() {} + constexpr SfizzParameterRange(float def, float min, float max) : def(def), min(min), max(max) {} + + constexpr float normalize(float x) const noexcept + { + return (x - min) / (max - min); + } + + constexpr float denormalize(float x) const noexcept + { + return min + x * (max - min); + } + + Vst::RangeParameter* createParameter(const Vst::TChar *title, Vst::ParamID tag, const Vst::TChar *units = nullptr, int32 stepCount = 0, int32 flags = Vst::ParameterInfo::kCanAutomate, Vst::UnitID unitID = Vst::kRootUnitId, const Vst::TChar *shortTitle = nullptr) const + { + return new Vst::RangeParameter(title, tag, units, min, max, def, stepCount, flags, unitID, shortTitle); + } +}; + +static constexpr SfizzParameterRange kParamVolumeRange(0.0, -60.0, +6.0); +static constexpr SfizzParameterRange kParamNumVoicesRange(64.0, 1.0, 256.0); +static constexpr SfizzParameterRange kParamOversamplingRange(0.0, 0.0, 3.0); +static constexpr SfizzParameterRange kParamPreloadSizeRange(8192.0, 1024.0, 65536.0); diff --git a/vst/VstPluginDefs.h.in b/vst/VstPluginDefs.h.in new file mode 100644 index 00000000..c67283d8 --- /dev/null +++ b/vst/VstPluginDefs.h.in @@ -0,0 +1,11 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#define VSTPLUGIN_NAME "@VSTPLUGIN_NAME@" +#define VSTPLUGIN_VENDOR "@VSTPLUGIN_VENDOR@" +#define VSTPLUGIN_URL "@VSTPLUGIN_URL@" +#define VSTPLUGIN_EMAIL "@VSTPLUGIN_EMAIL@" +#define VSTPLUGIN_VERSION "@PROJECT_VERSION@" diff --git a/vst/VstPluginFactory.cpp b/vst/VstPluginFactory.cpp new file mode 100644 index 00000000..cda0d7f3 --- /dev/null +++ b/vst/VstPluginFactory.cpp @@ -0,0 +1,49 @@ +// SPDX-License-Identifier: BSD-2-Clause + +// This code is part of the sfizz library and is licensed under a BSD 2-clause +// license. You should have receive a LICENSE.md file along with the code. +// If not, contact the sfizz maintainers at https://github.com/sfztools/sfizz + +#include "SfizzVstProcessor.h" +#include "SfizzVstController.h" +#include "VstPluginDefs.h" +#include "public.sdk/source/main/pluginfactory.h" +#include "pluginterfaces/vst/ivstcomponent.h" +#include "pluginterfaces/vst/ivstaudioprocessor.h" +#include "pluginterfaces/vst/ivsteditcontroller.h" + +BEGIN_FACTORY_DEF(VSTPLUGIN_VENDOR, + VSTPLUGIN_URL, + "mailto:" VSTPLUGIN_EMAIL) + +DEF_CLASS2 (INLINE_UID_FROM_FUID(SfizzVstProcessor::cid), + PClassInfo::kManyInstances, + kVstAudioEffectClass, + VSTPLUGIN_NAME, + Vst::kDistributable, + Vst::PlugType::kInstrumentSynth, + VSTPLUGIN_VERSION, + kVstVersionString, + SfizzVstProcessor::createInstance) + +DEF_CLASS2 (INLINE_UID_FROM_FUID(SfizzVstController::cid), + PClassInfo::kManyInstances, + kVstComponentControllerClass, + VSTPLUGIN_NAME, + 0, // not used here + "", // not used here + VSTPLUGIN_VERSION, + kVstVersionString, + SfizzVstController::createInstance) + +END_FACTORY + +bool InitModule() +{ + return true; +} + +bool DeinitModule() +{ + return true; +} diff --git a/vst/cmake/Vst3.cmake b/vst/cmake/Vst3.cmake new file mode 100644 index 00000000..544a34e6 --- /dev/null +++ b/vst/cmake/Vst3.cmake @@ -0,0 +1,275 @@ +find_package(Threads REQUIRED) + +# --- VST3SDK --- +function(plugin_add_vst3sdk NAME) + target_sources("${NAME}" PRIVATE + "${VST3SDK_BASEDIR}/base/source/baseiids.cpp" + "${VST3SDK_BASEDIR}/base/source/fbuffer.cpp" + "${VST3SDK_BASEDIR}/base/source/fdebug.cpp" + "${VST3SDK_BASEDIR}/base/source/fdynlib.cpp" + "${VST3SDK_BASEDIR}/base/source/fobject.cpp" + "${VST3SDK_BASEDIR}/base/source/fstreamer.cpp" + "${VST3SDK_BASEDIR}/base/source/fstring.cpp" + # "${VST3SDK_BASEDIR}/base/source/timer.cpp" + "${VST3SDK_BASEDIR}/base/source/updatehandler.cpp" + "${VST3SDK_BASEDIR}/base/thread/source/fcondition.cpp" + "${VST3SDK_BASEDIR}/base/thread/source/flock.cpp" + "${VST3SDK_BASEDIR}/pluginterfaces/base/conststringtable.cpp" + "${VST3SDK_BASEDIR}/pluginterfaces/base/coreiids.cpp" + "${VST3SDK_BASEDIR}/pluginterfaces/base/funknown.cpp" + "${VST3SDK_BASEDIR}/pluginterfaces/base/ustring.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/common/commoniids.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/common/pluginview.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/main/pluginfactory.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/vst/vstaudioeffect.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/vst/vstbus.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/vst/vstcomponent.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/vst/vstcomponentbase.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/vst/vsteditcontroller.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/vst/vstinitiids.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/vst/vstnoteexpressiontypes.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/vst/vstparameters.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/vst/vstpresetfile.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/vst/vstrepresentation.cpp") + if(WIN32) + target_sources("${NAME}" PRIVATE + "${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_win32.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/vst/vstgui_win32_bundle_support.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/main/dllmain.cpp") + elseif(APPLE) + target_sources("${NAME}" PRIVATE + "${VST3SDK_BASEDIR}/public.sdk/source/main/macmain.cpp") + else() + target_sources("${NAME}" PRIVATE + "${VST3SDK_BASEDIR}/public.sdk/source/common/threadchecker_linux.cpp" + "${VST3SDK_BASEDIR}/public.sdk/source/main/linuxmain.cpp") + endif() + target_include_directories("${NAME}" PRIVATE "${VST3SDK_BASEDIR}") + target_link_libraries("${NAME}" PRIVATE Threads::Threads) + if(MINGW) + target_compile_definitions("${NAME}" PRIVATE + "_NATIVE_WCHAR_T_DEFINED=1" "__wchar_t=wchar_t") + endif() + + if(${CMAKE_BUILD_TYPE} MATCHES "Debug") + target_compile_definitions("${NAME}" PRIVATE "DEVELOPMENT") + endif() + + if(${CMAKE_BUILD_TYPE} MATCHES "Release") + target_compile_definitions("${NAME}" PRIVATE "RELEASE") + endif() +endfunction() + +# --- VSTGUI --- +function(plugin_add_vstgui NAME) + target_sources("${NAME}" PRIVATE + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/animation/animations.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/animation/animator.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/animation/timingfunctions.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cbitmap.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cbitmapfilter.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/ccolor.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cdatabrowser.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cdrawcontext.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cdrawmethods.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cdropsource.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cfileselector.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cfont.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cframe.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cgradientview.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cgraphicspath.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/clayeredviewcontainer.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/clinestyle.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/coffscreencontext.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cautoanimation.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cbuttons.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/ccolorchooser.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/ccontrol.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cfontchooser.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cknob.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/clistcontrol.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cmoviebitmap.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cmoviebutton.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/coptionmenu.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cparamdisplay.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cscrollbar.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/csearchtextedit.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/csegmentbutton.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cslider.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cspecialdigit.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/csplashscreen.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cstringlist.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cswitch.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/ctextedit.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/ctextlabel.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cvumeter.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/controls/cxypad.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/copenglview.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cpoint.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/crect.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/crowcolumnview.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cscrollview.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cshadowviewcontainer.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/csplitview.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cstring.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/ctabview.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/ctooltipsupport.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cview.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cviewcontainer.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/cvstguitimer.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/genericstringlistdatabrowsersource.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/genericoptionmenu.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/vstguidebug.cpp") + + if(WIN32) + target_sources("${NAME}" PRIVATE + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/fileresourceinputstream.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/direct2d/d2dbitmap.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/direct2d/d2ddrawcontext.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/direct2d/d2dfont.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/direct2d/d2dgraphicspath.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32datapackage.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32dragging.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32frame.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32openglview.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32optionmenu.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32support.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/win32textedit.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/winfileselector.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/winstring.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/win32/wintimer.cpp") + elseif(APPLE) + target_sources("${NAME}" PRIVATE + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/fileresourceinputstream.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/genericoptionmenu.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/generictextedit.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/carbon/hiviewframe.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/carbon/hiviewoptionmenu.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/carbon/hiviewtextedit.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/caviewlayer.mm" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cfontmac.mm" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cgbitmap.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cgdrawcontext.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/autoreleasepool.mm" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/cocoahelpers.mm" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/cocoaopenglview.mm" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/cocoatextedit.mm" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/nsviewdraggingsession.mm" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/nsviewframe.mm" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/cocoa/nsviewoptionmenu.mm" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/macclipboard.mm" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/macfileselector.mm" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/macglobals.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/macstring.mm" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/mactimer.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/mac/quartzgraphicspath.cpp") + else() + target_sources("${NAME}" PRIVATE + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/fileresourceinputstream.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/common/generictextedit.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/cairobitmap.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/cairocontext.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/cairofont.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/cairogradient.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/cairopath.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/linuxstring.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/x11fileselector.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/x11frame.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/x11platform.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/x11timer.cpp" + "${VST3SDK_BASEDIR}/vstgui4/vstgui/lib/platform/linux/x11utils.cpp") + endif() + + target_include_directories("${NAME}" PRIVATE "${VST3SDK_BASEDIR}/vstgui4") + + if(WIN32) + target_compile_definitions("${NAME}" PRIVATE "NOMINMAX=1") + if (NOT MSVC) + # autolinked on MSVC with pragmas + find_library(OPENGL32_LIBRARY "opengl32") + find_library(D2D1_LIBRARY "d2d1") + find_library(DWRITE_LIBRARY "dwrite") + find_library(DWMAPI_LIBRARY "dwmapi") + find_library(WINDOWSCODECS_LIBRARY "windowscodecs") + find_library(SHLWAPI_LIBRARY "shlwapi") + target_link_libraries("${NAME}" PRIVATE + "${OPENGL32_LIBRARY}" + "${D2D1_LIBRARY}" + "${DWRITE_LIBRARY}" + "${DWMAPI_LIBRARY}" + "${WINDOWSCODECS_LIBRARY}" + "${SHLWAPI_LIBRARY}") + endif() + elseif(APPLE) + find_library(APPLE_COREFOUNDATION_LIBRARY "CoreFoundation") + find_library(APPLE_COCOA_LIBRARY "Cocoa") + find_library(APPLE_OPENGL_LIBRARY "OpenGL") + find_library(APPLE_ACCELERATE_LIBRARY "Accelerate") + find_library(APPLE_QUARTZCORE_LIBRARY "QuartzCore") + find_library(APPLE_CARBON_LIBRARY "Carbon") + target_link_libraries("${NAME}" PRIVATE + "${APPLE_COREFOUNDATION_LIBRARY}" + "${APPLE_COCOA_LIBRARY}" + "${APPLE_OPENGL_LIBRARY}" + "${APPLE_ACCELERATE_LIBRARY}" + "${APPLE_QUARTZCORE_LIBRARY}" + "${APPLE_CARBON_LIBRARY}") + else() + find_package(X11 REQUIRED) + find_package(Freetype REQUIRED) + find_package(PkgConfig REQUIRED) + pkg_check_modules(LIBXCB REQUIRED xcb) + pkg_check_modules(LIBXCB_UTIL REQUIRED xcb-util) + pkg_check_modules(LIBXCB_CURSOR REQUIRED xcb-cursor) + pkg_check_modules(LIBXCB_KEYSYMS REQUIRED xcb-keysyms) + pkg_check_modules(LIBXCB_XKB REQUIRED xcb-xkb) + pkg_check_modules(LIBXKB_COMMON REQUIRED xkbcommon) + pkg_check_modules(LIBXKB_COMMON_X11 REQUIRED xkbcommon-x11) + pkg_check_modules(CAIRO REQUIRED cairo) + pkg_check_modules(FONTCONFIG REQUIRED fontconfig) + target_include_directories("${NAME}" PRIVATE + ${X11_INCLUDE_DIRS} + ${FREETYPE_INCLUDE_DIRS} + ${LIBXCB_INCLUDE_DIRS} + ${LIBXCB_UTIL_INCLUDE_DIRS} + ${LIBXCB_CURSOR_INCLUDE_DIRS} + ${LIBXCB_KEYSYMS_INCLUDE_DIRS} + ${LIBXCB_XKB_INCLUDE_DIRS} + ${LIBXKB_COMMON_INCLUDE_DIRS} + ${LIBXKB_COMMON_X11_INCLUDE_DIRS} + ${CAIRO_INCLUDE_DIRS} + ${FONTCONFIG_INCLUDE_DIRS}) + target_link_libraries("${NAME}" PRIVATE + ${X11_LIBRARIES} + ${FREETYPE_LIBRARIES} + ${LIBXCB_LIBRARIES} + ${LIBXCB_UTIL_LIBRARIES} + ${LIBXCB_CURSOR_LIBRARIES} + ${LIBXCB_KEYSYMS_LIBRARIES} + ${LIBXCB_XKB_LIBRARIES} + ${LIBXKB_COMMON_LIBRARIES} + ${LIBXKB_COMMON_X11_LIBRARIES} + ${CAIRO_LIBRARIES} + ${FONTCONFIG_LIBRARIES}) + find_library(DL_LIBRARY "dl") + if(DL_LIBRARY) + target_link_libraries("${NAME}" PRIVATE "${DL_LIBRARY}") + endif() + endif() + + target_sources("${NAME}" PRIVATE + "${VST3SDK_BASEDIR}/public.sdk/source/vst/vstguieditor.cpp") + + target_include_directories("${NAME}" PRIVATE + external/steinberg/src) + + target_compile_definitions("${NAME}" PRIVATE "SMTG_MODULE_IS_BUNDLE=1") + + if(${CMAKE_BUILD_TYPE} MATCHES "Debug") + target_compile_definitions("${NAME}" PRIVATE "DEVELOPMENT") + endif() + + if(${CMAKE_BUILD_TYPE} MATCHES "Release") + target_compile_definitions("${NAME}" PRIVATE "RELEASE") + endif() +endfunction() diff --git a/vst/external/steinberg/LICENSE b/vst/external/steinberg/LICENSE new file mode 100644 index 00000000..a75f1d5b --- /dev/null +++ b/vst/external/steinberg/LICENSE @@ -0,0 +1,27 @@ +//----------------------------------------------------------------------------- +// VSTGUI LICENSE +// (c) 2018, Steinberg Media Technologies, All Rights Reserved +//----------------------------------------------------------------------------- +// Redistribution and use in source and binary forms, with or without modification, +// are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright notice, +// this list of conditions and the following disclaimer in the documentation +// and/or other materials provided with the distribution. +// * Neither the name of the Steinberg Media Technologies nor the names of its +// contributors may be used to endorse or promote products derived from this +// software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +// INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +// OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED +// OF THE POSSIBILITY OF SUCH DAMAGE. +//----------------------------------------------------------------------------- diff --git a/vst/external/steinberg/src/x11runloop.h b/vst/external/steinberg/src/x11runloop.h new file mode 100644 index 00000000..7cece455 --- /dev/null +++ b/vst/external/steinberg/src/x11runloop.h @@ -0,0 +1,110 @@ +#include "vstgui/lib/platform/linux/x11frame.h" +#include "pluginterfaces/gui/iplugview.h" +#include "base/source/fstring.h" + +namespace VSTGUI { + +// Map Steinberg Vst Interface to VSTGUI Interface +class RunLoop : public X11::IRunLoop, public AtomicReferenceCounted +{ +public: + struct EventHandler : Steinberg::Linux::IEventHandler, public Steinberg::FObject + { + X11::IEventHandler* handler {nullptr}; + + void PLUGIN_API onFDIsSet (Steinberg::Linux::FileDescriptor) override + { + if (handler) + handler->onEvent (); + } + DELEGATE_REFCOUNT (Steinberg::FObject) + DEFINE_INTERFACES + DEF_INTERFACE (Steinberg::Linux::IEventHandler) + END_DEFINE_INTERFACES (Steinberg::FObject) + }; + struct TimerHandler : Steinberg::Linux::ITimerHandler, public Steinberg::FObject + { + X11::ITimerHandler* handler {nullptr}; + + void PLUGIN_API onTimer () final + { + if (handler) + handler->onTimer (); + } + DELEGATE_REFCOUNT (Steinberg::FObject) + DEFINE_INTERFACES + DEF_INTERFACE (Steinberg::Linux::ITimerHandler) + END_DEFINE_INTERFACES (Steinberg::FObject) + }; + + bool registerEventHandler (int fd, X11::IEventHandler* handler) final + { + if(!runLoop) + return false; + + auto smtgHandler = Steinberg::owned (new EventHandler ()); + smtgHandler->handler = handler; + if (runLoop->registerEventHandler (smtgHandler, fd) == Steinberg::kResultTrue) + { + eventHandlers.push_back (smtgHandler); + return true; + } + return false; + } + bool unregisterEventHandler (X11::IEventHandler* handler) final + { + if(!runLoop) + return false; + + for (auto it = eventHandlers.begin (), end = eventHandlers.end (); it != end; ++it) + { + if ((*it)->handler == handler) + { + runLoop->unregisterEventHandler ((*it)); + eventHandlers.erase (it); + return true; + } + } + return false; + } + bool registerTimer (uint64_t interval, X11::ITimerHandler* handler) final + { + if(!runLoop) + return false; + + auto smtgHandler = Steinberg::owned (new TimerHandler ()); + smtgHandler->handler = handler; + if (runLoop->registerTimer (smtgHandler, interval) == Steinberg::kResultTrue) + { + timerHandlers.push_back (smtgHandler); + return true; + } + return false; + } + bool unregisterTimer (X11::ITimerHandler* handler) final + { + if(!runLoop) + return false; + + for (auto it = timerHandlers.begin (), end = timerHandlers.end (); it != end; ++it) + { + if ((*it)->handler == handler) + { + runLoop->unregisterTimer ((*it)); + timerHandlers.erase (it); + return true; + } + } + return false; + } + + RunLoop (Steinberg::FUnknown* runLoop) : runLoop (runLoop) {} +private: + using EventHandlers = std::vector>; + using TimerHandlers = std::vector>; + EventHandlers eventHandlers; + TimerHandlers timerHandlers; + Steinberg::FUnknownPtr runLoop; +}; + +} // namespace diff --git a/vst/gpl-3.0.txt b/vst/gpl-3.0.txt new file mode 100644 index 00000000..f288702d --- /dev/null +++ b/vst/gpl-3.0.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/vst/mac/Info.plist b/vst/mac/Info.plist new file mode 100644 index 00000000..fe09355f --- /dev/null +++ b/vst/mac/Info.plist @@ -0,0 +1,24 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + @SFIZZ_VST3_BUNDLE_EXECUTABLE@ + CFBundleIconFile + Plugin.icns + CFBundleIdentifier + tools.sfz.sfizz + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + BNDL + CFBundleSignature + ???? + CFBundleVersion + @SFIZZ_VST3_BUNDLE_VERSION@ + CSResourcesFileMapped + + + diff --git a/vst/mac/PkgInfo b/vst/mac/PkgInfo new file mode 100644 index 00000000..19a9cf67 --- /dev/null +++ b/vst/mac/PkgInfo @@ -0,0 +1 @@ +BNDL???? \ No newline at end of file diff --git a/vst/mac/Plugin.icns b/vst/mac/Plugin.icns new file mode 100644 index 00000000..f8ce53c4 Binary files /dev/null and b/vst/mac/Plugin.icns differ diff --git a/vst/resources/logo.png b/vst/resources/logo.png new file mode 100644 index 00000000..e67a60a3 Binary files /dev/null and b/vst/resources/logo.png differ diff --git a/vst/resources/logo.svg b/vst/resources/logo.svg new file mode 100644 index 00000000..f4a65f2c --- /dev/null +++ b/vst/resources/logo.svg @@ -0,0 +1,78 @@ + + + + +Created by potrace 1.11, written by Peter Selinger 2001-2013 + + + + + + + + + + diff --git a/vst/vst3.def b/vst/vst3.def new file mode 100644 index 00000000..279a6a5c --- /dev/null +++ b/vst/vst3.def @@ -0,0 +1,4 @@ +EXPORTS + GetPluginFactory + InitDll + ExitDll diff --git a/vst/vst3.version b/vst/vst3.version new file mode 100644 index 00000000..f86d95c3 --- /dev/null +++ b/vst/vst3.version @@ -0,0 +1,7 @@ +VST3ABI_1.0 { + global: + *GetPluginFactory*; + *ModuleEntry*; + *ModuleExit*; + local: *; +}; diff --git a/vst/win/Plugin.ico b/vst/win/Plugin.ico new file mode 100644 index 00000000..51656576 Binary files /dev/null and b/vst/win/Plugin.ico differ diff --git a/vst/win/desktop.ini b/vst/win/desktop.ini new file mode 100644 index 00000000..be3001a9 --- /dev/null +++ b/vst/win/desktop.ini @@ -0,0 +1,2 @@ +[.ShellClassInfo] +IconResource=Plugin.ico,0