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.


Inherited Methods

dispParameterDisplay information of single or multiple parameters
getParameterGet normalized value and information about parameter
infoGet information about hosted plugin
processProcess audio stream
setParameterSet normalized parameter value of hosted plugin
getSampleRateGet sample rate at which the plugin is run
setLatencyInSamplesSet latency in samples reported to DAW
setSampleRateSet sample rate at which the plugin is run
getSamplesPerFrameGet frame size returned by the plugin
setSamplesPerFrameSet frame size returned by the plugin (MATLAB environment only)

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Object Behavior.


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;

Introduced in R2016b