FluidWaveform:
Filter:
FluCoMa/Classes (extension) | Libraries > FluidCorpusManipulation

FluidWaveform
ExtensionExtension

Buffer waveform display with optional overlays

Description

FluidWaveform plots a buffer with optional overlays such as slices derived from a FluCoMa Slicer, or feature values from a FluCoMa audio descriptor.

Class Methods

.new

Create a new instance of FluidWaveform.

Arguments:

audioBuffer

The audio buffer to plot.

indicesBuffer

A Buffer of slice indices. This will very likely be in the form of a Buffer output from a FluCoMa slicer object. If this Buffer is only one channel it will plot lines at these slice points. If the Buffer is two channels it will consider the 0th channel to contain onsets and the 1st channel to contain offsets. This matches the output of FluidBufAmpGate.

featuresBuffer

A Buffer containing features to plot over the waveform. If this Buffer is multiple channels, it will plot each channel as a separate feature.

parent

A Window to place this FluidWaveform in. If nil, FluidWaveform will make its own window using the bounds argument. To create a view without parent and bounds (e.g. for GUIs with Layout Management), see the standalone argument below.

bounds

A Rect of where to place the FluidWaveform. If parent is nil, these bounds will be used to create a new Window. If parent is not nil, these bounds will be used to place this FluidWaveform in the parent.

lineWidth

The width of the line for plotting slice points and features.

waveformColor

A Color to make the waveform.

stackFeatures

If false, all the features (i.e., channels in the featureBuffer) will be overlayed on each other, as though on the same x and y axis. If true, each feature will occupy its own space covering the width of the plot and an fraction of the height (the number of channels in featureBuf / the height of the plot). The default is false.

imageBuffer

A Buffer that will be turned into a raster image and displayed. The buffer's frames will comprise the y axis, the buffer's channels will comprise the x axis (channel 0 at the bottom). Very likely this will come from the output of a Fluid analysis object, such as FluidBufSTFT which can be used to plot a spectrogram. Using FluidBufMelBands can be used to plot a Mel-frequency spectrum.

imageColorScheme

An integer indicating which color scheme1 to use to distinguish differences in the values in imageBuffer. The default is 0. One can also pass a Color and differences will be shown using alpha.

0Grey scale with slightly reduced contrast to avoid display saturation problems
1Black - Blue - Green - Yellow - White
2Blue - Magenta - Yellow highly saturated
3Black - Red - Yellow - White
4Black - Red - Yellow
imageAlpha

An transparency value (0-1) for displaying the waveform. 0 is fully transparent, 1 is fully visible. The default is 1.

normalizeFeaturesIndependently

Boolean. All the features in featureBuf need to be normalized for plotting. If true, this normalization will happen per feature, so that each will use the full visual range allowed to them. If false, the normalization will happen over all the values in the featureBuf (in all the channels), so that the features relative strengths will be preserved. The default is true.

imageColorScaling

An integer indicating how to scale the values in imageBuffer before applying the imageColorScheme. 0 indicates linear scaling, 1 indicates logarithmic scaling. The default is 1. These integers can also be accessed via FluidWaveform.lin and FluidWaveform.log.

standalone

If false, creates a View without parent or bounds, so that it can be used as part of a larger GUI, e.g. with Layout Management.

Returns:

A new instance of FluidWaveform.

.lin

Can be used as the colorScaling argument.

Returns:

0

.log

Can be used as the colorScaling argument.

Returns:

1

Instance Methods

.addAudioLayer

Add a graphic layer that shows a waveform.

Arguments:

audioBuffer

See this argument in the class method 'new' above.

waveformColor

See this argument in the class method 'new' above. The default is gray.

.addIndicesLayer

Add a grapic layer that shows indices.

Arguments:

indicesBuffer

See this argument in the class method 'new' above.

audioBuffer

The audioBuffer that the indices refer to.

color

The Color to display the indices. The default is red.

lineWidth

How wide to draw the indices lines. The default is 1.

.addFeaturesLayer

Add a grapic layer that shows feature curves.

Arguments:

featuresBuffer

See this argument in the class method 'new' above.

colors

An array of Color objects to use to display the different features. If there are more features than colors, FluidWaveform will modulo around the colors. If this is left blank, default colors will be used.

stackFeatures

See this argument in the class method 'new' above.

normalizeFeaturesIndependently

See this argument in the class method 'new' above.

lineWidth

See this argument in the class method 'new' above.

.addImageLayer

Add a grapic layer that shows an image derived from a buffer.

Arguments:

imageBuffer

See this argument in the class method 'new' above.

imageColorScheme

See this argument in the class method 'new' above.

imageColorScaling

See this argument in the class method 'new' above.

imageAlpha

See this argument in the class method 'new' above.

.front

Similar to Window's front method. Shows the FluidWaveform. This must be called after layers have been added in order to see the layers.

.refresh

Similar to Window's refresh method. Redraws all FluidWaveform layers. Has to be called after FluidWaveform: -addLayer in order to see the new layer.

.close

Close the FluidWaveform window. If parent is not nil, this method will close the parent window.

.parent

Returns:

The FluidWaveform window. If parent is not nil, this method will return the parent window.

Examples

Adding Layers One at a Time

[1] - The color schemes used are from https://colorcet.com/ Kovesi, Peter. "Good colour maps: How to design them." arXiv preprint arXiv:1509.03700 (2015). https://arxiv.org/abs/1509.03700