Audio Plugin
Libraries:
Audio Toolbox /
User-Defined Functions
Description
The Audio Plugin block allows you to use an audio plugin as a block in your Simulink® model. The Audio Plugin block generates a new block that has the same functionality as the desired plugin, and you can use the generated block to process audio signals in Simulink. For more information about audio plugins in MATLAB®, see Audio Plugins in MATLAB.
Using the Block
To use the Audio Plugin block, place the block in your model and double-click it to open the dialog box.
Specify the desired audio plugin in the Audio plugin field. You can specify the audio plugin as:
The name or file path of an audio plugin class. The class must derive from
audioPlugin
oraudioPluginSource
.An audio plugin binary file that is supported by
loadAudioPlugin
.An instance of an audio plugin class. This can either be a plugin authored in MATLAB or an externally authored plugin that is returned by
loadAudioPlugin
.
The Audio Plugin block generates a System object™ class file from the plugin and uses that System object to create the new block. You can optionally specify the file name and location of the generated System object with the Generated file name field. For more information about how the Audio Plugin block works and the System object it generates, see Algorithms.
Note
The generated System object file must be on the MATLAB path for the plugin block to work. If the plugin is a hosted external plugin, the block generates additional files required by the generated System object. For more information, see Code Generation.
After you specify an audio plugin and click OK, you have a block with the same functionality as the audio plugin.
For an example with a model that uses the Audio Plugin block, see Include an Audio Plugin in Simulink.
Generated Block Parameters
The generated block has the same parameters as the specified audio plugin. These
parameters are tunable, unless the parameter is an enumeration class that uses strings or
characters as the underlying type. Each tunable parameter can be specified from an input
port if you select the associated Specify parameter
from input port parameter, where parameter
is the
name of the tunable parameter.
Note
For audio plugins authored in MATLAB, a parameter must be specified as an audioPluginParameter
in the plugin's audioPluginInterface
for it to show in the block.
In addition to the parameters of the original plugin, the generated block has other, nontunable parameters that depend on whether the plugin is a source plugin or not. See Parameters for more information.
Examples
Limitations
Some Simulink functionality, such as Step Back, requires saving and restoring the simulation state. Blocks that use hosted external plugins do not support simulation save and restore and therefore do not support associated functionality. For tips on using simulation save and restore functionality with blocks that use plugins authored in MATLAB, see Tips.
Ports
Input
Output
Parameters
Block Characteristics
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals | |
Zero-Crossing Detection |
|
a Actual data type or capability support depends on block implementation. b See Nonvirtual Buses and MATLAB System Block for more information. c See Variable-Size Signals for more information. |
Tips
To use Simulink functionality that requires saving and restoring the simulation state, such as Step Back, with a block that uses a plugin authored in MATLAB, the original plugin implementation must correctly save and load its state.
If the original plugin is a System object, it must correctly save and load its state using the
saveObjectImpl
andloadObjectImpl
methods.If the original plugin is an
audioPlugin
and not a System object plugin, it must correctly save and load its state using thesaveobj
andloadobj
methods.
Note
If the original plugin does not maintain any state, no additional considerations are necessary for the save and restore functionality.
Algorithms
The Audio Plugin block generates the code for a System object class from the specified audio plugin using the generateSimulinkAudioPlugin
function.
generateSimulinkAudioPlugin
designs the System object to be compatible with Simulink through the MATLAB System (Simulink) block. The Audio
Plugin block then uses the MATLAB System block to create a new block
from the generated System object with the same parameters and functionality as the original audio plugin.
Extended Capabilities
Version History
Introduced in R2022b