madmom.evaluation.tempo¶
This module contains tempo evaluation functionality.
-
madmom.evaluation.tempo.
load_tempo
(values, split_value=1.0, sort=False, norm_strengths=False, max_len=None)[source]¶ Load tempo information from the given values or file.
Parameters: values : str, file handle, list of tuples or numpy array
Tempo values or file name/handle.
split_value : float, optional
Value to distinguish between tempi and strengths. values > split_value are interpreted as tempi [bpm], values <= split_value are interpreted as strengths.
sort : bool, optional
Sort the tempi by their strength.
norm_strengths : bool, optional
Normalize the strengths to sum 1.
max_len : int, optional
Return at most max_len tempi.
Returns: tempi : numpy array, shape (num_tempi, 2)
Array with tempi (rows, first column) and their relative strengths (second column).
Notes
The tempo must have the one of the following formats (separated by whitespace if loaded from file):
‘tempo_one’ ‘tempo_two’ ‘relative_strength’ (of the first tempo) ‘tempo_one’ ‘tempo_two’ ‘strength_one’ ‘strength_two’
If no strengths are given, uniformly distributed strengths are returned.
-
madmom.evaluation.tempo.
tempo_evaluation
(detections, annotations, tolerance=0.04)[source]¶ Calculate the tempo P-Score, at least one or both tempi correct.
Parameters: detections : list of tuples or numpy array
Detected tempi (rows, first column) and their relative strengths (second column).
annotations : list or numpy array
Annotated tempi (rows, first column) and their relative strengths (second column).
tolerance : float, optional
Evaluation tolerance (max. allowed deviation).
Returns: pscore : float
P-Score.
at_least_one : bool
At least one tempo correctly identified.
all : bool
All tempi correctly identified.
Notes
All given detections are evaluated against all annotations according to the relative strengths given. If no strengths are given, evenly distributed strengths are assumed. If the strengths do not sum to 1, they will be normalized.
References
[R17] M. McKinney, D. Moelants, M. Davies and A. Klapuri, “Evaluation of audio beat tracking and music tempo extraction algorithms”, Journal of New Music Research, vol. 36, no. 1, 2007.
-
class
madmom.evaluation.tempo.
TempoEvaluation
(detections, annotations, tolerance=0.04, double=True, triple=True, sort=True, max_len=None, name=None, **kwargs)[source]¶ Tempo evaluation class.
Parameters: detections : str, list of tuples or numpy array
Detected tempi (rows) and their strengths (columns). If a file name is given, load them from this file.
annotations : str, list or numpy array
Annotated ground truth tempi (rows) and their strengths (columns). If a file name is given, load them from this file.
tolerance : float, optional
Evaluation tolerance (max. allowed deviation).
double : bool, optional
Include double and half tempo variations.
triple : bool, optional
Include triple and third tempo variations.
sort : bool, optional
Sort the tempi by their strengths (descending order).
max_len : bool, optional
Evaluate at most max_len tempi.
name : str, optional
Name of the evaluation to be displayed.
Notes
For P-Score, the number of detected tempi will be limited to the number of annotations (if not further limited by max_len). For Accuracy 1 & 2 only one detected tempo is used. Depending on sort, this can be either the first or the strongest one.
-
class
madmom.evaluation.tempo.
TempoMeanEvaluation
(eval_objects, name=None, **kwargs)[source]¶ Class for averaging tempo evaluation scores.
-
pscore
¶ P-Score.
-
any
¶ At least one tempo correct.
-
all
¶ All tempi correct.
-
acc1
¶ Accuracy 1.
-
acc2
¶ Accuracy 2.
-
-
madmom.evaluation.tempo.
add_parser
(parser)[source]¶ Add a tempo evaluation sub-parser to an existing parser.
Parameters: parser : argparse parser instance
Existing argparse parser object.
Returns: sub_parser : argparse sub-parser instance
Tempo evaluation sub-parser.
parser_group : argparse argument group
Tempo evaluation argument group.