class_docstr: Shift the samples forwards or backwards, with or without rollover
docstr: :param min_shift: Minimum amount of shifting in time. See also shift_unit.
  :param max_shift: Maximum amount of shifting in time. See also shift_unit.
  :param shift_unit: Defines the unit of the value of min_shift and max_shift.
      "fraction": Fraction of the total sound length
      "samples": Number of audio samples
      "seconds": Number of seconds
  :param rollover: When set to True, samples that roll beyond the first or last position
      are re-introduced at the last or first. When set to False, samples that roll beyond
      the first or last position are discarded. In other words, rollover=False results in
      an empty space (with zeroes).
  :param fade_duration: If you set this to a positive number (in seconds), there
      will be a fade in and/or out at the "stitch" (that was the start or the end
      of the audio before the shift). This can smooth out an unwanted abrupt
      change between two consecutive samples (which sounds like a
      transient/click/pop). This parameter denotes the duration of the fade in
      seconds. To disable the fading feature, set this parameter to 0.0.
  :param p: The probability of applying this transform
docstr_tok: [":","param","min_shift",":","Minimum","amount","of","shifting","in","time",".","See","also","shift_unit",".",":","param","max_shift",":","Maximum","amount","of","shifting","in","time",".","See","also","shift_unit",".",":","param","shift_unit",":","Defines","the","unit","of","the","value","of","min_shift","and","max_shift",".","``","fraction","''",":","Fraction","of","the","total","sound","length","``","samples","''",":","Number","of","audio","samples","``","seconds","''",":","Number","of","seconds",":","param","rollover",":","When","set","to","True",",","samples","that","roll","beyond","the","first","or","last","position","are","re-introduced","at","the","last","or","first",".","When","set","to","False",",","samples","that","roll","beyond","the","first","or","last","position","are","discarded",".","In","other","words",",","rollover=False","results","in","an","empty","space","(","with","zeroes",")",".",":","param","fade_duration",":","If","you","set","this","to","a","positive","number","(","in","seconds",")",",","there","will","be","a","fade","in","and\/or","out","at","the","``","stitch","''","(","that","was","the","start","or","the","end","of","the","audio","before","the","shift",")",".","This","can","smooth","out","an","unwanted","abrupt","change","between","two","consecutive","samples","(","which","sounds","like","a","transient\/click\/pop",")",".","This","parameter","denotes","the","duration","of","the","fade","in","seconds",".","To","disable","the","fading","feature",",","set","this","parameter","to","0.0.",":","param","p",":","The","probability","of","applying","this","transform"]
code: def __init__(
      self,
      min_shift: Union[float, int] = -0.5,
      max_shift: Union[float, int] = 0.5,
      shift_unit: str = "fraction",
      rollover: bool = True,
      fade_duration: float = 0.005,
      p: float = 0.5,
  ):
      """
      :param min_shift: Minimum amount of shifting in time. See also shift_unit.
      :param max_shift: Maximum amount of shifting in time. See also shift_unit.
      :param shift_unit: Defines the unit of the value of min_shift and max_shift.
          "fraction": Fraction of the total sound length
          "samples": Number of audio samples
          "seconds": Number of seconds
      :param rollover: When set to True, samples that roll beyond the first or last position
          are re-introduced at the last or first. When set to False, samples that roll beyond
          the first or last position are discarded. In other words, rollover=False results in
          an empty space (with zeroes).
      :param fade_duration: If you set this to a positive number (in seconds), there
          will be a fade in and/or out at the "stitch" (that was the start or the end
          of the audio before the shift). This can smooth out an unwanted abrupt
          change between two consecutive samples (which sounds like a
          transient/click/pop). This parameter denotes the duration of the fade in
          seconds. To disable the fading feature, set this parameter to 0.0.
      :param p: The probability of applying this transform
      """
      super().__init__(p)
  
      if min_shift > max_shift:
          raise ValueError(
              "min_shift must not be greater than max_shift"
          )
      if shift_unit not in ("fraction", "samples", "seconds"):
          raise ValueError(
              'shift_unit must be "fraction", "samples" or "seconds"'
          )
      if shift_unit == "fraction":
          if min_shift < -1:
              raise ValueError(
                  'min_shift must be >= -1 when shift_unit is "fraction"'
              )
          if max_shift > 1:
              raise ValueError(
                  'max_shift must be <= 1 when shift_unit is "fraction"'
              )
  
      if fade_duration == 0.0:
          self.fade = False
      elif fade_duration < 0.0:
          raise ValueError("fade_duration must not be negative")
      elif fade_duration < DURATION_EPSILON:
          raise ValueError(
              "When fade_duration is set to a positive number, it must be >="
              f" {DURATION_EPSILON}"
          )
      else:
          self.fade = True
  
      self.min_shift = min_shift
      self.max_shift = max_shift
      self.shift_unit = shift_unit
      self.rollover = rollover
      self.fade_duration = fade_duration
  
file_path: audiomentations/audiomentations/augmentations/shift.py
imports: import random
  from typing import Union
  import numpy
  from numpy.typing import NDArray
  from audiomentations.core.transforms_interface import BaseWaveformTransform
  from audiomentations.core.utils import get_crossfade_mask_pair
label_desc: Use image node_id 1 to create a new Shift object from inherited base classes: BaseWaveformTransform with example: obj = Shift(min_shift, max_shift, shift_unit, rollover, fade_duration, p)