gpt4 book ai didi

audio - 调频(FM)代码段

转载 作者:行者123 更新时间:2023-12-03 01:00:43 26 4
gpt4 key购买 nike

我已经为音频信号的频率调制编写了以下代码。音频本身为1秒长,以8000 Hz采样。我想通过使用频率为50 Hz(表示为采样频率的一部分)的正弦波将FM应用于此音频信号。调制信号的调制指数为0.25,以便仅创建一对边带。

for (i = 0; i < 7999; i++) {
phi_delta = 8000 - 8000 * (1 + 0.25 * sin(2* pi * mf * i));
f_phi_accum += phi_delta; //this can have a negative value
/*keep only the integer part that'll be used as an index into the input array*/
i_phi_accum = f_phi_accum;
/*keep only the fractional part that'll be used to interpolate between samples*/
r_phi_accum = f_phi_accum - i_phi_accum;
//If I'm getting negative values should I convert them to positive
//r_phi_accum = fabs(f_phi_accum - i_phi_accum);
i_phi_accum = abs(i_phi_accum);
/*since i_phi_accum often exceeds 7999 I have to add this if statement so as to prevent out of bounds errors */
if (i_phi_accum < 7999)
output[i] = ((input[i_phi_accum] + input[i_phi_accum + 1])/2) * r_phi_accum;
}

最佳答案

您对phi_delta的计算偏离了8000倍和一个偏移量-它应为1 +/-一个小值,即

phi_delta = 1.0 + 0.25 * sin(2.0 * pi * mf * i));

这将导致phi_delta的范围为0.75到1.25。

关于audio - 调频(FM)代码段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8677497/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com