具有特定相位和频率的 FFT 后的波预测

Wave prediction after a FFT with a certain phase and frequency

我正在使用滑动 window 通过 FFT 从我的 EEG 数据中提取信息。现在我想预测来自 window 的信号到下一个。所以我从 0.25 秒的时间 window 中提取相位来预测下一个 0.25 秒长 window.

我是signal-processing/prediction的新手,所以我的知识有点生疏。

我无法使用提取的相位和频率生成正弦波。我只是没有找到解决方案。我可能只需要朝着正确的方向前进,谁知道呢。

R有没有函数可以帮我生成合适的正弦波?

所以我有我的最大频率和提取的相位,需要用这个信息生成一个波。

这里 pseudo-code 用于合成所选频率的正弦曲线...目前它假设初始种子相移为零,因此如果您需要不同的初始相移,只需更改 theta 值

func pop_audio_buffer(number_of_samples float64, given_freq float64,
    samples_per_second float64) ([]float64, error) {

    // output sinusoidal curve is assured to both start and stop at the zero cross over threshold,
    // independent of supplied input parms which control samples per cycle and buffer size.
    // This avoids that "pop" which otherwise happens when rendering audio curves
    // which begins at say 0.5 of a possible range -1 to 0 to +1


    int_number_of_samples := int(number_of_samples)

    if int_number_of_samples == 0 {

        panic("ERROR - seeing 0 number_of_samples in pop_audio_buffer ... float number_of_samples " +
            FloatToString(number_of_samples) + " is your desired_num_seconds too small ? " +
            " or maybe too low value of sample rate")
    }

    source_buffer := make([]float64, int_number_of_samples)

    incr_theta := (2.0 * math.Pi * given_freq) / samples_per_second

    theta := 0.0

    for curr_sample := 0; curr_sample < int_number_of_samples; curr_sample++ {

        source_buffer[curr_sample] = math.Sin(theta)

        theta += incr_theta
    }

    return source_buffer, nil

} //      pop_audio_buffer