0
votes

I've been racking my brain for days over this.

I'm planning on using PHP with SoX to produce audio pulses over a certain amount of time. In this case i'm using frequency as a way to describe how many pulses occur per second. So a frequency of 8 is 8 pulses per second.

Example of the pulse I'll be using (Isochronic tone)

img

I need to know the start time of each of these pulses so that I can plot them in time when producing the audio. This is easily done when the frequency remains constant. But when the frequency changes over time, I run into the problem that it takes too much or too little time to complete the average amount of pulses.

Here's an example in Javascript (I'm using JS for now to get the maths working)

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.
}

I've done a lot of researching on this subject using topics like:

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

But I'm still unable to figure out how to get the start time of each pulse using these techniques, or maybe I'm going about this all wrong.

Any help will be appreciated! :)

1
I could be mistaken, but I think this relates to the uncertainty principle: in order to know the frequency of a wave, you have to watch it for a while, and you therefore don't know where the wave began.Teepeemm
What do you mean with pulse? Do you mean a sinusoidal wave with some number of peaks, or something else?pingul
By pulse I'm referring to isochronic tone. I've edited my question to include an example..pJay

1 Answers

0
votes

you need to use proper math equation y=f(t) for your signal instead. In that way you will obtain also the amplitude. I do not know the properties of your signal but it does not look like logarithmic. I would construct it like this:

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

where:

  • t is time
  • c0=frequency of gaps / 2*Pi
  • c1 is sharpness of gap/signal transition
  • c2=frequency of pulses / 2*Pi
  • c3 is amplitude of signal

The first part just modulate the base signal with gaps and shaped amplitude shape, the last therm is your base signal.

The average pulses per second is not your signal frequency !!! instead it is around half of it (depends on the signal to gap ratio). Now just increment t in some loop and compute y(t) for your data. To avoid floating point rounding problems limit the t to common period between the 2 sin waves.