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:
Bill Kendrick 2019-09-21 16:33:55 -07:00
parent 9db366237c
commit f7d30d3222
13 changed files with 367 additions and 310 deletions

View file

@ -1,5 +1,5 @@
.\" tuxpaint.1 - 2019.09.12
.TH TUXPAINT 1 "12 September 2019" "0.9.24" "Tux Paint"
.\" tuxpaint.1 - 2019.09.21
.TH TUXPAINT 1 "21 September 2019" "0.9.24" "Tux Paint"
.SH NAME
tuxpaint -- "Tux Paint", a drawing program for young children.
@ -23,6 +23,8 @@ tuxpaint -- "Tux Paint", a drawing program for young children.
.br
[\-\-nosound]
.br
[\-\-nostereo]
.br
[\-\-noquit]
.br
[\-\-noprint]
@ -153,6 +155,8 @@ tuxpaint -- "Tux Paint", a drawing program for young children.
.br
[\-\-sound]
.br
[\-\-stereo]
.br
[\-\-quit]
.br
[\-\-print]
@ -277,7 +281,7 @@ orientations are both supported. (Also see \-\-orient, below.)
.TP 8
.B \-\-orient=landscape \-\-orient=portrait
If \-\-orient=portraitis set, asks \fITux Paint\fP to swap the WIDTH and HEIGHT
If \-\-orient=portrait is set, asks \fITux Paint\fP to swap the WIDTH and HEIGHT
values it uses for windowed or fullscreen mode, without having to actually
change the WIDTH and HEIGHT values in the configuration file or on the
command-line. (This is useful on devices where the screen can be rotated,
@ -287,6 +291,10 @@ e.g. tablet PCs.)
.B \-\-nosound \-\-sound
Disable or enable (default) sound.
.TP 8
.B \-\-nostereo \-\-stereo
Disable or enable (default) stereo panning support.
.TP 8
.B \-\-noquit \-\-quit
Disable or enable (default) the on-screen \fIQuit\fP button and \fIEscape\fP

View file

@ -146,6 +146,7 @@ shortcuts, NEGBOOL(noshortcuts)
showcursor, NEGBOOL(hide_cursor)
simpleshapes, POSBOOL(simple_shapes)
sound, POSBOOL(use_sound)
stereo, POSBOOL(use_stereo)
stampcontrols, NEGBOOL(disable_stamp_controls)
stamps, NEGBOOL(dont_load_stamps)
stampsize, MULTI(stamp_size_override)

View file

@ -54,6 +54,7 @@ struct cfginfo
const char *start_blank;
const char *use_print_config;
const char *use_sound;
const char *use_stereo;
const char *wheely;
const char *mouseaccessibility;
const char *onscreen_keyboard;

View file

@ -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);

View file

@ -1,6 +1,6 @@
/* playsound.h
Copyright (c) 2002-2009
Copyright (c) 2002-2019
http://www.tuxpaint.org/
This program is free software; you can redistribute it and/or modify
@ -35,7 +35,7 @@
#define SNDDIST_NEAR -999
extern Mix_Chunk *sounds[NUM_SOUNDS];
extern int mute, use_sound;
extern int mute, use_sound, use_stereo;
void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y);

View file

@ -30,6 +30,7 @@ _tuxpaint()
--orient=landscape --orient=portrait \
-b --startblank --startlast \
--sound -q --nosound \
--stereo --nostereo \
-x --noquit --quit
-p --print --noprint \
--complexshapes -s --simpleshapes \

View file

@ -22,7 +22,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
June 14, 2002 - August 29, 2019
June 14, 2002 - September 21, 2019
*/
@ -6456,6 +6456,7 @@ void show_usage(int exitcode)
" [--orient=landscape | --orient=portrait]\n"
" [--disablescreensaver | --allowscreensaver ]\n"
" [--sound | --nosound]\n"
" [--stereo | --nostereo]\n"
" [--colorfile FILE]\n"
"\n"
" Mouse/Keyboard:\n"
@ -18574,7 +18575,15 @@ static void magic_playsound(Mix_Chunk * snd, int left_right, int up_down)
else if (left_right > 255)
left_right = 255;
left = ((255 - dist) * (255 - left_right)) / 255;
if (use_stereo)
{
left = ((255 - dist) * (255 - left_right)) / 255;
}
else
{
/* Stereo disabled; no panning (see playsound.c) */
left = (255 - dist) / 2;
}
Mix_SetPanning(0, left, (255 - dist) - left);
#endif
@ -22590,6 +22599,7 @@ static void setup_config(char *argv[])
SETBOOL(start_blank);
SETBOOL(use_print_config);
SETBOOL(use_sound);
SETBOOL(use_stereo);
SETBOOL(wheely);
SETBOOL(mouseaccessibility);
SETBOOL(onscreen_keyboard);

View file

@ -7,7 +7,7 @@
# http://www.tuxpaint.org/
#
# Default distribution version last modified:
# April 30, 2012
# September 21, 2019
#
# $Id$
@ -76,6 +76,13 @@
# sound=yes
### Disable stereo sound (only use mono)?
### -------------------------------------
#
# nostereo=yes
# stereo=yes
### Disable the on-screen 'Quit' button in the toolbar?
### ---------------------------------------------------
### Note: Pressing the [Escape] key,