Low-Latency-Android-iOS-Linux-Windows-tvOS-macOS-Interactive-Audio-Platform icon indicating copy to clipboard operation
Low-Latency-Android-iOS-Linux-Windows-tvOS-macOS-Interactive-Audio-Platform copied to clipboard

StereoMixer produces invalid output with some (even) numbers of frames

Open svenoaks opened this issue 3 years ago • 3 comments

StereoMixer will produce floats like:

2022-05-18 10:57:16.648 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 6.141433 2022-05-18 10:57:16.648 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 6.114010 2022-05-18 10:57:16.650 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 256.063416 2022-05-18 10:57:16.650 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 256.031616 2022-05-18 10:57:16.650 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 4294967296.000000 2022-05-18 10:57:16.650 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 4294967296.000000 2022-05-18 10:57:16.650 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 4294967296.000000 2022-05-18 10:57:16.650 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 4294967296.000000 2022-05-18 10:57:16.650 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 117832973025280.000000 2022-05-18 10:57:16.650 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 117833149186048.000000 2022-05-18 10:57:16.650 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 117701599035392.000000 2022-05-18 10:57:16.650 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 117833149186048.000000 2022-05-18 10:57:16.650 18331-29817/? V/CROSSEXAMPLE: INVALID OUTPUT 117833149186048.000000

also some nan's.

with some numbers of input frames.

This is from code like this:

  numberOfFrames = 4172;
    float outputBuffer1[numberOfFrames * 2];
    float outputBuffer2[numberOfFrames * 2];
    //float outputBuffer3[numberOfFrames * 2];
    bool silence = !playerA->processStereo(outputBuffer1, false, numberOfFrames, volA);
    if (playerB->processStereo(outputBuffer2, !silence, numberOfFrames, volB)) silence = false;

    if (!silence) {
        mixer->process(outputBuffer1, outputBuffer2, NULL, NULL, outputBuffer1, numberOfFrames);
        for (int i = 0; i < numberOfFrames * 2; ++i) {
            float n = outputBuffer1[i];
            if (isnan(n) || n > 1.0 || n < -1.0) {
                log_print(ANDROID_LOG_VERBOSE, "CROSSEXAMPLE", "INVALID OUTPUT %f", n);
            }
        }
    }

Same thing if a different buffer from the inputs is used for the output.

I'd appreciate a fast bug fix or at least document the constraints on the number of frames because it's putting the brakes on my white label project work.

svenoaks avatar May 18 '22 15:05 svenoaks

I don't see anything weird here. Please check the "weird number state" for all buffers before mixer->process. Maybe they are coming from the players?

gaborszanto avatar May 19 '22 12:05 gaborszanto

I've checked and the buffers have no invalid samples before mixer->process. If you keep processing with this number of frames (4172 in this case) the mixer just keeps outputting these invalid sample values and not the mixed signal.

svenoaks avatar May 19 '22 14:05 svenoaks

I found the problem. It works until 4096 frames, but if any if the buffers are NULL and frames are above 4096, this happens.

The next update will have the fix, but I can't promise any deadline for that.

gaborszanto avatar May 19 '22 14:05 gaborszanto

Fix released.

gaborszanto avatar Aug 30 '22 09:08 gaborszanto