我正在使用滑动窗口通过FFT从我的脑电图数据中提取信息。现在我想预测从我的窗口到下一个窗口的信号。因此,我从0.25秒的时间窗口中提取相位,以预测下一个0.25秒的长窗口。
我是信号处理/预测的新手,所以我在这方面的知识有点生疏。
我不能用我提取的相位和频率生成正弦波。我只是没有找到一个解决方案。我可能只需要往正确的方向推动,谁知道呢。
R中有没有一个函数可以帮助我生成一个合适的正弦波?
因此,我有我的最大频率与相位提取,并需要产生一个波与此信息。
发布于 2019-06-18 00:22:46
这是一个伪代码,用来合成选定频率的正弦曲线。目前,它假定初始种子相移为零,因此如果需要不同的初始相移,只需更改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
https://stackoverflow.com/questions/56629236
复制相似问题