Skip to content

Instantly share code, notes, and snippets.

@multivac61
Last active December 18, 2015 11:05
Show Gist options
  • Save multivac61/8a259df0bc975f605db7 to your computer and use it in GitHub Desktop.
Save multivac61/8a259df0bc975f605db7 to your computer and use it in GitHub Desktop.
def freq_from_ZCR(sig, fs):
# Find all indices right before a rising-edge zero crossing
indices = find((sig[1:] >= 0) & (sig[:-1] < 0))
crossings = interpolate(indices, sig)
return fs / np.mean(np.diff(crossings))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment