From Pure Data To FMOD Plugin

NOTE: As of , the FMOD generator was merged into the hvcc development branch.

I'm currently working on a FMOD plugin generator for hvcc, a python-based dataflow audio programming language compiler that generates C/C++ code from Pure Data patches.

Additional generators wrap this code for DAW, Wwise or Unity plugins, or embedded hardware such as the Electrosmith Daisy.

This article provides a brief overview on how to create FMOD plugins using hvcc.

To follow along you should be familiar with git, python3, CMake, Pure Data and VS Code.

Installing hvcc

To install hvcc clone the git repository and install it using pip3.

git clone https://github.com/Wasted-Audio/hvcc
cd hvcc
pip3 install -e .

On Windows this should install hvcc.exe into:

C:\Users\<USERNAME>\AppData\Local\Programs\Python\Python<VERSION>\Scripts\hvcc.exe

Creating A PD Patch

For a modern Pure Data patching experience I recommend plugdata, but using regular PD works just as well.

NOTE: The .pd patch is merely the graphical representation of the signal flow and just the input file for the compiler.

Also, not all pd objects are supported!

Take note of this list of supported objects and other known limitations.

Here's a super simple example of a stereo gain patch. Lets save it as gain.pd.

.png

hvcc lets you expose parameters to the FMOD plugin via annotated receive objects.

For more details about supported parameter types read the official Getting Started page and the FMOD Generator documentation.

If you want to skip having to patch this yourself, you can copy/paste the below into an empty patch.

gain.pd:

#X obj 101 28 r gain @hv_param 0 1 0.5;
#X obj 30 143 *~;
#X obj 30 28 adc~;
#X obj 30 195 dac~;
#X obj 84 143 *~;
#X obj 101 96 line~;
#X msg 101 60 \$1 100;
#X connect 0 0 6 0;
#X connect 1 0 3 0;
#X connect 2 0 1 0;
#X connect 2 1 4 0;
#X connect 4 0 3 1;
#X connect 5 0 1 1;
#X connect 5 0 4 1;
#X connect 6 0 5 0;

Generating The Code

To generate the source code from the .pd file run the following in a terminal.

hvcc.exe gain.pd -o gain_plugin -g fmod -n gain -v

This will create the C source files along with the fmod plugin source files.

gain_plugin\c
gain_plugin\fmod
gain_plugin\hv
gain_plugin\ir

Compiling The Plugin

To compile the plugin on Windows, Visual Studio Community Edition 2022 needs to be installed along with the Desktop Development with C++ Workload.

Additionally the FMOD SDK, which is part of the FMOD Engine download, needs to either be present in fmod/include/fmod.

After downloading and installing (extracting) the FMOD Engine you find the SDK in

FMOD Studio API Windows\api

Copying the contents to the plugin project include directory it should look like this.

fmod\CMakeLists.txt
fmod\src\
fmod\include\Heavy\
fmod\include\fmod\api\
fmod\include\fmod\core\
fmod\include\fmod\studio\

The generated fmod directory contains a very bare bones CmakeLists.txt for building the plugin.

For the purpose of this guide I will be using VSCode along with Microsofts CMake Tools.

Once installed, open the fmod folder containing the CMakeLists.txt, make sure the [all] target is selected and run the following from the command palette or press F7.

> CMake: Build

You might be asked to select the target compiler first.

The resulting binaries should be placed into the build/Debug/ directory if you used the Debug configuration.

Using the Plugin

To use the plugin in a FMOD Studio project, place the .dll, in the Plugins directory:

<FMODPROJECT>/Plugins

Optionally copy the gain.plugin.js there too. It allows for customizing some of plugin UI.

For more details read the Plugin Scripting API.

.png

In order to use the plugin in Unreal Engine for instance, copy the .dll into the FMOD plugin directory in the Unreal Project.

<UNREALPROJECT>\Plugins\FMODStudio\Binaries\Win64

and then add it to the FMOD plugin settings.

.png

If everything went well the plugin should be loaded and functional.

I am looking for people to help test this FMOD generator to eventually open a PR.

If you want to give this a try and run into problems please let me know and I will try to address them.