1
$\begingroup$

I am writing a program to generate audio frequencies in multi-channel PCM format. This question may be more suited on an audio forum but I would like to know what is going on mathematically.

My understanding is that audio is represented as a sum of multiple fundamental frequencies at various points in time. Each fundamental frequency can be represented as amplitude versus time $amplitude=f(time)$.

I use the following formula to generate each fundamental frequency and plot it visually.

$a[t] = Sine((f*t)+p) * ma$

    where
       t = time
       f = desired frequency (per second)
       p = phase shift (offset for delays, etc.)
       ma = maximum amplitude to restrict to (between 0 and 1)

The three images below use the same formula but the last two are not making a uniform sine wave as I would have expected (consider only track 01 in the images). So there is either something wrong with the formula or my understanding of fundamental frequencies in audio.

If my expectation about uniform sine waves if wrong, then Fourier Transforms wouldn't be possible would they?

Any advice would be appreciated.

Figure 1 Figure 2 Figure 2

$\endgroup$

1 Answer 1

3
$\begingroup$

If your sample frequency is only 0.01 kHz as the pictures say, that's only 10 samples per second!

That won't allow you to see the shape of sine waves with any of the frequencies shown in the images, assuming that "1571" and so forth are in hertz. Instead what you're seeing is just a one-dimensional moiré pattern caused by the interaction between your very slow sample frequency and the much faster ideal oscillation of your tones.

In the green case you're lucky and get something that looks like a sine wave -- but notice that 100 seconds of sound ought to be 157,100 full waves, not just the 13 ones you see there.


By the way, in your formulas you lack a factor of $2\pi$ -- you want the argument to the sine to increase by $2\pi$ (one whole circle) each time $t$ increases by $1/f$.

$\endgroup$
3
  • 1
    $\begingroup$ And don't forget phase in radians. $\endgroup$
    – engineerC
    Sep 16, 2013 at 19:24
  • $\begingroup$ Thanks @Henning. Reading through your third para again did it. $\endgroup$ Sep 16, 2013 at 19:33
  • $\begingroup$ @Henning, could you please elaborate on the last paragraph. I'm assuming you are only referring to the visual representation of the data. $\endgroup$ Jul 3, 2014 at 5:19

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .