pygame-community / pygame-ce

🐍🎮 pygame - Community Edition is a FOSS Python library for multimedia applications (like games). Built on top of the excellent SDL library.
https://pyga.me
767 stars 120 forks source link

Add warning about 7.1 stereo on set_source_location #2881

Closed Starbuck5 closed 1 month ago

Starbuck5 commented 1 month ago

For #2751

MyreMylar commented 1 month ago

What about testing the available hardware/audio device channels as an advised safety wrapper?

e.g.

num_dev_channels = pygame.mixer.get_init()[2]
if (num_dev_channels  != 8):
     channel.set_source_location(90, 255)

Or we could handle this ourselves in the code for chan_set_source_location() using Mix_QuerySpec() and just skipping positional audio with 8 hardware channels until SDL resolves this?

Starbuck5 commented 1 month ago

What about testing the available hardware/audio device channels as an advised safety wrapper?

e.g.

num_dev_channels = pygame.mixer.get_init()[2]
if (num_dev_channels  != 8):
     channel.set_source_location(90, 255)

Or we could handle this ourselves in the code for chan_set_source_location() using Mix_QuerySpec() and just skipping positional audio with 8 hardware channels until SDL resolves this?

That isn't a bad idea. I went with my current recommendation because it will (theoretically) keep the source position working. If someone has some crazy fancy setup that supports 7.1 audio, and SDL emulates stereo on top of it, and the source location is set, they should still be able to hear the sound coming from an angle.

I'm hesitant to ignore an exception (or never even try) based on Mix_QuerySpec, since SDL will eventually fix this and then we'll need to remove that code. Also it gives no feedback to the user on why the function isn't working.