1
$\begingroup$

I am currently dabbeling with programming a real-time audio software and I already got a simple pipeline where notes can be played and released and each note has its own envelope so that the amplitude of each note signal begins and ends at 0 smoothly.

However, I am currently running into the problem that if 2 notes overlap not exactly, there are pop sounds appearing at the intersection points. So for example, if a note sounds from 0 to 1 s and another note from 0.5 to 1.5 s, there are pop sounds at 0.5 and 1 s.

I am not sure why there would be discontinuities there. If there is no overlap or the notes overlap exactly, there are no pop sounds.

Anyone have an idea, what could be the issue?

The samples are mixed via the arithmetic mean and the envelopes I have tried so far were with linear/quadratic fade-in/out. The underlying waves are single sinusoids.

UPDATE

I think, I found the issue. It is the arithmetic mean, I think @KnutInge alluded to that issue, the normalization factor I use is the inverse of the currently active notes, so if that changes from a frame to the next, the amplitude changes drastically.

I am not sure, how to handle this. Should I compute the interpolation factor via the envelope values? Basically something like $$\alpha = \frac{envelope_0}{envelope_0+envelope_1}$$ and then $$sample = \alpha\cdot sample_0 + (1-\alpha)\cdot sample_1$$? This generalizes to arbitrary amounts of active notes, right?

$\endgroup$
7
  • 2
    $\begingroup$ Can you share a plot of 1)the first note, 2)the second note, 3)the mix, all zoomed closely in at eg 0.5 seconds? By «arithmetic mean» do you mean that the mixer output is a static (a+b)/2, or do you change the normalization when the number of notes changes? $\endgroup$
    – Knut Inge
    Commented Aug 20, 2022 at 6:37
  • $\begingroup$ You might be clipping $\endgroup$
    – Hilmar
    Commented Aug 20, 2022 at 7:29
  • $\begingroup$ I mean the general arithmetic mean, yes,where it is divided by the number of notes. I will upload plots as soon as possible, hopefully today. $\endgroup$ Commented Aug 20, 2022 at 7:32
  • $\begingroup$ Are you are using floating point, fractional or integer math ? $\endgroup$
    – Hilmar
    Commented Aug 20, 2022 at 7:55
  • $\begingroup$ @KnutInge, please checkout the update, I think I have found the issue. $\endgroup$ Commented Aug 20, 2022 at 16:51

1 Answer 1

1
$\begingroup$

The most straight forward approach would be to mix as : (tone1 + tone2 +…) / max_number_of_tones

$\endgroup$
1
  • $\begingroup$ This does work better than my proposed solution since I still get popping when notes are in release phase with that version (still no idea why, especially why does the attack phase work then?). I like straightforward, but is this like, "pretty close to optimal" though? $\endgroup$ Commented Aug 20, 2022 at 20:29

Your Answer

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

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