This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

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
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 (MATLAB) in the MATLAB® documentation.


expand 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)
hostedSourcePlugin = 

  VST plugin 'oscillator'  source, 1 out, 256 samples

         Parameter    Value    Display
     1   Frequency:   0.5659   100.000 Hz
     2   Amplitude:   0.1000     1.000 AU
     3   DC Offset:   0.5000     0.000 AU

Use info to return information about the hosted plugin.

ans = 

  struct with fields:

        PluginName: 'oscillator'
            Format: 'VST'
     InputChannels: 0
    OutputChannels: 1
         NumParams: 3
        PluginPath: 'E:\jobarchive\Bdoc16b\2016_07_05_h07m05s16_job410158_...'
        VendorName: ''
     VendorVersion: 'V1.0.0'
          UniqueId: 'MWap'

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.

         Parameter    Value    Display
     1   Frequency:   0.8000   1741.101 Hz
     2   Amplitude:   0.1000      1.000 AU
     3   DC Offset:   0.5000      0.000 AU

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

ans =


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

Was this topic helpful?