madmom.features.tempo¶
This module contains tempo related functionality.
-
madmom.features.tempo.
smooth_histogram
(histogram, smooth)[source]¶ Smooth the given histogram.
Parameters: - histogram : tuple
Histogram (tuple of 2 numpy arrays, the first giving the strengths of the bins and the second corresponding delay values).
- smooth : int or numpy array
Smoothing kernel (size).
Returns: - histogram_bins : numpy array
Bins of the smoothed histogram.
- histogram_delays : numpy array
Corresponding delays.
Notes
If smooth is an integer, a Hamming window of that length will be used as a smoothing kernel.
-
madmom.features.tempo.
interval_histogram_acf
(activations, min_tau=1, max_tau=None)[source]¶ Compute the interval histogram of the given (beat) activation function via auto-correlation as in [1].
Parameters: - activations : numpy array
Beat activation function.
- min_tau : int, optional
Minimal delay for the auto-correlation function [frames].
- max_tau : int, optional
Maximal delay for the auto-correlation function [frames].
Returns: - histogram_bins : numpy array
Bins of the tempo histogram.
- histogram_delays : numpy array
Corresponding delays [frames].
References
[1] (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.
-
madmom.features.tempo.
interval_histogram_comb
(activations, alpha, min_tau=1, max_tau=None)[source]¶ Compute the interval histogram of the given (beat) activation function via a bank of resonating comb filters as in [1].
Parameters: - activations : numpy array
Beat activation function.
- alpha : float or numpy array
Scaling factor for the comb filter; if only a single value is given, the same scaling factor for all delays is assumed.
- min_tau : int, optional
Minimal delay for the comb filter [frames].
- max_tau : int, optional
Maximal delta for comb filter [frames].
Returns: - histogram_bins : numpy array
Bins of the tempo histogram.
- histogram_delays : numpy array
Corresponding delays [frames].
References
[1] (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.
-
madmom.features.tempo.
dominant_interval
(histogram, smooth=None)[source]¶ Extract the dominant interval of the given histogram.
Parameters: - histogram : tuple
Histogram (tuple of 2 numpy arrays, the first giving the strengths of the bins and the second corresponding delay values).
- smooth : int or numpy array, optional
Smooth the histogram with the given kernel (size).
Returns: - interval : int
Dominant interval.
Notes
If smooth is an integer, a Hamming window of that length will be used as a smoothing kernel.
-
madmom.features.tempo.
detect_tempo
(histogram, fps)[source]¶ Extract the tempo from the given histogram.
Parameters: - histogram : tuple
Histogram (tuple of 2 numpy arrays, the first giving the strengths of the bins and the second corresponding delay values).
- fps : float
Frames per second.
Returns: - tempi : numpy array
Numpy array with the dominant tempi [bpm] (first column) and their relative strengths (second column).
-
class
madmom.features.tempo.
TempoHistogramProcessor
(min_bpm, max_bpm, hist_buffer=10.0, fps=None, online=False, **kwargs)[source]¶ Tempo Histogram Processor class.
Parameters: - min_bpm : float
Minimum tempo to detect [bpm].
- max_bpm : float
Maximum tempo to detect [bpm].
- hist_buffer : float
Aggregate the tempo histogram over hist_buffer seconds.
- fps : float, optional
Frames per second.
Notes
This abstract class provides the basic tempo histogram functionality. Please use one of the following implementations:
-
min_interval
¶ Minimum beat interval [frames].
-
max_interval
¶ Maximum beat interval [frames].
-
intervals
¶ Beat intervals [frames].
-
class
madmom.features.tempo.
CombFilterTempoHistogramProcessor
(min_bpm=40.0, max_bpm=250.0, alpha=0.79, hist_buffer=10.0, fps=None, online=False, **kwargs)[source]¶ Create a tempo histogram with a bank of resonating comb filters.
Parameters: - min_bpm : float, optional
Minimum tempo to detect [bpm].
- max_bpm : float, optional
Maximum tempo to detect [bpm].
- alpha : float, optional
Scaling factor for the comb filter.
- hist_buffer : float
Aggregate the tempo histogram over hist_buffer seconds.
- fps : float, optional
Frames per second.
- online : bool, optional
Operate in online (i.e. causal) mode.
-
process_offline
(activations, **kwargs)[source]¶ Compute the histogram of the beat intervals with a bank of resonating comb filters.
Parameters: - activations : numpy array
Beat activation function.
Returns: - histogram_bins : numpy array
Bins of the beat interval histogram.
- histogram_delays : numpy array
Corresponding delays [frames].
-
process_online
(activations, reset=True, **kwargs)[source]¶ Compute the histogram of the beat intervals with a bank of resonating comb filters in online mode.
Parameters: - activations : numpy float
Beat activation function.
- reset : bool, optional
Reset to initial state before processing.
Returns: - histogram_bins : numpy array
Bins of the tempo histogram.
- histogram_delays : numpy array
Corresponding delays [frames].
-
class
madmom.features.tempo.
ACFTempoHistogramProcessor
(min_bpm=40.0, max_bpm=250.0, hist_buffer=10.0, fps=None, online=False, **kwargs)[source]¶ Create a tempo histogram with autocorrelation.
Parameters: - min_bpm : float, optional
Minimum tempo to detect [bpm].
- max_bpm : float, optional
Maximum tempo to detect [bpm].
- hist_buffer : float
Aggregate the tempo histogram over hist_buffer seconds.
- fps : float, optional
Frames per second.
- online : bool, optional
Operate in online (i.e. causal) mode.
-
process_offline
(activations, **kwargs)[source]¶ Compute the histogram of the beat intervals with the autocorrelation function.
Parameters: - activations : numpy array
Beat activation function.
Returns: - histogram_bins : numpy array
Bins of the beat interval histogram.
- histogram_delays : numpy array
Corresponding delays [frames].
-
process_online
(activations, reset=True, **kwargs)[source]¶ Compute the histogram of the beat intervals with the autocorrelation function in online mode.
Parameters: - activations : numpy float
Beat activation function.
- reset : bool, optional
Reset to initial state before processing.
Returns: - histogram_bins : numpy array
Bins of the tempo histogram.
- histogram_delays : numpy array
Corresponding delays [frames].
-
class
madmom.features.tempo.
DBNTempoHistogramProcessor
(min_bpm=40.0, max_bpm=250.0, hist_buffer=10.0, fps=None, online=False, **kwargs)[source]¶ Create a tempo histogram with a dynamic Bayesian network (DBN).
Parameters: - min_bpm : float, optional
Minimum tempo to detect [bpm].
- max_bpm : float, optional
Maximum tempo to detect [bpm].
- hist_buffer : float
Aggregate the tempo histogram over hist_buffer seconds.
- fps : float, optional
Frames per second.
- online : bool, optional
Operate in online (i.e. causal) mode.
-
process_offline
(activations, **kwargs)[source]¶ Compute the histogram of the beat intervals with a DBN.
Parameters: - activations : numpy array
Beat activation function.
Returns: - histogram_bins : numpy array
Bins of the beat interval histogram.
- histogram_delays : numpy array
Corresponding delays [frames].
-
process_online
(activations, reset=True, **kwargs)[source]¶ Compute the histogram of the beat intervals with a DBN using the forward algorithm.
Parameters: - activations : numpy float
Beat activation function.
- reset : bool, optional
Reset DBN to initial state before processing.
Returns: - histogram_bins : numpy array
Bins of the tempo histogram.
- histogram_delays : numpy array
Corresponding delays [frames].
-
class
madmom.features.tempo.
TempoEstimationProcessor
(method='comb', min_bpm=40.0, max_bpm=250.0, act_smooth=0.14, hist_smooth=9, fps=None, online=False, histogram_processor=None, **kwargs)[source]¶ Tempo Estimation Processor class.
Parameters: - method : {‘comb’, ‘acf’, ‘dbn’}
Method used for tempo estimation.
- min_bpm : float, optional
Minimum tempo to detect [bpm].
- max_bpm : float, optional
Maximum tempo to detect [bpm].
- act_smooth : float, optional (default: 0.14)
Smooth the activation function over act_smooth seconds.
- hist_smooth : int, optional (default: 7)
Smooth the tempo histogram over hist_smooth bins.
- alpha : float, optional
Scaling factor for the comb filter.
- fps : float, optional
Frames per second.
- histogram_processor :
TempoHistogramProcessor
, optional Processor used to create a tempo histogram. If ‘None’, a default combfilter histogram processor will be created and used.
- kwargs : dict, optional
Keyword arguments passed to
CombFilterTempoHistogramProcessor
if no histogram_processor was given.
Examples
Create a TempoEstimationProcessor. The returned array represents the estimated tempi (given in beats per minute) and their relative strength.
>>> proc = TempoEstimationProcessor(fps=100) >>> proc <madmom.features.tempo.TempoEstimationProcessor object at 0x...>
Call this TempoEstimationProcessor with the beat activation function obtained by RNNBeatProcessor to estimate the tempi.
>>> from madmom.features.beats import RNNBeatProcessor >>> act = RNNBeatProcessor()('tests/data/audio/sample.wav') >>> proc(act) array([[176.47059, 0.47469], [117.64706, 0.17667], [240. , 0.15371], [ 68.96552, 0.09864], [ 82.19178, 0.09629]])
-
min_bpm
¶ Minimum tempo [bpm].
-
max_bpm
¶ Maximum tempo [bpm].
-
intervals
¶ Beat intervals [frames].
-
min_interval
¶ Minimum beat interval [frames].
-
max_interval
¶ Maximum beat interval [frames].
-
process_offline
(activations, **kwargs)[source]¶ Detect the tempi from the (beat) activations.
Parameters: - activations : numpy array
Beat activation function.
Returns: - tempi : numpy array
Array with the dominant tempi [bpm] (first column) and their relative strengths (second column).
-
process_online
(activations, reset=True, **kwargs)[source]¶ Detect the tempi from the (beat) activations in online mode.
Parameters: - activations : numpy array
Beat activation function processed frame by frame.
- reset : bool, optional
Reset the TempoEstimationProcessor to its initial state before processing.
Returns: - tempi : numpy array
Array with the dominant tempi [bpm] (first column) and their relative strengths (second column).
-
interval_histogram
(activations, **kwargs)[source]¶ Compute the histogram of the beat intervals.
Parameters: - activations : numpy array
Beat activation function.
Returns: - histogram_bins : numpy array
Bins of the beat interval histogram.
- histogram_delays : numpy array
Corresponding delays [frames].
-
dominant_interval
(histogram)[source]¶ Extract the dominant interval of the given histogram.
Parameters: - histogram : tuple
Histogram (tuple of 2 numpy arrays, the first giving the strengths of the bins and the second corresponding delay values).
Returns: - interval : int
Dominant interval.
-
static
add_arguments
(parser, method=None, min_bpm=None, max_bpm=None, act_smooth=None, hist_smooth=None, hist_buffer=None, alpha=None)[source]¶ Add tempo estimation related arguments to an existing parser.
Parameters: - parser : argparse parser instance
Existing argparse parser.
- method : {‘comb’, ‘acf’, ‘dbn’}
Method used for tempo estimation.
- min_bpm : float, optional
Minimum tempo to detect [bpm].
- max_bpm : float, optional
Maximum tempo to detect [bpm].
- act_smooth : float, optional
Smooth the activation function over act_smooth seconds.
- hist_smooth : int, optional
Smooth the tempo histogram over hist_smooth bins.
- hist_buffer : float, optional
Aggregate the tempo histogram over hist_buffer seconds.
- alpha : float, optional
Scaling factor for the comb filter.
Returns: - parser_group : argparse argument group
Tempo argument parser group.
Notes
Parameters are included in the group only if they are not ‘None’.