madmom.features.beats

This module contains beat tracking related functionality.

class madmom.features.beats.MultiModelSelectionProcessor(num_ref_predictions, **kwargs)[source]

Processor for selecting the most suitable model (i.e. the predictions thereof) from a multiple models/predictions.

Parameters:

num_ref_predictions : int

Number of reference predictions (see below).

Notes

This processor selects the most suitable prediction from multiple models by comparing them to the predictions of a reference model. The one with the smallest mean squared error is chosen.

If num_ref_predictions is 0 or None, an averaged prediction is computed from the given predictions and used as reference.

References

[R13]Sebastian Böck, Florian Krebs and Gerhard Widmer, “A Multi-Model Approach to Beat Tracking Considering Heterogeneous Music Styles”, Proceedings of the 15th International Society for Music Information Retrieval Conference (ISMIR), 2014.
process(predictions)[source]

Selects the most appropriate predictions form the list of predictions.

Parameters:

predictions : list

Predictions (beat activation functions) of multiple models.

Returns:

numpy array

Most suitable prediction.

Notes

The reference beat activation function must be the first one in the list of given predictions.

madmom.features.beats.detect_beats(activations, interval, look_aside=0.2)[source]

Detects the beats in the given activation function as in [R14].

Parameters:

activations : numpy array

Beat activations.

interval : int

Look for the next beat each interval frames.

look_aside : float

Look this fraction of the interval to each side to detect the beats.

Returns:

numpy array

Beat positions [frames].

Notes

A Hamming window of 2 * look_aside * interval is applied around the position where the beat is expected to prefer beats closer to the centre.

References

[R14](1, 2) Sebastian Böck and Markus Schedl, “Enhanced Beat Tracking with Context-Aware Neural Networks”, Proceedings of the 14th International Conference on Digital Audio Effects (DAFx), 2011.
class madmom.features.beats.BeatTrackingProcessor(look_aside=0.2, look_ahead=10, fps=None, **kwargs)[source]

Track the beats according to previously determined (local) tempo by iteratively aligning them around the estimated position [R15].

Parameters:

look_aside : float, optional

Look this fraction of the estimated beat interval to each side of the assumed next beat position to look for the most likely position of the next beat.

look_ahead : float, optional

Look look_ahead seconds in both directions to determine the local tempo and align the beats accordingly.

fps : float, optional

Frames per second.

Notes

If look_ahead is not set, a constant tempo throughout the whole piece is assumed. If look_ahead is set, the local tempo (in a range +/- look_ahead seconds around the actual position) is estimated and then the next beat is tracked accordingly. This procedure is repeated from the new position to the end of the piece.

Instead of the auto-correlation based method for tempo estimation proposed in [R15], it uses a comb filter based method [R16] per default. The behaviour can be controlled with the tempo_method parameter.

References

[R15](1, 2, 3) Sebastian Böck and Markus Schedl, “Enhanced Beat Tracking with Context-Aware Neural Networks”, Proceedings of the 14th International Conference on Digital Audio Effects (DAFx), 2011.
[R16](1, 2) Sebastian Böck, Florian Krebs and Gerhard Widmer, “Accurate Tempo Estimation based on Recurrent Neural Networks and Resonating Comb Filters”, Proceedings of the 16th International Society for Music Information Retrieval Conference (ISMIR), 2015.
process(activations)[source]

Detect the beats in the given activation function.

Parameters:

activations : numpy array

Beat activation function.

Returns

——-

beats : numpy array

Detected beat positions [seconds].

static add_arguments(parser, look_aside=0.2, look_ahead=10)[source]

Add beat tracking related arguments to an existing parser.

Parameters:

parser : argparse parser instance

Existing argparse parser object.

look_aside : float, optional

Look this fraction of the estimated beat interval to each side of the assumed next beat position to look for the most likely position of the next beat.

look_ahead : float, optional

Look look_ahead seconds in both directions to determine the local tempo and align the beats accordingly.

Returns:

parser_group : argparse argument group

Beat tracking argument parser group.

Notes

Parameters are included in the group only if they are not ‘None’.

class madmom.features.beats.BeatDetectionProcessor(look_aside=0.2, fps=None, **kwargs)[source]

Class for detecting beats according to the previously determined global tempo by iteratively aligning them around the estimated position [R18].

Parameters:

look_aside : float

Look this fraction of the estimated beat interval to each side of the assumed next beat position to look for the most likely position of the next beat.

fps : float, optional

Frames per second.

Notes

A constant tempo throughout the whole piece is assumed.

Instead of the auto-correlation based method for tempo estimation proposed in [R18], it uses a comb filter based method [R19] per default. The behaviour can be controlled with the tempo_method parameter.

References

[R18](1, 2, 3) Sebastian Böck and Markus Schedl, “Enhanced Beat Tracking with Context-Aware Neural Networks”, Proceedings of the 14th International Conference on Digital Audio Effects (DAFx), 2011.
[R19](1, 2) Sebastian Böck, Florian Krebs and Gerhard Widmer, “Accurate Tempo Estimation based on Recurrent Neural Networks and Resonating Comb Filters”, Proceedings of the 16th International Society for Music Information Retrieval Conference (ISMIR), 2015.
class madmom.features.beats.CRFBeatDetectionProcessor(interval_sigma=0.18, use_factors=False, num_intervals=5, factors=array([ 0.5, 0.67, 1., 1.5, 2. ]), **kwargs)[source]

Conditional Random Field Beat Detection.

Tracks the beats according to the previously determined global tempo using a conditional random field (CRF) model.

Parameters:

interval_sigma : float, optional

Allowed deviation from the dominant beat interval per beat.

use_factors : bool, optional

Use dominant interval multiplied by factors instead of intervals estimated by tempo estimator.

num_intervals : int, optional

Maximum number of estimated intervals to try.

factors : list or numpy array, optional

Factors of the dominant interval to try.

References

[R21]Filip Korzeniowski, Sebastian Böck and Gerhard Widmer, “Probabilistic Extraction of Beat Positions from a Beat Activation Function”, Proceedings of the 15th International Society for Music Information Retrieval Conference (ISMIR), 2014.
process(activations)[source]

Detect the beats in the given activation function.

Parameters:

activations : numpy array

Beat activation function.

Returns:

numpy array

Detected beat positions [seconds].

static add_arguments(parser, interval_sigma=0.18, use_factors=False, num_intervals=5, factors=array([ 0.5, 0.67, 1., 1.5, 2. ]))[source]

Add CRFBeatDetection related arguments to an existing parser.

Parameters:

parser : argparse parser instance

Existing argparse parser object.

interval_sigma : float, optional

allowed deviation from the dominant beat interval per beat

use_factors : bool, optional

use dominant interval multiplied by factors instead of intervals estimated by tempo estimator

num_intervals : int, optional

max number of estimated intervals to try

factors : list or numpy array, optional

factors of the dominant interval to try

Returns:

parser_group : argparse argument group

CRF beat tracking argument parser group.

class madmom.features.beats.DBNBeatTrackingProcessor(min_bpm=55.0, max_bpm=215.0, num_tempi=None, transition_lambda=100, observation_lambda=16, correct=True, fps=None, **kwargs)[source]

Beat tracking with RNNs and a dynamic Bayesian network (DBN) approximated by a Hidden Markov Model (HMM).

Parameters:

min_bpm : float, optional

Minimum tempo used for beat tracking [bpm].

max_bpm : float, optional

Maximum tempo used for beat tracking [bpm].

num_tempi : int, optional

Number of tempi to model; if set, limit the number of tempi and use a log spacing, otherwise a linear spacing.

transition_lambda : float, optional

Lambda for the exponential tempo change distribution (higher values prefer a constant tempo from one beat to the next one).

observation_lambda : int, optional

Split one beat period into observation_lambda parts, the first representing beat states and the remaining non-beat states.

correct : bool, optional

Correct the beats (i.e. align them to the nearest peak of the beat activation function).

fps : float, optional

Frames per second.

Notes

Instead of the originally proposed state space and transition model for the DBN [R22], the more efficient version proposed in [R23] is used.

References

[R22](1, 2) Sebastian Böck, Florian Krebs and Gerhard Widmer, “A Multi-Model Approach to Beat Tracking Considering Heterogeneous Music Styles”, Proceedings of the 15th International Society for Music Information Retrieval Conference (ISMIR), 2014.
[R23](1, 2) Florian Krebs, Sebastian Böck and Gerhard Widmer, “An Efficient State Space Model for Joint Tempo and Meter Tracking”, Proceedings of the 16th International Society for Music Information Retrieval Conference (ISMIR), 2015.
process(activations)[source]

Detect the beats in the given activation function.

Parameters:

activations : numpy array

Beat activation function.

Returns:

beats : numpy array

Detected beat positions [seconds].

static add_arguments(parser, min_bpm=55.0, max_bpm=215.0, num_tempi=None, transition_lambda=100, observation_lambda=16, correct=True)[source]

Add DBN related arguments to an existing parser object.

Parameters:

parser : argparse parser instance

Existing argparse parser object.

min_bpm : float, optional

Minimum tempo used for beat tracking [bpm].

max_bpm : float, optional

Maximum tempo used for beat tracking [bpm].

num_tempi : int, optional

Number of tempi to model; if set, limit the number of tempi and use a log spacing, otherwise a linear spacing.

transition_lambda : float, optional

Lambda for the exponential tempo change distribution (higher values prefer a constant tempo over a tempo change from one beat to the next one).

observation_lambda : int, optional

Split one beat period into observation_lambda parts, the first representing beat states and the remaining non-beat states.

correct : bool, optional

Correct the beats (i.e. align them to the nearest peak of the beat activation function).

Returns:

parser_group : argparse argument group

DBN beat tracking argument parser group

class madmom.features.beats.DownbeatTrackingProcessor[source]

Renamed to PatternTrackingProcessor in v0.13. Will be removed in v0.14.

class madmom.features.beats.PatternTrackingProcessor(pattern_files, min_bpm=[55, 60], max_bpm=[205, 225], num_tempi=[None, None], transition_lambda=[100, 100], downbeats=False, fps=None, **kwargs)[source]

Pattern tracking with a dynamic Bayesian network (DBN) approximated by a Hidden Markov Model (HMM).

Parameters:

pattern_files : list

List of files with the patterns (including the fitted GMMs and information about the number of beats).

min_bpm : list, optional

Minimum tempi used for pattern tracking [bpm].

max_bpm : list, optional

Maximum tempi used for pattern tracking [bpm].

num_tempi : int or list, optional

Number of tempi to model; if set, limit the number of tempi and use a log spacings, otherwise a linear spacings.

transition_lambda : float or list, optional

Lambdas for the exponential tempo change distributions (higher values prefer constant tempi from one beat to the next .one)

downbeats : bool, optional

Report only the downbeats instead of the beats and the respective position inside the bar.

fps : float, optional

Frames per second.

Notes

min_bpm, max_bpm, num_tempo_states, and transition_lambda must contain as many items as rhythmic patterns are modeled (i.e. length of pattern_files). If a single value is given for num_tempo_states and transition_lambda, this value is used for all rhythmic patterns.

Instead of the originally proposed state space and transition model for the DBN [R24], the more efficient version proposed in [R25] is used.

References

[R24](1, 2) Florian Krebs, Sebastian Böck and Gerhard Widmer, “Rhythmic Pattern Modeling for Beat and Downbeat Tracking in Musical Audio”, Proceedings of the 15th International Society for Music Information Retrieval Conference (ISMIR), 2013.
[R25](1, 2) Florian Krebs, Sebastian Böck and Gerhard Widmer, “An Efficient State Space Model for Joint Tempo and Meter Tracking”, Proceedings of the 16th International Society for Music Information Retrieval Conference (ISMIR), 2015.
process(activations)[source]

Detect the beats based on the given activations.

Parameters:

activations : numpy array

Activations (i.e. multi-band spectral features).

Returns:

beats : numpy array

Detected beat positions [seconds].

static add_arguments(parser, pattern_files=None, min_bpm=[55, 60], max_bpm=[205, 225], num_tempi=[None, None], transition_lambda=[100, 100])[source]

Add DBN related arguments for pattern tracking to an existing parser object.

Parameters:

parser : argparse parser instance

Existing argparse parser object.

pattern_files : list

Load the patterns from these files.

min_bpm : list, optional

Minimum tempi used for beat tracking [bpm].

max_bpm : list, optional

Maximum tempi used for beat tracking [bpm].

num_tempi : int or list, optional

Number of tempi to model; if set, limit the number of states and use log spacings, otherwise a linear spacings.

transition_lambda : float or list, optional

Lambdas for the exponential tempo change distribution (higher values prefer constant tempi from one beat to the next one).

Returns:

parser_group : argparse argument group

Pattern tracking argument parser group

Notes

pattern_files, min_bpm, max_bpm, num_tempi, and transition_lambda must the same number of items.