Documentation

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.

externalAudioPlugin class

Base class for external audio plugins

Description

externalAudioPlugin is the base class for hosted audio 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.

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

Inherited Methods

getSampleRateGet sample rate at which the plugin is run
setSampleRateSet sample rate at which the plugin is run

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Object Behavior (MATLAB) in the MATLAB® documentation.

Examples

expand all

Load a VST audio 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/ParametricEqualizer.dll');
hostedPlugin = loadAudioPlugin(pluginPath)
hostedPlugin = 

  VST plugin 'ParametricEQ'  2 in, 2 out

                       Parameter    Value    Display
        _____________________________________________
     1             Low Peak Gain:   0.5000      0.000 dB
     2      Low Center Frequency:   0.2330    100.000 Hz
     3              Low Q Factor:   0.2822      2.000   
     4          Medium Peak Gain:   0.5000      0.000 dB
     5   Medium Center Frequency:   0.5663   1000.000 Hz
   4 parameters not displayed. Use dispParameter(hostedPlugin) to see all 9 params.

Use info to return information about the hosted plugin.

info(hostedPlugin)
ans = 

  struct with fields:

        PluginName: 'ParametricEQ'
            Format: 'VST'
     InputChannels: 2
    OutputChannels: 2
         NumParams: 9
        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 Medium Center Frequency parameter to 0.75. Specify the parameter by its index.

setParameter(hostedPlugin,5,0.75)

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

Use dispParameter to display the updated table of parameters.

dispParameter(hostedPlugin)
                       Parameter    Value    Display
        _____________________________________________
     1             Low Peak Gain:   0.5000       0.000 dB
     2      Low Center Frequency:   0.2330     100.000 Hz
     3              Low Q Factor:   0.2822       2.000   
     4          Medium Peak Gain:   0.5000       0.000 dB
     5   Medium Center Frequency:   0.7500    3556.559 Hz
     6           Medium Q Factor:   0.2822       2.000   
     7            High Peak Gain:   0.5000       0.000 dB
     8     High Center Frequency:   0.8997   10000.000 Hz
     9             High Q Factor:   0.2822       2.000   

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

parameterIndex = 5;
parameterValue = getParameter(hostedPlugin,parameterIndex)
parameterValue =

    0.7500

Load a VST audio 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/ParametricEqualizer.dll');
hostedPlugin = loadAudioPlugin(pluginPath);

Create input and output objects for an audio stream loop that reads from a file and writes to your audio device. Set the sample rate of the hosted plugin to the sample rate of the input to the plugin.

fileReader   = dsp.AudioFileReader('FunkyDrums-44p1-stereo-25secs.mp3');
deviceWriter = audioDeviceWriter('SampleRate',fileReader.SampleRate);
setSampleRate(hostedPlugin,fileReader.SampleRate);

Set the MediumPeakGain property to -20 dB.

hostedPlugin.MediumPeakGain = -20;

Use the hosted plugin to process the audio file in an audio stream loop. Sweep the medium peak gain upward in the loop to hear the effect.

while hostedPlugin.MediumPeakGain < 19
    hostedPlugin.MediumPeakGain = hostedPlugin.MediumPeakGain + 0.04;
    x = fileReader();
    y = process(hostedPlugin,x);
    deviceWriter(y);
end

release(fileReader)
release(deviceWriter)

Introduced in R2016b

Was this topic helpful?