Main Content

externalAudioPluginSource Class

Base class for external audio source plugins


externalAudioPluginSource is the base class for hosted audio source plugins. When you load an external plugin using loadAudioPlugin, an object of that plugin is created having externalAudioPlugin or externalAudioPluginSource as a base class. The externalAudioPluginSource class is used when the external audio plugin is a source plugin.

For a tutorial on hosting audio plugins, see Host External Audio Plugins.

The externalAudioPluginSource class is a handle class.


expand all


collapse all

Load a VST audio source plugin into MATLAB® by specifying its full path. If you are using a Mac, replace the .dll file extension with .vst.

pluginPath = fullfile(matlabroot,'toolbox/audio/samples/oscillator.dll');
hostedSourcePlugin = loadAudioPlugin(pluginPath)

Use info to return information about the hosted plugin.


Use setParameter to change the normalized value of the Frequency parameter to 0.8. Specify the parameter by its index.


When you set the normalized parameter value, the parameter display value is automatically updated. Generally, the normalized parameter value corresponds to the position of a UI widget or MIDI controller. The parameter display value typically reflects the value used internally by the plugin for processing.

Use dispParameter to display the updated table of parameters.


Alternatively, you can use getParameter to return the normalized value of a single parameter.


Load a VST audio source plugin into MATLAB™ by specifying its full path. If you are using a Mac, replace the .dll file extension with .vst.

pluginPath = fullfile(matlabroot,'toolbox','audio','samples','oscillator.dll');
hostedSourcePlugin = loadAudioPlugin(pluginPath);

Set the Amplitude property to 0.5. Set the Frequency property to 16 kHz.

hostedSourcePlugin.Amplitude = 0.5;
hostedSourcePlugin.Frequency = 16000;

Set the sample rate at which to run the plugin. Create an output object to write to your audio device.

deviceWriter = audioDeviceWriter('SampleRate',44100);

Use the hosted source plugin to output an audio stream. The processing in the audio stream loop ramps the frequency parameter down and then up.

k = 1;
for i = 1:1000
    hostedSourcePlugin.Frequency = hostedSourcePlugin.Frequency - 30*k;
    y = process(hostedSourcePlugin);
    if (hostedSourcePlugin.Frequency - 30 <= 0.1) || (hostedSourcePlugin.Frequency + 30 >= 20e3)
        k = -1*k;



  • Saving an external plugin as a MAT-file and then loading it preserves the external settings and parameters of the plugin but does not preserve its internal state or memory. Do not save and load your plugins when you are processing audio.

Version History

Introduced in R2016b