Create object class compatible with Simulink
code for a System object™ class with the same functionality as the provided audio plugin and opens the
generated file. The generated System object is compatible with Simulink® through the MATLAB System (Simulink) block. See Audio Plugin for a
block that uses
generateSimulinkAudioPlugin to include an audio plugin
in a Simulink model.
Generate Audio Plugin System object to Use in Simulink
You can include an audio plugin in your Simulink model by generating a System object with
generateSimulinkAudioPlugin and then using that
System object with the MATLAB System (Simulink) block.
generateSimulinkAudioPlugin with the
audiopluginexample.LFOFilter audio plugin to generate a System object class.
In Simulink, place the MATLAB System block in your model.
Double-click the block to open the dialog box, and specify the System
object name as the generated class,
Click OK to generate a block with the same functionality as the
You can now use the block in your model. The block has the same parameters as the original plugin. For more information about the generated block and its parameters, see Audio Plugin.
Specify Generated Class Name
generate the System object class with that name in the current directory.
plugin — Audio plugin
audio plugin object
Audio plugin from which to generate the System object class, specified as an audio plugin object. Plugins authored in
MATLAB® derive from
audioPluginSource. Externally authored plugins derive from
externalAudioPluginSource and are returned by
If the input plugin is an externally hosted plugin returned by
loadAudioPlugin, the function generates additional files required by the
System object. For more information, see Code Generation.
fileName — File name of generated class
"audioSimulinkSysObj" (default) | string | character vector
File name of the generated System object class, specified as a string or character vector. You can optionally
specify the path and
.m file extension. By default,
generateSimulinkAudioPlugin creates a class named
audioSimulinkSysObj in the current directory.
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.
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
If the original plugin is an
audioPluginand not a System object plugin, it must correctly save and load its state using the
If the original plugin does not maintain any state, no additional considerations are necessary for the save and restore functionality.
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
Generating code from blocks that use external audio plugins has additional requirements.
External audio plugins include plugins loaded into MATLAB with
generateSimulinkAudioPluginfunction generates files in addition to the System object file to aid in code generation. These files include
sysObjNameis the name of the generated System object. The function also generates
if the plugin has any parameters. These additional files are required for both code generation and running the block in simulation.
You must select the Support long long (Simulink) parameter in the Hardware Implementation pane of the Model Settings.
If you are using an ERT target, you must set the Language (Simulink Coder) parameter to
C++under the Target selection section of the Code Generation pane in the Model Settings. You must also select the Dynamic memory allocation in MATLAB functions (Simulink) parameter in the Advanced parameters section of the Simulation Target pane.
To use a standalone executable generated from a block with an external plugin, you must generate the
jucehost.dllfile on Windows® or the
libjucehost.dylibfile on Mac by selecting the Package code and artifacts (Simulink Coder) parameter under the Build process section of the Code Generation pane in the Model Settings.
On Windows platforms, you must make the
jucehost.dllfile visible to the standalone executable. To do this, add the path to the
jucehost.dllfile to the
PATHenvironment variable or copy the
jucehost.dllfile to the same folder as the standalone executable .
On Mac platforms, you must make the
libjucehost.dylibfile visible to the standalone executable. To do this, place the
libjucehost.dylibfile in the
Hosted AUv3 plugins do not support code generation.
Introduced in R2022b
Audio Plugin |