libsdl-org / SDL_mixer

An audio mixer that supports various file formats for Simple Directmedia Layer.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mix_SetPanning disables the right channel when the value for left is greater than or equal to 193

Fulgen301 opened this issue · comments

Windows 11x64, SDL_mixer version 2.6.3.
Mix_OpenAudio called with frequency = 44100, format = AUDIO_S16SYS, channels= 2, chunksize = 1024.

If I call Mix_SetPanning with a value of 193 or higher for left, the right channel is completely disabled. I verified this by unplugging my left speaker and slowly incrementing the value of left - as soon as it reached 193, the right speaker didn't play the sound anymore, regardless of the value for right (I had it at both 255 and 62).

This not only causes broken playback positions, but also an annoying jump at 255,255 - with 254,255, only the left speaker plays, with 255,255, the effect gets unregistered and both play, with 255,254, only the left speaker plays again.

The same code works fine when SDL 1.2 and SDL_mixer 1.2 are used.

Significant changes to effect_position.c (where Mix_SetPanning() resides)
are these (in order of commit dates) :
502f4e2
ba19795

Full history of effect_position.c is this:
https://github.com/libsdl-org/SDL_mixer/commits/main/src/effect_position.c

Can you pinpoint any suspicious patches there?

CC: @slouken, @icculus (possibly related ticket: #261)

CC: @Wohlstand: Have you ever hit this bug, either in mainstream version or in your Mixer-X?

(Sorry that I can't test this one myself)

Sounds weird... I tested the thing on my end, and it works fine. I can change panning on the fly, and it doesn't lead any channel being muted.

Anyway, just now I set comparison of the code, and first thing I found is this:
изображение
(it's another problem, related to Position where I attempted to fix the problem).

    if (channels == 2) {
#if 0 /* Buggy code, makes position play at right speaker only. Gets been fixed when room_angle is always 0 */
        if (angle > 180)
            room_angle = 180; /* exchange left and right channels */
        else room_angle = 0;
#endif
        /*FIXME: Verify this for correctness */
        room_angle = 0;
    }

Unfortunately it's user error - I accidentally had my speaker configured for four channels instead of two, so SDL_mixer was using four channels. I retested with the correct two channel configuration and panning worked as expected.

Glad that you figured it out

Unfortunately it's user error - I accidentally had my speaker configured for four channels instead of two, so SDL_mixer was using four channels. I retested with the correct two channel configuration and panning worked as expected.

Off-Topic: Speaking about multi-channels... I wanted to verify the panning / position behaviour on my end, I still want to buy a surrount sound system, just forgetting about that... And, you reminded me about that!