Main Content

audioPluginGridLayout

Specify layout for audio plugin UI

Description

gridLayout = audioPluginGridLayout creates an object that specifies the layout grid for an audio plugin graphical user interface. Use the plugin grid layout object, gridLayout, as an argument to audioPluginInterface in your plugin class definition. audioPluginGridLayout specifies only the grid. The placement of individual graphical elements is specified using audioPluginParameter.

To learn how to design a graphic user interface, see Design User Interface for Audio Plugin.

For example plugins, see Audio Plugin Example Gallery.

example

gridLayout = audioPluginGridLayout(Name,Value) specifies audioPluginGridLayout properties using one or more Name,Value pair arguments.

example

Examples

collapse all

The default audio plugin grid layout specifies a 2-by-2 grid. Call audioPluginGridLayout with no arguments to view the default settings.

audioPluginGridLayout
ans = 

  audioPluginGridLayout with properties:

        RowHeight: [100 100]
      ColumnWidth: [100 100]
       RowSpacing: 10
    ColumnSpacing: 10
          Padding: [10 10 10 10]

noisifyClassic uses a default grid layout by passing audioPluginGridLayout, without any arguments, to audioPluginInterface. When you use audioPluginGridLayout, you must specify the position of each audioPluginParameter on the grid using Layout. Display names corresponding to parameters occupy cells on the grid also. The default grid contains only four cells and noisifyClassic has four parameters, so you must set DisplayNameLocation to none to fit all elements on the grid. audioPluginGridLayout is passed to the audioPluginInterface. Save noisifyClassic to your current folder.

classdef noisifyClassic < audioPlugin
    properties
        DropoutLeft = false
        DropoutRight = false
        NoiseLeftGain = 0
        NoiseRightGain = 0
    end
    properties (Constant)
        PluginInterface = audioPluginInterface( ...
            audioPluginParameter('DropoutLeft', ...
                'Layout',[2,1], ...
                'DisplayNameLocation','none'), ...
            audioPluginParameter('DropoutRight', ...
                'Layout',[2,2], ...
                'DisplayNameLocation','none'), ...
            audioPluginParameter('NoiseLeftGain', ...
                'Layout',[1,1], ...
                'DisplayNameLocation','none'), ...
            audioPluginParameter('NoiseRightGain', ...
                'Layout',[1,2], ...
                'DisplayNameLocation','none'), ...
            ...
            audioPluginGridLayout)
    end
    methods
        function out = process(plugin,in)
            r = size(in,1);
            dropRate = 0.1;
            
            if plugin.DropoutLeft
                idx = randperm(r,round(r*dropRate));
                in(idx,1) = 0;
            end
            if plugin.DropoutRight
                idx = randperm(r,round(r*dropRate));
                in(idx,2) = 0;
            end

            in(:,1) = in(:,1) + plugin.NoiseLeftGain*(2*rand(r,1,'like',in)-1);
            in(:,2) = in(:,2) + plugin.NoiseRightGain*(2*rand(r,1,'like',in)-1);

            out = in;
        end
    end
end
        

You can quickly iterate on your UI design by using parameterTuner to visualize the plugin UI. Call parameterTuner on noisifyClassic.

parameterTuner(noisifyClassic)

The example plugin, noisify, adds noise to your audio signal channel-wise at a specified gain (per channel) and dropout rate.

classdef noisifyOriginal < audioPlugin
    properties
        DropoutLeft = false;
        DropoutRight = false;
        NoiseLeftGain = 0;
        NoiseRightGain = 0;
        DropoutRate = 0.1;
    end
    properties (Constant)
        PluginInterface = audioPluginInterface(...
            audioPluginParameter('DropoutLeft'), ...
            audioPluginParameter('DropoutRight'), ...
            audioPluginParameter('NoiseLeftGain'), ...
            audioPluginParameter('NoiseRightGain'), ...
            audioPluginParameter('DropoutRate'))
    end
    methods
        function out = process(plugin,in)
            r = size(in,1);
            
            if plugin.DropoutLeft
                idx = randperm(r,round(r*plugin.DropoutRate));
                in(idx,1) = 0;
            end
            if plugin.DropoutRight
                idx = randperm(r,round(r*plugin.DropoutRate));
                in(idx,2) = 0;
            end

            in(:,1) = in(:,1) + plugin.NoiseLeftGain*randn(r,1,'like',in);
            in(:,2) = in(:,2) + plugin.NoiseRightGain*randn(r,1,'like',in);

            out = in;
        end
    end
end

To see the corresponding UI for the plugin, call parameterTuner with the plugin. When you generate an audio plugin and deploy it to a DAW, the DAW uses a default UI that is similar to the default UI of parameterTuner.

parameterTuner(noisifyOriginal)

You can create a more intuitive and visually pleasing UI using audioPluginInterface, audioPluginGridLayout, and audioPluginParameter. For example, to create a more intuitive UI for noisyOriginal, you could update the audioPluginInterface as follows:

classdef noisify < audioPlugin
    properties
        DropoutLeft = false;
        DropoutRight = false;
        NoiseLeftGain = 0;
        NoiseRightGain = 0;
        DropoutRate = 0.1;
    end
    properties (Constant)
        PluginInterface = audioPluginInterface(...
            audioPluginParameter('DropoutLeft', ...
                'Layout',[4,1], ...
                'DisplayName','Dropout (L)', ...
                'DisplayNameLocation','above', ...
                'Style','vrocker'), ...
            audioPluginParameter('DropoutRight', ...
                'Layout',[4,4], ...
                'DisplayName','Dropout (R)', ...
                'DisplayNameLocation','above', ...
                'Style','vrocker'), ...
            audioPluginParameter('NoiseLeftGain', ...
                'DisplayName','Noise Gain (L)', ...
                'Layout',[2,1;2,2], ...
                'DisplayNameLocation','above', ...
                'Style','rotaryknob'), ...
            audioPluginParameter('NoiseRightGain', ...
                'Layout',[2,3;2,4], ...
                'DisplayName','Noise Gain (R)', ...
                'DisplayNameLocation','above', ...
                'Style','rotaryknob'), ...
            audioPluginParameter('DropoutRate', ...
                'Layout',[4,2;4,3], ...
                'DisplayName','Droput Rate', ...
                'DisplayNameLocation','below', ...
                'Style','vslider'), ...
            ...
            audioPluginGridLayout( ...
                'RowHeight',[15,150,15,150,15], ...
                'ColumnWidth',[100,40,40,100], ...
                'RowSpacing',30))
    end
    methods
        function out = process(plugin,in)
            r = size(in,1);
            
            if plugin.DropoutLeft
                idx = randperm(r,round(r*plugin.DropoutRate));
                in(idx,1) = 0;
            end
            if plugin.DropoutRight
                idx = randperm(r,round(r*plugin.DropoutRate));
                in(idx,2) = 0;
            end

            in(:,1) = in(:,1) + plugin.NoiseLeftGain*randn(r,1,'like',in);
            in(:,2) = in(:,2) + plugin.NoiseRightGain*randn(r,1,'like',in);

            out = in;
        end
    end
end

You can quickly iterate on your UI design by using parameterTuner to visualize incremental changes. Call parameterTuner on noisify. When you generate an audio plugin and deploy it to a DAW, the DAW uses the enhanced UI.

parameterTuner(noisify)

Input Arguments

collapse all

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: 'RowHeight', [50,200,150] species a grid with three rows. The first row is 50 pixels high, the second row is 200 pixels high, and the third row is 150 pixels high.

Height in pixels of each row in the grid, specified as a comma-separated pair consisting of 'RowHeight' and a row vector of positive integers.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Width in pixels of each column in the grid, specified as a comma-separated pair consisting of 'ColumnWidth' and a row vector of positive integers.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Distance between rows in pixels, specified as a comma-separated pair consisting of 'RowSpacing' and a nonnegative integer.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Distance between columns in pixels, specified as a comma-separated pair consisting of 'ColumnSpacing' and a nonnegative integer.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Padding around the outer perimeter of the grid in pixels, specified as a comma-separated pair consisting of 'Padding' and a four-element row vector of nonnegative integers. The elements of the vector are interpreted as [left, bottom, right, top], where:

  • left –– Distance in pixels from the left edge of the grid to the left edge of the parent container.

  • bottom –– Distance in pixels from the bottom edge of the grid to the bottom edge of the parent container.

  • right –– Distance in pixels from the right edge of the grid to the right edge of the parent container.

  • top –– Distance in pixels from the top edge of the grid to the top edge of the parent container.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Version History

Introduced in R2019b