madmom.features.beats_hmm¶
This module contains HMM state spaces, transition and observation models used for beat, downbeat and pattern tracking.
Notes¶
Please note that (almost) everything within this module is discretised to integer values because of performance reasons.
-
class
madmom.features.beats_hmm.
BeatStateSpace
(min_interval, max_interval, num_intervals=None)[source]¶ State space for beat tracking with a HMM.
Parameters: - min_interval : float
Minimum interval to model.
- max_interval : float
Maximum interval to model.
- num_intervals : int, optional
Number of intervals to model; if set, limit the number of intervals and use a log spacing instead of the default linear spacing.
References
[1] 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. Attributes: - num_states : int
Number of states.
- intervals : numpy array
Modeled intervals.
- num_intervals : int
Number of intervals.
- state_positions : numpy array
Positions of the states (i.e. 0…1).
- state_intervals : numpy array
Intervals of the states (i.e. 1 / tempo).
- first_states : numpy array
First state of each interval.
- last_states : numpy array
Last state of each interval.
-
class
madmom.features.beats_hmm.
BarStateSpace
(num_beats, min_interval, max_interval, num_intervals=None)[source]¶ State space for bar tracking with a HMM.
Model num_beat identical beats with the given arguments in a single state space.
Parameters: - num_beats : int
Number of beats to form a bar.
- min_interval : float
Minimum beat interval to model.
- max_interval : float
Maximum beat interval to model.
- num_intervals : int, optional
Number of beat intervals to model; if set, limit the number of intervals and use a log spacing instead of the default linear spacing.
References
[1] 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. Attributes: - num_beats : int
Number of beats.
- num_states : int
Number of states.
- num_intervals : int
Number of intervals.
- state_positions : numpy array
Positions of the states.
- state_intervals : numpy array
Intervals of the states.
- first_states : list
First states of each beat.
- last_states : list
Last states of each beat.
-
class
madmom.features.beats_hmm.
MultiPatternStateSpace
(state_spaces)[source]¶ State space for rhythmic pattern tracking with a HMM.
Model a joint state space with the given state_spaces by stacking the individual state spaces.
Parameters: - state_spaces : list
List with state spaces to model.
References
[1] 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.
-
madmom.features.beats_hmm.
exponential_transition
(from_intervals, to_intervals, transition_lambda, threshold=2.220446049250313e-16, norm=True)[source]¶ Exponential tempo transition.
Parameters: - from_intervals : numpy array
Intervals where the transitions originate from.
- to_intervals
Intervals where the transitions terminate.
- transition_lambda : float
Lambda for the exponential tempo change distribution (higher values prefer a constant tempo from one beat/bar to the next one). If None, allow only transitions from/to the same interval.
- threshold : float, optional
Set transition probabilities below this threshold to zero.
- norm : bool, optional
Normalize the emission probabilities to sum 1.
Returns: - probabilities : numpy array, shape (num_from_intervals, num_to_intervals)
Probability of each transition from an interval to another.
References
[1] 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.
-
class
madmom.features.beats_hmm.
BeatTransitionModel
(state_space, transition_lambda)[source]¶ Transition model for beat tracking with a HMM.
Within the beat the tempo stays the same; at beat boundaries transitions from one tempo (i.e. interval) to another are allowed, following an exponential distribution.
Parameters: - state_space :
BeatStateSpace
instance BeatStateSpace instance.
- transition_lambda : float
Lambda for the exponential tempo change distribution (higher values prefer a constant tempo from one beat to the next one).
References
[1] 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. - state_space :
-
class
madmom.features.beats_hmm.
BarTransitionModel
(state_space, transition_lambda)[source]¶ Transition model for bar tracking with a HMM.
Within the beats of the bar the tempo stays the same; at beat boundaries transitions from one tempo (i.e. interval) to another following an exponential distribution are allowed.
Parameters: - state_space :
BarStateSpace
instance BarStateSpace instance.
- transition_lambda : float or list
Lambda for the exponential tempo change distribution (higher values prefer a constant tempo from one beat to the next one). None can be used to set the tempo change probability to 0. If a list is given, the individual values represent the lambdas for each transition into the beat at this index position.
Notes
Bars performing tempo changes only at bar boundaries (and not at the beat boundaries) must have set all but the first transition_lambda values to None, e.g. [100, None, None] for a bar with 3 beats.
References
[1] 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. - state_space :
-
class
madmom.features.beats_hmm.
MultiPatternTransitionModel
(transition_models, transition_prob=None)[source]¶ Transition model for pattern tracking with a HMM.
Add transitions with the given probability between the individual transition models. These transition models must correspond to the state spaces forming a
MultiPatternStateSpace
.Parameters: - transition_models : list
List with
TransitionModel
instances.- transition_prob : numpy array or float, optional
Probabilities to change the pattern at pattern boundaries. If an array is given, the first dimension corresponds to the origin pattern, the second to the destination pattern. If a single value is given, a uniform transition distribution to all other patterns is assumed. Set to None to stay within the same pattern.
-
class
madmom.features.beats_hmm.
RNNBeatTrackingObservationModel
(state_space, observation_lambda)[source]¶ Observation model for beat tracking with a HMM.
Parameters: - state_space :
BeatStateSpace
instance BeatStateSpace instance.
- observation_lambda : int
Split one beat period into observation_lambda parts, the first representing beat states and the remaining non-beat states.
References
[1] 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. -
log_densities
(observations)[source]¶ Compute the log densities of the observations.
Parameters: - observations : numpy array, shape (N, )
Observations (i.e. 1D beat activations of the RNN).
Returns: - numpy array, shape (N, 2)
Log densities of the observations, the columns represent the observation log probability densities for no-beats and beats.
- state_space :
-
class
madmom.features.beats_hmm.
RNNDownBeatTrackingObservationModel
(state_space, observation_lambda)[source]¶ Observation model for downbeat tracking with a HMM.
Parameters: - state_space :
BarStateSpace
instance BarStateSpace instance.
- observation_lambda : int
Split each (down-)beat period into observation_lambda parts, the first representing (down-)beat states and the remaining non-beat states.
References
[1] Sebastian Böck, Florian Krebs and Gerhard Widmer, “Joint Beat and Downbeat Tracking with Recurrent Neural Networks” Proceedings of the 17th International Society for Music Information Retrieval Conference (ISMIR), 2016. -
log_densities
(observations)[source]¶ Compute the log densities of the observations.
Parameters: - observations : numpy array, shape (N, 2)
Observations (i.e. 2D activations of a RNN, the columns represent ‘beat’ and ‘downbeat’ probabilities)
Returns: - numpy array, shape (N, 3)
Log densities of the observations, the columns represent the observation log probability densities for no-beats, beats and downbeats.
- state_space :
-
class
madmom.features.beats_hmm.
GMMPatternTrackingObservationModel
(pattern_files, state_space)[source]¶ Observation model for GMM based beat tracking with a HMM.
Parameters: - pattern_files : list
List with files representing the rhythmic patterns, one entry per pattern; each pattern being a list with fitted GMMs.
- state_space :
MultiPatternStateSpace
instance Multi pattern state space.
References
[1] Florian Krebs, Sebastian Böck and Gerhard Widmer, “Rhythmic Pattern Modeling for Beat and Downbeat Tracking in Musical Audio”, Proceedings of the 14th International Society for Music Information Retrieval Conference (ISMIR), 2013. -
log_densities
(observations)[source]¶ Compute the log densities of the observations using (a) GMM(s).
Parameters: - observations : numpy array
Observations (i.e. multi-band spectral flux features).
Returns: - numpy array, shape (N, num_gmms)
Log densities of the observations, the columns represent the observation log probability densities for the individual GMMs.