diff --git a/.gitignore b/.gitignore index 5fb95eb..de73544 100755 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ build +vst3sdk Makefile CMakeCache.txt CMakeFiles diff --git a/CMakeLists.txt b/CMakeLists.txt index 428c02a..778b385 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,14 +8,15 @@ set(CMAKE_COLOR_MAKEFILE ON) # uncomment to build as VST2.4 instead of VST3.0 (provides wider DAW compatibility), not supported on Linux #set(SMTG_CREATE_VST2_VERSION "Use VST2" ON) -project(transformant) +project(Transformant) set(PROJECT_VERSION 1) set(target transformant) -set(copyright "igorski.nl 2020-2023") +set(copyright "igorski.nl 2020-2024") set(major_version 1) set(minor_version 0) set(release_number 4) set(build_number 1) # TODO supply through CLI (build number is not included in public facing version strings) +set(version_string "${major_version}.${minor_version}.${release_number}") # also see audiounitconfig.h#kAUcomponentVersion and related Info.plist set(SMTG_CREATE_MODULE_INFO false) ##################### @@ -35,16 +36,18 @@ if(MSVC) endif() if(UNIX) - if(XCODE) - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++17") - set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") - elseif(APPLE) - set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -stdlib=libc++") - link_libraries(c++) - # support Yosemite and up - set(CMAKE_OSX_SYSROOT macosx10.13) - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13") + if(APPLE) + if (XCODE) + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LANGUAGE_STANDARD "c++17") + set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") + else() + set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -stdlib=libc++") + link_libraries(c++) + endif() + # support Yosemite and up + set(CMAKE_OSX_SYSROOT macosx10.13) + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13") else() set(LINUX true) add_definitions( -D__cdecl= ) @@ -64,24 +67,23 @@ endif() list(APPEND CMAKE_MODULE_PATH "${VST3_SDK_ROOT}/cmake/modules") -include(SMTG_Global) +# include(SMTG_AAXSupport) include(SMTG_AddVST3Library) +include(SMTG_AddVST3Options) include(SMTG_Bundle) +include(SMTG_CoreAudioSupport) include(SMTG_ExportedSymbols) -include(SMTG_PrefixHeader) +include(SMTG_Global) include(SMTG_PlatformIOS) include(SMTG_PlatformToolset) -include(SMTG_CoreAudioSupport) -include(SMTG_AAXSupport) -include(SMTG_VstGuiSupport) +include(SMTG_PrefixHeader) include(SMTG_UniversalBinary) -include(SMTG_AddVST3Options) +include(SMTG_VstGuiSupport) ######################### # Steinberg VST sources # ######################### -set(VSTSDK_INCLUDE_DIR ${VST3_SDK_ROOT}) set(VSTSDK_PLUGIN_SOURCE ${VST3_SDK_ROOT}/public.sdk/source/common/commoniids.cpp ${VST3_SDK_ROOT}/public.sdk/source/vst/vstaudioeffect.cpp @@ -154,60 +156,17 @@ set(vst_resources ) set(vst_ui_descr "resource/plugin.uidesc") -############## -# Audio Unit # -############## - -if (JAMBA_ENABLE_AUDIO_UNIT) - set(JAMBA_TEST_CASES_DIR "${JAMBA_ROOT}/test/cpp") - set(JAMBA_TEST_CASES_SOURCES - ${JAMBA_TEST_CASES_DIR}/pongasoft/Utils/Collection/test-CircularBuffer.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/Utils/Concurrent/test-concurrent.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/Utils/Concurrent/test-concurrent_lockfree.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/Utils/test-Lerp.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/Utils/test-StringUtils.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/VST/GUI/Params/test-GUIParameters.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/VST/GUI/Params/test-ParamAware.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/VST/GUI/Views/test-CustomViewCreator.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/VST/GUI/Views/test-SelfContainedViewListener.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/VST/test-AudioBuffers.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/VST/test-AudioUtils.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/VST/test-ParamConverters.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/VST/test-SampleRateBasedClock.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/VST/Utils/test-Utils.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/VST/Utils/test-FastWriteMemoryStream.cpp - ${JAMBA_TEST_CASES_DIR}/pongasoft/VST/Utils/test-ReadOnlyMemoryStream.cpp - ) - - include(jamba.cmake) - set(CPP_SOURCES src) - - configure_file(${CPP_SOURCES}/version.h ${CMAKE_BINARY_DIR}/generated/version.h) - include_directories(${CMAKE_BINARY_DIR}/generated/) - - jamba_add_vst_plugin( - TARGET "${target}" - RELEASE_FILENAME "${target}.component" - TARGETS_PREFIX "jmb_" - VST_SOURCES "${vst_sources}" - UIDESC "${vst_ui_descr}" - RESOURCES "${vst_resources}" - TEST_CASE_SOURCES "${JAMBA_TEST_CASES_SOURCES}" - TEST_LINK_LIBRARIES "jamba" - ) - -else() - ####### # VST # ####### smtg_add_vst3plugin(${target} ${vst_sources}) +smtg_target_configure_version_file(${target}) ## include Steinberg libraries -set(steinberg_libs "base" "pluginterfaces" "sdk" "vstgui_support" "vstgui_uidescription" "vstgui") -include_directories(${VSTSDK_INCLUDE_DIR}) +set(steinberg_libs "base" "pluginterfaces" "sdk" "vstgui" "vstgui_support" "vstgui_uidescription") +include_directories(${VST3_SDK_ROOT}) foreach(lib IN ITEMS ${steinberg_libs}) if(UNIX) target_link_libraries(${target} PRIVATE ${VST3_SDK_ROOT}/build/lib/Release/lib${lib}.a) @@ -230,32 +189,9 @@ target_sources(${target} PRIVATE IF (APPLE) target_sources (${target} PRIVATE ${VST3_SDK_ROOT}/public.sdk/source/main/macmain.cpp - ${VST3_SDK_ROOT}/vstgui4/vstgui/vstgui_mac.mm ) if(XCODE) - if(SMTG_IOS_DEVELOPMENT_TEAM) - ## iOS plugin - set(target ${target}_ios) - smtg_add_ios_vst3plugin("${SMTG_CODE_SIGN_IDENTITY_IOS}" ${target} "${target}" "${vst_sources}") - set_target_properties(${target} PROPERTIES ${SDK_IDE_PLUGIN_EXAMPLES_FOLDER}) - target_link_libraries(${target} PRIVATE - base_ios - sdk_ios - "-framework UIKit" - "-framework CoreGraphics" - "-framework QuartzCore" - "-framework CoreText" - "-framework Accelerate" - "-framework ImageIO" - "-framework MobileCoreServices" - ) - target_sources(${target} PRIVATE - ${VST3_SDK_ROOT}/vstgui4/vstgui/vstgui_ios.mm - ) - else() - ## macOS plugin - target_link_libraries(${target} PRIVATE "-framework Cocoa" "-framework OpenGL" "-framework Accelerate" "-framework QuartzCore" "-framework Carbon") - endif() + target_link_libraries(${target} PRIVATE "-framework Cocoa" "-framework OpenGL" "-framework Accelerate" "-framework QuartzCore" "-framework Carbon") else() find_library(COREFOUNDATION_FRAMEWORK CoreFoundation) find_library(COCOA_FRAMEWORK Cocoa) @@ -271,10 +207,10 @@ IF (APPLE) BUNDLE_EXTENSION "vst3" XCODE_ATTRIBUTE_WRAPPER_EXTENSION "vst3" MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/mac/Info.plist" - MACOSX_BUNDLE_BUNDLE_NAME "${project}" + MACOSX_BUNDLE_BUNDLE_NAME "${target}" MACOSX_BUNDLE_GUI_IDENTIFIER "nl.igorski.vst.${target}" MACOSX_BUNDLE_ICON_FILE "" - MACOSX_BUNDLE_SHORT_VERSION_STRING "${major_version}.${minor_version}.${release_number}" + MACOSX_BUNDLE_SHORT_VERSION_STRING "${version_string}" MACOSX_BUNDLE_COPYRIGHT "${copyright}" ) endif() @@ -317,7 +253,7 @@ endif() ## Include Windows specific libraries if(WIN) - target_sources (${target} PRIVATE + target_sources(${target} PRIVATE ${VST3_SDK_ROOT}/public.sdk/source/main/dllmain.cpp # ${VST3_SDK_ROOT}/vstgui4/vstgui/vstgui_win32.cpp ) @@ -330,15 +266,29 @@ smtg_target_add_plugin_resources(${target} ) if(APPLE) - smtg_target_set_bundle(${target} INFOPLIST "${CMAKE_CURRENT_SOURCE_DIR}/mac/Info.plist" PREPROCESS) - # adding PkgInfo at root level makes plugin appear as a file instead of folder - smtg_target_add_plugin_resources(${target} RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/mac/PkgInfo" OUTPUT_SUBDIRECTORY "../") + ############## + # Audio Unit # + ############## + if (XCODE AND SMTG_CREATE_AU_VERSION) + message(STATUS "SMTG_CREATE_AU_VERSION is set. An Audio Unit version of the plug-in will be created.") + smtg_target_codesign(${target} ${SMTG_IOS_DEVELOPMENT_TEAM} ${SMTG_CODE_SIGN_IDENTITY_MAC}) + add_subdirectory(mac/audio-unit) + create_audio_unit(${target}) + else() + smtg_target_set_bundle(${target} INFOPLIST "${CMAKE_CURRENT_SOURCE_DIR}/mac/Info.plist" PREPROCESS) + # adding PkgInfo at root level makes plugin appear as a file instead of folder + smtg_target_add_plugin_resources(${target} RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/mac/PkgInfo" OUTPUT_SUBDIRECTORY "../") + endif() + smtg_target_set_bundle(${target} + BUNDLE_IDENTIFIER "nl.igorski.${target}" + COMPANY_NAME "igorski.nl" + ) elseif(WIN) target_sources(${target} PRIVATE resource/plugin.rc) endif() if (SMTG_CREATE_VST2_VERSION) - message(STATUS "SMTG_CREATE_VST2_VERSION is set. A VST 2 version of the plug-in will be created (just rename the generated file from .vst3 to .vst).") + message(STATUS "SMTG_CREATE_VST2_VERSION is set. A VST 2 version of the plug-in will be created.") if(XCODE) # fix missing VSTPluginMain symbol when also building VST 2 version set_target_properties(${target} PROPERTIES XCODE_ATTRIBUTE_EXPORTED_SYMBOLS_FILE "") @@ -348,26 +298,24 @@ if (SMTG_CREATE_VST2_VERSION) endif() endif() -endif() - ###################### # Installation paths # ###################### if(APPLE) - install(TARGETS ${target} - DESTINATION "$ENV{HOME}/Library/Audio/Plug-Ins/VST" - ) + install(TARGETS ${target} + DESTINATION "$ENV{HOME}/Library/Audio/Plug-Ins/VST" + ) elseif(WIN32) - install(TARGETS ${target} - DESTINATION "C:/Program Files (x86)/Common Files/VST3/" - ) + install(TARGETS ${target} + DESTINATION "C:/Program Files (x86)/Common Files/VST3/" + ) elseif(WIN) - install(TARGETS ${target} - DESTINATION "C:/Program Files/Common Files/VST3/" - ) + install(TARGETS ${target} + DESTINATION "C:/Program Files/Common Files/VST3/" + ) elseif(LINUX) - install(TARGETS ${target} - DESTINATION "/usr/lib/lxvst" - ) -endif() + install(TARGETS ${target} + DESTINATION "/usr/lib/lxvst" + ) +endif() \ No newline at end of file diff --git a/README.md b/README.md index 26c8f3a..9e8e06c 100755 --- a/README.md +++ b/README.md @@ -4,71 +4,44 @@ Transformant is a VST/AU plug-in which provides a stereo formant filter effect, You can hear it being the leading effect on Drosophelia's [Detractor](https://songwhip.com/drosophelia/detractor). -## On compatibility +## Build instructions -### Build as VST 2.4 +The project uses [CMake](https://cmake.org) to generate the Makefiles and has been built and tested on macOS, Windows 10 and Linux (Ubuntu). -VST3 is great and all, but support across DAW's is poor (looking at a certain popular German product). You can however build as a VST2.4 plugin and enjoy it on a wider range of host platforms. +### Environment setup -However: as of SDK 3.6.11, Steinberg no longer packages the required _./pluginterfaces/vst2.x_-folder inside the vst3sdk folder. -If you wish to build a VST2 plugin, copying the folder from an older SDK version _could_ work (verified 3.6.9. _vst2.x_ folders to work with SDK 3.7.6), though be aware -that you _need a license to target VST2_. You can view [Steinbergs rationale on this decision here](https://www.steinberg.net/en/newsandevents/news/newsdetail/article/vst-2-coming-to-an-end-4727.html). +Apart from requiring _CMake_ and a C(++) compiler such as _Clang_ or _MSVC_, the only other dependency is the [VST SDK from Steinberg](https://www.steinberg.net/en/company/developers.html) (the projects latest update requires SDK version 3.7.11). -Once your SDK is "setup" for VST2, simply uncomment the following line in _CMakeLists.txt_: +#### Setting up the easy way : installing a local version of the Steinberg SDK -``` -set(SMTG_CREATE_VST2_VERSION "Use VST2" ON) -``` +You can instantly retrieve and build the SDK using the following commands. -And rename the generated plugin extension from _.vst3_ to _.vst_ (or _.dll_ on Windows). Alternatively, pass -"_vst2_" as an argument to the _build.sh_ and _build.bat_ files without having to edit the make file or -rename the generated VST manually. E.g.: +##### Installation on Unix: ``` -sh build.sh vst2 +sh setup.sh --platform PLATFORM ``` -### Compiling for both 32-bit and 64-bit architectures - -Depending on your host software having 32-bit or 64-bit support (either Intel or M1), you can best compile for a wider range of architectures. To do so, -replace all invocations of _cmake_ in this README with the following: +Where optional flag _--platform_ can be either `mac` or `linux` (defaults to linux). -**macOS:** +##### Installation on Windows: ``` -cmake -"DCMAKE_OSX_ARCHITECTURES=x86_64;arm64;i1386" .. +setup.bat ``` -Which will allow you to compile a single, "fat" binary that supports all architectures (Intel, M1 and legacy 32-bit Intel). +This will create a (Git ignored) subfolder in this repository folder with a prebuilt Steinberg SDK. -**Windows:** +#### Setting up the flexible way : pointing towards an external SDK build / supporting VST2 -``` -cmake.exe -G "Visual Studio 16 2019" -A Win64 -S .. -B "build64" -cmake.exe --build . --config Release +In case you wish to use a different SDK version (for instance to reuse an existing build elsewhere on your computer or to +target VST2 builds), you can invoke all build scripts by providing the `VST3_SDK_ROOT` environment variable, like so: -cmake.exe -G "Visual Studio 16 2019" -A Win32 -S .. -B "build32" -cmake.exe --build . --config Release +``` +VST3_SDK_ROOT=/path/to/prebuilt/VST3_SDK sh build.sh ``` -Which is a little more cumbersome as you compile separate binaries for the separate architectures. - -Note that the above also needs to be done when building the Steinberg SDK (which for the Windows build implies that a separate build is created for each architecture). - -While macOS has been fully 64-bit for the past versions, building for 32-bit provides the best backward -compatibility for older OS versions. And musicians are known to keep working systems at the cost of not -running an up to date system... - -## Build instructions - -The project uses [CMake](https://cmake.org) to generate the Makefiles and has been built and tested on macOS, Windows 10 and Linux (Ubuntu). - -### Environment setup - -Apart from requiring _CMake_ and a C(++) compiler such as _Clang_ or _MSVC_, the only other dependency is the [VST SDK from Steinberg](https://www.steinberg.net/en/company/developers.html) (the projects latest update requires SDK version 3.7.10+). - -Be aware that prior to building the plugin, the Steinberg SDK needs to be built from source as well. Following Steinbergs guidelines, the build target should be a _/build_-subfolder of the _/vst3sdk_-folder. -To generate a release build of the library, execute the following commands from the root of the Steinberg SDK folder: +After downloading the Steinberg SDK you must generate a release build of its sources. To do this, execute the following commands from the root of the Steinberg SDK folder: ``` cd vst3sdk @@ -78,10 +51,11 @@ cmake -DCMAKE_BUILD_TYPE=Release .. cmake --build . --config Release ``` -The result being that _{VST3_SDK_ROOT}/build/lib/Release/_ will contain the Steinberg VST libraries required to build the plugin. -NOTE: Windows users need to append _--config Release_ to the last cmake (build) call as the build type must be defined during this step. +The result being that `{VST3_SDK_ROOT}/build/lib/Release/` will contain the Steinberg VST libraries required to build the plugin. -If you intend to build VST2 versions as well, run the following from the root of the Steinberg SDK folder (run the _.bat_ version instead of the _.sh_ version on Windows) prior to building the library: +In case you intend to build VST2 versions as well, keep in mind that as of SDK 3.6.11, Steinberg no longer packages the required `/pluginterfaces/vst2.x`-folder inside the vst3sdk folder. If you wish to build a VST2 plugin, copying the folder from an older SDK version _could_ work (verified 3.6.9. `vst2.x` folders to work with SDK 3.7.11), though be aware that you _need a license to target VST2_. You can view [Steinbergs rationale on this decision here](https://helpcenter.steinberg.de/hc/en-us/articles/4409561018258-VST-2-Discontinued). + +To prepare for building VST2 versions of the plugin, run the following from the root of the Steinberg SDK folder (run the _.bat_ version instead of the _.sh_ version on Windows) prior to building the library: ``` ./copy_vst2_to_vst3_sdk.sh @@ -95,72 +69,104 @@ And if you are running Linux, you can easily resolve all dependencies by first r ### Building the plugin -Run CMake to generate the Makefile for your environment, after which you can compile the plugin using make. The build output will be stored in _./build/VST3/transformant.vst3_ as well as symbolically linked to your systems VST-plugin folder (on Unix). - -You must provide the path to the Steinberg SDK by providing _VST3_SDK_ROOT_ to CMake like so: - -``` -cmake -DVST3_SDK_ROOT=/path/to/VST_SDK/vst3sdk/ .. -``` +See the provided shell scripts. The build output will be stored in `./build/VST3/transformant.vst3` as well as symbolically linked to your systems VST-plugin folder (on Unix). #### Compiling on Unix systems: ``` -mkdir build -cd build -cmake -DVST3_SDK_ROOT=/path/to/VST_SDK/vst3sdk/ .. -make . +sh build.sh --type TYPE ``` +Where optional flag _--type_ can be either `vst3`, `vst2` or `au` (defaults to vst3)*. + #### Compiling on Windows: Assuming the Visual Studio Build Tools have been installed: ``` -mkdir build -cd build -cmake.exe -G"Visual Studio 16 2019" -DVST3_SDK_ROOT=/path/to/VST_SDK/vst3sdk/ .. -cmake.exe --build . +build.bat ``` -### Running the plugin +Where you can optionally append `vst2` to the command to build a VST2* plugin. -You can copy the build output into your system VST(3) folder and run it directly in a VST host / DAW of your choice. +_*As mentioned in the "setup" section, VST2 builds are not supported out-of-the-box._ -When debugging, you can also choose to run the plugin against Steinbergs validator and editor host utilities: +## On compatibility + +### Compiling for both 32-bit and 64-bit architectures + +Depending on your host software having 32-bit or 64-bit support (with the latter targeting either Intel or ARM), you can choose to compile for a wider range of architectures. To do so, updating the build shell scripts/batch files to contain the following: + +**macOS:** ``` -{VST3_SDK_ROOT}/build/bin/validator build/VST3/*.vst3 -{VST3_SDK_ROOT}/build/bin/editorhost build/VST3/transformant.vst3 +cmake -"DCMAKE_OSX_ARCHITECTURES=x86_64;arm64;i1386" .. ``` +Which will allow you to compile a single, "fat" binary that supports all architectures (Intel, ARM and legacy 32-bit Intel). Note +that by default compilation is for 64-bit architecture for both Intel and ARM CPU's, _you can likely ignore this section_. + +**Windows:** + +``` +cmake.exe -G "Visual Studio 16 2019" -A Win64 -S .. -B "build64" +cmake.exe --build build64 --config Release + +cmake.exe -G "Visual Studio 16 2019" -A Win32 -S .. -B "build32" +cmake.exe --build build32 --config Release +``` + +Which is a little more cumbersome as you compile separate binaries for the separate architectures. + +Note that the above also needs to be done when building the Steinberg SDK (which for the Windows build implies that a separate build is created for each architecture). + +While both macOS and Windows have been fully 64-bit for the past versions, building for 32-bit provides the best backward +compatibility for older OS versions. Musicians are known to keep working systems at the cost of not +running an up to date system... _still, you can likely ignore this section_. + ### Build as Audio Unit (macOS only) -For this you will need a little extra preparation while building Steinberg SDK. Additionally, you will need the -CoreAudio SDK and XCode. Execute the following instructions to build the SDK with Audio Unit support, replace `SMTG_COREAUDIO_SDK_PATH` with the actual installation location of the CoreAudio SDK: +For this you will need a little extra preparation while building Steinberg SDK as you will need the +"[CoreAudio SDK](https://developer.apple.com/library/archive/samplecode/CoreAudioUtilityClasses/Introduction/Intro.html)" and XCode. Execute the following instructions to build the SDK with Audio Unit support, +providing the appropriate path to the actual installation location of the CoreAudio SDK: ``` -cd vst3sdk -mkdir build -cd build -cmake -GXcode -DCMAKE_BUILD_TYPE=Release -DSMTG_COREAUDIO_SDK_PATH=/Library/CoreAudioSDK/CoreAudio .. -cmake --build . --config Release +sh setup.sh --platform mac --coresdk /path/to/CoreAudioUtilityClasses/CoreAudio +``` + +After which you can run the build script like so: + +``` +sh build.sh --type au ``` -Execute the following instructions to build the plugin as an Audio Unit: +The Audio Unit component will be located in `./build/bin/Release/Transformant AUv3.app` + +You can validate the Audio Unit using Apple's _auval_ utility, by running `auval -v aufx frmt IGOR` on the command line (reflecting the values defined in `audiounitconfig.h`). Note that there is the curious behaviour that you might need to reboot before the plugin shows up, though you can force a flush of the Audio Unit cache at runtime by running `killall -9 AudioComponentRegistrar`. + +In case of errors you can look for instances of [kAudioUnitErr](https://www.osstatus.com/search/results?platform=all&framework=all&search=kaudiouniterr) + +### Running the plugin -* Run _sh build_au.sh_ from the repository root, providing the path to _VST3_SDK_ROOT_ as before: +You can copy the build output into your system VST(3) folder and run it directly in a VST host / DAW of your choice. + +When debugging, you can also choose to run the plugin against Steinbergs validator and editor host utilities: ``` -VST3_SDK_ROOT=/path/to/VST_SDK/vst3sdk sh build_au.sh +{VST3_SDK_ROOT}/build/bin/validator build/VST3/transformant.vst3 +{VST3_SDK_ROOT}/build/bin/editorhost build/VST3/transformant.vst3 ``` -The subsequent Audio Unit component will be located in _./build/VST3/transformant.component_ as well as linked -in _~/Library/Audio/Plug-Ins/Components/_ +### Signing the plugin on macOS -You can validate the Audio Unit using Apple's _auval_ utility, by running _auval -v aufx frmt IGOR_ on the command line. Note that there is the curious behaviour that you might need to reboot before the plugin shows up, though you can force a flush of the Audio Unit cache at runtime by running _killall -9 AudioComponentRegistrar_. If you -experience errors testing your plugin, you can look up the [error code](https://www.osstatus.com/). +You will need to have your code signing set up appropriately. Assuming you have set up your Apple Developer account, you can find your signing identity like so: -NOTE: Updates of the Steinberg SDK have been known to break Audio Unit support. You can always try building -the plugin as part of the SDK examples (see CMakeLists.txt in audio-unit folder) when building the VST3_SDK as -that _might_ work. +``` +security find-identity -p codesigning -v +``` + +From which you can take your name and team id and pass them to the build script like so: + +``` +sh build.sh --team_id TEAM_ID --identity "YOUR_NAME" +``` \ No newline at end of file diff --git a/audio-unit/CMakeLists.txt b/audio-unit/CMakeLists.txt deleted file mode 100644 index e197812..0000000 --- a/audio-unit/CMakeLists.txt +++ /dev/null @@ -1,96 +0,0 @@ - -cmake_minimum_required(VERSION 3.15.0) - -project(smtg-vst3-au - VERSION 1.0.3.0 - DESCRIPTION "igorski.nl transformant" -) - -if(NOT SMTG_ADD_VSTGUI) - return() -endif() - -set(plugin_sources - src/global.h - src/audiobuffer.h - src/audiobuffer.cpp - src/bitcrusher.h - src/bitcrusher.cpp - src/formantfilter.h - src/formantfilter.cpp - src/lfo.h - src/lfo.cpp - src/limiter.h - src/limiter.cpp - src/paramids.h - src/pluginprocess.h - src/pluginprocess.cpp - src/vst.h - src/vst.cpp - src/vstentry.cpp - src/version.h - src/waveshaper.h - src/waveshaper.cpp - src/ui/controller.h - src/ui/controller.cpp - src/ui/uimessagecontroller.h - resource/plugin.uidesc -) -set(target transformant) - -smtg_add_vst3plugin(${target} ${plugin_sources}) -smtg_target_configure_version_file(${target}) - -#smtg_add_vst3plugin(${target} PACKAGE_NAME "transformant" SOURCES_LIST ${plugin_sources}) -set_target_properties(${target} - PROPERTIES - ${SDK_IDE_PLUGIN_EXAMPLES_FOLDER} -) - -target_compile_features(${target} - PUBLIC - cxx_std_17 -) - -target_link_libraries(${target} - PRIVATE - sdk - vstgui_support -) -smtg_target_add_plugin_resources(${target} - RESOURCES - resource/plugin.uidesc - resource/background.png - resource/version.png -) - -#smtg_target_add_plugin_snapshots (${target} -# RESOURCES -# resource/84E8DE5F92554F5396FAE4133C935A18_snapshot.png -# resource/84E8DE5F92554F5396FAE4133C935A18_snapshot_2.0x.png -# resource/41347FD6FED64094AFBB12B7DBA1D441_snapshot.png -# resource/41347FD6FED64094AFBB12B7DBA1D441_snapshot_2.0x.png -#) - -if(SMTG_MAC) - smtg_target_set_bundle(${target} - BUNDLE_IDENTIFIER "nl.igorski.vst.${target}" - COMPANY_NAME "igorski.nl" - ) -elseif(SMTG_WIN) - target_sources(${target} - PRIVATE - resource/plugin.rc - ) -endif(SMTG_MAC) - -# Add an AUv2 target -if (SMTG_MAC AND XCODE AND SMTG_COREAUDIO_SDK_PATH) - include(SMTG_AddVST3AuV2) - smtg_target_add_auv2(${target}-au - BUNDLE_NAME transformant - BUNDLE_IDENTIFIER nl.igorski.vst.${target}.audiounit - INFO_PLIST_TEMPLATE ${CMAKE_CURRENT_SOURCE_DIR}/audio-unit/Info.plist - VST3_PLUGIN_TARGET ${target} - ) -endif(SMTG_MAC AND XCODE AND SMTG_COREAUDIO_SDK_PATH) diff --git a/audio-unit/Info.plist b/audio-unit/Info.plist deleted file mode 100755 index c00929d..0000000 --- a/audio-unit/Info.plist +++ /dev/null @@ -1,67 +0,0 @@ - - - - - CFBundleDevelopmentRegion - English - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - kAudioUnitBundleIdentifier - CFBundleName - $(PRODUCT_NAME) - CFBundleInfoDictionaryVersion - 6.0 - CFBundlePackageType - BNDL - CFBundleSignature - ???? - CFBundleVersion - 1.0 - CSResourcesFileMapped - yes - AudioUnit SupportedNumChannels - - - Outputs - 2 - Inputs - 2 - - - Outputs - 0 - Inputs - 1 - - - Outputs - 1 - Inputs - 1 - - - AudioUnit Version - kAudioUnitVersion - AudioComponents - - - description - Transformant - factoryFunction - AUWrapperFactory - manufacturer - IGOR - name - igorski: Transformant - subtype - frmt - type - aufx - version - 65539 - - - - - diff --git a/build.bat b/build.bat old mode 100755 new mode 100644 index c19e2a1..0f39674 --- a/build.bat +++ b/build.bat @@ -9,6 +9,12 @@ IF /I "%1"=="vst2" ( set SMTG_CREATE_VST2_VERSION="" ) +if not defined VST3_SDK_ROOT ( + set VST3_SDK_ROOT=%CD%\vst3sdk +) + +echo Building using VST3 SDK located at %VST3_SDK_ROOT% + cmake.exe -G"Visual Studio 16 2019" %SMTG_CREATE_VST2_VERSION% -DVST3_SDK_ROOT=%VST3_SDK_ROOT% .. cmake --build . --config Release diff --git a/build.sh b/build.sh old mode 100755 new mode 100644 index c1e1a90..8129b4d --- a/build.sh +++ b/build.sh @@ -1,5 +1,16 @@ #!/usr/bin/env bash clear + +# get current working directory + +SOURCE="${BASH_SOURCE[0]}" +while [ -h "$SOURCE" ]; do +DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" +SOURCE="$(readlink "$SOURCE")" +[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" +done +BASEDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + echo "Flushing build caches and output folders" rm -rf build echo "Creating build folders" @@ -8,28 +19,72 @@ cd build echo "Building project" echo "----------------" +# env variable for VST3_SDK_ROOT set ? pass it to CMake configuration + if [ -n "${VST3_SDK_ROOT}" ]; then - DVST3_SDK_ROOT="-DVST3_SDK_ROOT=${VST3_SDK_ROOT}" + DVST3_SDK_ROOT=${VST3_SDK_ROOT} +else + DVST3_SDK_ROOT="${BASEDIR}/vst3sdk" fi +echo "Building using VST3 SDK located at ${DVST3_SDK_ROOT}" + +type="vst3" + +# Parse arguments + +while [[ "$#" -gt 0 ]]; do + case $1 in + --type) type="$2"; shift ;; + --team_id) team_id="$2"; shift ;; + --identity) identity="$2"; shift ;; + *) echo "Unknown parameter passed: $1"; exit 1 ;; + esac + shift +done + # flag to build as VST2 supplied ? pass it to CMake configuration -if [ "$1" == "vst2" ]; then - SMTG_CREATE_VST2_VERSION="-DSMTG_CREATE_VST2_VERSION=ON" +if [ "$type" == "vst2" ]; then + FLAGS="-DSMTG_CREATE_VST2_VERSION=ON" +elif [ "$type" == "au" ]; then + FLAGS="-GXcode -DSMTG_CREATE_AU_VERSION=ON" fi -cmake "-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64" ${SMTG_CREATE_VST2_VERSION} ${DVST3_SDK_ROOT} .. -make +if [ -z "$identity" ]; then + cmake "-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64" -DVST3_SDK_ROOT=${DVST3_SDK_ROOT} ${FLAGS} .. +else + echo "Plugin will be signed using ${identity}" + cmake "-DCMAKE_OSX_ARCHITECTURES=x86_64;arm64" -DVST3_SDK_ROOT=${DVST3_SDK_ROOT} ${FLAGS} -DSMTG_IOS_DEVELOPMENT_TEAM=${team_id} "-DSMTG_CODE_SIGN_IDENTITY_MAC=${identity}" .. +fi +cmake --build . --config Release buildStatus=$? if [ $buildStatus -eq 0 ]; then - if [ "$1" == "vst2" ]; then - mv ./VST3/transformant.vst3 ./VST3/transformant.vst + FILE="./VST3/transformant.vst3" + + # code signing (macOS) + + if [ "$identity" ]; then + if [ "$type" == "au" ]; then + FILE="./bin/Release/Transformant AUV3.app" + fi + codesign -s "${identity}" "${FILE}" --timestamp --deep --strict --options=runtime --force + if [ "$type" == "au" ]; then + codesign -s "${identity}" "${FILE}/Contents/PlugIns/auv3.appex" --timestamp --deep --strict --options=runtime --force --entitlements "${BASEDIR}/mac/audio-unit/plugin.entitlements" + fi + codesign --verify --deep --verbose "${FILE}" + fi + + # VST2/AU specific operations + + if [ "$type" == "vst2" ]; then + mv "${FILE}" ./VST3/transformant.vst fi echo "Plugin built successfully" else echo "An error occurred during build of plugin" fi -exit $buildStatus +exit $buildStatus \ No newline at end of file diff --git a/build32.bat b/build32.bat index e851ba6..403fd54 100644 --- a/build32.bat +++ b/build32.bat @@ -3,6 +3,12 @@ rmdir /Q /S build mkdir build cd build +if not defined VST3_SDK_ROOT ( + set VST3_SDK_ROOT=%CD%\vst3sdk +) + +echo Building using VST3 SDK located at %VST3_SDK_ROOT% + cmake -G "Visual Studio 16 2019" -A Win32 -S .. -B "build32" -DSMTG_CREATE_VST2_VERSION=ON -DVST3_SDK_ROOT=%VST3_SDK_ROOT_32BIT% cmake --build build32 --config Release diff --git a/build_au.sh b/build_au.sh deleted file mode 100755 index 4897f96..0000000 --- a/build_au.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env bash -clear -echo "Flushing build caches and output folders" -rm -rf build -echo "Building project" -echo "----------------" - -# from http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in -SOURCE="${BASH_SOURCE[0]}" -while [ -h "$SOURCE" ]; do - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" -done -BASEDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - -mkdir -p build -cd build - -if [ -n "${VST3_SDK_ROOT}" ]; then - DVST3_SDK_ROOT="-DVST3_SDK_ROOT=${VST3_SDK_ROOT}" -fi - -# run CMake using Audio Unit build target -cmake -GXcode ${DVST3_SDK_ROOT} "-DCMAKE_OSX_ARCHITECTURES=x86_64" "-DCREATE_AUDIO_UNIT=ON" "-DSMTG_COREAUDIO_SDK_PATH=/Library/CoreAudioSDK/CoreAudio" "${BASEDIR}" -cmake --build . --config Release - -cd .. diff --git a/jamba.cmake b/jamba.cmake deleted file mode 100644 index a2d4b18..0000000 --- a/jamba.cmake +++ /dev/null @@ -1,45 +0,0 @@ -cmake_minimum_required(VERSION 3.17) - -include(FetchContent) - -if(JAMBA_ROOT_DIR) - # instructs FetchContent to not download or update but use the location instead - set(FETCHCONTENT_SOURCE_DIR_JAMBA ${JAMBA_ROOT_DIR}) -else() - set(FETCHCONTENT_SOURCE_DIR_JAMBA "") -endif() - -set(JAMBA_GIT_REPO "https://github.com/pongasoft/jamba" CACHE STRING "Jamba git repository url" FORCE) -set(JAMBA_GIT_TAG v5.0.0 CACHE STRING "Jamba git tag" FORCE) - -FetchContent_Declare(jamba - GIT_REPOSITORY ${JAMBA_GIT_REPO} - GIT_TAG ${JAMBA_GIT_TAG} - GIT_CONFIG advice.detachedHead=false - GIT_SHALLOW true - SOURCE_DIR "${CMAKE_BINARY_DIR}/jamba" - BINARY_DIR "${CMAKE_BINARY_DIR}/jamba-build" - CONFIGURE_COMMAND "" - BUILD_COMMAND "" - INSTALL_COMMAND "" - TEST_COMMAND "" - ) - -FetchContent_GetProperties(jamba) - -if(NOT jamba_POPULATED) - - if(FETCHCONTENT_SOURCE_DIR_JAMBA) - message(STATUS "Using jamba from local ${FETCHCONTENT_SOURCE_DIR_JAMBA}") - else() - message(STATUS "Fetching jamba ${JAMBA_GIT_REPO}@${JAMBA_GIT_TAG}") - endif() - - FetchContent_Populate(jamba) - -endif() - -set(JAMBA_ROOT_DIR ${jamba_SOURCE_DIR}) - -# finally we include jamba itself -include(${JAMBA_ROOT_DIR}/jamba.cmake) \ No newline at end of file diff --git a/mac/audio-unit/CMakeLists.txt b/mac/audio-unit/CMakeLists.txt new file mode 100644 index 0000000..2bcda01 --- /dev/null +++ b/mac/audio-unit/CMakeLists.txt @@ -0,0 +1,68 @@ + +include(SMTG_AddVST3AuV3) + +function(create_audio_unit vst3_target) + set(audio_unit_src_dir ${CMAKE_CURRENT_SOURCE_DIR}/mac/audio-unit) + + set(au_app_sources + ${audio_unit_src_dir}/src/ViewController.m + ${audio_unit_src_dir}/src/ViewController.h + ${audio_unit_src_dir}/src/AppDelegate.m + ${audio_unit_src_dir}/src/AppDelegate.h + ${audio_unit_src_dir}/audiounitconfig.h + ) + + set(au_app_ui_resources + ${audio_unit_src_dir}/resource/Main.storyboard + ${audio_unit_src_dir}/resource/plugin.icns + ${audio_unit_src_dir}/resource/loop.wav + ) + + # these redefine values set in SMTG_AddVST3AuV3.cmake --- + set(public_sdk_SOURCE_DIR ${VST3_SDK_ROOT}/public.sdk) + set(auv3wrappermacos_sources + ${VST3_SDK_ROOT}/public.sdk/source/vst/auv3wrapper/AUv3WrappermacOS/main.mm + ) + set(auv3wrappermacosextension_sources + ${VST3_SDK_ROOT}/public.sdk/source/vst/auv3wrapper/Shared/AUv3WrapperFactory.mm + ${VSTSDK_PLUGIN_SOURCE} + ) + # --- E.O. SMTG_*.cmake overrides + + set(au_target ${target}_auv3) + + smtg_add_auv3_app( + ${au_target} + "macOS" + "Transformant AUV3" + "nl.igorski.vst.${target}" + "${audio_unit_src_dir}/audiounitconfig.h" + "${audio_unit_src_dir}/plugin.entitlements" + "${au_app_sources}" + "${au_app_ui_resources}" + "${audio_unit_src_dir}/resource/Info.plist" + "${audio_unit_src_dir}/resource/Info.appex.plist" + ${vst3_target} + ) + + #exposes auv3wrappermacos + target_link_directories(${au_target}_appextension_macos PRIVATE "${VST3_SDK_ROOT}/build/lib") + target_link_directories(${au_target} PRIVATE "${VST3_SDK_ROOT}/build/lib") + + target_link_libraries(${au_target} + PUBLIC + base + pluginterfaces + sdk + sdk_common + sdk_hosting + ) + + target_link_libraries(${au_target}_appextension_macos + PUBLIC + base + pluginterfaces + sdk + sdk_hosting + ) +endfunction() \ No newline at end of file diff --git a/mac/audio-unit/audiounitconfig.h b/mac/audio-unit/audiounitconfig.h new file mode 100644 index 0000000..db4c870 --- /dev/null +++ b/mac/audio-unit/audiounitconfig.h @@ -0,0 +1,57 @@ +// The specific variant of the Audio Unit app extension. +// The four possible types and their values are: +// Effect (aufx), Generator (augn), Instrument (aumu), and Music Effect (aufm) +#define kAUcomponentType 'aufx' +#define kAUcomponentType1 aufx + +// A subtype code (unique ID) for the audio unit, such as gav3. +// This value must be exactly 4 alphanumeric characters +#define kAUcomponentSubType 'frmt' +#define kAUcomponentSubType1 frmt + +// A manufacturer code for the audio unit, such as Aaud. +// This value must be exactly 4 alphanumeric characters +#define kAUcomponentManufacturer 'IGOR' +#define kAUcomponentManufacturer1 IGOR + +// A product name for the audio unit +#define kAUcomponentDescription AUv3WrapperExtension + +// The full name of the audio unit. +// This is derived from the manufacturer and description key values +#define kAUcomponentName Transformant + +// Displayed Tags +#define kAUcomponentTag Effects + +// A version number for the Audio Unit app extension (decimal value of hexadecimal representation with zeros between subversions) +// Hexadecimal indexes representing: [0] = main version, [1] = 0 = dot, [2] = sub version, [3] = 0 = dot, [4] = sub-sub version, +// e.g. 1.0.0 == 0x10000 == 65536, 1.2.3 = 0x10203 = 66051 +// needs to correspond with semver version in Info.plist +#define kAUcomponentVersion 65540 + +// Supported number of channels of your audio unit. +// Integer indexes representing: [0] = input count, [1] = output count, [2] = 2nd input count, +// [3]=2nd output count, etc. +// e.g. 1122 == config1: [mono input, mono output], config2: [stereo input, stereo output] +// see channelCapabilities for discussion +#define kSupportedNumChannels 1122 + +// The preview audio file name. +// To add your own custom audio file (for standalone effects), add an audio file to the project (AUv3WrappermacOS and AUv3WrapperiOS targets) and +// enter the file name here +#define kAudioFileName "loop" + +// The preview audio file format. +// To add your own custom audio file (for standalone effects), add an audio file to the project (AUv3WrappermacOS and AUv3WrapperiOS targets) and +// enter the file format here +#define kAudioFileFormat "wav" + +// componentFlags (leave at 0) +#define kAUcomponentFlags 0 + +// componentFlagsMask (leave at 0) +#define kAUcomponentFlagsMask 0 + +// class name for the application delegate +#define kAUapplicationDelegateClassName AppDelegate diff --git a/mac/audio-unit/plugin.entitlements b/mac/audio-unit/plugin.entitlements new file mode 100644 index 0000000..852fa1a --- /dev/null +++ b/mac/audio-unit/plugin.entitlements @@ -0,0 +1,8 @@ + + + + + com.apple.security.app-sandbox + + + diff --git a/mac/audio-unit/resource/Info.appex.plist b/mac/audio-unit/resource/Info.appex.plist new file mode 100644 index 0000000..4d60d84 --- /dev/null +++ b/mac/audio-unit/resource/Info.appex.plist @@ -0,0 +1,61 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleDisplayName + AUv3WrapperExtension + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + XPC! + CFBundleShortVersionString + 1.0 + CFBundleVersion + 1 + NSExtension + + NSExtensionAttributes + + NSExtensionServiceRoleType + NSExtensionServiceRoleTypeEditor + AudioComponents + + + description + kAUcomponentDescription + manufacturer + kAUcomponentManufacturer1 + name + kAUcomponentName + sandboxSafe + + subtype + kAUcomponentSubType1 + tags + + kAUcomponentTag + + type + kAUcomponentType1 + version + kAUcomponentVersion + + + + NSExtensionPointIdentifier + com.apple.AudioUnit-UI + NSExtensionPrincipalClass + AUv3WrapperViewController + + SupportedNumChannels + kSupportedNumChannels + + diff --git a/mac/audio-unit/resource/Info.plist b/mac/audio-unit/resource/Info.plist new file mode 100644 index 0000000..5f81e74 --- /dev/null +++ b/mac/audio-unit/resource/Info.plist @@ -0,0 +1,36 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIconFile + plugin + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + $(PRODUCT_NAME) + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0.4 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSMinimumSystemVersion + $(MACOSX_DEPLOYMENT_TARGET) + NSHumanReadableCopyright + Copyright © 2019-2024 igorski.nl + NSMainStoryboardFile + Main + NSPrincipalClass + NSApplication + SupportedNumChannels + kSupportedNumChannels + + diff --git a/mac/audio-unit/resource/Main.storyboard b/mac/audio-unit/resource/Main.storyboard new file mode 100644 index 0000000..cd2db0d --- /dev/null +++ b/mac/audio-unit/resource/Main.storyboard @@ -0,0 +1,176 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/mac/audio-unit/resource/loop.wav b/mac/audio-unit/resource/loop.wav new file mode 100644 index 0000000..edc27f9 Binary files /dev/null and b/mac/audio-unit/resource/loop.wav differ diff --git a/mac/audio-unit/resource/plugin.icns b/mac/audio-unit/resource/plugin.icns new file mode 100644 index 0000000..8e1a4c9 Binary files /dev/null and b/mac/audio-unit/resource/plugin.icns differ diff --git a/mac/audio-unit/src/AppDelegate.h b/mac/audio-unit/src/AppDelegate.h new file mode 100644 index 0000000..bcf0970 --- /dev/null +++ b/mac/audio-unit/src/AppDelegate.h @@ -0,0 +1,40 @@ +//----------------------------------------------------------------------------- +// Project : VST SDK +// +// Category : Helpers +// Filename : +// Created by : Steinberg, 07/2017. +// Description : VST 3 AUv3Wrapper +// +//----------------------------------------------------------------------------- +// LICENSE +// (c) 2022, Steinberg Media Technologies GmbH, 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. +//----------------------------------------------------------------------------- + +#import + +@interface AppDelegate : NSObject +@end diff --git a/mac/audio-unit/src/AppDelegate.m b/mac/audio-unit/src/AppDelegate.m new file mode 100644 index 0000000..be7bb22 --- /dev/null +++ b/mac/audio-unit/src/AppDelegate.m @@ -0,0 +1,52 @@ +//----------------------------------------------------------------------------- +// Project : VST SDK +// +// Category : Helpers +// Filename : +// Created by : Steinberg, 07/2017. +// Description : VST 3 AUv3Wrapper +// +//----------------------------------------------------------------------------- +// LICENSE +// (c) 2022, Steinberg Media Technologies GmbH, 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. +//----------------------------------------------------------------------------- + +#import "AppDelegate.h" + +@implementation AppDelegate + +- (void)applicationDidFinishLaunching:(NSNotification *)aNotification { +} + +- (void)applicationWillTerminate:(NSNotification *)aNotification { +} + +- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender +{ + return YES; +} + +@end diff --git a/mac/audio-unit/src/ViewController.h b/mac/audio-unit/src/ViewController.h new file mode 100644 index 0000000..eca9a83 --- /dev/null +++ b/mac/audio-unit/src/ViewController.h @@ -0,0 +1,43 @@ +//----------------------------------------------------------------------------- +// Project : VST SDK +// +// Category : Helpers +// Filename : +// Created by : Steinberg, 07/2017. +// Description : VST 3 AUv3Wrapper +// +//----------------------------------------------------------------------------- +// LICENSE +// (c) 2022, Steinberg Media Technologies GmbH, 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. +//----------------------------------------------------------------------------- + +#import + +@interface ViewController : NSViewController + +@end + + diff --git a/mac/audio-unit/src/ViewController.m b/mac/audio-unit/src/ViewController.m new file mode 100644 index 0000000..85fb20b --- /dev/null +++ b/mac/audio-unit/src/ViewController.m @@ -0,0 +1,183 @@ +//----------------------------------------------------------------------------- +// Project : VST SDK +// +// Category : Helpers +// Filename : +// Created by : Steinberg, 07/2017. +// Description : VST 3 AUv3Wrapper +// +//----------------------------------------------------------------------------- +// LICENSE +// (c) 2022, Steinberg Media Technologies GmbH, 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. +//----------------------------------------------------------------------------- +#import "ViewController.h" +#import +#import "public.sdk/source/vst/auv3wrapper/Shared/AUv3AudioEngine.h" +#import "public.sdk/source/vst/auv3wrapper/Shared/AUv3Wrapper.h" + +@class AUv3WrapperViewController; + +@interface ViewController () +{ + // Button for playback + IBOutlet NSButton* playButton; + + AUv3AudioEngine* audioEngine; + + // Container for the custom view. + AUv3WrapperViewController* auV3ViewController; +} + +@property IBOutlet NSView *containerView; +-(IBAction)togglePlay:(id)sender; +-(void)handleMenuSelection:(id)sender; + +@end + +@implementation ViewController +//------------------------------------------------------------------------ +- (void)viewDidLoad +{ + [super viewDidLoad]; + + // Do any additional setup after loading the view. + [self embedPlugInView]; + + AudioComponentDescription desc; + + desc.componentType = kAUcomponentType; + desc.componentSubType = kAUcomponentSubType; + desc.componentManufacturer = kAUcomponentManufacturer; + desc.componentFlags = kAUcomponentFlags; + desc.componentFlagsMask = kAUcomponentFlagsMask; + + if (desc.componentType == 'aufx' || desc.componentType == 'aumf') + [self addFileMenuEntry]; + + [AUAudioUnit registerSubclass: AUv3Wrapper.class asComponentDescription:desc name:@"Local AUv3" version: UINT32_MAX]; + + audioEngine = [[AUv3AudioEngine alloc] initWithComponentType:desc.componentType]; + + [audioEngine loadAudioUnitWithComponentDescription:desc completion:^{ + auV3ViewController.audioUnit = (AUv3Wrapper*)audioEngine.currentAudioUnit; + + NSString* fileName = @kAudioFileName; + NSString* fileFormat = @kAudioFileFormat; + NSURL* fileURL = [[NSBundle mainBundle] URLForResource:fileName withExtension:fileFormat]; + NSError* error = [audioEngine loadAudioFile:fileURL]; + if (error) + { + NSLog (@"Error setting up audio or midi file: %@", [error description]); + } + }]; +} + +//------------------------------------------------------------------------ +- (void)embedPlugInView +{ + NSURL *builtInPlugInURL = [[NSBundle mainBundle] builtInPlugInsURL]; + NSURL *pluginURL = [builtInPlugInURL URLByAppendingPathComponent: @"vst3plugin.appex"]; + NSBundle *appExtensionBundle = [NSBundle bundleWithURL: pluginURL]; + + auV3ViewController = [[AUv3WrapperViewController alloc] initWithNibName: @"AUv3WrapperViewController" bundle: appExtensionBundle]; + + // Present the view controller's view. + NSView *view = auV3ViewController.view; + view.frame = _containerView.bounds; + + [_containerView addSubview: view]; + + view.translatesAutoresizingMaskIntoConstraints = NO; + + NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat: @"H:|-[view]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(view)]; + [_containerView addConstraints: constraints]; + + constraints = [NSLayoutConstraint constraintsWithVisualFormat: @"V:|-[view]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(view)]; + [_containerView addConstraints: constraints]; +} + +//------------------------------------------------------------------------ +-(void)addFileMenuEntry +{ + NSApplication *app = [NSApplication sharedApplication]; + NSMenu *fileMenu = [[app.mainMenu itemWithTag:123] submenu]; + + NSMenuItem *openFileItem = [[NSMenuItem alloc] initWithTitle:@"Load file..." + action:@selector(handleMenuSelection:) + keyEquivalent:@"O"]; + [fileMenu insertItem:openFileItem atIndex:0]; +} + +//------------------------------------------------------------------------ +-(void)handleMenuSelection:(NSMenuItem *)sender +{ + // create the open dialog + NSOpenPanel* openPanel = [NSOpenPanel openPanel]; + openPanel.title = @"Choose an audio file"; + openPanel.showsResizeIndicator = YES; + openPanel.canChooseFiles = YES; + openPanel.allowsMultipleSelection = NO; + openPanel.canChooseDirectories = NO; + openPanel.canCreateDirectories = YES; + openPanel.allowedFileTypes = @[@"aac", @"aif", @"aiff", @"caf", @"m4a", @"mp3", @"wav"]; + + if ( [openPanel runModal] == NSModalResponseOK ) + { + NSArray* urls = [openPanel URLs]; + + // Loop through all the files and process them. + for(int i = 0; i < [urls count]; i++ ) + { + NSError* error = [audioEngine loadAudioFile:[urls objectAtIndex:i]]; + + if (error != nil) + { + NSAlert *alert = [[NSAlert alloc] init]; + [alert setMessageText:@"Error loading file"]; + [alert setInformativeText:@"Something went wrong loading the audio file. Please make sure to select the correct format and try again."]; + [alert addButtonWithTitle:@"Ok"]; + [alert runModal]; + } + } + } +} + +//------------------------------------------------------------------------ +-(IBAction)togglePlay:(id)sender +{ + BOOL isPlaying = [audioEngine startStop]; + + [playButton setTitle: isPlaying ? @"Stop" : @"Play"]; +} + +#pragma mark +//------------------------------------------------------------------------ +- (void)windowWillClose:(NSNotification *)notification +{ + // Main applicaiton window closing, we're done + auV3ViewController = nil; +} +@end diff --git a/setup.bat b/setup.bat new file mode 100644 index 0000000..f7a245b --- /dev/null +++ b/setup.bat @@ -0,0 +1,15 @@ +@echo off +cls + +echo "Retrieving Steinberg VST3 SDK..." +git clone --recursive https://github.com/steinbergmedia/vst3sdk.git --branch v3.7.11_build_10 + +cd vst3sdk +rmdir /Q /S build +mkdir build +cd build + +cmake.exe -G"Visual Studio 16 2019" .. +cmake --build . --config Release + +cd .. diff --git a/setup.sh b/setup.sh new file mode 100644 index 0000000..1039332 --- /dev/null +++ b/setup.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +clear + +echo "Retrieving Steinberg VST3 SDK..." +git clone --recursive https://github.com/steinbergmedia/vst3sdk.git --branch v3.7.11_build_10 + +echo "--------------------------------" +echo "Setting up Steinberg VST3 SDK..." + +cd vst3sdk +rm -rf build +mkdir build +cd build + +echo "---------------------" + +# Parse arguments + +while [[ "$#" -gt 0 ]]; do + case $1 in + --platform) platform="$2"; shift ;; + --coresdk) coresdk="$2"; shift ;; + *) echo "Unknown parameter passed: $1"; exit 1 ;; + esac + shift +done + +if [ "$platform" == "mac" ]; then + echo "Building for macOS..." + if [ "$coresdk" ]; then + echo "Building with CoreAudio support. Library specified to be at $coresdk" + FLAGS="-DSMTG_COREAUDIO_SDK_PATH=$coresdk" + fi + cmake -GXcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="arm64;x86_64" ${FLAGS} .. +else + echo "Building for Linux..." + make +fi + +cmake --build . --config Release \ No newline at end of file diff --git a/src/ui/controller.cpp b/src/ui/controller.cpp index 9089afa..2087587 100755 --- a/src/ui/controller.cpp +++ b/src/ui/controller.cpp @@ -1,7 +1,7 @@ /** * The MIT License (MIT) * - * Copyright (c) 2020-2023 Igor Zinken - https://www.igorski.nl + * Copyright (c) 2020-2024 Igor Zinken - https://www.igorski.nl * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in @@ -89,7 +89,7 @@ tresult PLUGIN_API PluginController::initialize( FUnknown* context ) )); parameters.addParameter( - USTRING( "Vowel Sync" ), 0, 1, 0, ParameterInfo::kCanAutomate, kVowelSyncId, unitId + USTRING( "Vowel Sync" ), 0, 1, 1, ParameterInfo::kCanAutomate, kVowelSyncId, unitId ); // LFO controls @@ -102,7 +102,7 @@ tresult PLUGIN_API PluginController::initialize( FUnknown* context ) parameters.addParameter( new RangeParameter( USTRING( "Vowel L LFO depth" ), kLFOVowelLDepthId, USTRING( "%" ), - 0.f, 1.f, 0.f, + 0.f, 1.f, 0.5f, 0, ParameterInfo::kCanAutomate, unitId )); @@ -114,7 +114,7 @@ tresult PLUGIN_API PluginController::initialize( FUnknown* context ) parameters.addParameter( new RangeParameter( USTRING( "Vowel R LFO depth" ), kLFOVowelRDepthId, USTRING( "%" ), - 0.f, 1.f, 0.f, + 0.f, 1.f, 0.5f, 0, ParameterInfo::kCanAutomate, unitId ));