pyACA: Documentation 0.3.1
Source Code for Audio Content Analysis
Loading...
Searching...
No Matches
Functions
pyACA.PitchTimeZeroCrossings Namespace Reference

Functions

 PitchTimeZeroCrossings (x, iBlockLength, iHopLength, f_s)
 computes f0 via zero crossing distances
 

Function Documentation

◆ PitchTimeZeroCrossings()

PitchTimeZeroCrossings ( x,
iBlockLength,
iHopLength,
f_s )

computes f0 via zero crossing distances

Parameters
xarray with floating point audio data (dimension samples x channels)
iBlockLengthinternal block length
iHopLengthinternal hop length
f_ssample rate of audio data
Returns
f_0: fundamental frequency (in Hz)
t: time stamp

Definition at line 17 of file PitchTimeZeroCrossings.py.

17def PitchTimeZeroCrossings(x, iBlockLength, iHopLength, f_s):
18
19 # block audio data
20 x_b, t = ToolBlockAudio(x, iBlockLength, iHopLength, f_s)
21 iNumOfBlocks = x_b.shape[0]
22
23 # initialize
24 f_0 = np.zeros(iNumOfBlocks)
25
26 for n, block in enumerate(x_b):
27
28 # get current block
29 if not block.sum():
30 continue
31 else:
32 x_tmp = block
33
34 # compute zero crossing indices
35 x_tmp = x_tmp[np.arange(0, iBlockLength - 1)] * x_tmp[np.arange(1, iBlockLength)]
36 i_tmp = np.diff(np.argwhere(x_tmp < 0), axis=0)
37
38 # average distance of zero crossings indicates half period
39 if i_tmp.size:
40 f_0[n] = f_s / np.mean(2 * i_tmp)
41
42 return f_0, t