Parameter tuning is the ability to modify parameters of your audio system in real time while streaming an audio signal. In algorithm development, tunable parameters enable you to quickly prototype and test various parameter configurations. In deployed applications, tunable parameters enable users to fine-tune general algorithms for specific purposes, and to react to changing dynamics.
Audio Toolbox™ is optimized for parameter tuning in a real-time audio stream. The System objects, blocks, and audio plugins provide various tunable parameters, including sample rate and frame size, making them robust tools when used in an audio stream loop.
To optimize your use of Audio Toolbox, package your audio processing algorithm as an audio plugin. Packaging your audio algorithm as an audio plugin enables you to prototype your algorithm using the Audio Test Bench. The Audio Test Bench creates a user interface (UI) for tunable parameters, enables you to specify input and output from your audio stream loop, and provides access to analysis tools such as the time scope and spectrum analyzer. Packaging your code as an audio plugin also enables you to quickly synchronize your parameters with MIDI controls. For more information, see Design an Audio Plugin and Audio Test Bench Walkthrough.
Other methods to create UIs in MATLAB® include:
App Designer –– Development environment for a large set of interactive controls with support for 2-D plots. See Create and Run a Simple App Using App Designer (MATLAB) for more information.
GUIDE –– Drag-and-drop environment for laying out user interfaces with support for any type of plot. See Create a Simple App Using GUIDE (MATLAB) for more information.
Programmatic workflow –– Use MATLAB functions to define your app element-by-element. This tutorial uses a programmatic approach.
See Ways to Build Apps (MATLAB) for a more detailed list of the costs and benefits of the different approaches to parameter tuning.
In this tutorial, you tune the value of a parameter in an audio stream loop.
This tutorial contains three files:
parameterRef –– Class definition that contains
parameterTuningUI –– Function that creates a UI for
AudioProcessingScript –– Script for audio
Inspect the diagram for an overview of how real-time parameter tuning is implemented. To implement real-time parameter tuning, walk through the example for explanations and step-by-step instructions.
To tune a parameter in an audio stream loop using a UI, you need to associate the parameter with the position of a UI widget. To associate a parameter with a UI widget, make the parameter an object of a handle class. Objects of handle classes are passed by reference, meaning that you can modify the value of the object in one place and use the updated value in another. For example, you can modify the value of the object using a slider on a figure and use the updated value in an audio processing loop.
parameterRef class definition file to your current
classdef parameterRef < handle properties name value end end
Objects of the
parameterRef class have a
name is for display purposes on the UI. You use the
value for tuning.
parameterTuningUI function accepts your parameter,
specified as an object handle, and the desired range. The function creates a
figure with a slider associated with your parameter. The nested function,
slidercb, is called whenever the slider position changes.
The slider callback function maps the position of the slider to the parameter
range, updates the value of the parameter, and updates the text on the UI. You
can easily modify this function to tune multiple parameters in the same
The audio processing script:
Creates input and output objects for an audio stream loop.
Creates an object of the handle class,
parameterRef, that stores your parameter name
Calls the tuning UI function,
parameterTuningUI, with your parameter and the
Processes the audio in a loop. You can tune your parameter,
x, in the audio stream loop.
While the script runs, move the position of the slider to update your parameter value and hear the result.