home *** CD-ROM | disk | FTP | other *** search
/ ftp.ee.lbl.gov / 2014.05.ftp.ee.lbl.gov.tar / ftp.ee.lbl.gov / bmd-1.0beta.tar.Z / bmd-1.0beta.tar / bmd-1.0beta / app / mtools / mute.c < prev    next >
C/C++ Source or Header  |  1991-08-21  |  2KB  |  75 lines

  1. /*
  2.  * Copyright (c) 1991 Regents of the University of California.
  3.  * All rights reserved.
  4.  *
  5.  * Redistribution and use in source and binary forms are permitted
  6.  * provided that the above copyright notice and this paragraph are
  7.  * duplicated in all such forms and that any documentation,
  8.  * advertising materials, and other materials related to such
  9.  * distribution and use acknowledge that the software was developed
  10.  * by the University of California, Lawrence Berkeley Laboratory,
  11.  * Berkeley, CA.  The name of the University may not be used to
  12.  * endorse or promote products derived from this software without
  13.  * specific prior written permission.
  14.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
  15.  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
  16.  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  17.  */
  18.  
  19. #ifndef lint
  20. static char rcsid[] =
  21.     "@(#) $Header: mute.c,v 1.1 91/08/20 21:05:25 mccanne Exp $ (LBL)";
  22. #endif
  23.  
  24. #include <stdio.h>
  25. #include <sys/types.h>
  26. #include <sys/file.h>
  27. #include <sundev/midi.h>
  28.  
  29. usage()
  30. {
  31.     printf("usage: mute [-p port]\n");
  32.     exit(1);
  33. }
  34.  
  35. void
  36. mute(fd)
  37. {
  38.     int i;
  39.     struct midi_msg m = { 0, { 0xb0, 123, 0 } };
  40.  
  41.     for (i = 0; i < 16; ++i) {
  42.         m.mm_data[0] = 0xb0 | i;
  43.         if (write(fd, (char *)&m, sizeof(m)) < 0) {
  44.             perror("write");
  45.             exit(1);
  46.         }
  47.     }
  48. }
  49.  
  50. extern char *optarg;
  51.  
  52. main(argc, argv)
  53.     int argc;
  54.     char **argv;
  55. {
  56.     int fd, c;
  57.     int port = 1;
  58.  
  59.     while ((c = getopt(argc, argv, "p:")) != -1) {
  60.         switch(c) {
  61.  
  62.         case 'p':
  63.             port = atoi(optarg);
  64.             break;
  65.  
  66.         default:
  67.             usage();
  68.         }
  69.     }
  70.     fd = midi_open(O_WRONLY, port);
  71.     mute(fd);
  72.     close(fd);
  73.     return 0;
  74. }
  75.