Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AudioMixer4 behaves poorly when saturating #431

Open
h4yn0nnym0u5e opened this issue Feb 15, 2022 · 0 comments
Open

AudioMixer4 behaves poorly when saturating #431

h4yn0nnym0u5e opened this issue Feb 15, 2022 · 0 comments

Comments

@h4yn0nnym0u5e
Copy link
Contributor

Description

When 2 or more inputs sum to values outside the ±1.0 (±32767) range, the mixer output can be erroneous at some (but not all) points in the waveform.

Steps To Reproduce Problem

Consider using just two inputs, with maximum-amplitude square waves of differing frequency applied to them. Input 0 has a gain of 2.0, input 1 a gain of 0.5. The only output values possible from such a system are 2.5, 1.5, -1.5 and -2.5; these should be output, therefore, as either 1.0 or -1.0, depending only on the state of input 0.

Because AudioMixer4 saturates on the fly, though, we can see an effect whereby input 0 is saturated to ±1.0; at a point where the existing value is +1.0, when input 1 is mixed in, if its value is +0.5 then the output remains saturated at +1.0, but if it's at -0.5 then the output becomes an erroneous +0.5. We therefore end up with an incorrect waveform containing values of +1.0, +0.5, -0.5 and -1.0.

Hardware & Software

Any

Arduino Sketch

Shouldn't be necessary, but I could do one if you really want it.

Errors or Incorrect Output

As noted in "steps to reproduce", above

Proposed solution

Mix into an intermediate 32-bit buffer, and only saturate once mixing is complete. This should suffice for inputs with the gains set to any value up to 8192.0, which is a reasonably unlikely value.

Or possibly don't solve it - this may be what would happen with an analogue mixer...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant