def pitch_strength_all_candidates(f_erbs, L, pc):
"""
Calculates the pitch ``strength'' of all candidate
pitches
Args:
f_erbs (array): frequencies in ERBs
L (matrix): loudness matrix
pc (array): pitch candidates array
Returns:
S (array): strength of pitches corresponding to pc's
"""
# create pitch strength matrix
S = np.zeros((pc.size, L.shape[1]))
# define integration regions
k = np.zeros(pc.size+1)
for j in range(k.size-1):
idx = int(k[j])
f = f_erbs[idx:]
val = find(f > pc[j] / 4)[0]
k[j+1] = k[j] + val
k = k[1:] # TODO: fix this sloppiness
# create loudness normalization matrix
N = np.sqrt(np.flipud(np.cumsum(np.flipud(L * L), 0)))
for j in range(pc.size):
# normalize loudness
n = N[int(k[j]), :]
n[n == 0] = -np.inf # to make zero-loudness equal zero after normalization
nL = L[int(k[j]):] / np.tile(n, (int(L.shape[0] - k[j]), 1))
# compute pitch strength
S[j] = pitch_strength_one_candidate(f_erbs[int(k[j]):], nL, pc[j])
return S
评论列表
文章目录