-1
$\begingroup$

I need to mix "n" sinusoidal waveforms which can be all active or some or all can be silent. The math seemed simple (working with float32 samples) because I just added all waveforms and then divide the result by 10 but the result is not what I wanted (too faint).

So, empyrically I found that the right value to divide the sum is not "n" but was something around 3.3 when N is 10.

Searching around I found another valid formula... which is to divide the sum by the square root of the number of waveforms...but also that doesn't seem quite right...

I wonder if that is true or there is a better formula (considering that the sinuses are going from 1 to -1.

The N frequencies are never multiple of each other and never "sync". I think the formula must include some triginometry and the difference in waveforms frequencies in Hz... just by instinct...

Any idea?

$\endgroup$
1

1 Answer 1

2
$\begingroup$

You have multiple options that have different options with different trade offs

  1. Amplitude scaling: $1/N$. This will guarantee that the resulting wave form will not clip but the ernergy of the sum will a be a lot less than the sum of the energies, i.e. it will be very soft.
  2. Energy Scaling: $1/\sqrt{N}$. This will make sure that the energy of the sum equals the sum of the energies, so it's equally roughly loud. However, there is risk of clipping.
  3. Equal volume scaling: If want all sine wave to be eqaully loud, you need to factor in the frequency dependencies of the human auditory system. You could scale with an inverse A-weighting curve.

In order to avoid clipping you need to determine the crest factor or worst case amplitude of your final signal. If the number of sine wave is fairly large, you can assume a Gaussian distribution which technically has an infinite crest factor but for signals on the time scale of typical audio signals a crest factor of 5 is a pretty safe assumption.

$\endgroup$
1
  • $\begingroup$ So? How to do 3. ? $\endgroup$
    – Zibri
    Sep 13, 2019 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.