【问题标题】:Wave prediction after a FFT with a certain phase and frequency具有特定相位和频率的 FFT 后的波预测
【发布时间】:2019-06-17 10:16:08
【问题描述】:

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

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

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

R 中是否有函数可以帮助我生成合适的正弦波?

所以我已经提取了相位的最大频率,并且需要使用此信息生成波。

【问题讨论】:

    标签: r signal-processing fft prediction


    【解决方案1】:

    这里是合成所选频率的正弦曲线的伪代码......目前它假设初始种子相移为零,因此如果您需要不同的初始相移,只需更改 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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-10-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-10
      相关资源
      最近更新 更多