This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materials including this page, select Japan from the country navigator on the bottom of this page.

Real-Time Parameter Tuning

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 System 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 System 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 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.

Programmatic Parameter Tuning

In this tutorial, you tune the value of a parameter in an audio stream loop.

This tutorial contains three files:

  1. parameterRef — Class definition that contains tunable parameters

  2. parameterTuningUI — Function that creates a UI for parameter tuning

  3. AudioProcessingScript — Script for audio processing

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.

1. Create Class with Tunable Parameters

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.

Save the parameterRef class definition file to your current folder.

classdef parameterRef < handle

Objects of the parameterRef class have a name and value. The name is for display purposes on the UI. You use the value for tuning.

2. Create Function to Generate a UI

The 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 UI.

 Save parameterTuningUI to Current Folder

3. Create Script for Audio Processing

The audio processing script:

  1. Creates input and output objects for an audio stream loop.

  2. Creates an object of the handle class, parameterRef, that stores your parameter name and value.

  3. Calls the tuning UI function, parameterTuningUI, with your parameter and the parameter range.

  4. Processes the audio in a loop. You can tune your parameter, x, in the audio stream loop.

 Run AudioProcessingScript

While the script runs, move the position of the slider to update your parameter value and hear the result.

See Also

Related Topics

Was this topic helpful?