home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2375 / audio.c next >
C/C++ Source or Header  |  1990-12-28  |  2KB  |  93 lines

  1. /* 
  2.  *   Copyright (c) 1989 Oki Electric Industry Co., Ltd.
  3.  *
  4.  *   This file is part of vtalk.
  5.  *
  6.  *   Permission to use, copy, modify and distribute this program without
  7.  *   fee is grtanted,  provided that  the above  copyright notice appear
  8.  *   in all copies.
  9.  *
  10.  */
  11. /*
  12.  *  audio.c    audio control routine for vtalk
  13.  *
  14.  *  vtalk is a command for 
  15.  *  Voice TALK with the user on another machine.
  16.  *
  17.  */
  18.  
  19. #include <stdio.h>
  20. #include <sys/ioctl.h>            /* for audio */
  21. #define AUDIO_CHIP
  22. #include <sbusdev/audio_79C30.h>
  23. #include <sun/audioio.h>
  24.  
  25. int fd_audio;
  26.  
  27.  
  28. device_open()
  29. {
  30.     struct audio_ioctl audioreg;
  31.     
  32.     if((fd_audio = open("/dev/audio", 2)) < 0){
  33.         fprintf(stderr,"vtalk: can't open /dev/audio\n");
  34.         exit(1);
  35.     }
  36.  
  37.     /* set MMR1 register */
  38.     audioreg.control = AUDIO_MAP_MMR1;
  39.     audioreg.data[0] = AUDIO_MMR1_BITS_LOAD_GX |
  40.       AUDIO_MMR1_BITS_LOAD_GR | AUDIO_MMR1_BITS_LOAD_GER;
  41.     if (ioctl(fd_audio,AUDIOSETREG,&audioreg) < 0) {
  42.         perror("vtalk: set MMR1 register");
  43.     }
  44.     
  45.     /* set MMR2 register                      *
  46.          * send the output to the builtin speaker */
  47.     audioreg.control = AUDIO_MAP_MMR2;
  48.     if (ioctl(fd_audio,AUDIOGETREG,&audioreg) < 0) {
  49.         perror("vtalk: set MMR2 register");
  50.     }
  51.     audioreg.data[0] |= AUDIO_MMR2_BITS_LS;
  52.     if (ioctl(fd_audio,AUDIOSETREG,&audioreg) < 0) {
  53.         perror("vtalk: set MMR2 register");
  54.     }
  55.     
  56.     return(fd_audio);
  57. }
  58.  
  59.  
  60. void
  61. set_volume()
  62. {
  63.     struct    audio_ioctl    audioreg;
  64.  
  65.     /* register GR set 5db for play volume */
  66.     audioreg.control = AUDIO_MAP_GR;
  67.     audioreg.data[0] = 0x3b;
  68.     audioreg.data[1] = 0x11;
  69.     if (ioctl(fd_audio,AUDIOSETREG,&audioreg) < 0) {
  70.         perror("vtalk: set GR register");
  71.     }
  72.     
  73.     /* register GER set 5db for play volume */
  74.     audioreg.control = AUDIO_MAP_GER;
  75.     audioreg.data[0] = 0x31;
  76.     audioreg.data[1] = 0xdd;
  77.     if (ioctl(fd_audio,AUDIOSETREG,&audioreg) < 0) {
  78.         perror("vtalk: set GER register");
  79.     }
  80.     
  81.     /* register GX set 11db for record volume */
  82.     audioreg.control = AUDIO_MAP_GX;
  83.     audioreg.data[0] = 0x13;
  84.     audioreg.data[1] = 0x00;
  85.     if (ioctl(fd_audio,AUDIOSETREG,&audioreg) < 0) {
  86.         perror("vtalk: set GX register");
  87.     }
  88. }
  89.  
  90.  
  91.  
  92.  
  93.