libsdl-org / SDL

Simple Directmedia Layer
https://libsdl.org
zlib License
9.92k stars 1.84k forks source link

Audio Feature request: SDL_SetAudioStreamGainChannelMap, SDL_GetAudioStreamGainChannelMap #10887

Open luppichristian opened 1 month ago

luppichristian commented 1 month ago

Right now the Audio API provides SDL_GetAudioStreamGain() and SDL_SetAudioStreamGain() that modify the gain of an audio stream.

It would be useful to implement SDL_SetAudioStreamGainChannelMap(), SDL_GetAudioStreamGainChannelMap() to specifically set the gain of a channel.

This allows the user to implement for example audio panning where the gain must be set dynamically and is often changed depending by the position of the sound in a custom world.

Instead of "Gain Channel Map" perhaps a better name would be "Panning Channel Map"

icculus commented 1 month ago

I dunno, this feels feature-creepy to me.

flibitijibibo commented 1 month ago

This does start to get into the matrix coefficients territory, yeah - for something like this FAudio might work better:

https://github.com/FNA-XNA/FAudio

luppichristian commented 1 month ago

Now that I think about a matrix would offer much more control. I think that implementing some sort of channel map or matrix would be a necessary feature for a good audio system. I get that SDL does not try to be a complete audio system but i think that it should provide at least one API to allow the user to dynamically modify the samples of an audio stream.