home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / sys / next / misc / 19430 < prev    next >
Encoding:
Text File  |  1992-09-08  |  3.7 KB  |  100 lines

  1. Path: sparky!uunet!gatech!purdue!mentor.cc.purdue.edu!news
  2. From: kane@cs.purdue.edu (Christopher Kane)
  3. Newsgroups: comp.sys.next.misc
  4. Subject: Re: Volume Levels set in Preferences (3.0 question)
  5. Message-ID: <BuAI10.7n@mentor.cc.purdue.edu>
  6. Date: 9 Sep 92 02:38:59 GMT
  7. References: <5171@news.duke.edu>
  8. Sender: news@mentor.cc.purdue.edu (USENET News)
  9. Organization: Purdue University
  10. Lines: 88
  11.  
  12. In article <5171@news.duke.edu> dblakele@hercules.acpub.duke.edu writes:
  13.  
  14. > Anyway, we noticed fairly quickly that with the Preferences in NS2.1
  15. > the volume settings are not individualized to the different users.
  16. > We both have loginhook sounds which are rather fun, but alas, Denise
  17. > developed serious AcChen addiction.  Thus, the problem.  I turn up the
  18. > volume to hear my system beeps, loginhooks and logouthooks.  When she
  19. > logs in to play AcChen and it screams "*WELCOME*" she turns around and
  20. > yells back at me for fiddling with the volume control.
  21.  
  22. I can't tell you about 3.0, not having gotten to experience it yet, but
  23. you could set the volume in the log{in,out}hooks with a command line
  24. program like the one below that I wrote recently.  Note that this would
  25. mean "hardcoding" the volume desired in the log{in,out}hook.  As an
  26. alternative, I suppose a little bit of code to play with the defaults
  27. database could be hacked in, and the desired volume read from there.
  28.  
  29. Compile with 'cc -s -object -O -o volume volume.c' to get the smallest
  30. executable.  (Assuming you save the program below as 'volume.c'.)
  31.  
  32. Christopher Kane
  33. kane@cs.purdue.edu  (NeXTMail accepted)
  34.  
  35. --snip--------------snip--------------snip--------------snip--
  36. /*
  37.    Displays and sets the mute status and volume on a NeXT.
  38.     - Christopher J. Kane (kane@cs.purdue.edu)
  39.  
  40.    Released into the public domain, August 21, 1992.
  41. */
  42.  
  43. #include <sound/sound.h>
  44. #include <stdio.h>
  45. extern volatile void exit(int);
  46. extern int getopt(int, char **, char *);
  47. extern char *optarg;
  48.  
  49. #define SETTORANGE(v,min,max)    v = (v<min?min:(v>max?max:v))
  50. #define MINVOL    0
  51. #define MAXVOL    43
  52.  
  53. #define USAGE    \
  54. "Usage: %s [-s] [-m | -M] [-l <left_vol>] [-r <right_vol>] [-v <vol>]\n"\
  55. "\tDisplays and optionally sets the mute and volume settings.\n"    \
  56. "\tOptions: (in any order)\n"                        \
  57. "\t  -s  silent mode; settings are not displayed\n"            \
  58. "\t  -m  unmute external speakers\n"                    \
  59. "\t  -M  mute external speakers\n"                    \
  60. "\t  -l  set volume of left speaker\n"                    \
  61. "\t  -r  set volume of right speaker\n"                    \
  62. "\t  -v  set both speakers; shorthand for '-l <vol> -r <vol>'\n"    \
  63. "\tIf both -m and -M are specified, the rightmost of them has effect.\n"\
  64. "\tThe parameters <left_vol>, <right_vol>, and <vol> should be\n"    \
  65. "\tintegers in the range %i (minimum volume) to %i (maximum volume).\n\n"
  66.  
  67. #define OUTSTR    "\nExternal speaker is%s muted.\n"\
  68.         "Left speaker volume: %i\n"    \
  69.         "Right speaker volume: %i\n\n"
  70.  
  71. void main(int argc, char *argv[])
  72. {
  73.     int mute,left,right,c,silent=0;
  74.     SNDGetMute(&mute);
  75.     SNDGetVolume(&left, &right);
  76.     if (argc>1)
  77.       {
  78.         while ((c = getopt(argc, argv, "mMsl:r:v:h"))!=EOF)
  79.           switch (c)
  80.             {
  81.               case 'm': mute = 1; break;
  82.               case 'M': mute = 0; break;
  83.               case 's': silent = 1; break;
  84.               case 'l': left = atoi(optarg); break;
  85.               case 'r': right = atoi(optarg); break;
  86.               case 'v': left = right = atoi(optarg); break;
  87.               case 'h':
  88.               default : fprintf(stderr, USAGE, argv[0], MINVOL, MAXVOL);
  89.                     exit(1);
  90.             }
  91.     SETTORANGE(left, MINVOL, MAXVOL);
  92.     SETTORANGE(right, MINVOL, MAXVOL);
  93.         SNDSetMute(mute);
  94.         SNDSetVolume(left, right);
  95.       }
  96.     if (!silent)
  97.       printf(OUTSTR, (mute?" NOT":""), left, right);
  98.     exit(0);
  99. }
  100.