wfm 模块计算 (音频数据转化为wfm数据)

2023-12-24 20:37:59
import numpy as np

def fm_mod(input,samplerate):
    output = []
    for x in range(0,len(input)):
        output.append(0)
    i = 0
    audio_amp = 0.9
    fm_deviation = 2.0*np.pi*75.0e3/samplerate
    for i in range(0,len(input)):
        if audio_amp > 0.0:
            audio_amp = 1.0
        else:
            audio_amp = -1.0
        fm_phase += fm_deviation*audio_amp
        while fm_phase > np.float32(2.0*np.pi):
            fm_phase -= np.float32(np.pi)
        while fm_phase < np.float32(-np.pi):
            fm_phase += np.float32(2.0*np.pi)

        output[i*2] = np.float32(np.sin(fm_phase))
        output[i*2+1] = np.float32(np.cos(fm_phase))
    return np.complex64(output)

文章来源:https://blog.csdn.net/nn_84/article/details/135185909
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。