首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >具有一定相位和频率的FFT后的波形预测

具有一定相位和频率的FFT后的波形预测
EN

Stack Overflow用户
提问于 2019-06-17 18:16:08
回答 1查看 107关注 0票数 1

我正在使用滑动窗口通过FFT从我的脑电图数据中提取信息。现在我想预测从我的窗口到下一个窗口的信号。因此,我从0.25秒的时间窗口中提取相位,以预测下一个0.25秒的长窗口。

我是信号处理/预测的新手,所以我在这方面的知识有点生疏。

我不能用我提取的相位和频率生成正弦波。我只是没有找到一个解决方案。我可能只需要往正确的方向推动,谁知道呢。

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

因此,我有我的最大频率与相位提取,并需要产生一个波与此信息。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-06-18 00:22:46

这是一个伪代码,用来合成选定频率的正弦曲线。目前,它假定初始种子相移为零,因此如果需要不同的初始相移,只需更改theta值

代码语言:javascript
复制
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
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56629236

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档