0

オーディオ信号の周波数変調用に次のコードを作成しました。オーディオ自体の長さは 1 秒で、8000 Hz でサンプリングされています。周波数 50 Hz (サンプリング周波数の分数として表される) の正弦波を使用して、このオーディオ信号に FM を適用したいと考えています。変調信号の変調指数は 0.25 で、1 組の側波帯のみが作成されます。

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;            
}
4

1 に答える 1

1

あなたの phi_delta の計算は、8000 倍の係数とオフセットによってずれています。つまり、1 +/- 小さな値である必要があります。

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

これにより、phi_delta の範囲は 0.75 ~ 1.25 になります。

于 2011-12-30T09:53:32.740 に答える