Main Content

Convert Audio Plugin System Objects to Simulink Blocks

You can convert System object™ audio plugins to blocks for real-time parameter tuning in Simulink®. Use this workflow to convert your own System object plugins to Simulink blocks, or to convert any of the System object plugins found in the Audio Plugin Example Gallery.

Open the Basic Audio Player Template in Simulink

On the Simulink Start Page, under Audio Toolbox™, click Basic Audio Player. See Real-Time Audio in Simulink for a tutorial on using Simulink model templates.

Import Audio Plugin Functionality

To import System object plugins into Simulink, use the MATLAB System block. This block is compatible with System object plugins but not basic plugins. See Audio Plugins in MATLAB for more information about defining plugins in MATLAB®.

  1. Add the System object plugin used in this example to the MATLAB path. At the command prompt, enter:


  2. From the Simulink / User-Defined Functions library, drag a MATLAB System block to your model.

  3. In the MATLAB System block, enter the name of your System object: SoundPosition

The SoundPosition audio plugin enables you to tune two parameters: stereo width, and panning.

Create an Audio Plugin Block Interface

When you import a plugin into a Simulink model, the plugin parameters are set to the initial values defined in the properties section of the plugin class. To use dials for tunable parameters, create a custom interface by using a block mask. See Masking Fundamentals (Simulink) for more information.

  1. Open the SoundPosition block.

    1. Set Width to the variable W.

    2. Set Pan to the variable P.

    3. Click OK.

  2. Make your SoundPosition block a subsystem. Select the SoundPosition block then, in the Modeling tab, select Create Subsystem.

  3. Add a mask to your Subsystem block. In the Subsystem Block tab, select Create Mask.

  4. In the Mask Editor, click the Parameters & Dialog tab.

  5. Add a dial to the dialog box for controlling stereo width. From the Controls pane, drag a Dial to the Dialog box pane. Then, in the Property editor pane, set these properties:

    • Name –– W

    • Value –– 2

    • Prompt –– Stereo width

    • Type –– dial

    • Minimum –– 0

    • Maximum –– 4

  6. To control the panning, add another dial to the dialog box. From the Controls pane, drag a Dial to the Dialog box pane. Then, in the Property editor pane, set these properties:

    • Name –– P

    • Value –– 0

    • Prompt –– Pan

    • Type –– dial

    • Minimum –– -1

    • Maximum –– 1

  7. Click OK.

Run the Model

  1. Open the From Multimedia File block.

    1. To modify the frame size used in your model, set Samples per audio channel to 256.

    2. To hear the effect of the stereo widening, specify an audio file with a distinct stereo field recording. Set File name to FunkyDrums-44p1-stereo-25secs.mp3.

    3. Click OK.

  2. To open the parameter controls of your SoundPosition block, double-click the Subsystem block.

  3. Run your model. To hear the effect of your audio plugin, open the Subsystem block and modify the Stereo width and Pan parameters in real time.

Open the completed model.

After you complete this tutorial, it is a best practice to undo the modification to the MATLAB path. At the command prompt, enter:


Related Topics