musicaiz.features.compute_ssm¶
- musicaiz.features.compute_ssm(file: Union[musicaiz.loaders.Musa, str, TextIO, pathlib.Path], ssm_type: str = 'louie', measures: Optional[Union[List[str], str]] = None, is_binary: bool = True, threshold: float = 0.5) numpy.ndarray [source]¶
Computes the selected SSM.
- Parameters
- file: Union[Musa, str, TextIO, Path]
A file or a musicaiz
Musa()
object.- ssm_type: str
Valid values:
louie
,measure
,measures
.louie
: Computes the SSM with Louie’s methodself_similarity_louie()
measure
: Computes the SSM with one of the_DEFAULT_MEASURES
measures
self_similarity_single_measure()
. Note that if thisssm_type
is selected, themeasures
argument must be a valid measure str.measures
: Computes the SSM with more than one of the_DEFAULT_MEASURES
measures
self_similarity_measures()
. Note that if thisssm_type
is selected, themeasures
argument must be a list of valid measure strs orall
.- measures: Union[List[str], str]
The measure or list of measures to compute the SSM with. It also accepts
all
as a value ifssm_type
is set tomeasures
.- is_binary: bool = True
Binarizes the SSM.
- threshold: int = 0.5
The threshold value used to binarize the SSSM.
- Returns
- s: np.ndarray [shape=(n_bars, n_bars)]
The SSM computed from the feature_vector or measure(s).
Examples
>>> from pathlib import Path >>> file = Path("tests/fixtures/tokenizers/mmm_tokens.mid") >>> ssm = musicaiz.features.compute_ssm( file=file, ssm_type="measures", measures="all" )