jal@cs.wayne.edu (Jason Leigh) (01/05/91)
Submitted-by: Jason Leigh <jal@cs.wayne.edu> Posting-number: Volume 16, Issue 21 Archive-name: soundmail/part01 This is the first release of soundmail. A program that attaches to your current unix mail command so that you can include digitized sounds in your email messages. Unfortunately this only works on SPARC stations... It's really simple so don't take it too seriously. But if any one is interested in enhancing it, it should be easy. Have fun... @@snd laughter Of course the following is a shar file... #!/bin/sh-----cut here-----cut here-----cut here-----cut here----- # This is a shell archive. # Run the following text with /bin/sh to extract. cat - << \Funky!Stuff! > Sound Funky!Stuff! cat - << \Funky!Stuff! > install.p #! /bin/csh -f # This is for personal installations of sound mail. clear echo Installing Sound Mail... mkdir ~/.sm cc smore.c -o ~/.sm/smore -O cp mmore ~/.sm/mmore chmod u+x ~/.sm/mmore cp Sound ~/.sm/Sound chmod u+r ~/.sm/Sound cp ms ~/.sm/ms chmod u+x ~/.sm/ms echo "" echo "Cool\!" echo "" echo You need to put the following in your .cshrc: echo "" echo set path = \(\$path ~/.sm\) echo setenv SNDPROMPT ~/.sm echo setenv SNDLIB ~/.sm echo "" echo The last setenv may be to whatever directory has SPARC sound files; echo but note, all sound files must be suffixed with .au. echo "" echo You must put the following in your .mailrc: echo set PAGER="mmore" echo set crt=1 Funky!Stuff! cat - << \Funky!Stuff! > mmore #! /bin/csh -f # This program first attempts to do an arch command. The output # is captured to a file called /tmp/$user.arch. This is done # using the set command so as not to produce an error in the script # if the arch command does not exist. set dummy=`arch >& /tmp/$user.arch` # Extract the 1st parameter in the arch file. set machine=`awk '{print $1}' /tmp/$user.arch` /bin/rm -f /tmp/$user.arch # If it is a sun4 then use my smore else use good old more. if ($machine == "sun4") then smore else more endif Funky!Stuff! cat - << \Funky!Stuff! > ms # uuencode a sound file into a file called mailsound # ready for inclusion in mail scripts with sound in them. echo "@@addsnd" > $2 uuencode $1 sod >> $2 Funky!Stuff! cat - << \Funky!Stuff! > sm.sh Funky!Stuff! cat - << \Funky!Stuff! > smore.c /* * Sound More * Version 1.0 12/3/90 * * This program reads standard input and depending on whether * it is text or sound information, displays or plays them. * Read soundmail.doc for more details. */ #include <stdio.h> #define BUFFERSIZE 500 /* Environment variables indicating the directory containing the * sound files; the directory containing the sound prompt and * the user's login id. */ char *soundLib, *soundPrompt, *user, *getenv(); main() { char command[BUFFERSIZE]; char fileName[BUFFERSIZE]; char temp1[BUFFERSIZE], temp2[BUFFERSIZE]; char str[BUFFERSIZE], ch; FILE *so, *in; /* Get environment variables */ user = getenv("USER"); soundLib = getenv("SNDLIB"); soundPrompt = getenv("SNDPROMPT"); /* * Open temp buffer and copy all of one * mail message into it. */ sprintf(fileName, "/tmp/%s.mess", user); so = fopen(fileName, "w"); while (!feof(stdin)) { if (gets(str) == NULL) break; fprintf(so, "%s\n", str); } fclose(so); /* * Re-open the temp file as input to be * read. */ in = fopen(fileName, "r"); /* * Open a temp file called 'so' to * extract text information from sound * information. */ start: sprintf(fileName, "/tmp/%s.so", user); so = fopen(fileName, "w"); while (!feof(in)) { /* Get a string. */ if (fgets(str, BUFFERSIZE, in) == NULL) break; temp1[0] = '\0'; /* * If string length is greater * than 1 then check to see if * it's a @@snd command or a * @@addsnd command. */ if (strlen(str) > 1) { sscanf(str, "%s", temp1); /* * If it is a @@snd * command then close * output file extract * the sound identifier * from the input, print * the output file and * play the sound found * in the sound library. */ if (strcmp(temp1, "@@snd") == 0) { fclose(so); sscanf(str, "%s %s", temp1, temp2); sprintf(command, "cat /tmp/%s.so | more ", user); system(command); sprintf(command, "more %s/Sound", soundPrompt); system(command); sprintf(command, "play %s/%s.au &", soundLib, temp2); system(command); str[0] = '\0'; goto start; } /* * If it is a @@addsnd * command then what * follows is a uuencoded * sound file created * with 'ms'. If this is * the case we must first * close off the output * file, rename it to * something else. Read * in all the uuencoded * information and write * it to a new output * file. When this is * done, the text output * file is displayed and * then the sound file is * played. */ if (strcmp(str, "@@addsnd\n") == 0) { fclose(so); sprintf(command, "mv /tmp/%s.so /tmp/%s.sox", user, user); system(command); so = fopen(fileName, "w"); while (!feof(in)) { fgets(str, BUFFERSIZE, in); fprintf(so, "%s", str); if (strcmp(str, "end\n") == 0) { goto out; } } out: fclose(so); sprintf(command, "cat /tmp/%s.sox | more ", user); system(command); sprintf(command, "more %s/Sound", soundPrompt); system(command); sprintf(command, "cd /tmp ; uudecode /tmp/%s.so ; play /tmp/sod &", user); system(command); goto start; } else fprintf(so, "%s", str); } } fclose(so); /* * If EOF reached print whatever text has * been left accumulating in the text * output file. */ sprintf(command, "cat /tmp/%s.so | more", user); system(command); /* * Clean up by deleting all the temp * files. */ sprintf(command, "rm -f /tmp/%s.mess /tmp/%s.so /tmp/%s.sod /tmp/%s.sox", user, user, user, user); system(command); } Funky!Stuff! cat - << \Funky!Stuff! > soundmail.doc SOUND MAIL 1.0 by JASON LEIGH jal@cs.wayne.edu Welcome to sound mail, my first attempt at incorporating sound into email! No longer are we limited to the little character codes such as :^) to represent our "feelings" about a message, we can now truely express our emotions by using sound. This first version of sound mail allows the inclusion of sounds from a library of sound files that are stored on a system or the inclusion of one's own sound files. This is particularly easy in light of the fact that all SPARC's have an audio input port at the back of them. Sound mail is particularly flexible because you are not limited to using it for mail. Just about any application that requires the use of the 'more' command can take advantage of it. In fact sound mail makes no changes to your current 'mail' program. It simply provides a new version of 'more' that can display text as well as play sounds. So it is real possibility that you can now write programs that have sounds included to document the source code. Whether that's of any use is another issue. Basically sound mail was designed for absolutely no purpose what so ever except that it's neat and fun! And who knows, it may be useful. System Requirements: ------------------- o Sun SPARC Station o Installation of the 'play' program by Sun in some accessible directory. o Installation of some library of SPARC audio files all suffixed with .au o Installation of uuencode and uudecode in some accesible directory. (You should already have this on your system.) The optional parts are for those who would like to incorporate their own personalized sounds in their mail messages. o (optional) SPARC connector for microphone. o (optional) Installation of the 'record' program or soundtool by Sun. Installation: ------------ For a personalized copy of sound mail run the program: install.p It will give you more details. To Write a Sound Mail Message: ----------------------------- Send mail to yourself as a test first. Basically there are no special instructions for this, just type the usual: mail <login id>. Then the subject line and the message. Now if you wish to include a sound at a particular point in your message and the sound you want included is part of a sound library that you know the receiver has access to, type on a new line: @@snd <sound name> followed by a RETURN. <sound name> is the name of the sound file without the .au suffix. That's it. Whenever you wish to include a sound just start a new line and type the above command. Now to include your own sounds as part of the message, first run the 'ms' program on all the audio files you intend to send. For example if you wanted to send the audio files foo bar baz, type: ms foo foo.snd ms bar bar.snd ms baz baz.snd With that done whenever you want to include a particular sound file into the document, simply use 'mail's ~r command to read in the .snd file. For example: ~r foo.snd Problems: -------- Mail messages have a limited size so it isn't a good idea to include too many of your own personalized sound messages as it does take up a lot of memory for a few second of sound. Now I realize that often times you will log in on some other machine that is not a SPARC or log in from home etc.. in which case 1. you won't be able to hear the sounds and 2. (if it is on some other machine that is not a SPARC) you'd expect my program to crash because you compiled it originally on a SPARC. NEVER FEAR! There is an interfacing shell script that checks to make sure you are on a SPARC before it attempts to run the binaries for the sound mail. So you can safely read your messages on a VAX as well as a SPARC; except you won't hear anything. It won't work on Sun's 'mailtool' (obviously because it doesn't use more). Final Notes: ----------- Well that's about it. At this point I suppose I should disclaim all responsibility for possible damages that may result through the use, misuse or abuse of this program. And if you like this program tell a friend and lets get some interesting email going. If you'd like to make some cool improvements please feel free, just give me some credit for my part and let me know what you did. If you have any questions, you can send me sound mail at: jal@cs.wayne.edu I have access to all the demo sound files that came with the SPARC. Have fun! Funky!Stuff! -- :^) :^) :^) :^) :^) :^) :^) :^) ;^) O^: (^: (^: (^: (^: (^: (^: (^: :^) Where the telescope ends, the microscope begins. (^: :v) Which of the two has the grander view? - Victor Hugo (v: :v) :v) :v) :v) :v) :v) :v) :v) :v( $v: (v: (v: (v: (v: (v: (v: (v: exit 0 # Just in case... -- Kent Landfield INTERNET: kent@sparky.IMD.Sterling.COM Sterling Software, IMD UUCP: uunet!sparky!kent Phone: (402) 291-8300 FAX: (402) 291-4362 Please send comp.sources.misc-related mail to kent@uunet.uu.net.