home *** CD-ROM | disk | FTP | other *** search
/ ftp.eri.u-tokyo.ac.jp / 2014.03.ftp.eri.u-tokyo.ac.jp.zip / ftp.eri.u-tokyo.ac.jp / pub / SUN / www / showaudio < prev   
Text File  |  1995-03-24  |  6KB  |  188 lines

  1. #!/bin/csh -f
  2. # Copyright (c) 1991 Bell Communications Research, Inc. (Bellcore)
  3. # Permission to use, copy, modify, and distribute this material 
  4. # for any purpose and without fee is hereby granted, provided 
  5. # that the above copyright notice and this permission notice 
  6. # appear in all copies, and that the name of Bellcore not be 
  7. # used in advertising or publicity pertaining to this 
  8. # material without the specific, prior written permission 
  9. # of an authorized representative of Bellcore.  BELLCORE 
  10. # MAKES NO REPRESENTATIONS ABOUT THE ACCURACY OR SUITABILITY 
  11. # OF THIS MATERIAL FOR ANY PURPOSE.  IT IS PROVIDED "AS IS", 
  12. # WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES.
  13. #
  14. # First, figure out which machine to play it on!
  15. set thishost=`hostname`
  16.  
  17. # Note that there are some special lines in here that only work at Bellcore,
  18. # Specifically involving phone playback from the machine "greenbush".
  19. # Everything should work fine at other sites, though
  20. set AUDIOBINDIR=/u/andrew/phone-sau/bin
  21. set AUDIOPHONEHOST=greenbush
  22. set AUDIOPHONEHOSTLONG=greenbush.bellcore.com
  23. set AUDIOLOGMAIL=andrew@thumper.bellcore.com
  24. set ORG="Bellcore"
  25. if ($1 == "-p") then
  26.     set AUDIOPHONE=$2
  27.     shift
  28.     shift
  29. endif
  30. if ($1 == "-s") then
  31.     set AUDIOSPEAKERFORCE = 1
  32.     shift
  33. endif
  34. if ($?AUDIOPHONE || $?AUDIOPHONEFORCE) then
  35.     goto playphone
  36. endif
  37. if (! -d $AUDIOBINDIR) then
  38.     set AUDIOSPEAKERFORCE=1
  39. endif
  40.     
  41. if (! $?AUDIOSPEAKERFORCE && ! $?AUDIOPHONEFORCE) then
  42.     if ($?MM_NOTTTY) then
  43.     if ($MM_NOTTTY == 1) then
  44.         setenv MM_NOTTTY 0
  45.         xterm -e showaudio $*
  46.         exit 0
  47.     endif
  48.     endif
  49. choosehardware:
  50.     echo This program can display audio on the speakers of some workstations, 
  51.     echo "or (at some sites) it can call you on the telephone.  Please choose one:"
  52.     echo ""
  53.     echo "1 -- Use the computer's speaker"
  54.     echo "2 -- Call me on the telephone"
  55.     echo ""
  56.     echo -n "Which do you prefer (1 or 2)? "
  57.     set ans=$<
  58.     if ($ans == 2)  then
  59.     echo "OK, we'll use the telephone..."
  60.     set AUDIOPHONEFORCE=1
  61.     echo "In the future, you can avoid this question by setting the environment variable"
  62.     echo "AUDIOPHONEFORCE to 1"
  63.     goto playphone
  64.     else if ($ans == 1) then
  65.         echo "OK, Attempting to play the audio using your computer's speaker.."
  66.         set AUDIOSPEAKERFORCE=1
  67.     echo "In the future, you can avoid this question by setting the environment variable"
  68.     echo "AUDIOSPEAKERFORCE to 1"
  69.     else
  70.     echo "That is NOT one of your choices."
  71.     goto choosehardware
  72.     endif
  73. endif
  74.  
  75. if ($1 == "-") then
  76.     set STDINPUT=1
  77.     shift
  78. endif
  79.  
  80. set audiohost=$thishost
  81. if ($?DISPLAY) then
  82.     set audiohost=`echo $DISPLAY | sed -e 's/:.*//'`
  83.     if ($audiohost == "unix") set audiohost=$thishost
  84.     if ($audiohost == "") set audiohost=$thishost
  85. endif
  86. if ($?AUDIOHOST) then
  87.     set audiohost=$AUDIOHOST
  88. endif
  89.  
  90. if ($audiohost != $thishost) then
  91.     echo Sending audio to $audiohost...
  92.     if ($?MMS_AUDIO) then
  93.         if ($?STDINPUT) then
  94.             cat | mms -host $audiohost "show audio/basic" -
  95.         else
  96.             cat $* | mms -host $audiohost "show audio/basic" -
  97.         endif
  98.         exit 0
  99.     endif
  100.  
  101. # The next two lines are very inefficient, but not everyone has their path right for an rsh
  102.     pushd ~ >& /dev/null
  103.     set thisprog=`which showaudio`
  104.     popd >& /dev/null
  105.     if ($?STDINPUT) then
  106.         cat | rsh $audiohost $thisprog -s -
  107.     else
  108.         cat $* | rsh $audiohost $thisprog  -s -
  109.     endif
  110.     exit 0
  111. endif
  112.  
  113. if (-f /usr/sbin/sfplay) then
  114.     if ($#argv >= 1) then
  115.     exec /usr/sbin/sfplay -i mu-law chan 1 rate 8000 end $*
  116.     else
  117.     cat > /tmp/audio.$$
  118.     /usr/sbin/sfplay -i mu-law chan 1 rate 8000 end /tmp/audio.$$
  119.     rm /tmp/audio.$$
  120.     exit 0
  121.     endif
  122. else if (-d /usr/sony) then
  123.     set dev=/dev/sb0
  124. else
  125.     set dev=/dev/audio
  126. endif
  127.  
  128. if (-w $dev) then
  129. echo Playing audio on $thishost using $dev, one moment please...
  130. if ($#argv >= 1) then
  131.         cat $* > $dev
  132. else
  133.         cat > $dev
  134. endif
  135. exit 0
  136. endif
  137.  
  138. playphone:
  139. if (-d $AUDIOBINDIR) then
  140.               set thisprog=`which showaudio`
  141.     if (! $?AUDIOPHONE) then
  142.         if ($?MM_NOTTTY) then
  143.         if ($MM_NOTTTY == 1) then
  144.             setenv MM_NOTTTY 0
  145.             xterm -e $thisprog $*
  146.             exit 0
  147.         endif
  148.         endif
  149.         echo This message contains audio, which can be sent to your telephone.
  150.         echo Please enter the telephone number at which you would like to hear this
  151.         echo -n "audio message as you would dial it from INSIDE ${ORG}:  "
  152.         set AUDIOPHONE=$<
  153.     endif
  154.     if ($thishost == $AUDIOPHONEHOST || $thishost == $AUDIOPHONEHOSTLONG) then
  155.         echo Calling Phone number $AUDIOPHONE
  156.         echo "You MUST SAY HELLO when you answer the phone, or you will not hear the message."
  157.         mail -s "showaudio: `whoami` called $AUDIOPHONE" $AUDIOLOGMAIL < /dev/null
  158.         if ($?STDINPUT) then
  159.             cat $AUDIOBINDIR/../GREET.au $* - | $AUDIOBINDIR/play -\# $AUDIOPHONE -
  160.         else
  161.             cat $AUDIOBINDIR/../GREET.au $* | $AUDIOBINDIR/play -\# $AUDIOPHONE -
  162.         endif
  163.         echo All done
  164.         exit 0
  165.     else
  166.         echo Trying to rsh to $AUDIOPHONEHOST to send audio via telephone
  167.         cat $* | rsh $AUDIOPHONEHOST $thisprog -p $AUDIOPHONE -
  168.         exit 0
  169.     endif
  170. endif
  171. echo ""
  172. echo This message contains an audio mesage, which can not currently be
  173. echo played on this type of workstation.   If you log into an appropriate 
  174. echo "machine (currently a SPARCstations or Sony News workstation)"
  175. echo and read this message there, you should be able to hear the audio
  176. echo message.  
  177. echo ""
  178. echo -n "Do you want to write the audio out to a file [y] ? "
  179. set ANS=$<
  180. if ("$ANS" =~ n* ||  "$ANS" =~ N* ) exit 0
  181. echo -n "File name:"
  182. set fname=$<
  183. cp $1 $fname
  184. if ($status == 0) echo Wrote file $fname
  185. exit 0
  186.  
  187.