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.

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 System 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 Design an Audio Plugin 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:

    addpath(fullfile(matlabroot,'/examples/audio'))

  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. With the SoundPosition block selected, from the Simulink Editor menu, select Diagram > Subsystem & Model Reference > Create Subsystem from Selection.

  3. Add a mask to your Subsystem block. Select your Subsystem block, and then from the Simulink Editor menu, select Diagram > Mask > 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:

    • NameW

    • Value2

    • PromptStereo width

    • Typedial

    • Minimum0

    • Maximum4

  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:

    • NameP

    • Value0

    • PromptPan

    • Typedial

    • Minimum-1

    • Maximum1

  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 Subystem 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:

rmpath(fullfile(matlabroot,'/examples/audio'))

Related Topics

Was this topic helpful?