def find_xdb_bin(wnd, power=.5, res=1500):
  """
  A not so fast way to find the x-dB cutoff frequency "bin" index.

  Parameters
  ----------
  wnd:
    The window itself as an iterable.
  power:
    The power value (squared amplitude) where the x-dB value should lie,
    using ``x = dB10(power)``.
  res :
    Zero-padding factor. 1 for no zero-padding, 2 for twice the length, etc..
  """
  spectrum = dB20(rfft(wnd, res * len(wnd)))
  root_at_xdb = spectrum - spectrum[0] - dB10(power)
  return next(i for i, el in enumerate(zcross(root_at_xdb)) if el) / res
def find_xdb_bin(wnd, power=.5, res=1500):
    """
  A not so fast way to find the x-dB cutoff frequency "bin" index.

  Parameters
  ----------
  wnd:
    The window itself as an iterable.
  power:
    The power value (squared amplitude) where the x-dB value should lie,
    using ``x = dB10(power)``.
  res :
    Zero-padding factor. 1 for no zero-padding, 2 for twice the length, etc..
  """
    spectrum = dB20(rfft(wnd, res * len(wnd)))
    root_at_xdb = spectrum - spectrum[0] - dB10(power)
    return next(i for i, el in enumerate(zcross(root_at_xdb)) if el) / res
Example #3
0
def zcross_pitch(sig, size=2048, hop=None):
    for blk in zcross(sig, hysteresis=.01).blocks(size=size, hop=hop):
        crossings = sum(blk)
        yield 0. if crossings == 0 else lag2freq(2. * size / crossings)
def zcross_pitch(sig, size=2048, hop=None):
  for blk in zcross(sig, hysteresis=.01).blocks(size=size, hop=hop):
    crossings = sum(blk)
    yield 0. if crossings == 0 else lag_to_freq(2. * size / crossings)
def find_xdb_bin(wnd, power=.5, res=1500):
  """ A not so fast way to find the x-dB cutoff frequency "bin" index """
  spectrum = dB20(rfft(wnd, res * len(wnd)))
  root_at_xdb = spectrum - spectrum[0] - dB10(power)
  return next(i for i, el in enumerate(zcross(root_at_xdb)) if el) / res