Skip to content

RinoReyns/CrossPlatformVstHost

Repository files navigation

Coverage Status

ViewCount

Cross-Platform Vst Host

General Idea

Since I found that there are not many easy-to-use command-line based VST Hosts, and some of them are no longer supported, I always wanted to create my own cmd VST Host. Unfortunately, I also found that samples provided in VST 3 SDK are way to complicated for me to use, so I decided to created my own easy-to-use repository. Thus, the main goal of this project is to learn how to work with VST 3 SDK, how to create custom VST Host and handler VST 3 Plugins. During the work on cmd-based VST Host I found out that it would be also a good idea to learn how to read audio from audio endpoint on different operation systems like Windows, Linux, MacOS and Android and process audio in real time with VST Host. So that is why this repository was created. I know that it will take a lot of work but it will also be a good way to learn about everything that I'm interested in. My idea here was also to use as many available elements as it is possible.

How to Build

  1. Windows & Linux

    git submodule update --init --recursive
    pip install -r VstHost_Python/requirements.txt
    mkdir build
    cd build
    cmake ../VstHost_VisualC++ -DCMAKE_BUILD_TYPE=Release -DBUILD_GMOCK=1
    cd ..
    cmake --build build --config Release -j 8
    
  2. Mac OS

    git submodule update --init --recursive
    pip install -r VstHost_Python/requirements.txt
    brew install doxygen
    mkdir build
    cd build
    cmake -G Xcode ../VstHost_VisualC++ -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=gcc -DBUILD_GMOCK=1
    cd ..
    cmake --build build --config Release -j 8 --resolve-package-references on
    
  3. Android

    NOTE:
    Following instruction is made for Linux enviroment. However, steps for any OS should be similar.
    1. Download Android NDK and unzip in the chosen location. (https://developer.android.com/ndk/downloads).
    
    2. Set environmental variable for Android NDK as foloow:
       
       > export ANDROID_NDK_PATH=/path/to/android/ndk/main/folder
    
    3. Build VST Host for chosen architecture:
       a. armeabi-v7a:
         > cmake "../VstHost_VisualC++" -B build_armeabi-v7a -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DANDROID_PLATFORM=android-28 -D ANDROID_ABI=armeabi-v7a -DANDROID_BUILD=True
         > cd build_armeabi-v7a
         > $ANDROID_NDK_PATH/prebuilt/linux-x86_64/bin/make
       
       b. arm64-v8a:
         > cmake "../VstHost_VisualC++"  -B build_arm64-v8a -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DANDROID_PLATFORM=android-28 -D ANDROID_ABI=arm64-v8a -DANDROID_BUILD=True
         > cd build_arm64-v8a
         > $ANDROID_NDK_PATH/prebuilt/linux-x86_64/bin/make
       
       c. build_x86:
         > cmake "../VstHost_VisualC++" -B build_x86 -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DANDROID_PLATFORM=android-28 -D ANDROID_ABI=x86 -DANDROID_BUILD=True
         > cd build_x86
         > $ANDROID_NDK_PATH/prebuilt/linux-x86_64/bin/make
       
       d. build_x86_64:
         > cmake "../VstHost_VisualC++" -B build_x86_64 -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DANDROID_PLATFORM=android-28 -D ANDROID_ABI=x86_64 -DANDROID_BUILD=True
         > cd build_x86_64
         > $ANDROID_NDK_PATH/prebuilt/linux-x86_64/bin/make
    
    4. Build Android Demo App that uses VST Host lib
       a. Copy necessery dependencess. In the example below dependeces for all architectures were copied. Also note that
          in the example VST plugin has been copied from "build_x86_64" due to the fact that Instrumentation test are 
          executed in androdi simulater on regular CPU.
    
         > mkdir VstHost_Android/AndroidPack
         > cp -rv build_armeabi-v7a/bin/Release/AndroidPack/ VstHost_Android/
         > cp -rv build_arm64-v8a/bin/Release/AndroidPack/ VstHost_Android/
         > cp -rv build_x86/bin/Release/AndroidPack/ VstHost_Android/
         > cp -rv build_x86_64/bin/Release/AndroidPack/ VstHost_Android/
         > cp -rv build_x86_64/VST3/Release VstHost_Android/app/src/main/assets
         > cp -v VstHost_VisualC++/modules/UnitTests/data/sine_440.wav VstHost_Android/app/src/main/assets/
         > cp -v VstHost_VisualC++/modules/UnitTests/data/sine_440_output_ref.wav VstHost_Android/app/src/main/assets/
       
       b. Build Android App
         > cd VstHost_Android
         > chmod +x gradlew
       
       c. Run Intrumentation Test
         > ./gradlew connectedCheck
    

Examples of usage

  1. Print help: VstHostTool.exe --help
  2. Dump an empty configuration needed to run the tool: VstHostTool.exe -dump_app_config -config config.json
  3. Dump an empty configuration for VST plugin/plugins that will be used be. VstHostTool.exe -dump_plugins_config -config config.json
  4. Run Audio Processing with Vst Plugin. VstHostTool.exe -config config.json

Features list

  1. Platform Agnostic Features

    • Implemented:
      • CMake based project
      • Use submodules
      • Arg Parser
      • Json Reader
      • Treat Warnings as Errors
      • VST Host library in C++
      • VST Host Offline Tool in C++
      • Unit Test for library and offline tool in C++
      • CI for each configuration (Windows, Linux, MacOs, Android)
      • VST Host Library with C api that allows to use it in e.g. Python
      • Basic python and android unit test for C api
      • Allow to use multiple plugins and configs for them
      • Generate Documentation
      • AudioProcessing Class that can wrap different non-vst algorithms
      • Cross-Platform Audio Endpoint Render-Capture with RtAudio (Validated only for Windows)
      • Create and pass config for AudioProcessing Class
    • TODO:
      • Implement simple Vst plugin that allows to process data in real-time (e.g. context buffering). Start from delay validation implemented in VST SDK.
      • Enable streaming processing (one frame in, one frame out)
      • Integrate Open Vino to process audio with AI based Audio Algorithms
      • Enable Apple Silicon AI acceleration
      • Add more advanced python-based Vst Host Lib utilization
      • Add more UT for python and Android
      • Integrate better wave reader
      • Build solution for ARM
      • Handle different audio formats e.g. sampling rate, bit depth etc.
      • Validate RtAudio for different OSes
      • Move vst_host_config_ from WaveProcessingPipeline class to AudioProcessingVstHost class.
      • Rename ** to AudioProcessingTool
      • Create Baseclass for processing modules and extract common parameters
  2. Android

    • TODO:
      • Add endpoint reader
      • Add platform specific offline tool

Credits (repositories used in project)

  1. VST 3 SDK
  2. Google Test
  3. Logger
  4. Arg Parser
  5. Wave Reader
  6. C ++ Json Handler
  7. Windows Endpoint Reader
  8. Implementation of audio filters in C
  9. Real Timie Audio Render and Capture

VST is a trademark held by Steinberg Media Technologies, GMBH.

License

This project is licensed under the terms of the GNU GPLv3 license. Moreover, it is a derivative work of the original VST 3 SDK. However, I don't not redistribute any of the original source code.

Useful links

  1. How to read data from audio endpoint (Windows, Linux, MacOS)?
  2. Audio Capture on Windows
  3. Treat warnings as errors on linux
  4. More info about treating warnings as errors
  5. How to build c++ code for Android?
  6. How to use c++ .so on Android?
  7. Rendering an audio stream on windows