class_docstr: Track the beats according to previously determined (local) tempo by
  iteratively aligning them around the estimated position [1]_.
  
  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.
  tempo_estimator : :class:`TempoEstimationProcessor`, optional
      Use this processor to estimate the (local) tempo. If 'None' a default
      tempo estimator will be created and used.
  fps : float, optional
      Frames per second.
  kwargs : dict, optional
      Keyword arguments passed to
      :class:`madmom.features.tempo.TempoEstimationProcessor` if no
      `tempo_estimator` was given.
  
  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 [1]_, it uses a comb filter based method [2]_ per default. The behaviour
  can be controlled with the `tempo_method` parameter.
  
  References
  ----------
  .. [1] 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.
  .. [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.
  
  Examples
  --------
  Create a BeatTrackingProcessor. The returned array represents the positions
  of the beats in seconds, thus the expected sampling rate has to be given.
  
  >>> proc = BeatTrackingProcessor(fps=100)
  >>> proc  # doctest: +ELLIPSIS
  <madmom.features.beats.BeatTrackingProcessor object at 0x...>
  
  Call this BeatTrackingProcessor with the beat activation function returned
  by RNNBeatProcessor to obtain the beat positions.
  
  >>> act = RNNBeatProcessor()('tests/data/audio/sample.wav')
  >>> proc(act)
  array([0.11, 0.45, 0.79, 1.13, 1.47, 1.81, 2.15, 2.49])
class_docstr_tok: ["Track","the","beats","according","to","previously","determined","(","local",")","tempo","by","iteratively","aligning","them","around","the","estimated","position","[","1","]","_.","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",".","tempo_estimator",":",":","class",":","`","TempoEstimationProcessor","`",",","optional","Use","this","processor","to","estimate","the","(","local",")","tempo",".","If","'None","'","a","default","tempo","estimator","will","be","created","and","used",".","fps",":","float",",","optional","Frames","per","second",".","kwargs",":","dict",",","optional","Keyword","arguments","passed","to",":","class",":","`","madmom.features.tempo.TempoEstimationProcessor","`","if","no","`","tempo_estimator","`","was","given",".","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","[","1","]","_",",","it","uses","a","comb","filter","based","method","[","2","]","_","per","default",".","The","behaviour","can","be","controlled","with","the","`","tempo_method","`","parameter",".","References","--","--","--","--","--","..","[","1","]","Sebastian","B\u00f6ck","and","Markus","Schedl",",","``","Enhanced","Beat","Tracking","with","Context-Aware","Neural","Networks","''",",","Proceedings","of","the","14th","International","Conference","on","Digital","Audio","Effects","(","DAFx",")",",","2011",".","..","[","2","]","Sebastian","B\u00f6ck",",","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",".","Examples","--","--","--","--","Create","a","BeatTrackingProcessor",".","The","returned","array","represents","the","positions","of","the","beats","in","seconds",",","thus","the","expected","sampling","rate","has","to","be","given",".",">",">",">","proc","=","BeatTrackingProcessor","(","fps=100",")",">",">",">","proc","#","doctest",":","+ELLIPSIS","<","madmom.features.beats.BeatTrackingProcessor","object","at","0x","...",">","Call","this","BeatTrackingProcessor","with","the","beat","activation","function","returned","by","RNNBeatProcessor","to","obtain","the","beat","positions",".",">",">",">","act","=","RNNBeatProcessor","(",")","(","'tests\/data\/audio\/sample.wav","'",")",">",">",">","proc","(","act",")","array","(","[","0.11",",","0.45",",","0.79",",","1.13",",","1.47",",","1.81",",","2.15",",","2.49","]",")"]
docstr: Detect the beats in the given activation function.
  
  Parameters
  ----------
  activations : numpy array
      Beat activation function.
  
  Returns
  -------
  beats : numpy array
      Detected beat positions [seconds].
docstr_tok: ["Detect","the","beats","in","the","given","activation","function",".","Parameters","--","--","--","--","--","activations",":","numpy","array","Beat","activation","function",".","Returns","--","--","--","-","beats",":","numpy","array","Detected","beat","positions","[","seconds","]","."]
code: def process(self, activations, **kwargs):
      """
      Detect the beats in the given activation function.
  
      Parameters
      ----------
      activations : numpy array
          Beat activation function.
  
      Returns
      -------
      beats : numpy array
          Detected beat positions [seconds].
  
      """
      # smooth activations
      act_smooth = int(self.fps * self.tempo_estimator.act_smooth)
      activations = smooth_signal(activations, act_smooth)
      # TODO: refactor interval stuff to use TempoEstimation
      # if look_ahead is not defined, assume a global tempo
      if self.look_ahead is None:
          # create a interval histogram
          histogram = self.tempo_estimator.interval_histogram(
              activations
          )
          # get the dominant interval
          interval = self.tempo_estimator.dominant_interval(histogram)
          # detect beats based on this interval
          detections = detect_beats(
              activations, interval, self.look_aside
          )
      else:
          # allow varying tempo
          look_ahead_frames = int(self.look_ahead * self.fps)
          # detect the beats
          detections = []
          pos = 0
          # TODO: make this _much_ faster!
          while pos < len(activations):
              # look N frames around the actual position
              act = signal_frame(
                  activations, pos, look_ahead_frames * 2, 1
              )
              # create a interval histogram
              histogram = self.tempo_estimator.interval_histogram(act)
              # get the dominant interval
              interval = self.tempo_estimator.dominant_interval(
                  histogram
              )
              # add the offset (i.e. the new detected start position)
              positions = detect_beats(act, interval, self.look_aside)
              # correct the beat positions
              positions += pos - look_ahead_frames
              # remove all positions < already detected beats + min_interval
              next_pos = (
                  detections[-1] + self.tempo_estimator.min_interval
                  if detections
                  else 0
              )
              positions = positions[positions >= next_pos]
              # search the closest beat to the predicted beat position
              pos = positions[(np.abs(positions - pos)).argmin()]
              # append to the beats
              detections.append(pos)
              pos += interval
  
      # convert detected beats to a list of timestamps
      detections = np.array(detections) / float(self.fps)
      # remove beats with negative times and return them
      return detections[np.searchsorted(detections, 0) :]
  
imports: from __future__ import absolute_import, division, print_function
  import sys
  import numpy
  from ..audio.signal import signal_frame, smooth
  from ..ml.nn import average_predictions
  from ..processors import OnlineProcessor, ParallelProcessor, Processor, SequentialProcessor
label_desc: Use image node_id 2 for calling the BeatTrackingProcessor obj's underlying member method code with example usage: obj.process(activations) and returns: detections