Added --nostereo option
Ability to disable stereo panning effect (e.g., paint brush, UI elements sound effect feedback, etc.), useful for users with hearing impairment in one ear, or situations where one speaker or headphone is being used. Use "--nostereo" command-line option or "nostereo=yes" config. file option.
This commit is contained in:
parent
9db366237c
commit
f7d30d3222
13 changed files with 367 additions and 310 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
playsound.c
|
||||
|
||||
Copyright (c) 2002-2009
|
||||
Copyright (c) 2002-2019
|
||||
http://www.tuxpaint.org/
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
|
|
@ -31,6 +31,7 @@ Mix_Chunk *sounds[NUM_SOUNDS];
|
|||
|
||||
int mute;
|
||||
int use_sound = 1;
|
||||
int use_stereo = 1;
|
||||
static int old_sound[4] = { -1, -1, -1, -1 };
|
||||
|
||||
/**
|
||||
|
|
@ -80,22 +81,31 @@ void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y
|
|||
dist = (255 * ((screen->h - 1) - y)) / (screen->h - 1);
|
||||
}
|
||||
|
||||
if (x == SNDPOS_LEFT)
|
||||
left = 255 - dist;
|
||||
else if (x == SNDPOS_CENTER)
|
||||
left = (255 - dist) / 2;
|
||||
else if (x == SNDPOS_RIGHT)
|
||||
left = 0;
|
||||
|
||||
if (use_stereo)
|
||||
{
|
||||
if (x == SNDPOS_LEFT)
|
||||
left = 255 - dist;
|
||||
else if (x == SNDPOS_CENTER)
|
||||
left = (255 - dist) / 2;
|
||||
else if (x == SNDPOS_RIGHT)
|
||||
left = 0;
|
||||
else
|
||||
{
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
else if (x >= screen->w)
|
||||
x = screen->w - 1;
|
||||
|
||||
left = ((255 - dist) * ((screen->w - 1) - x)) / (screen->w - 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x < 0)
|
||||
x = 0;
|
||||
else if (x >= screen->w)
|
||||
x = screen->w - 1;
|
||||
|
||||
left = ((255 - dist) * ((screen->w - 1) - x)) / (screen->w - 1);
|
||||
/* Stereo disabled; treat everything like a SNDPOS_CENTER
|
||||
(equal amount in each of the left/right channels) */
|
||||
left = (255 - dist) / 2;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Panning of sound #%d in channel %d, left=%d, right=%d\n", s, chan, left, (255 - dist) - left);
|
||||
fflush(stdout);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue