🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.next.misc
Article #1931

Re: Volume Levels set in Preferences (3.0 question)

#1931
From: Christopher Kane
Date: Wed, 09 Sep 1992 02:38
88 lines
3859 bytes
In article <5171@news.duke.edu> dblakele@hercules.acpub.duke.edu writes:

> Anyway, we noticed fairly quickly that with the Preferences in NS2.1
> the volume settings are not individualized to the different users.
> We both have loginhook sounds which are rather fun, but alas, Denise
> developed serious AcChen addiction.  Thus, the problem.  I turn up the
> volume to hear my system beeps, loginhooks and logouthooks.  When she
> logs in to play AcChen and it screams "*WELCOME*" she turns around and
> yells back at me for fiddling with the volume control.

I can't tell you about 3.0, not having gotten to experience it yet, but
you could set the volume in the log{in,out}hooks with a command line
program like the one below that I wrote recently.  Note that this would
mean "hardcoding" the volume desired in the log{in,out}hook.  As an
alternative, I suppose a little bit of code to play with the defaults
database could be hacked in, and the desired volume read from there.

Compile with 'cc -s -object -O -o volume volume.c' to get the smallest
executable.  (Assuming you save the program below as 'volume.c'.)

Christopher Kane
kane@cs.purdue.edu  (NeXTMail accepted)

--snip--------------snip--------------snip--------------snip--
/*
   Displays and sets the mute status and volume on a NeXT.
    - Christopher J. Kane (kane@cs.purdue.edu)

   Released into the public domain, August 21, 1992.
*/

#include <sound/sound.h>
#include <stdio.h>
extern volatile void exit(int);
extern int getopt(int, char **, char *);
extern char *optarg;

#define SETTORANGE(v,min,max)	v = (v<min?min:(v>max?max:v))
#define MINVOL	0
#define MAXVOL	43

#define USAGE	\
"Usage: %s [-s] [-m | -M] [-l <left_vol>] [-r <right_vol>] [-v <vol>]\n"\
"\tDisplays and optionally sets the mute and volume settings.\n"	\
"\tOptions: (in any order)\n"						\
"\t  -s  silent mode; settings are not displayed\n"			\
"\t  -m  unmute external speakers\n"					\
"\t  -M  mute external speakers\n"					\
"\t  -l  set volume of left speaker\n"					\
"\t  -r  set volume of right speaker\n"					\
"\t  -v  set both speakers; shorthand for '-l <vol> -r <vol>'\n"	\
"\tIf both -m and -M are specified, the rightmost of them has effect.\n"\
"\tThe parameters <left_vol>, <right_vol>, and <vol> should be\n"	\
"\tintegers in the range %i (minimum volume) to %i (maximum volume).\n\n"

#define OUTSTR	"\nExternal speaker is%s muted.\n"\
		"Left speaker volume: %i\n"	\
		"Right speaker volume: %i\n\n"

void main(int argc, char *argv[])
{
    int mute,left,right,c,silent=0;
    SNDGetMute(&mute);
    SNDGetVolume(&left, &right);
    if (argc>1)
      {
        while ((c = getopt(argc, argv, "mMsl:r:v:h"))!=EOF)
          switch (c)
            {
              case 'm': mute = 1; break;
              case 'M': mute = 0; break;
              case 's': silent = 1; break;
              case 'l': left = atoi(optarg); break;
              case 'r': right = atoi(optarg); break;
              case 'v': left = right = atoi(optarg); break;
              case 'h':
              default : fprintf(stderr, USAGE, argv[0], MINVOL, MAXVOL);
	                exit(1);
            }
	SETTORANGE(left, MINVOL, MAXVOL);
	SETTORANGE(right, MINVOL, MAXVOL);
        SNDSetMute(mute);
        SNDSetVolume(left, right);
      }
    if (!silent)
      printf(OUTSTR, (mute?" NOT":""), left, right);
    exit(0);
}
Technical Details
Message-ID: <BuAI10.7n@mentor.cc.purdue.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!purdue!mentor.cc.purdue.edu!news
References: <5171@news.duke.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!gatech!purdue!mentor.cc.purdue.edu!news
From: kane@cs.purdue.edu (Christopher Kane)
Newsgroups: comp.sys.next.misc
Subject: Re: Volume Levels set in Preferences (3.0 question)
Message-ID: <BuAI10.7n@mentor.cc.purdue.edu>
Date: 9 Sep 92 02:38:59 GMT
References: <5171@news.duke.edu>
Sender: news@mentor.cc.purdue.edu (USENET News)
Organization: Purdue University
Lines: 88