【问题标题】:Plot exponential pulses over time随时间绘制指数脉冲
【发布时间】:2016-09-18 21:21:20
【问题描述】:

我已经为此绞尽脑汁好几天了。

我计划在一定时间内使用 PHP 和 SoX 来产生音频脉冲。在这种情况下,我使用频率来描述每秒发生多少脉冲。所以 8 的频率是每秒 8 个脉冲。

我将使用的脉冲示例(等时音)

我需要知道每个脉冲的开始时间,以便在生成音频时及时绘制它们。当频率保持恒定时,这很容易做到。但是当频率随时间变化时,我遇到了完成平均脉冲量所需时间过多或过少的问题。

这是一个 Javascript 示例(我现在使用 JS 来进行数学运算)

var f0 = 8;        //Start frequency
var f1 = 1;        //End frequency
var interval = 30; //Total time

var average_freq = (f0 + f1) / 2;      //Average frequency
var pulses = average_freq * interval;  //Total number of pulses needed

var pulse_start_time = 0;

for(var i = 0; i < pulses; i++) {
    var delta = i / pulses;
    var this_freq = f0 + (f1 - f0) * delta;

    /*
      need exponential formula to find start time
    */

    console.log(            "pulse: "+ (i+1)     + ", "+ 
                  "pulse frequency: "+ this_freq + ", "+
                       "start time: "+ pulse_start_time);

    pulse_start_time += 1 / this_freq; //This method works fine providing 
                                       //both start and end frequency are 
                                       //the same.
}

我已经使用以下主题对这个主题进行了大量研究:

Drawing sine wave with increasing Amplitude and frequency over time

Plot Frequency Sweep In Python

sine wave that slowly ramps up frequency from f1 to f2 for a given time

sine wave that exponentialy changes between frequencies f1 and f2 at given time/amount of samples

但我仍然无法弄清楚如何使用这些技术获取每个脉冲的开始时间,或者我可能完全搞错了。

任何帮助将不胜感激! :)

【问题讨论】:

  • 我可能弄错了,但我认为这与不确定性原理有关:要知道波的频率,您必须观察一段时间,因此您不知道在哪里浪潮开始了。
  • pulse 是什么意思?您是指具有一定数量峰值的正弦波,还是其他?
  • 脉冲我指的是等时音。我已经编辑了我的问题以包含一个示例..

标签: javascript php algorithm math


【解决方案1】:

您需要为您的信号使用正确的数学方程式y=f(t)。这样,您还将获得幅度。我不知道你的信号的属性,但它看起来不像对数。我会这样构建它:

y=( |sin(c0*t)| + sin(c0*t) )^c1 * sin(c2*t) * c3

地点:

  • t是时候了
  • c0=frequency of gaps / 2*Pi
  • c1 是间隙/信号转换的锐度
  • c2=frequency of pulses / 2*Pi
  • c3 是信号幅度

第一部分只是用间隙和整形幅度形状调制基本信号,最后一个热是你的基本信号。

每秒的平均脉冲不是你的信号频率!!!相反,它大约是它的一半(取决于信号间隙比)。现在只需在某个循环中增加 t 并为您的数据计算 y(t)。为避免浮点舍入问题,请将t 限制为 2 个正弦波之间的公共周期。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-25
    • 1970-01-01
    • 1970-01-01
    • 2017-12-11
    • 1970-01-01
    • 2016-09-28
    相关资源
    最近更新 更多