Main Content

Design an Audio Plugin

An audio plugin encapsulates an audio processing algorithm and enables you to tune the parameters of the algorithm while streaming audio.

Define an Audio Plugin

To define a plugin that enables users to adjust stereo width:

  1. Create a class definition that inherits from audioPlugin.

  2. Parameterize the stereo width of the processing algorithm by defining the public property Width.

  3. Enable users to tune the stereo width by defining an audioPluginInterface that contains Width as an audioPluginParameter.

  4. Define the audio processing by creating a process method. The process method takes the audio input, in, and adjusts the stereo width by: (a) applying mid-side encoding, (b) adjusting the stereo width based on the user-controlled Width parameter, and then (c) applying mid-side decoding.

classdef StereoWidth < audioPlugin                            % <== (1) Inherit from audioPlugin.
        Width = 1;                                            % <== (2) Define tunable property.
    properties (Constant)
        PluginInterface = audioPluginInterface( ...           % <== (3) Map tunable property to plugin parameter.
            audioPluginParameter('Width', ...
        function out = process(plugin,in)                     %< == (4) Define audio processing.

            x = [in(:,1) + in(:,2), in(:,1) - in(:,2)];             %  (a) Mid-side encoding.
            y = [x(:,1), x(:,2)*plugin.Width];                      %  (b) Adjust stereo width.
            out = [(y(:,1) + y(:,2))/2, (y(:,1) - y(:,2))/2];       %  (c) Mid-side decoding.


Prototype the Audio Plugin

Once you have defined an audio plugin, you can prototype it using the Audio Test Bench app. The Audio Test Bench app enables you to stream audio through the plugin while you tune parameters, perform listening tests, and visualize the original and processed audio. To open your StereoWidth plugin in the Audio Test Bench app, at the MATLAB® command prompt, enter:


Validate and Generate a VST Plugin

You can validate a MATLAB® audio plugin and generate a VST plugin from the Audio Test Bench. You can also validate and generate the plugin from the command line by using the validateAudioPlugin and generateAudioPlugin functions. Once generated, you can deploy your plugin to a digital audio workstation (DAW).

validateAudioPlugin StereoWidth
Checking plugin class 'StereoWidth'... 
Generating testbench file 'testbench_StereoWidth.m'... done.
Running testbench... passed.
Generating mex file 'testbench_StereoWidth_mex.mexw64'... done.
Running mex testbench... passed.
Deleting testbench.
Ready to generate audio plugin.
generateAudioPlugin StereoWidth

The VST plugin is saved to your working directory.

See Also

| | | | | | |

Related Topics