What's the best way to approximate two added sine waves with one?

245 Views Asked by At

Background: I'm writing a synthesizer with the creative limitation that it uses a single oscillator and a single amplitude multiplier.

$y=\sin(t*f(t))*a(t)$

$(t=$time, $f=$frequency, $a=$ amplitude$)$

What I'd like to do is cheat a bit and create something that approximates the sound of two sine waves using the above formula.

To put this mathematically,

What functions, $a$ and $f$, can I use in the above formula to get as close as possible to the following formula:

$$y=\sin(t*f_1)*a_1+\sin(t*f_2)*a_2$$

I don't believe that it's possible to find an exact way to emulate the second formula with the first but I'm assuming one could get pretty close.

2

There are 2 best solutions below

0
On

Hint:

If you allow variable amplitude and variable frequency, there is more than you need. You can try to construct a phase function ($t\,f(t)$) that takes the values $k\pi$ at the successive zeroes of $y$, then find the amplitude function as

$$a(t)=\frac{y(t)}{\sin(t\,f(t))}.$$

Needless to say, this is more complex to design than a double oscillator.

0
On

Think what happens if $\sin(t f(t)) = 0$ then $a(t)$ would need to be infinite to create $y \neq 0$. Since this is not a physical/numerically tractable solution, $\sin(t f(t))$ must have the same zero crossings as the desired $y(t)$. This imposes quite a restriction.

It is not impossible though but quite difficult.

$f(t)$ can be obtained by observing the phase of the analytic signal of the desired $y$. That is

$t f(t) = \arg \{ a_1 \exp(t f_1) + a_2 \exp(t f_2) \}$.

This is quite tedious to calculate, but possible. Then $a(t)$ is just given by the ratio of $y$ and the sine waveform with $f(t)$.

The better way

In signal processing one makes ones life much easier when using a complex oscillator. That is

$y(t) = \Re \{\exp ( -\mathrm i f(t) t) a(t) \} = a_r(t) \cos(f(t) t) + a_i(t) \sin( f(t) t)$

with $a(t) = a_r(t) + \mathrm i a_i(t)$ the complex amplitude envelope.

Then it is very easy to create a two (or more) tone signal. Just set

$a(t) = a_1 \exp ( -\mathrm i (f_1 - f(t)) t) ) + a_2 \exp ( -\mathrm i (f_2 - f(t)) t) )$

This works for arbitrary $f(t)$.

Note: The quantity $f(t)$ is not a frequency. The instantaneous (angular) frequency is $\frac{d}{dt} (t f(t))$. So $f(t)$ is only a frequency if it is time-independent (let alone the $2 \pi$ factor).