SoundUtils.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:PyPeVoc 作者: goiosunsw 项目源码 文件源码
def HeterodynWithF0Track(x, tf0, f0, sr=1,
                         nwind=1024, nhop=512,
                         windfunc=np.blackman):
    '''
    Calculates the amplitude near frequency f0 in x
    (f0 is time-varying, values given at tf0

    nwind should be at least 3 periods if the signal
    is periodic.
    '''
    valid_idx = np.logical_not(np.isnan(f0))
    tx = np.arange(len(x))/float(sr)
    f0s = np.interp(tx, tf0[valid_idx], f0[valid_idx])
    phs = np.cumsum(2*np.pi*f0s/sr)
    sinsig = np.exp(1j*phs)

    hamp, t = FuncWind(np.sum, x*sinsig, power=1, sr=sr,
                       nwind=nwind, nhop=nhop,
                       windfunc=windfunc)
    return np.array(hamp)*2, np.array(t)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号