Stereo panning
[Visual Basic]
Public Shared Function Mix_SetPanning( _
ByVal
channel As
Integer, _
ByVal
left As
Byte, _
ByVal
right As
Byte _
) As
Integer
[C#]
public static
int Mix_SetPanning(
int channel,
byte left,
byte right);
Parameters
-
channel
- Channel number to register this effect on. Use MIX_CHANNEL_POST to process the postmix stream.
-
left
- Volume for the left channel, range is 0(silence) to 255(loud)
-
right
- Volume for the left channel, range is 0(silence) to 255(loud)
Return Value
Zero on errors, such as bad channel, or if Mix_RegisterEffect failed.
Remarks
This effect will only work on stereo audio. Meaning you called Mix_OpenAudio with 2 channels (MIX_DEFAULT_CHANNELS). The easiest way to do true panning is to call Mix_SetPanning(channel, left, 254 - left); so that the total volume is correct, if you consider the maximum volume to be 127 per channel for center, or 254 max for left, this works, but about halves the effective volume.
This Function registers the effect for you, so don't try to Mix_RegisterEffect it yourself.
NOTE: Setting both left and right to 255 will unregister the effect from channel. You cannot unregister it any other way, unless you use Mix_UnregisterAllEffects on the channel.
NOTE: Using this function on a mono audio device will not register the effect, nor will it return an error status.
Binds to C-function in SDL_mixer.h
int Mix_SetPanning(int channel, Uint8 left, Uint8 right)
Example
// pan channel 1 halfway to the left
if(!Mix_SetPanning(1, 255, 127))
{
printf("Mix_SetPanning: %s\n", Mix_GetError());
// no panning, is it ok?
}
See Also
SdlMixer Class | Tao.Sdl Namespace | Mix_SetPosition | Mix_UnregisterAllEffects