Main Content

plotFeatures

Plot extracted audio features

Since R2022b

    Description

    plotFeatures(afe,audioIn) extracts the enabled features of the audioFeatureExtractor object afe from the audio input and plots them.

    example

    plotFeatures(___,Name=Value) specifies properties of the plot using one or more name-value arguments. For example, to plot the audio signal along with the features, set PlotInput to true.

    example

    figureHandle = plotFeatures(___) returns a handle to the figure containing the plot.

    Examples

    collapse all

    Use plotFeatures to visualize audio features extracted with an audioFeatureExtractor object.

    Read in an audio signal from a file.

    [audioIn,fs] = audioread("Counting-16-44p1-mono-15secs.wav");

    Create an audioFeatureExtractor object that extracts the gammatone cepstral coefficients (GTCCs) and the delta of the GTCCs. Set the SampleRate property to the sample rate of the audio signal, and use the default values for the other properties.

    afe = audioFeatureExtractor(SampleRate=fs,gtcc=true,gtccDelta=true);

    Plot the features extracted from the audio signal.

    plotFeatures(afe,audioIn)

    Figure audioFeatureExtractor contains 2 axes objects and another object of type uipanel. Axes object 1 with title GTCC, xlabel Time (s), ylabel Coefficient contains an object of type image. Axes object 2 with title GTCC Delta, xlabel Time (s), ylabel Coefficient contains an object of type image.

    Read in an audio signal from a file.

    [audioIn,fs] = audioread("SingingAMajor-16-mono-18secs.ogg");

    Create an audioFeatureExtractor object that extracts the pitch and harmonic ratio. Set the SampleRate property to the sample rate of the audio signal, and use the default values for the other properties.

    afe = audioFeatureExtractor(SampleRate=fs,pitch=true,harmonicRatio=true);

    Plot the features with PlotInput set to true to include the audio signal in the plot.

    plotFeatures(afe,audioIn,PlotInput=true)

    Figure audioFeatureExtractor contains 3 axes objects and another object of type uipanel. Axes object 1 with title Pitch, xlabel Time (s), ylabel f0 (Hz) contains an object of type line. Axes object 2 with title Harmonic Ratio, xlabel Time (s), ylabel Harmonic Ratio contains an object of type line. Axes object 3 with title Audio, xlabel Time (s), ylabel Amplitude contains an object of type line.

    Input Arguments

    collapse all

    Input object, specified as an audioFeatureExtractor object. The audioFeatureExtractor object must have at least one feature enabled.

    Input audio, specified as a column vector or matrix of independent channels (columns). If the input has multiple channels, then the function plots only the features of the first channel. The length of the audio signal must be greater than or equal to the length of the Window property of the audioFeatureExtractor object.

    Data Types: single | double

    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: plotFeatures(afe,audioIn,PlotInput=true)

    Plot the input audio signal in addition to the extracted features, specified as true or false. If audioIn has multiple channels (columns), then the function plots only the first channel.

    Data Types: logical

    Parent container for the plot, specified as an object that is a valid Parent of a TiledChartLayout object.

    Output Arguments

    collapse all

    Handle to the figure containing the plot, returned as a Figure object.

    If the Parent argument is specified, plotFeatures returns the specified parent.

    Version History

    Introduced in R2022b