Ssm¶
Auto-generated documentation for musicalgestures._ssm module.
mg_ssm¶
def mg_ssm(
self,
features='motiongrams',
filtertype='Regular',
thresh=0.05,
blur='None',
norm=np.inf,
threshold=0.001,
cmap='gray_r',
use_median=False,
kernel_size=5,
invert_yaxis=True,
title=None,
target_name=None,
overwrite=False,
):
Compute Self-Similarity Matrix (SSM) by converting the input signal into a suitable feature sequence and comparing each element of the feature sequence with all other elements of the sequence. SSMs can be computed over different input features such as 'motiongrams', 'spectrogram', 'chromagram' and 'tempogram'.
Arguments¶
featuresstr, optional - Defines the type of features on which to compute SSM. Possible to compute SSM on 'motiongrams', 'videograms', 'spectrogram', 'chromagram' and 'tempogram'. Defaults to 'motiongrams'.filtertypestr, optional - 'Regular' turns all values belowthreshto 0. 'Binary' turns all values belowthreshto 0, abovethreshto 1. 'Blob' removes individual pixels with erosion method. Defaults to 'Regular'.threshfloat, optional - Eliminates pixel values less than given threshold. Ranges from 0 to 1. Defaults to 0.05.blurstr, optional - 'Average' to apply a 10px * 10px blurring filter, 'None' otherwise. Defaults to 'None'.normint, optional - Normalize the columns of the feature sequence. Possible to compute Manhattan norm (1), Euclidean norm (2), Minimum norm (-np.inf), Maximum norm (np.inf), etc. Defaults to np.inf.thresholdfloat, optional - Only the columns with norm at least the amount ofthresholdindicated are normalized. Defaults to 0.001.cmapstr, optional - A Colormap instance or registered colormap name. The colormap maps the C values to colors. Defaults to 'gray_r'.use_medianbool, optional - If True the algorithm applies a median filter on the thresholded frame-difference stream. Defaults to False.kernel_sizeint, optional - Size of the median filter (ifuse_median=True) or the erosion filter (iffiltertype='blob'). Defaults to 5.invert_axisbool, optional - Whether to invert the y axis of the SSM. Defaults to True.titlestr, optional - Optionally add title to the figure. Possible to set the filename as the title using the string 'filename'. Defaults to None.target_name[type], optional - Target output name for the SSM. Defaults to None.overwritebool, optional - Whether to allow overwriting existing files or to automatically increment target filenames to avoid overwriting. Defaults to False.
Returns¶
if features='motiongrams':¶
MgList- An MgList pointing to the output SSM images (as MgImages).
else:¶
MgImage- An MgImage to the output SSM.
slow_dot¶
Low-memory implementation of dot product
smooth_downsample_feature_sequence¶
Smoothes and downsamples a feature sequence. Smoothing is achieved by convolution with a filter kernel
Arguments¶
Xnp.ndarray - Feature sequence.srint - Sampling rate.filt_lenint, optional - Length of smoothing filter. Defaults to 41.down_samplingint, optional - Downsampling factor. Defaults to 10.w_typestr, optional - Window type of smoothing filter. Defaults to 'boxcar'.
Returns¶
X_smoothnp.ndarray - Smoothed and downsampled feature sequence.sr_featurescalar - Sampling rate ofX_smooth.